From da9267ac987cc2a09e51208a74e9a93fd454c4fd Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:28:50 -0500 Subject: [PATCH 1/5] Added AOS Leech Properties --- data/js/combat/leechstats.js | 60 ++++++++++++++++++++ data/js/jse_fileassociations.scp | 1 + source/CPacketSend.cpp | 22 ++++++++ source/UOXJSPropertyEnums.h | 4 +- source/UOXJSPropertyFuncs.cpp | 6 ++ source/UOXJSPropertySpecs.h | 3 + source/cBaseObject.cpp | 96 +++++++++++++++++++++++++++++++- source/cBaseObject.h | 16 ++++++ source/cChar.cpp | 8 +++ source/cItem.cpp | 11 ++++ source/items.cpp | 3 + source/ssection.cpp | 6 ++ source/ssection.h | 3 + 13 files changed, 237 insertions(+), 2 deletions(-) create mode 100644 data/js/combat/leechstats.js diff --git a/data/js/combat/leechstats.js b/data/js/combat/leechstats.js new file mode 100644 index 000000000..6663958ba --- /dev/null +++ b/data/js/combat/leechstats.js @@ -0,0 +1,60 @@ +function onEquip( pEquipper, iEquipped ) +{ + pEquipper.AddScriptTrigger( 7003 ); +} + +// Remove script trigger on unequip +function onUnequip( pUnequipper, iUnequipped ) +{ + pUnequipper.RemoveScriptTrigger( 7003 ); +} + +function onDamageDeal( attacker, damaged, damageValue, damageType ) +{ + // Fetch weapon in main hand or secondary hand + var iWeapon = attacker.FindItemLayer( 0x01 ); + if( !ValidateObject( iWeapon )) + { + iWeapon = attacker.FindItemLayer( 0x02 ); + } + + if( ValidateObject( iWeapon )) + { // Apply leech effects based on weapon properties + ApplyLeech( attacker, damaged, damageValue, iWeapon, 'healthLeech', 30 ); + ApplyLeech( attacker, damaged, damageValue, iWeapon, 'staminaLeech', 100 ); + ApplyLeech( attacker, damaged, damageValue, iWeapon, 'manaLeech', 40 ); + } + + return true; +} + +function ApplyLeech( attacker, damaged, damageValue, weapon, leechType, multiplier ) +{ + // Get the leech amount for the specified leech type from the weapon + var leechAmount = weapon[ leechType ]; + if( leechAmount > 0 ) + { // Calculate the minimum and maximum leech values + var minLeech = Math.round( damageValue * ( leechAmount / 100 ) * ( multiplier/100 )); + var maxLeech = Math.round( ( ( weapon.speed / 100 ) * 2500 ) / ( 100 + weapon.speedIncrease )); + var leechAmt = RandomNumber( minLeech, maxLeech ); + + // Apply the leech effect based on the leech type + switch( leechType ) + { + case 'healthLeech': + attacker.Heal( leechAmt ); + damaged.health -= leechAmt; + break; + case 'staminaLeech': + attacker.stamina += leechAmt; + damaged.stamina -= leechAmt; + break; + case 'manaLeech': + attacker.mana += leechAmt; + damaged.mana -= leechAmt; + break; + } + + attacker.SoundEffect( 0x44D, true ); + } +} \ No newline at end of file diff --git a/data/js/jse_fileassociations.scp b/data/js/jse_fileassociations.scp index 2cbb8e3d5..7b16b631a 100644 --- a/data/js/jse_fileassociations.scp +++ b/data/js/jse_fileassociations.scp @@ -329,6 +329,7 @@ // Combat Scripts [7000-7499] //------------------------------------------- 7000=combat/peacemake_effect.js +7003=combat/leechstats.js //------------------------------------------- // Misc Player Scripts [8000-8499] diff --git a/source/CPacketSend.cpp b/source/CPacketSend.cpp index e1d8ee4ca..28f3a2a40 100644 --- a/source/CPacketSend.cpp +++ b/source/CPacketSend.cpp @@ -7465,6 +7465,28 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou tempEntry.ourText = oldstrutil::number( cItem.GetTempVar( CITV_MOREZ )); FinalizeData( tempEntry, totalStringLen ); } + + if( cItem.GetManaLeech() > 0 ) + { + tempEntry.stringNum = 1060427; // hit mana leech ~1_val~% + tempEntry.ourText = oldstrutil::number( cItem.GetManaLeech() ); + FinalizeData( tempEntry, totalStringLen ); + } + + if( cItem.GetStaminaLeech() > 0 ) + { + tempEntry.stringNum = 1060430; // hit stamina leech ~1_val~% + tempEntry.ourText = oldstrutil::number( cItem.GetStaminaLeech() ); + FinalizeData( tempEntry, totalStringLen ); + } + + if( cItem.GetHealthLeech() > 0 ) + { + tempEntry.stringNum = 1060422; // hit life leech ~1_val~% + tempEntry.ourText = oldstrutil::number( cItem.GetHealthLeech() ); + FinalizeData( tempEntry, totalStringLen ); + } + if( cItem.GetType() == IT_SPELLCHANNELING ) { tempEntry.stringNum = 1060482; // spell channeling diff --git a/source/UOXJSPropertyEnums.h b/source/UOXJSPropertyEnums.h index af309d496..ada680894 100644 --- a/source/UOXJSPropertyEnums.h +++ b/source/UOXJSPropertyEnums.h @@ -495,7 +495,9 @@ enum CI_Properties CIP_SECTIONALIST, CIP_MININTERVAL, CIP_MAXINTERVAL, - + CIP_HEALTHLEECH, + CIP_STAMINALEECH, + CIP_MANALEECH, CIP_ISNEWBIE, CIP_ISDISPELLABLE, CIP_MADEWITH, diff --git a/source/UOXJSPropertyFuncs.cpp b/source/UOXJSPropertyFuncs.cpp index 3823356f9..2e210e2d0 100644 --- a/source/UOXJSPropertyFuncs.cpp +++ b/source/UOXJSPropertyFuncs.cpp @@ -676,6 +676,9 @@ JSBool CItemProps_getProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp case CIP_DAMAGERAIN: *vp = BOOLEAN_TO_JSVAL( gPriv->GetWeatherDamage( RAIN )); break; case CIP_DAMAGESNOW: *vp = BOOLEAN_TO_JSVAL( gPriv->GetWeatherDamage( SNOW )); break; case CIP_SPEED: *vp = INT_TO_JSVAL( gPriv->GetSpeed() ); break; + case CIP_HEALTHLEECH: *vp = INT_TO_JSVAL( gPriv->GetHealthLeech() ); break; + case CIP_STAMINALEECH: *vp = INT_TO_JSVAL( gPriv->GetStaminaLeech() ); break; + case CIP_MANALEECH: *vp = INT_TO_JSVAL( gPriv->GetManaLeech() ); break; case CIP_NAME2: tString = JS_NewStringCopyZ( cx, gPriv->GetName2().c_str() ); *vp = STRING_TO_JSVAL( tString ); @@ -1321,6 +1324,9 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp case CIP_DAMAGERAIN: gPriv->SetWeatherDamage( RAIN, encaps.toBool() ); break; case CIP_DAMAGESNOW: gPriv->SetWeatherDamage( SNOW, encaps.toBool() ); break; case CIP_SPEED: gPriv->SetSpeed( static_cast( encaps.toInt() )); break; + case CIP_HEALTHLEECH: gPriv->SetHealthLeech( static_cast( encaps.toInt() )); break; + case CIP_STAMINALEECH: gPriv->SetStaminaLeech( static_cast( encaps.toInt() )); break; + case CIP_MANALEECH: gPriv->SetManaLeech( static_cast( encaps.toInt() )); break; case CIP_NAME2: gPriv->SetName2( encaps.toString() ); break; case CIP_RACE: gPriv->SetRace( static_cast( encaps.toInt() )); break; case CIP_MAXHP: gPriv->SetMaxHP( static_cast( encaps.toInt() )); break; diff --git a/source/UOXJSPropertySpecs.h b/source/UOXJSPropertySpecs.h index 3149dc0ec..15795c036 100644 --- a/source/UOXJSPropertySpecs.h +++ b/source/UOXJSPropertySpecs.h @@ -535,6 +535,9 @@ inline JSPropertySpec CItemProps[] = { "ammoFXHue", CIP_AMMOFXHUE, JSPROP_ENUMANDPERM, nullptr, nullptr }, { "ammoFXRender", CIP_AMMOFXRENDER, JSPROP_ENUMANDPERM, nullptr, nullptr }, { "speed", CIP_SPEED, JSPROP_ENUMANDPERM, nullptr, nullptr }, + { "healthLeech", CIP_HEALTHLEECH, JSPROP_ENUMANDPERM, nullptr, nullptr }, + { "staminaLeech", CIP_STAMINALEECH, JSPROP_ENUMANDPERM, nullptr, nullptr }, + { "manaLeech", CIP_MANALEECH, JSPROP_ENUMANDPERM, nullptr, nullptr }, { "multi", CIP_MULTI, JSPROP_ENUMANDPERM, nullptr, nullptr }, { "maxRange", CIP_MAXRANGE, JSPROP_ENUMANDPERM, nullptr, nullptr }, { "baseRange", CIP_BASERANGE, JSPROP_ENUMANDPERM, nullptr, nullptr }, diff --git a/source/cBaseObject.cpp b/source/cBaseObject.cpp index 506c247ac..2c5ce0b89 100644 --- a/source/cBaseObject.cpp +++ b/source/cBaseObject.cpp @@ -94,6 +94,9 @@ const SI16 DEFBASE_KILLS = 0; const UI16 DEFBASE_RESIST = 0; const bool DEFBASE_NAMEREQUESTACTIVE = 0; const ExpansionRuleset DEFBASE_ORIGIN = ER_UO; +const SI16 DEFBASE_HEALTHLEECH = 0; +const SI16 DEFBASE_STAMINALEECH = 0; +const SI16 DEFBASE_MANALEECH = 0; //o------------------------------------------------------------------------------------------------o //| Function - CBaseObject constructor @@ -110,7 +113,8 @@ loDamage( DEFBASE_LODAMAGE ), weight( DEFBASE_WEIGHT ), mana( DEFBASE_MANA ), stamina( DEFBASE_STAMINA ), scriptTrig( DEFBASE_SCPTRIG ), st2( DEFBASE_STR2 ), dx2( DEFBASE_DEX2 ), in2( DEFBASE_INT2 ), FilePosition( DEFBASE_FP ), poisoned( DEFBASE_POISONED ), carve( DEFBASE_CARVE ), oldLocX( 0 ), oldLocY( 0 ), oldLocZ( 0 ), oldTargLocX( 0 ), oldTargLocY( 0 ), -fame( DEFBASE_FAME ), karma( DEFBASE_KARMA ), kills( DEFBASE_KILLS ), subRegion( DEFBASE_SUBREGION ), nameRequestActive( DEFBASE_NAMEREQUESTACTIVE ), origin( DEFBASE_ORIGIN ) +fame( DEFBASE_FAME ), karma( DEFBASE_KARMA ), kills( DEFBASE_KILLS ), subRegion( DEFBASE_SUBREGION ), nameRequestActive( DEFBASE_NAMEREQUESTACTIVE ), origin( DEFBASE_ORIGIN ), +healthLeech( DEFBASE_HEALTHLEECH ), staminaLeech( DEFBASE_STAMINALEECH ), manaLeech( DEFBASE_MANALEECH ) { multis = nullptr; tempMulti = INVALIDSERIAL; @@ -1631,6 +1635,66 @@ void CBaseObject::SetIntelligence2( SI16 nVal ) } } +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::GetHealthLeech() +//| CBaseObject::SetHealthLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Gets/Sets the Health Leech +//o------------------------------------------------------------------------------------------------o +SI16 CBaseObject::GetHealthLeech( void ) const +{ + return healthLeech; +} +void CBaseObject::SetHealthLeech( SI16 nVal ) +{ + healthLeech = nVal; + + if( CanBeObjType( OT_ITEM )) + { + ( static_cast( this ))->UpdateRegion(); + } +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::GetStaminaLeech() +//| CBaseObject::SetStaminaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Gets/Sets the Stamina Leech +//o------------------------------------------------------------------------------------------------o +SI16 CBaseObject::GetStaminaLeech( void ) const +{ + return staminaLeech; +} +void CBaseObject::SetStaminaLeech( SI16 nVal ) +{ + staminaLeech = nVal; + + if( CanBeObjType( OT_ITEM )) + { + ( static_cast( this ))->UpdateRegion(); + } +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::GetManaLeech() +//| CBaseObject::SetManaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Gets/Sets the Mana Leech +//o------------------------------------------------------------------------------------------------o +SI16 CBaseObject::GetManaLeech( void ) const +{ + return manaLeech; +} +void CBaseObject::SetManaLeech( SI16 nVal ) +{ + manaLeech = nVal; + + if( CanBeObjType( OT_ITEM )) + { + ( static_cast( this ))->UpdateRegion(); + } +} + //o------------------------------------------------------------------------------------------------o //| Function - CBaseObject::IncStrength() //o------------------------------------------------------------------------------------------------o @@ -1661,6 +1725,36 @@ void CBaseObject::IncIntelligence( SI16 toInc ) SetIntelligence( intelligence + toInc ); } +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::IncHealthLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Increments the object's Health Leech Points value +//o------------------------------------------------------------------------------------------------o +void CBaseObject::IncHealthLeech( SI16 toInc ) +{ + SetHealthLeech( healthLeech + toInc ); +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::IncStaminaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Increments the object's Stamina Leech Points value +//o------------------------------------------------------------------------------------------------o +void CBaseObject::IncStaminaLeech( SI16 toInc ) +{ + SetStaminaLeech( staminaLeech + toInc ); +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::IncManaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Increments the object's Mana Leech Points value +//o------------------------------------------------------------------------------------------------o +void CBaseObject::IncManaLeech( SI16 toInc ) +{ + SetManaLeech( manaLeech + toInc ); +} + //o------------------------------------------------------------------------------------------------o //| Function - CBaseObject::DumpFooter() //o------------------------------------------------------------------------------------------------o diff --git a/source/cBaseObject.h b/source/cBaseObject.h index 638e826f7..316cd2530 100644 --- a/source/cBaseObject.h +++ b/source/cBaseObject.h @@ -75,6 +75,9 @@ class CBaseObject SI32 weight; SI16 mana; SI16 stamina; + SI16 healthLeech; + SI16 staminaLeech; + SI16 manaLeech; UI16 scriptTrig; SI16 st2; SI16 dx2; @@ -256,6 +259,19 @@ class CBaseObject void IncDexterity( SI16 toInc = 1 ); void IncIntelligence( SI16 toInc = 1 ); + SI16 GetHealthLeech( void ) const; + virtual void SetHealthLeech( SI16 nVal ); + + SI16 GetStaminaLeech( void ) const; + virtual void SetStaminaLeech( SI16 nVal ); + + SI16 GetManaLeech( void ) const; + virtual void SetManaLeech( SI16 nVal ); + + void IncHealthLeech( SI16 toInc = 1 ); + void IncStaminaLeech( SI16 toInc = 1 ); + void IncManaLeech( SI16 toInc = 1 ); + virtual void PostLoadProcessing( void ); virtual bool LoadRemnants( void ) = 0; diff --git a/source/cChar.cpp b/source/cChar.cpp index 7aa03f6fa..439a72527 100644 --- a/source/cChar.cpp +++ b/source/cChar.cpp @@ -2920,6 +2920,10 @@ bool CChar::WearItem( CItem *toWear ) IncDexterity2( itemLayers[tLayer]->GetDexterity2() ); IncIntelligence2( itemLayers[tLayer]->GetIntelligence2() ); + IncHealthLeech( itemLayers[tLayer]->GetHealthLeech() ); + IncStaminaLeech( itemLayers[tLayer]->GetStaminaLeech() ); + IncManaLeech( itemLayers[tLayer]->GetManaLeech() ); + if( toWear->IsPostLoaded() ) { if( itemLayers[tLayer]->GetPoisoned() ) @@ -2979,6 +2983,10 @@ bool CChar::TakeOffItem( ItemLayers Layer ) IncStrength2( -itemLayers[Layer]->GetStrength2() ); IncDexterity2( -itemLayers[Layer]->GetDexterity2() ); IncIntelligence2( -itemLayers[Layer]->GetIntelligence2() ); + + IncHealthLeech( -itemLayers[Layer]->GetHealthLeech() ); + IncStaminaLeech( -itemLayers[Layer]->GetStaminaLeech() ); + IncManaLeech( -itemLayers[Layer]->GetManaLeech() ); if( itemLayers[Layer]->GetPoisoned() ) { if( itemLayers[Layer]->GetPoisoned() > GetPoisoned() ) diff --git a/source/cItem.cpp b/source/cItem.cpp index 3c6523d5d..672ece4dd 100644 --- a/source/cItem.cpp +++ b/source/cItem.cpp @@ -1644,6 +1644,9 @@ auto CItem::CopyData( CItem *target ) -> void target->SetStamina( GetStamina() ); target->SetStrength( GetStrength() ); target->SetStrength2( GetStrength2() ); + target->SetHealthLeech( GetHealthLeech() ); + target->SetStaminaLeech( GetStaminaLeech() ); + target->SetManaLeech( GetManaLeech() ); target->SetTitle( GetTitle() ); target->SetType( GetType() ); target->SetBuyValue( GetBuyValue() ); @@ -1739,6 +1742,7 @@ bool CItem::DumpBody( std::ostream &outStream ) const outStream << "Speed=" + std::to_string( GetSpeed() ) + newLine; outStream << "Movable=" + std::to_string( GetMovable() ) + newLine; outStream << "Priv=" + std::to_string( GetPriv() ) + newLine; + outStream << "LeechStats=" + std::to_string( GetHealthLeech() ) + "," + std::to_string( GetStaminaLeech() ) + "," + std::to_string( GetManaLeech() ) + newLine; outStream << "Value=" + std::to_string( GetBuyValue() ) + "," + std::to_string( GetSellValue() ) + "," + std::to_string( GetVendorPrice() ) + newLine; outStream << "Restock=" + std::to_string( GetRestock() ) + newLine; outStream << "AC=" + std::to_string( GetArmourClass() ) + newLine; @@ -1922,6 +1926,13 @@ bool CItem::HandleLine( std::string &UTag, std::string &data ) SetWeatherDamage( LIGHTNING, static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 )) == 1 ); rValue = true; } + else if( UTag == "LEECHSTATS" ) + { + SetHealthLeech( static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" )), nullptr, 0 ))); + SetStaminaLeech( static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 ))); + SetManaLeech( static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[2], "//" )), nullptr, 0 ))); + rValue = true; + } break; case 'M': if( UTag == "MAXITEMS" ) diff --git a/source/items.cpp b/source/items.cpp index 1cd4a2aaf..a3cec1199 100644 --- a/source/items.cpp +++ b/source/items.cpp @@ -138,6 +138,9 @@ auto ApplyItemSection( CItem *applyTo, CScriptSection *toApply, std::string sect } break; case DFNTAG_AC: applyTo->SetArmourClass( static_cast( ndata )); break; + case DFNTAG_HEALTHLEECH: applyTo->SetHealthLeech( static_cast( ndata )); break; + case DFNTAG_STAMINALEECH: applyTo->SetStaminaLeech( static_cast( ndata )); break; + case DFNTAG_MANALEECH: applyTo->SetManaLeech( static_cast( ndata )); break; case DFNTAG_BASERANGE: applyTo->SetBaseRange( static_cast( ndata )); break; case DFNTAG_CREATOR: applyTo->SetCreator( ndata ); break; case DFNTAG_COLOUR: applyTo->SetColour( static_cast( ndata )); break; diff --git a/source/ssection.cpp b/source/ssection.cpp index c2a563b47..2ed0d8b70 100644 --- a/source/ssection.cpp +++ b/source/ssection.cpp @@ -115,6 +115,7 @@ const UI08 dfnDataTypes[DFNTAG_COUNTOFTAGS] = DFN_NODATA, // DFNTAG_HIRELING, DFN_DOUBLENUMERIC, // DFNTAG_HP, DFN_DOUBLENUMERIC, // DFNTAG_HPMAX, + DFN_NUMERIC, // DFNTAG_HEALTHLEECH, DFN_UPPERSTRING, // DFNTAG_ID, DFN_DOUBLENUMERIC, // DFNTAG_IMBUING, DFN_NUMERIC, // DFNTAG_INTADD, @@ -140,6 +141,7 @@ const UI08 dfnDataTypes[DFNTAG_COUNTOFTAGS] = DFN_DOUBLENUMERIC, // DFNTAG_MAGICRESISTANCE, DFN_DOUBLENUMERIC, // DFNTAG_MANA, DFN_DOUBLENUMERIC, // DFNTAG_MANAMAX, + DFN_NUMERIC, // DFNTAG_MANALEECH, DFN_NUMERIC, // DFNTAG_MAXHP, DFN_NUMERIC, // DFNTAG_MAXITEMS, DFN_NUMERIC, // DFNTAG_MAXLOYALTY, @@ -222,6 +224,7 @@ const UI08 dfnDataTypes[DFNTAG_COUNTOFTAGS] = DFN_NUMERIC, // DFNTAG_SPLITCHANCE, DFN_DOUBLENUMERIC, // DFNTAG_STAMINA, DFN_DOUBLENUMERIC, // DFNTAG_STAMINAMAX, + DFN_NUMERIC, // DFNTAG_STAMINALEECH, DFN_DOUBLENUMERIC, // DFNTAG_STRENGTH, DFN_NUMERIC, // DFNTAG_STRADD, DFN_NUMERIC, // DFNTAG_STEALABLE, @@ -370,6 +373,7 @@ const std::map strToDFNTag {"HIRELING"s, DFNTAG_HIRELING}, {"HP"s, DFNTAG_HP}, {"HPMAX"s, DFNTAG_HPMAX}, + {"HEALTHLEECH"s, DFNTAG_HEALTHLEECH}, {"ID"s, DFNTAG_ID}, {"IMBUING"s, DFNTAG_IMBUING}, {"IN"s, DFNTAG_INTELLIGENCE}, @@ -399,6 +403,7 @@ const std::map strToDFNTag {"MAGICRESISTANCE"s, DFNTAG_MAGICRESISTANCE}, {"MANA"s, DFNTAG_MANA}, {"MANAMAX"s, DFNTAG_MANAMAX}, + {"MANALEECH"s, DFNTAG_MANALEECH}, {"MAXHP"s, DFNTAG_MAXHP}, {"MAXITEMS"s, DFNTAG_MAXITEMS}, {"MAXLOYALTY"s, DFNTAG_MAXLOYALTY}, @@ -483,6 +488,7 @@ const std::map strToDFNTag {"ST"s, DFNTAG_STRENGTH}, {"STAMINA"s, DFNTAG_STAMINA}, {"STAMINAMAX"s, DFNTAG_STAMINAMAX}, + {"STAMINALEECH"s, DFNTAG_STAMINALEECH}, {"STR"s, DFNTAG_STRENGTH}, {"STRENGTH"s, DFNTAG_STRENGTH}, {"ST2"s, DFNTAG_STRADD}, diff --git a/source/ssection.h b/source/ssection.h index a2a660aec..be29b8d36 100644 --- a/source/ssection.h +++ b/source/ssection.h @@ -122,6 +122,7 @@ enum DFNTAGS DFNTAG_HIRELING, DFNTAG_HP, DFNTAG_HPMAX, + DFNTAG_HEALTHLEECH, DFNTAG_ID, DFNTAG_IMBUING, DFNTAG_INTADD, @@ -147,6 +148,7 @@ enum DFNTAGS DFNTAG_MAGICRESISTANCE, DFNTAG_MANA, DFNTAG_MANAMAX, + DFNTAG_MANALEECH, DFNTAG_MAXHP, DFNTAG_MAXITEMS, DFNTAG_MAXLOYALTY, @@ -229,6 +231,7 @@ enum DFNTAGS DFNTAG_SPLITCHANCE, DFNTAG_STAMINA, DFNTAG_STAMINAMAX, + DFNTAG_STAMINALEECH, DFNTAG_STRENGTH, DFNTAG_STRADD, DFNTAG_STEALABLE, From 03c2ba6dc03a5c130d097f25e9356677410e6ccb Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:36:04 -0500 Subject: [PATCH 2/5] changelog --- source/Changelog.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/Changelog.txt b/source/Changelog.txt index f64afbc32..ca3c53f46 100644 --- a/source/Changelog.txt +++ b/source/Changelog.txt @@ -1,3 +1,12 @@ +18/06/2024 - Dragon Slayer + Added three new DFN tags for Items: + HEALTHLEECH=# // It gives an attacker the ability to leech health from his opponent every time he successfully delivers a hit adds it to himself. + STAMINALEECH=# // It gives an attacker the ability to leech Stamina from his opponent every time he successfully delivers a hit adds it to himself. + MANALEECH=# // It gives an attacker the ability to leech Mana from his opponent every time he successfully delivers a hit adds it to himself. + These are also available as JS Engine object properties: .healthLeech, .staminaLeech and .manaLeech + Added leechstats.js file that controls the combat for the properties. (script 7003) + To add this script to a weapon only. add in SCRIPT=7003, HEALTHLEECH=# or STAMINALEECH=# or MANALEECH=# it can also be all three on the weapon. + 1/05/2024 - Dragon Slayer/Xuri Fixed AutoUnequipAttempt function in clumsy.js, createfood.js level1target.js, will no longer fail on casting and return to hardcode. Fixed createfood to check for reagents on cast. From d28b8daf166b51c599972fdf055e0c652b1f9cbd Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Sat, 22 Jun 2024 17:53:00 -0500 Subject: [PATCH 3/5] Update leechstats.js --- data/js/combat/leechstats.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/data/js/combat/leechstats.js b/data/js/combat/leechstats.js index 6663958ba..fc1086fdf 100644 --- a/data/js/combat/leechstats.js +++ b/data/js/combat/leechstats.js @@ -31,27 +31,23 @@ function onDamageDeal( attacker, damaged, damageValue, damageType ) function ApplyLeech( attacker, damaged, damageValue, weapon, leechType, multiplier ) { // Get the leech amount for the specified leech type from the weapon - var leechAmount = weapon[ leechType ]; - if( leechAmount > 0 ) - { // Calculate the minimum and maximum leech values - var minLeech = Math.round( damageValue * ( leechAmount / 100 ) * ( multiplier/100 )); - var maxLeech = Math.round( ( ( weapon.speed / 100 ) * 2500 ) / ( 100 + weapon.speedIncrease )); - var leechAmt = RandomNumber( minLeech, maxLeech ); + var leechPercentVal = weapon[ leechType ]; + if( leechPercentVal > 0 ) + { + // Calculate the percent of health restored to the attacker + var leechAmt = Math.round( damageValue * ( leechPercentVal / 100 ) * ( multiplier/100 )); // Apply the leech effect based on the leech type switch( leechType ) { case 'healthLeech': attacker.Heal( leechAmt ); - damaged.health -= leechAmt; break; case 'staminaLeech': attacker.stamina += leechAmt; - damaged.stamina -= leechAmt; break; case 'manaLeech': attacker.mana += leechAmt; - damaged.mana -= leechAmt; break; } From 41c7ee467664ed3242d8c40603f4be83e8e4a571 Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:36:53 -0600 Subject: [PATCH 4/5] Moved Leech Props Moved Leech props to just items --- source/cBaseObject.cpp | 96 +----------------------------------------- source/cBaseObject.h | 16 ------- source/cItem.cpp | 83 +++++++++++++++++++++++++++++++++++- source/cItem.h | 16 +++++++ 4 files changed, 99 insertions(+), 112 deletions(-) diff --git a/source/cBaseObject.cpp b/source/cBaseObject.cpp index 2c5ce0b89..506c247ac 100644 --- a/source/cBaseObject.cpp +++ b/source/cBaseObject.cpp @@ -94,9 +94,6 @@ const SI16 DEFBASE_KILLS = 0; const UI16 DEFBASE_RESIST = 0; const bool DEFBASE_NAMEREQUESTACTIVE = 0; const ExpansionRuleset DEFBASE_ORIGIN = ER_UO; -const SI16 DEFBASE_HEALTHLEECH = 0; -const SI16 DEFBASE_STAMINALEECH = 0; -const SI16 DEFBASE_MANALEECH = 0; //o------------------------------------------------------------------------------------------------o //| Function - CBaseObject constructor @@ -113,8 +110,7 @@ loDamage( DEFBASE_LODAMAGE ), weight( DEFBASE_WEIGHT ), mana( DEFBASE_MANA ), stamina( DEFBASE_STAMINA ), scriptTrig( DEFBASE_SCPTRIG ), st2( DEFBASE_STR2 ), dx2( DEFBASE_DEX2 ), in2( DEFBASE_INT2 ), FilePosition( DEFBASE_FP ), poisoned( DEFBASE_POISONED ), carve( DEFBASE_CARVE ), oldLocX( 0 ), oldLocY( 0 ), oldLocZ( 0 ), oldTargLocX( 0 ), oldTargLocY( 0 ), -fame( DEFBASE_FAME ), karma( DEFBASE_KARMA ), kills( DEFBASE_KILLS ), subRegion( DEFBASE_SUBREGION ), nameRequestActive( DEFBASE_NAMEREQUESTACTIVE ), origin( DEFBASE_ORIGIN ), -healthLeech( DEFBASE_HEALTHLEECH ), staminaLeech( DEFBASE_STAMINALEECH ), manaLeech( DEFBASE_MANALEECH ) +fame( DEFBASE_FAME ), karma( DEFBASE_KARMA ), kills( DEFBASE_KILLS ), subRegion( DEFBASE_SUBREGION ), nameRequestActive( DEFBASE_NAMEREQUESTACTIVE ), origin( DEFBASE_ORIGIN ) { multis = nullptr; tempMulti = INVALIDSERIAL; @@ -1635,66 +1631,6 @@ void CBaseObject::SetIntelligence2( SI16 nVal ) } } -//o------------------------------------------------------------------------------------------------o -//| Function - CBaseObject::GetHealthLeech() -//| CBaseObject::SetHealthLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Gets/Sets the Health Leech -//o------------------------------------------------------------------------------------------------o -SI16 CBaseObject::GetHealthLeech( void ) const -{ - return healthLeech; -} -void CBaseObject::SetHealthLeech( SI16 nVal ) -{ - healthLeech = nVal; - - if( CanBeObjType( OT_ITEM )) - { - ( static_cast( this ))->UpdateRegion(); - } -} - -//o------------------------------------------------------------------------------------------------o -//| Function - CBaseObject::GetStaminaLeech() -//| CBaseObject::SetStaminaLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Gets/Sets the Stamina Leech -//o------------------------------------------------------------------------------------------------o -SI16 CBaseObject::GetStaminaLeech( void ) const -{ - return staminaLeech; -} -void CBaseObject::SetStaminaLeech( SI16 nVal ) -{ - staminaLeech = nVal; - - if( CanBeObjType( OT_ITEM )) - { - ( static_cast( this ))->UpdateRegion(); - } -} - -//o------------------------------------------------------------------------------------------------o -//| Function - CBaseObject::GetManaLeech() -//| CBaseObject::SetManaLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Gets/Sets the Mana Leech -//o------------------------------------------------------------------------------------------------o -SI16 CBaseObject::GetManaLeech( void ) const -{ - return manaLeech; -} -void CBaseObject::SetManaLeech( SI16 nVal ) -{ - manaLeech = nVal; - - if( CanBeObjType( OT_ITEM )) - { - ( static_cast( this ))->UpdateRegion(); - } -} - //o------------------------------------------------------------------------------------------------o //| Function - CBaseObject::IncStrength() //o------------------------------------------------------------------------------------------------o @@ -1725,36 +1661,6 @@ void CBaseObject::IncIntelligence( SI16 toInc ) SetIntelligence( intelligence + toInc ); } -//o------------------------------------------------------------------------------------------------o -//| Function - CBaseObject::IncHealthLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Increments the object's Health Leech Points value -//o------------------------------------------------------------------------------------------------o -void CBaseObject::IncHealthLeech( SI16 toInc ) -{ - SetHealthLeech( healthLeech + toInc ); -} - -//o------------------------------------------------------------------------------------------------o -//| Function - CBaseObject::IncStaminaLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Increments the object's Stamina Leech Points value -//o------------------------------------------------------------------------------------------------o -void CBaseObject::IncStaminaLeech( SI16 toInc ) -{ - SetStaminaLeech( staminaLeech + toInc ); -} - -//o------------------------------------------------------------------------------------------------o -//| Function - CBaseObject::IncManaLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Increments the object's Mana Leech Points value -//o------------------------------------------------------------------------------------------------o -void CBaseObject::IncManaLeech( SI16 toInc ) -{ - SetManaLeech( manaLeech + toInc ); -} - //o------------------------------------------------------------------------------------------------o //| Function - CBaseObject::DumpFooter() //o------------------------------------------------------------------------------------------------o diff --git a/source/cBaseObject.h b/source/cBaseObject.h index 316cd2530..638e826f7 100644 --- a/source/cBaseObject.h +++ b/source/cBaseObject.h @@ -75,9 +75,6 @@ class CBaseObject SI32 weight; SI16 mana; SI16 stamina; - SI16 healthLeech; - SI16 staminaLeech; - SI16 manaLeech; UI16 scriptTrig; SI16 st2; SI16 dx2; @@ -259,19 +256,6 @@ class CBaseObject void IncDexterity( SI16 toInc = 1 ); void IncIntelligence( SI16 toInc = 1 ); - SI16 GetHealthLeech( void ) const; - virtual void SetHealthLeech( SI16 nVal ); - - SI16 GetStaminaLeech( void ) const; - virtual void SetStaminaLeech( SI16 nVal ); - - SI16 GetManaLeech( void ) const; - virtual void SetManaLeech( SI16 nVal ); - - void IncHealthLeech( SI16 toInc = 1 ); - void IncStaminaLeech( SI16 toInc = 1 ); - void IncManaLeech( SI16 toInc = 1 ); - virtual void PostLoadProcessing( void ); virtual bool LoadRemnants( void ) = 0; diff --git a/source/cItem.cpp b/source/cItem.cpp index 672ece4dd..45559d0a9 100644 --- a/source/cItem.cpp +++ b/source/cItem.cpp @@ -93,6 +93,9 @@ const UI16 DEFITEM_MAXUSES = 0; const UI16 DEFITEM_REGIONNUM = 255; const UI16 DEFITEM_TEMPLASTTRADED = 0; const SI08 DEFITEM_STEALABLE = 1; +const SI16 DEFITEM_HEALTHLEECH = 0; +const SI16 DEFITEM_STAMINALEECH = 0; +const SI16 DEFITEM_MANALEECH = 0; //o------------------------------------------------------------------------------------------------o //| Function - CItem() @@ -107,7 +110,7 @@ spd( DEFITEM_SPEED ), maxHp( DEFITEM_MAXHP ), amount( DEFITEM_AMOUNT ), layer( DEFITEM_LAYER ), type( DEFITEM_TYPE ), offspell( DEFITEM_OFFSPELL ), entryMadeFrom( DEFITEM_ENTRYMADEFROM ), creator( DEFITEM_CREATOR ), gridLoc( DEFITEM_GRIDLOC ), weightMax( DEFITEM_WEIGHTMAX ), baseWeight( DEFITEM_BASEWEIGHT ), maxItems( DEFITEM_MAXITEMS ), maxRange( DEFITEM_MAXRANGE ), baseRange( DEFITEM_BASERANGE ), maxUses( DEFITEM_MAXUSES ), usesLeft( DEFITEM_USESLEFT ), regionNum( DEFITEM_REGIONNUM ), -tempLastTraded( DEFITEM_TEMPLASTTRADED ), stealable( DEFITEM_STEALABLE ) +tempLastTraded( DEFITEM_TEMPLASTTRADED ), stealable( DEFITEM_STEALABLE ), healthLeech( DEFITEM_HEALTHLEECH ), staminaLeech( DEFITEM_STAMINALEECH ), manaLeech( DEFITEM_MANALEECH ) { spells[0] = spells[1] = spells[2] = 0; value[0] = value[1] = value[2] = 0; @@ -542,6 +545,54 @@ auto CItem::SetSpawnerList( bool newValue ) -> void UpdateRegion(); } +//o------------------------------------------------------------------------------------------------o +//| Function - CItem::GetHealthLeech() +//| CItem::SetHealthLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Gets/Sets the Health Leech +//o------------------------------------------------------------------------------------------------o +SI16 CItem::GetHealthLeech( void ) const +{ + return healthLeech; +} +void CItem::SetHealthLeech( SI16 nVal ) +{ + healthLeech = nVal; + UpdateRegion(); +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CItem::GetStaminaLeech() +//| CItem::SetStaminaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Gets/Sets the Stamina Leech +//o------------------------------------------------------------------------------------------------o +SI16 CItem::GetStaminaLeech( void ) const +{ + return staminaLeech; +} +void CItem::SetStaminaLeech( SI16 nVal ) +{ + staminaLeech = nVal; + UpdateRegion(); +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CItem::GetManaLeech() +//| CItem::SetManaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Gets/Sets the Mana Leech +//o------------------------------------------------------------------------------------------------o +SI16 CItem::GetManaLeech( void ) const +{ + return manaLeech; +} +void CItem::SetManaLeech( SI16 nVal ) +{ + manaLeech = nVal; + UpdateRegion(); +} + //o------------------------------------------------------------------------------------------------o //| Function - CItem::GetName2() //| CItem::SetName2() @@ -1340,6 +1391,36 @@ auto CItem::SetWeightMax( SI32 newValue ) -> void UpdateRegion(); } +//o------------------------------------------------------------------------------------------------o +//| Function - CItem::IncHealthLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Increments the object's Health Leech Points value +//o------------------------------------------------------------------------------------------------o +void CItem::IncHealthLeech( SI16 toInc ) +{ + SetHealthLeech( healthLeech + toInc ); +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CItem::IncStaminaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Increments the object's Stamina Leech Points value +//o------------------------------------------------------------------------------------------------o +void CItem::IncStaminaLeech( SI16 toInc ) +{ + SetStaminaLeech( staminaLeech + toInc ); +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CItem::IncManaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Increments the object's Mana Leech Points value +//o------------------------------------------------------------------------------------------------o +void CItem::IncManaLeech( SI16 toInc ) +{ + SetManaLeech( manaLeech + toInc ); +} + //o------------------------------------------------------------------------------------------------o //| Function - CItem::GetBaseWeight() //| CItem::SetBaseWeight() diff --git a/source/cItem.h b/source/cItem.h index 3a3b60e5d..542aa62d6 100644 --- a/source/cItem.h +++ b/source/cItem.h @@ -41,6 +41,9 @@ class CItem : public CBaseObject TIMERVAL decayTime; UI08 spd; // The speed of the weapon UI16 maxHp; // Max number of hit points an item can have. + SI16 healthLeech; + SI16 staminaLeech; + SI16 manaLeech; UI16 amount; // Amount of items in pile ItemLayers layer; // Layer if equipped on paperdoll ItemTypes type; // For things that do special things on doubleclicking @@ -166,6 +169,19 @@ class CItem : public CBaseObject auto InDungeon() -> bool; + virtual SI16 GetHealthLeech( void ) const; + virtual void SetHealthLeech( SI16 nVal ); + + virtual SI16 GetStaminaLeech( void ) const; + virtual void SetStaminaLeech( SI16 nVal ); + + virtual SI16 GetManaLeech( void ) const; + virtual void SetManaLeech( SI16 nVal ); + + void IncHealthLeech( SI16 toInc = 1 ); + void IncStaminaLeech( SI16 toInc = 1 ); + void IncManaLeech( SI16 toInc = 1 ); + auto GetLayer() const -> ItemLayers; auto SetLayer( ItemLayers newValue ) -> void; From 6583a518dfbafc305a5adf4aad156478dedd849d Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Thu, 16 Jan 2025 19:09:59 -0600 Subject: [PATCH 5/5] Revert "Moved Leech Props" This reverts commit 41c7ee467664ed3242d8c40603f4be83e8e4a571. --- source/cBaseObject.cpp | 96 +++++++++++++++++++++++++++++++++++++++++- source/cBaseObject.h | 16 +++++++ source/cItem.cpp | 83 +----------------------------------- source/cItem.h | 16 ------- 4 files changed, 112 insertions(+), 99 deletions(-) diff --git a/source/cBaseObject.cpp b/source/cBaseObject.cpp index 506c247ac..2c5ce0b89 100644 --- a/source/cBaseObject.cpp +++ b/source/cBaseObject.cpp @@ -94,6 +94,9 @@ const SI16 DEFBASE_KILLS = 0; const UI16 DEFBASE_RESIST = 0; const bool DEFBASE_NAMEREQUESTACTIVE = 0; const ExpansionRuleset DEFBASE_ORIGIN = ER_UO; +const SI16 DEFBASE_HEALTHLEECH = 0; +const SI16 DEFBASE_STAMINALEECH = 0; +const SI16 DEFBASE_MANALEECH = 0; //o------------------------------------------------------------------------------------------------o //| Function - CBaseObject constructor @@ -110,7 +113,8 @@ loDamage( DEFBASE_LODAMAGE ), weight( DEFBASE_WEIGHT ), mana( DEFBASE_MANA ), stamina( DEFBASE_STAMINA ), scriptTrig( DEFBASE_SCPTRIG ), st2( DEFBASE_STR2 ), dx2( DEFBASE_DEX2 ), in2( DEFBASE_INT2 ), FilePosition( DEFBASE_FP ), poisoned( DEFBASE_POISONED ), carve( DEFBASE_CARVE ), oldLocX( 0 ), oldLocY( 0 ), oldLocZ( 0 ), oldTargLocX( 0 ), oldTargLocY( 0 ), -fame( DEFBASE_FAME ), karma( DEFBASE_KARMA ), kills( DEFBASE_KILLS ), subRegion( DEFBASE_SUBREGION ), nameRequestActive( DEFBASE_NAMEREQUESTACTIVE ), origin( DEFBASE_ORIGIN ) +fame( DEFBASE_FAME ), karma( DEFBASE_KARMA ), kills( DEFBASE_KILLS ), subRegion( DEFBASE_SUBREGION ), nameRequestActive( DEFBASE_NAMEREQUESTACTIVE ), origin( DEFBASE_ORIGIN ), +healthLeech( DEFBASE_HEALTHLEECH ), staminaLeech( DEFBASE_STAMINALEECH ), manaLeech( DEFBASE_MANALEECH ) { multis = nullptr; tempMulti = INVALIDSERIAL; @@ -1631,6 +1635,66 @@ void CBaseObject::SetIntelligence2( SI16 nVal ) } } +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::GetHealthLeech() +//| CBaseObject::SetHealthLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Gets/Sets the Health Leech +//o------------------------------------------------------------------------------------------------o +SI16 CBaseObject::GetHealthLeech( void ) const +{ + return healthLeech; +} +void CBaseObject::SetHealthLeech( SI16 nVal ) +{ + healthLeech = nVal; + + if( CanBeObjType( OT_ITEM )) + { + ( static_cast( this ))->UpdateRegion(); + } +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::GetStaminaLeech() +//| CBaseObject::SetStaminaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Gets/Sets the Stamina Leech +//o------------------------------------------------------------------------------------------------o +SI16 CBaseObject::GetStaminaLeech( void ) const +{ + return staminaLeech; +} +void CBaseObject::SetStaminaLeech( SI16 nVal ) +{ + staminaLeech = nVal; + + if( CanBeObjType( OT_ITEM )) + { + ( static_cast( this ))->UpdateRegion(); + } +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::GetManaLeech() +//| CBaseObject::SetManaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Gets/Sets the Mana Leech +//o------------------------------------------------------------------------------------------------o +SI16 CBaseObject::GetManaLeech( void ) const +{ + return manaLeech; +} +void CBaseObject::SetManaLeech( SI16 nVal ) +{ + manaLeech = nVal; + + if( CanBeObjType( OT_ITEM )) + { + ( static_cast( this ))->UpdateRegion(); + } +} + //o------------------------------------------------------------------------------------------------o //| Function - CBaseObject::IncStrength() //o------------------------------------------------------------------------------------------------o @@ -1661,6 +1725,36 @@ void CBaseObject::IncIntelligence( SI16 toInc ) SetIntelligence( intelligence + toInc ); } +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::IncHealthLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Increments the object's Health Leech Points value +//o------------------------------------------------------------------------------------------------o +void CBaseObject::IncHealthLeech( SI16 toInc ) +{ + SetHealthLeech( healthLeech + toInc ); +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::IncStaminaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Increments the object's Stamina Leech Points value +//o------------------------------------------------------------------------------------------------o +void CBaseObject::IncStaminaLeech( SI16 toInc ) +{ + SetStaminaLeech( staminaLeech + toInc ); +} + +//o------------------------------------------------------------------------------------------------o +//| Function - CBaseObject::IncManaLeech() +//o------------------------------------------------------------------------------------------------o +//| Purpose - Increments the object's Mana Leech Points value +//o------------------------------------------------------------------------------------------------o +void CBaseObject::IncManaLeech( SI16 toInc ) +{ + SetManaLeech( manaLeech + toInc ); +} + //o------------------------------------------------------------------------------------------------o //| Function - CBaseObject::DumpFooter() //o------------------------------------------------------------------------------------------------o diff --git a/source/cBaseObject.h b/source/cBaseObject.h index 638e826f7..316cd2530 100644 --- a/source/cBaseObject.h +++ b/source/cBaseObject.h @@ -75,6 +75,9 @@ class CBaseObject SI32 weight; SI16 mana; SI16 stamina; + SI16 healthLeech; + SI16 staminaLeech; + SI16 manaLeech; UI16 scriptTrig; SI16 st2; SI16 dx2; @@ -256,6 +259,19 @@ class CBaseObject void IncDexterity( SI16 toInc = 1 ); void IncIntelligence( SI16 toInc = 1 ); + SI16 GetHealthLeech( void ) const; + virtual void SetHealthLeech( SI16 nVal ); + + SI16 GetStaminaLeech( void ) const; + virtual void SetStaminaLeech( SI16 nVal ); + + SI16 GetManaLeech( void ) const; + virtual void SetManaLeech( SI16 nVal ); + + void IncHealthLeech( SI16 toInc = 1 ); + void IncStaminaLeech( SI16 toInc = 1 ); + void IncManaLeech( SI16 toInc = 1 ); + virtual void PostLoadProcessing( void ); virtual bool LoadRemnants( void ) = 0; diff --git a/source/cItem.cpp b/source/cItem.cpp index 45559d0a9..672ece4dd 100644 --- a/source/cItem.cpp +++ b/source/cItem.cpp @@ -93,9 +93,6 @@ const UI16 DEFITEM_MAXUSES = 0; const UI16 DEFITEM_REGIONNUM = 255; const UI16 DEFITEM_TEMPLASTTRADED = 0; const SI08 DEFITEM_STEALABLE = 1; -const SI16 DEFITEM_HEALTHLEECH = 0; -const SI16 DEFITEM_STAMINALEECH = 0; -const SI16 DEFITEM_MANALEECH = 0; //o------------------------------------------------------------------------------------------------o //| Function - CItem() @@ -110,7 +107,7 @@ spd( DEFITEM_SPEED ), maxHp( DEFITEM_MAXHP ), amount( DEFITEM_AMOUNT ), layer( DEFITEM_LAYER ), type( DEFITEM_TYPE ), offspell( DEFITEM_OFFSPELL ), entryMadeFrom( DEFITEM_ENTRYMADEFROM ), creator( DEFITEM_CREATOR ), gridLoc( DEFITEM_GRIDLOC ), weightMax( DEFITEM_WEIGHTMAX ), baseWeight( DEFITEM_BASEWEIGHT ), maxItems( DEFITEM_MAXITEMS ), maxRange( DEFITEM_MAXRANGE ), baseRange( DEFITEM_BASERANGE ), maxUses( DEFITEM_MAXUSES ), usesLeft( DEFITEM_USESLEFT ), regionNum( DEFITEM_REGIONNUM ), -tempLastTraded( DEFITEM_TEMPLASTTRADED ), stealable( DEFITEM_STEALABLE ), healthLeech( DEFITEM_HEALTHLEECH ), staminaLeech( DEFITEM_STAMINALEECH ), manaLeech( DEFITEM_MANALEECH ) +tempLastTraded( DEFITEM_TEMPLASTTRADED ), stealable( DEFITEM_STEALABLE ) { spells[0] = spells[1] = spells[2] = 0; value[0] = value[1] = value[2] = 0; @@ -545,54 +542,6 @@ auto CItem::SetSpawnerList( bool newValue ) -> void UpdateRegion(); } -//o------------------------------------------------------------------------------------------------o -//| Function - CItem::GetHealthLeech() -//| CItem::SetHealthLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Gets/Sets the Health Leech -//o------------------------------------------------------------------------------------------------o -SI16 CItem::GetHealthLeech( void ) const -{ - return healthLeech; -} -void CItem::SetHealthLeech( SI16 nVal ) -{ - healthLeech = nVal; - UpdateRegion(); -} - -//o------------------------------------------------------------------------------------------------o -//| Function - CItem::GetStaminaLeech() -//| CItem::SetStaminaLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Gets/Sets the Stamina Leech -//o------------------------------------------------------------------------------------------------o -SI16 CItem::GetStaminaLeech( void ) const -{ - return staminaLeech; -} -void CItem::SetStaminaLeech( SI16 nVal ) -{ - staminaLeech = nVal; - UpdateRegion(); -} - -//o------------------------------------------------------------------------------------------------o -//| Function - CItem::GetManaLeech() -//| CItem::SetManaLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Gets/Sets the Mana Leech -//o------------------------------------------------------------------------------------------------o -SI16 CItem::GetManaLeech( void ) const -{ - return manaLeech; -} -void CItem::SetManaLeech( SI16 nVal ) -{ - manaLeech = nVal; - UpdateRegion(); -} - //o------------------------------------------------------------------------------------------------o //| Function - CItem::GetName2() //| CItem::SetName2() @@ -1391,36 +1340,6 @@ auto CItem::SetWeightMax( SI32 newValue ) -> void UpdateRegion(); } -//o------------------------------------------------------------------------------------------------o -//| Function - CItem::IncHealthLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Increments the object's Health Leech Points value -//o------------------------------------------------------------------------------------------------o -void CItem::IncHealthLeech( SI16 toInc ) -{ - SetHealthLeech( healthLeech + toInc ); -} - -//o------------------------------------------------------------------------------------------------o -//| Function - CItem::IncStaminaLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Increments the object's Stamina Leech Points value -//o------------------------------------------------------------------------------------------------o -void CItem::IncStaminaLeech( SI16 toInc ) -{ - SetStaminaLeech( staminaLeech + toInc ); -} - -//o------------------------------------------------------------------------------------------------o -//| Function - CItem::IncManaLeech() -//o------------------------------------------------------------------------------------------------o -//| Purpose - Increments the object's Mana Leech Points value -//o------------------------------------------------------------------------------------------------o -void CItem::IncManaLeech( SI16 toInc ) -{ - SetManaLeech( manaLeech + toInc ); -} - //o------------------------------------------------------------------------------------------------o //| Function - CItem::GetBaseWeight() //| CItem::SetBaseWeight() diff --git a/source/cItem.h b/source/cItem.h index 542aa62d6..3a3b60e5d 100644 --- a/source/cItem.h +++ b/source/cItem.h @@ -41,9 +41,6 @@ class CItem : public CBaseObject TIMERVAL decayTime; UI08 spd; // The speed of the weapon UI16 maxHp; // Max number of hit points an item can have. - SI16 healthLeech; - SI16 staminaLeech; - SI16 manaLeech; UI16 amount; // Amount of items in pile ItemLayers layer; // Layer if equipped on paperdoll ItemTypes type; // For things that do special things on doubleclicking @@ -169,19 +166,6 @@ class CItem : public CBaseObject auto InDungeon() -> bool; - virtual SI16 GetHealthLeech( void ) const; - virtual void SetHealthLeech( SI16 nVal ); - - virtual SI16 GetStaminaLeech( void ) const; - virtual void SetStaminaLeech( SI16 nVal ); - - virtual SI16 GetManaLeech( void ) const; - virtual void SetManaLeech( SI16 nVal ); - - void IncHealthLeech( SI16 toInc = 1 ); - void IncStaminaLeech( SI16 toInc = 1 ); - void IncManaLeech( SI16 toInc = 1 ); - auto GetLayer() const -> ItemLayers; auto SetLayer( ItemLayers newValue ) -> void;