From 022612f19da5aee1e158d7dae55fbbb8c51aefe1 Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:30:32 -0600 Subject: [PATCH 1/8] fixed pr --- source/CPacketSend.cpp | 7 +++++++ source/Changelog.txt | 4 ++++ source/UOXJSPropertyEnums.h | 1 + source/UOXJSPropertyFuncs.cpp | 2 ++ source/UOXJSPropertySpecs.h | 1 + source/cItem.cpp | 27 ++++++++++++++++++++++++++- source/cItem.h | 4 ++++ source/items.cpp | 7 +++++++ 8 files changed, 52 insertions(+), 1 deletion(-) diff --git a/source/CPacketSend.cpp b/source/CPacketSend.cpp index ba30f52d8..26ace5932 100644 --- a/source/CPacketSend.cpp +++ b/source/CPacketSend.cpp @@ -7467,6 +7467,13 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou FinalizeData( tempEntry, totalStringLen ); } + if( cItem.GetDurabilityHpBonus() > 0) + { + tempEntry.stringNum = 1151780; // durability +~1_VAL~% + tempEntry.ourText = oldstrutil::number( cItem.GetDurabilityHpBonus() ); + FinalizeData( tempEntry, totalStringLen ); + } + if( cItem.GetType() == IT_MAGICWAND && cItem.GetTempVar( CITV_MOREZ )) { tempEntry.stringNum = 1060584; // uses remaining: ~1_val~ diff --git a/source/Changelog.txt b/source/Changelog.txt index b0801d426..6793d7f87 100644 --- a/source/Changelog.txt +++ b/source/Changelog.txt @@ -1,3 +1,7 @@ +11/05/2024 - Dragon Slayer/Xuri/Maarc + Added Support for new AOS property tag. + -DURABILITYHPBONUS - Add durability (aka Health) to the hp and max hp as a bonus + 13/05/2024 - Dragon Slayer Added New Shield Type 107 so shield ID's no longer have to be in hard code for shields to work properly diff --git a/source/UOXJSPropertyEnums.h b/source/UOXJSPropertyEnums.h index 45517f28d..a251ff810 100644 --- a/source/UOXJSPropertyEnums.h +++ b/source/UOXJSPropertyEnums.h @@ -462,6 +462,7 @@ enum CI_Properties CIP_DAMAGERAIN, CIP_DAMAGESNOW, CIP_ARTIFACTRARITY, + CIP_DURABILITYHPBONUS, CIP_NAME2, CIP_ISITEM, CIP_ISCHAR, diff --git a/source/UOXJSPropertyFuncs.cpp b/source/UOXJSPropertyFuncs.cpp index 5fc2a3a82..3ff32a939 100644 --- a/source/UOXJSPropertyFuncs.cpp +++ b/source/UOXJSPropertyFuncs.cpp @@ -676,6 +676,7 @@ 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_DURABILITYHPBONUS: *vp = INT_TO_JSVAL( gPriv->GetDurabilityHpBonus() ); break; case CIP_ARTIFACTRARITY: *vp = INT_TO_JSVAL( gPriv->GetArtifactRarity() ); break; case CIP_NAME2: tString = JS_NewStringCopyZ( cx, gPriv->GetName2().c_str() ); @@ -1323,6 +1324,7 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp case CIP_DAMAGESNOW: gPriv->SetWeatherDamage( SNOW, encaps.toBool() ); break; case CIP_SPEED: gPriv->SetSpeed( static_cast( encaps.toInt() )); break; case CIP_ARTIFACTRARITY: gPriv->SetArtifactRarity( static_cast( encaps.toInt() )); break; + case CIP_DURABILITYHPBONUS: gPriv->SetDurabilityHpBonus( 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 8607ffab5..d6e870642 100644 --- a/source/UOXJSPropertySpecs.h +++ b/source/UOXJSPropertySpecs.h @@ -536,6 +536,7 @@ inline JSPropertySpec CItemProps[] = { "ammoFXRender", CIP_AMMOFXRENDER, JSPROP_ENUMANDPERM, nullptr, nullptr }, { "speed", CIP_SPEED, JSPROP_ENUMANDPERM, nullptr, nullptr }, { "artifactRarity", CIP_ARTIFACTRARITY, JSPROP_ENUMANDPERM, nullptr, nullptr }, + { "durabilityHpBonus", CIP_DURABILITYHPBONUS, 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/cItem.cpp b/source/cItem.cpp index 3a2acd106..73d7ba539 100644 --- a/source/cItem.cpp +++ b/source/cItem.cpp @@ -94,6 +94,7 @@ const UI16 DEFITEM_REGIONNUM = 255; const UI16 DEFITEM_TEMPLASTTRADED = 0; const SI08 DEFITEM_STEALABLE = 1; const SI16 DEFITEM_ARTIFACTRARITY = 0; +const SI16 DEFITEM_DURABLITITYHPBONUS = 0; //o------------------------------------------------------------------------------------------------o //| Function - CItem() @@ -108,7 +109,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 ), artifactRarity(DEFITEM_ARTIFACTRARITY) +tempLastTraded( DEFITEM_TEMPLASTTRADED ), stealable( DEFITEM_STEALABLE ), artifactRarity(DEFITEM_ARTIFACTRARITY), durabilityHpBonus( DEFITEM_DURABLITITYHPBONUS ) { spells[0] = spells[1] = spells[2] = 0; value[0] = value[1] = value[2] = 0; @@ -1374,6 +1375,23 @@ auto CItem::SetBaseWeight( SI32 newValue ) -> void UpdateRegion(); } +//o------------------------------------------------------------------------------------------------o +//| Function - CItem::GetDurabilityHpBonus() +//| CItem::SetDurabilityHpBonus() +//| Date - 5 May, 2024 +//o------------------------------------------------------------------------------------------------o +//| Purpose - Gets/Sets the Bonus hp on the object +//o------------------------------------------------------------------------------------------------o +SI16 CItem::GetDurabilityHpBonus(void) const +{ + return durabilityHpBonus; +} +void CItem::SetDurabilityHpBonus(SI16 newValue) +{ + durabilityHpBonus = newValue; + UpdateRegion(); +} + //o------------------------------------------------------------------------------------------------o //| Function - CItem::GetMaxItems() //| CItem::SetMaxItems() @@ -1655,6 +1673,7 @@ auto CItem::CopyData( CItem *target ) -> void target->SetSpawn( GetSpawn() ); target->SetSpeed( GetSpeed() ); target->SetArtifactRarity( GetArtifactRarity() ); + target->SetDurabilityHpBonus( GetDurabilityHpBonus() ); target->SetSpell( 0, GetSpell( 0 )); target->SetSpell( 1, GetSpell( 1 )); target->SetSpell( 2, GetSpell( 2 )); @@ -1755,6 +1774,7 @@ bool CItem::DumpBody( std::ostream &outStream ) const outStream << "MaxHP=" + std::to_string( GetMaxHP() ) + newLine; outStream << "Speed=" + std::to_string( GetSpeed() ) + newLine; outStream << "ArtifactRarity=" + std::to_string( GetArtifactRarity() ) + newLine; + outStream << "DurabilityHpBonus=" + std::to_string( GetDurabilityHpBonus() ) + newLine; outStream << "Movable=" + std::to_string( GetMovable() ) + newLine; outStream << "Priv=" + std::to_string( GetPriv() ) + newLine; outStream << "Value=" + std::to_string( GetBuyValue() ) + "," + std::to_string( GetSellValue() ) + "," + std::to_string( GetVendorPrice() ) + newLine; @@ -1877,6 +1897,11 @@ bool CItem::HandleLine( std::string &UTag, std::string &data ) SetDir( static_cast( std::stoi(oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 ))); rValue = true; } + else if( UTag == "DURABILITYHPBONUS" ) + { + SetDurabilityHpBonus( static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 ))); + rValue = true; + } else if( UTag == "DYEABLE" ) { SetDye( static_cast( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 )) == 1 ); diff --git a/source/cItem.h b/source/cItem.h index 4b220999e..a9ae5bec6 100644 --- a/source/cItem.h +++ b/source/cItem.h @@ -49,6 +49,7 @@ class CItem : public CBaseObject SERIAL creator; // Store the serial of the player made this item SI08 gridLoc; SI16 artifactRarity; + SI16 durabilityHpBonus; SI32 weightMax; // Maximum weight a container can hold SI32 baseWeight; // Base weight of item. Applied when item is created for the first time, based on weight. Primarily used to determine base weight of containers UI16 maxItems; // Maximum amount of items a container can hold @@ -114,6 +115,9 @@ class CItem : public CBaseObject virtual SI16 GetArtifactRarity(void) const; virtual void SetArtifactRarity(SI16 newValue); + virtual SI16 GetDurabilityHpBonus(void) const; + virtual void SetDurabilityHpBonus(SI16 newValue); + auto GetStealable() const -> UI08; auto SetStealable( UI08 newValue ) -> void; diff --git a/source/items.cpp b/source/items.cpp index a95e80f70..d1ed78f7f 100644 --- a/source/items.cpp +++ b/source/items.cpp @@ -1194,6 +1194,13 @@ CItem * cItem::CreateBaseScriptItem( CItem *mCont, std::string ourItem, const UI Console.Error( "Trying to apply an item section failed" ); } + // If the durabilityhpbonus tag is on the item, it will add to its Durability (aka Health). + auto durabilityHpBonus = iCreated->GetDurabilityHpBonus(); + if( durabilityHpBonus > 0 ) + { + iCreated->SetHP( iCreated->GetHP() + durabilityHpBonus ); + } + // If maxHP has not been defined for a new item, set it to the same value as HP if( !iCreated->GetMaxHP() && iCreated->GetHP() ) { From c1f2a79973511b51993d01a19cde72775cdc3d75 Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:33:31 -0600 Subject: [PATCH 2/8] fix --- source/items.cpp | 1 + source/ssection.h | 1 + 2 files changed, 2 insertions(+) diff --git a/source/items.cpp b/source/items.cpp index d1ed78f7f..e460d1944 100644 --- a/source/items.cpp +++ b/source/items.cpp @@ -118,6 +118,7 @@ auto ApplyItemSection( CItem *applyTo, CScriptSection *toApply, std::string sect Console.Warning( oldstrutil::format( "Invalid data found in AMOUNT tag inside item script [%s]", sectionId.c_str() )); } break; + case DFNTAG_DURABILITYHPBONUS: applyTo->SetDurabilityHpBonus( static_cast( ndata )); break; case DFNTAG_DAMAGE: case DFNTAG_ATT: if( ndata >= 0 ) diff --git a/source/ssection.h b/source/ssection.h index c652b9d3b..86be259dc 100644 --- a/source/ssection.h +++ b/source/ssection.h @@ -60,6 +60,7 @@ enum DFNTAGS DFNTAG_CREATOR, DFNTAG_CUSTOMSTRINGTAG, DFNTAG_CUSTOMINTTAG, + DFNTAG_DURABILITYHPBONUS, DFNTAG_DAMAGE, DFNTAG_DAMAGEABLE, DFNTAG_DECAY, From 21082cf4ebece06734566fa7d8f63b23fe9bee7d Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:35:32 -0600 Subject: [PATCH 3/8] Update ssection.cpp --- source/ssection.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/ssection.cpp b/source/ssection.cpp index fae41e7a1..9cea48baf 100644 --- a/source/ssection.cpp +++ b/source/ssection.cpp @@ -65,6 +65,7 @@ const UI08 dfnDataTypes[DFNTAG_COUNTOFTAGS] = DFN_NODATA, // DFNTAG_DISPELLABLE, DFN_NUMERIC, // DFNTAG_DISABLED, DFN_NUMERIC, // DFNTAG_DOORFLAG, + DFN_NUMERIC, // DFNTAG_DURABILITYHPBONUS, DFN_NUMERIC, // DFNTAG_DYE, DFN_NUMERIC, // DFNTAG_DYEBEARD, DFN_NUMERIC, // DFNTAG_DYEHAIR, @@ -319,6 +320,7 @@ const std::map strToDFNTag {"DISPELLABLE"s, DFNTAG_DISPELLABLE}, {"DISABLED"s, DFNTAG_DISABLED}, {"DOORFLAG"s, DFNTAG_DOORFLAG}, + {"DURABILITYHPBONUS"s, DFNTAG_DURABILITYHPBONUS}, {"DYE"s, DFNTAG_DYE}, {"DYEABLE"s, DFNTAG_DYE}, {"DYEHAIR"s, DFNTAG_DYEHAIR}, From add5789e065504a138cac07ed8bda8f9d559b00a Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:37:08 -0600 Subject: [PATCH 4/8] Update items.cpp --- source/items.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/items.cpp b/source/items.cpp index e460d1944..1189d3dc5 100644 --- a/source/items.cpp +++ b/source/items.cpp @@ -1207,6 +1207,10 @@ CItem * cItem::CreateBaseScriptItem( CItem *mCont, std::string ourItem, const UI { iCreated->SetMaxHP( iCreated->GetHP() ); } + else + {// If you add a maxhp tag and have durabilityHpBonus, it will increase the Durability (aka Health). + iCreated->SetMaxHP( iCreated->GetMaxHP() + durabilityHpBonus ); + } // If maxUses is higher than usesLeft for a new item, randomize the amount of usesLeft the item should have! if( iCreated->GetMaxUses() > iCreated->GetUsesLeft() ) From 39cda622d2dff605de1db0397f208ad80ad5afb1 Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Thu, 16 Jan 2025 21:50:00 -0600 Subject: [PATCH 5/8] Update Changelog.txt --- source/Changelog.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/Changelog.txt b/source/Changelog.txt index 6793d7f87..cc2108ceb 100644 --- a/source/Changelog.txt +++ b/source/Changelog.txt @@ -1,10 +1,10 @@ +13/05/2024 - Dragon Slayer + Added New Shield Type 107 so shield ID's no longer have to be in hard code for shields to work properly + 11/05/2024 - Dragon Slayer/Xuri/Maarc Added Support for new AOS property tag. -DURABILITYHPBONUS - Add durability (aka Health) to the hp and max hp as a bonus -13/05/2024 - Dragon Slayer - Added New Shield Type 107 so shield ID's no longer have to be in hard code for shields to work properly - 09/05/2024 - Dragon Slayer Added ArtifactRarity AOS Property for items -ARTIFACTRARITY=# From c338f92f6a201ffb2824c67f4a337561ff9364dd Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Thu, 16 Jan 2025 22:09:54 -0600 Subject: [PATCH 6/8] Update cItem.h --- source/cItem.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/cItem.h b/source/cItem.h index a9ae5bec6..2f503918c 100644 --- a/source/cItem.h +++ b/source/cItem.h @@ -112,11 +112,11 @@ class CItem : public CBaseObject auto GetGridLocation() const -> SI08; auto SetGridLocation( SI08 newLoc ) -> void; - virtual SI16 GetArtifactRarity(void) const; - virtual void SetArtifactRarity(SI16 newValue); + SI16 GetArtifactRarity(void) const; + void SetArtifactRarity(SI16 newValue); - virtual SI16 GetDurabilityHpBonus(void) const; - virtual void SetDurabilityHpBonus(SI16 newValue); + SI16 GetDurabilityHpBonus(void) const; + void SetDurabilityHpBonus(SI16 newValue); auto GetStealable() const -> UI08; auto SetStealable( UI08 newValue ) -> void; From 1d2bab8889539ebd64285fd93ac1e26fd2306276 Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Wed, 22 Jan 2025 09:28:03 -0600 Subject: [PATCH 7/8] Fixed Fixed what maarc was talking about also adjusted this to be percent. --- source/items.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/source/items.cpp b/source/items.cpp index 1189d3dc5..be0149117 100644 --- a/source/items.cpp +++ b/source/items.cpp @@ -1197,19 +1197,32 @@ CItem * cItem::CreateBaseScriptItem( CItem *mCont, std::string ourItem, const UI // If the durabilityhpbonus tag is on the item, it will add to its Durability (aka Health). auto durabilityHpBonus = iCreated->GetDurabilityHpBonus(); - if( durabilityHpBonus > 0 ) - { - iCreated->SetHP( iCreated->GetHP() + durabilityHpBonus ); - } // If maxHP has not been defined for a new item, set it to the same value as HP - if( !iCreated->GetMaxHP() && iCreated->GetHP() ) + if (!iCreated->GetMaxHP() && iCreated->GetHP()) { - iCreated->SetMaxHP( iCreated->GetHP() ); + iCreated->SetMaxHP(iCreated->GetHP()); } - else - {// If you add a maxhp tag and have durabilityHpBonus, it will increase the Durability (aka Health). - iCreated->SetMaxHP( iCreated->GetMaxHP() + durabilityHpBonus ); + + if( durabilityHpBonus > 0 ) + { + // Calculate percentage increase + auto baseHP = iCreated->GetHP(); + auto baseMaxHP = iCreated->GetMaxHP(); + + // If maxHP has not been defined, default it to HP + if( baseMaxHP == 0 && baseHP > 0 ) + { + baseMaxHP = baseHP; + iCreated->SetMaxHP( baseMaxHP ); + } + + // Apply the percentage bonus to HP and MaxHP + auto hpBonus = static_cast( baseHP * ( durabilityHpBonus / 100.0 )); + auto maxHpBonus = static_cast( baseMaxHP * ( durabilityHpBonus / 100.0 )); + + iCreated->SetHP( baseHP + hpBonus ); + iCreated->SetMaxHP( baseMaxHP + maxHpBonus ); } // If maxUses is higher than usesLeft for a new item, randomize the amount of usesLeft the item should have! From a895f604c600fecbe8e71817ce598118867dbca5 Mon Sep 17 00:00:00 2001 From: Dragon Slayer <85514184+DragonSlayer62@users.noreply.github.com> Date: Fri, 24 Jan 2025 10:49:47 -0600 Subject: [PATCH 8/8] Update Changelog.txt --- source/Changelog.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/Changelog.txt b/source/Changelog.txt index cc2108ceb..dab54daf9 100644 --- a/source/Changelog.txt +++ b/source/Changelog.txt @@ -3,7 +3,8 @@ 11/05/2024 - Dragon Slayer/Xuri/Maarc Added Support for new AOS property tag. - -DURABILITYHPBONUS - Add durability (aka Health) to the hp and max hp as a bonus + -DURABILITYHPBONUS = # - Add durability (aka Health) at percentage multiplier to hp. + .durabilityhpbonus (js) 09/05/2024 - Dragon Slayer Added ArtifactRarity AOS Property for items