Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOS Properties Regeneration #277

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
9 changes: 9 additions & 0 deletions data/js/commands/targeting/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,15 @@ function HandleGetItem( socket, ourItem, uKey )
case "RESISTPOISON":
socket.SysMessage( ourObj.Resist( 7 ));
break;
case "HEALTHREGEN":
socket.SysMessage( ourItem.healthRegen );
break;
case "STAMINAREGEN":
socket.SysMessage( ourItem.staminaRegen );
break;
case "MANAREGEN":
socket.SysMessage( ourItem.manaRegen );
break;
case "ARMORCLASS":
case "ARMOURCLASS":
case "AC":
Expand Down
12 changes: 12 additions & 0 deletions data/js/commands/targeting/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ function onCallback0( socket, ourObj )
ourObj.Resist( 7, nVal );
okMsg( socket );
break;
case "HEALTHREGEN":
ourItem.healthRegen = nVal;
okMsg( socket );
break;
case "STAMINAREGEN":
ourItem.staminaRegen = nVal;
okMsg( socket );
break;
case "MANAREGEN":
ourItem.manaRegen = nVal;
okMsg( socket );
break;
case "HP":
case "HEALTH":
ourObj.health = nVal;
Expand Down
6 changes: 3 additions & 3 deletions data/js/skill/animallore.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ function onCallback0( pSock, ourObj )
animalLoreGump.AddGump( 28, 76, 0x826 );
animalLoreGump.AddHTMLGump( 47, 74, 160, 18, false, false, "<basefont color=#0000C8>" + GetDictionaryEntry( 2135, pSock.language ) + "</basefont>" ); // Attributes
animalLoreGump.AddHTMLGump( 53, 92, 160, 18, false, false, "<basefont color=#33310b>" + GetDictionaryEntry( 2144, pSock.language ) + "</basefont>" ); // Hit Point Regeneration
animalLoreGump.AddHTMLGump( position, 92, 75, 18, false, false, "N/A" ); // Not implemented yet
animalLoreGump.AddHTMLGump( position, 92, 75, 18, false, false, ourObj.healthRegen.toString() );
animalLoreGump.AddHTMLGump( 53, 110, 160, 18, false, false, "<basefont color=#33310b>" + GetDictionaryEntry( 2145, pSock.language ) + "</basefont>" ); // Stamina Regeneration
animalLoreGump.AddHTMLGump( position, 110, 75, 18, false, false, "N/A" ); // Not implemented yet
animalLoreGump.AddHTMLGump( position, 110, 75, 18, false, false, ourObj.staminaRegen.toString() );
animalLoreGump.AddHTMLGump( 53, 128, 160, 18, false, false, "<basefont color=#33310b>" + GetDictionaryEntry( 2146, pSock.language ) + "</basefont>" ); // Mana Regeneration
animalLoreGump.AddHTMLGump( position, 128, 75, 18, false, false, "N/A" ); // Not implemented yet
animalLoreGump.AddHTMLGump( position, 128, 75, 18, false, false, ourObj.manaRegen.toString() );
animalLoreGump.AddButton( 240, 328, 0x15E1, 0x15E5, 0, 3, 0 );
animalLoreGump.AddButton( 217, 328, 0x15E3, 0x15E7, 0, 1, 0 );
}
Expand Down
21 changes: 21 additions & 0 deletions source/CPacketSend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7657,6 +7657,27 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
FinalizeData( tempEntry, totalStringLen );
}

if( cItem.GetHealthRegen() > 0 )
{
tempEntry.stringNum = 1060444; // hit point regeneration ~1_val~
tempEntry.ourText = oldstrutil::number( cItem.GetHealthRegen() );
FinalizeData( tempEntry, totalStringLen );
}

if( cItem.GetStaminaRegen() > 0 )
{
tempEntry.stringNum = 1060443; // stamina regeneration ~1_val~
tempEntry.ourText = oldstrutil::number( cItem.GetStaminaRegen() );
FinalizeData( tempEntry, totalStringLen );
}

if( cItem.GetManaRegen() > 0 )
{
tempEntry.stringNum = 1060440; // mana regeneration ~1_val~
tempEntry.ourText = oldstrutil::number( cItem.GetManaRegen() );
FinalizeData( tempEntry, totalStringLen );
}

if( cItem.GetStrength() > 1 )
{
tempEntry.stringNum = 1061170; // strength requirement ~1_val~
Expand Down
12 changes: 12 additions & 0 deletions source/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
Fixed createfood to check for reagents on cast.
Fixed many places missing proper null checks and refresh checks in magic js scripts.

30/04/2024 - Dragon Slayer/Xuri/Maarc
Added three new DFN tags for NPCs and Items:
HEALTHREGEN=# // amount of health a character regains (continously) over time defined in regen timer settings
STAMINAREGEN=# // amount of stamina a character regains (continously) over time defined in regen timer settings
MANAREGEN=# // amount of mana a character regains (continously) over time defined in regen timer settings
These are also available as JS Engine object properties: .healthRegen, .staminaRegen and .manaRegen
Added AOS-specific formula for mana regeneration
Added INI Settings:
HEALTHREGENCAP=# // Max cap for Health Regeneration stat per character
STAMINAREGENCAP=# // Max cap for Stamina Regeneration stat per character
MANAREGENCAP=# // Max cap for Mana Regeneration stat per character

27/04/2024 - Dragon Slayer/Xuri
Fixed an issue where non-corpse containers - including treasure chests in dungeons - would decay and leave all their contents on the ground.
Converted LOOTDECAYSWITHCORPSE ini setting to two new settings, one for player corpses, one for NPC corpses:
Expand Down
9 changes: 9 additions & 0 deletions source/SEFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5086,6 +5086,15 @@ JSBool SE_GetServerSetting( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN
case 349: // LOOTDECAYSWITHPLAYERCORPSE
*rval = BOOLEAN_TO_JSVAL( cwmWorldState->ServerData()->NpcCorpseLootDecay() );
break;
case 350: // HEALTHREGENCAP
*rval = INT_TO_JSVAL( static_cast<SI16>( cwmWorldState->ServerData()->HealthRegenCap() ));
break;
case 351: // STAMINAREGENCAP
*rval = INT_TO_JSVAL( static_cast<SI16>( cwmWorldState->ServerData()->StaminaRegenCap() ));
break;
case 352: // MANAREGENCAP
*rval = INT_TO_JSVAL( static_cast<SI16>( cwmWorldState->ServerData()->ManaRegenCap() ));
break;
default:
ScriptError( cx, "GetServerSetting: Invalid server setting name provided" );
return false;
Expand Down
6 changes: 6 additions & 0 deletions source/UOXJSPropertyEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ enum CC_Properties
CCP_ACTUALDEXTERITY,
CCP_ACTUALINTELLIGENCE,
CCP_ACTUALSTRENGTH,
CCP_HEALTHREGEN,
CCP_STAMINAREGEN,
CCP_MANAREGEN,
CCP_SKILLS,
CCP_MANA,
CCP_STAMINA,
Expand Down Expand Up @@ -447,6 +450,9 @@ enum CI_Properties
CIP_HIDAMAGE,
CIP_AC,
CIP_DEF,
CIP_HEALTHREGEN,
CIP_STAMINAREGEN,
CIP_MANAREGEN,
CIP_RESISTCOLD,
CIP_RESISTHEAT,
CIP_RESISTLIGHT,
Expand Down
12 changes: 12 additions & 0 deletions source/UOXJSPropertyFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,9 @@ JSBool CItemProps_getProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
case CIP_HIDAMAGE: *vp = INT_TO_JSVAL( gPriv->GetHiDamage() ); break;
case CIP_AC: *vp = INT_TO_JSVAL( gPriv->GetArmourClass() ); break;
case CIP_DEF: *vp = INT_TO_JSVAL( gPriv->GetResist( PHYSICAL )); break;
case CIP_HEALTHREGEN: *vp = INT_TO_JSVAL( gPriv->GetHealthRegen() ); break;
case CIP_STAMINAREGEN: *vp = INT_TO_JSVAL( gPriv->GetStaminaRegen() ); break;
case CIP_MANAREGEN: *vp = INT_TO_JSVAL( gPriv->GetManaRegen() ); break;
case CIP_RESISTCOLD: *vp = INT_TO_JSVAL( gPriv->GetResist( COLD )); break;
case CIP_RESISTHEAT: *vp = INT_TO_JSVAL( gPriv->GetResist( HEAT )); break;
case CIP_RESISTLIGHT: *vp = INT_TO_JSVAL( gPriv->GetResist( LIGHT )); break;
Expand Down Expand Up @@ -1306,6 +1309,9 @@ JSBool CItemProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
case CIP_HIDAMAGE: gPriv->SetHiDamage( static_cast<SI16>( encaps.toInt() )); break;
case CIP_AC: gPriv->SetArmourClass( static_cast<UI08>( encaps.toInt() )); break;
case CIP_DEF: gPriv->SetResist( static_cast<UI16>( encaps.toInt() ), PHYSICAL ); break;
case CIP_HEALTHREGEN: gPriv->SetHealthRegen( static_cast<SI16>( encaps.toInt() )); break;
case CIP_STAMINAREGEN: gPriv->SetStaminaRegen( static_cast<SI16>( encaps.toInt() )); break;
case CIP_MANAREGEN: gPriv->SetManaRegen( static_cast<SI16>( encaps.toInt() )); break;
case CIP_RESISTCOLD: gPriv->SetResist( static_cast<UI16>( encaps.toInt() ), COLD ); break;
case CIP_RESISTHEAT: gPriv->SetResist( static_cast<UI16>( encaps.toInt() ), HEAT ); break;
case CIP_RESISTLIGHT: gPriv->SetResist( static_cast<UI16>( encaps.toInt() ), LIGHT ); break;
Expand Down Expand Up @@ -1839,6 +1845,9 @@ JSBool CCharacterProps_getProperty( JSContext *cx, JSObject *obj, jsval id, jsva
}
break;
}
case CCP_HEALTHREGEN: *vp = INT_TO_JSVAL( gPriv->GetHealthRegen() ); break;
case CCP_STAMINAREGEN: *vp = INT_TO_JSVAL( gPriv->GetStaminaRegen() ); break;
case CCP_MANAREGEN: *vp = INT_TO_JSVAL( gPriv->GetManaRegen() ); break;
case CCP_ORIGIN:
tString = JS_NewStringCopyZ( cx, cwmWorldState->ServerData()->EraEnumToString( static_cast<ExpansionRuleset>( gPriv->GetOrigin() )).c_str() );
*vp = STRING_TO_JSVAL( tString );
Expand Down Expand Up @@ -2405,6 +2414,9 @@ JSBool CCharacterProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsva
case CCP_AWAKE: gPriv->SetAwake( encaps.toBool() ); break;
case CCP_DIRECTION: gPriv->SetDir( static_cast<UI08>( encaps.toInt() )); break;
case CCP_REGION: gPriv->SetRegion( static_cast<UI16>( encaps.toInt() )); break;
case CCP_HEALTHREGEN: gPriv->SetHealthRegen( static_cast<SI16>( encaps.toInt() )); break;
case CCP_STAMINAREGEN: gPriv->SetStaminaRegen( static_cast<SI16>( encaps.toInt() )); break;
case CCP_MANAREGEN: gPriv->SetManaRegen( static_cast<SI16>( encaps.toInt() )); break;
case CCP_ORIGIN: gPriv->SetOrigin( cwmWorldState->ServerData()->EraStringToEnum( encaps.toString() )); break;
case CCP_TOWN:
cwmWorldState->townRegions[gPriv->GetTown()]->RemoveTownMember( *gPriv );
Expand Down
6 changes: 6 additions & 0 deletions source/UOXJSPropertySpecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ inline JSPropertySpec CCharacterProps[] =
{ "actualDexterity", CCP_ACTUALDEXTERITY, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "actualIntelligence", CCP_ACTUALINTELLIGENCE, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "actualStrength", CCP_ACTUALSTRENGTH, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "healthRegen", CCP_HEALTHREGEN, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "staminaRegen", CCP_STAMINAREGEN, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "manaRegen", CCP_MANAREGEN, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "skills", CCP_SKILLS, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "mana", CCP_MANA, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "stamina", CCP_STAMINA, JSPROP_ENUMANDPERM, nullptr, nullptr },
Expand Down Expand Up @@ -503,6 +506,9 @@ inline JSPropertySpec CItemProps[] =
{ "strength", CIP_STRENGTH, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "dexterity", CIP_DEXTERITY, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "intelligence", CIP_INTELLIGENCE, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "healthRegen", CIP_HEALTHREGEN, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "staminaRegen", CIP_STAMINAREGEN, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "manaRegen", CIP_MANAREGEN, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "corpse", CIP_CORPSE, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "desc", CIP_DESC, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "event", CIP_EVENT, JSPROP_ENUMANDPERM, nullptr, nullptr },
Expand Down
105 changes: 105 additions & 0 deletions source/cBaseObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ bool CBaseObject::DumpBody( std::ostream &outStream ) const
outStream << "Strength=" + std::to_string( strength ) + "," + std::to_string( temp_st2 ) + newLine;
outStream << "HitPoints=" + std::to_string( hitpoints ) + newLine;
outStream << "Race=" + std::to_string( race ) + newLine;
outStream << "RegenStats=" + std::to_string( GetHealthRegen() ) + "," + std::to_string( GetStaminaRegen() ) + "," + std::to_string( GetManaRegen() ) + newLine;
outStream << "Visible=" + std::to_string( visible ) + newLine;
outStream << "Disabled=" << ( IsDisabled() ? "1" : "0" ) << newLine;
outStream << "Damage=" + std::to_string( loDamage ) + "," + std::to_string( hiDamage ) + newLine;
Expand Down Expand Up @@ -1005,6 +1006,69 @@ void CBaseObject::SetIntelligence( SI16 newValue )
}
}

//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject::GetHealthRegen()
//| CBaseObject::SetHealthRegen()
//| Date - 29 April, 2024
//o------------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the Health Regen of the object
//o------------------------------------------------------------------------------------------------o
SI16 CBaseObject::GetHealthRegen( void ) const
{
return healthRegen;
}
void CBaseObject::SetHealthRegen( SI16 newValue )
{
healthRegen = newValue;

if( CanBeObjType( OT_ITEM ))
{
( static_cast<CItem *>( this ))->UpdateRegion();
}
}

//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject::GetStaminaRegen()
//| CBaseObject::SetStaminaRegen()
//| Date - 29 April, 2024
//o------------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the Stamina Regen of the object
//o------------------------------------------------------------------------------------------------o
SI16 CBaseObject::GetStaminaRegen( void ) const
{
return staminaRegen;
}
void CBaseObject::SetStaminaRegen( SI16 newValue )
{
staminaRegen = newValue;

if( CanBeObjType( OT_ITEM ))
{
( static_cast<CItem *>( this ))->UpdateRegion();
}
}

//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject::GetManaRegen()
//| CBaseObject::SetManaRegen()
//| Date - 29 April, 2024
//o------------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the Mana Regen of the object
//o------------------------------------------------------------------------------------------------o
SI16 CBaseObject::GetManaRegen( void ) const
{
return manaRegen;
}
void CBaseObject::SetManaRegen( SI16 newValue )
{
manaRegen = newValue;

if( CanBeObjType( OT_ITEM ))
{
( static_cast<CItem *>( this ))->UpdateRegion();
}
}

//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject::GetHP()
//| CBaseObject::SetHP()
Expand Down Expand Up @@ -1661,6 +1725,37 @@ void CBaseObject::IncIntelligence( SI16 toInc )
SetIntelligence( intelligence + toInc );
}

//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject::IncHealthRegen()
//o------------------------------------------------------------------------------------------------o
//| Purpose - Increments the object's Health Regen value
//o------------------------------------------------------------------------------------------------o
void CBaseObject::IncHealthRegen( SI16 toInc )
{
SetHealthRegen( healthRegen + toInc );
}

//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject::IncStaminaRegen()
//o------------------------------------------------------------------------------------------------o
//| Purpose - Increments the object's Stamina Regen value
//o------------------------------------------------------------------------------------------------o
void CBaseObject::IncStaminaRegen( SI16 toInc )
{
SetStaminaRegen( staminaRegen + toInc );
}

//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject::IncManaRegen()
//o------------------------------------------------------------------------------------------------o
//| Purpose - Increments the object's Mana Regen value
//o------------------------------------------------------------------------------------------------o
void CBaseObject::IncManaRegen( SI16 toInc )
{
SetManaRegen( manaRegen + toInc );
}


//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject::DumpFooter()
//o------------------------------------------------------------------------------------------------o
Expand Down Expand Up @@ -1983,6 +2078,13 @@ bool CBaseObject::HandleLine( std::string &UTag, std::string &data )
SetKills( static_cast<SI16>( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( csecs[2], "//" )), nullptr, 0 )));
}
}
else if( UTag == "REGENSTATS" )
{
SetHealthRegen( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" )), nullptr, 0 )));
SetStaminaRegen( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 )));
SetManaRegen( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[2], "//" )), nullptr, 0 )));
rValue = true;
}
else
{
rValue = false;
Expand Down Expand Up @@ -2525,6 +2627,9 @@ void CBaseObject::CopyData( CBaseObject *target )
target->SetStrength( GetStrength() );
target->SetDexterity( GetDexterity() );
target->SetIntelligence( GetIntelligence() );
target->SetHealthRegen( GetHealthRegen() );
target->SetStaminaRegen( GetStaminaRegen() );
target->SetManaRegen( GetManaRegen() );
target->SetHP( GetHP() );
target->SetDir( GetDir() );
target->SetVisible( GetVisible() );
Expand Down
15 changes: 15 additions & 0 deletions source/cBaseObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class CBaseObject
SI16 dexterity;
SI16 intelligence;
SI16 hitpoints;
SI16 healthRegen;
SI16 staminaRegen;
SI16 manaRegen;
VisibleTypes visible;
SI16 hiDamage;
SI16 loDamage;
Expand Down Expand Up @@ -217,12 +220,20 @@ class CBaseObject
virtual SI16 GetIntelligence( void ) const;
SI16 GetHP( void ) const;

virtual SI16 GetHealthRegen( void ) const;
virtual SI16 GetStaminaRegen( void ) const;
virtual SI16 GetManaRegen( void ) const;

virtual void SetStrength( SI16 newValue );
virtual void SetDexterity( SI16 newValue );
virtual void SetIntelligence( SI16 newValue );
virtual void SetHP( SI16 newValue );
void IncHP( SI16 amtToChange );

virtual void SetHealthRegen( SI16 newValue );
virtual void SetStaminaRegen( SI16 newValue );
virtual void SetManaRegen( SI16 newValue );

void SetDir( UI08 newDir, bool sendUpdate = true );
UI08 GetDir( void ) const;

Expand Down Expand Up @@ -256,6 +267,10 @@ class CBaseObject
void IncDexterity( SI16 toInc = 1 );
void IncIntelligence( SI16 toInc = 1 );

void IncHealthRegen( SI16 toInc = 1 );
void IncStaminaRegen( SI16 toInc = 1 );
void IncManaRegen( SI16 toInc = 1 );

virtual void PostLoadProcessing( void );
virtual bool LoadRemnants( void ) = 0;

Expand Down
Loading
Loading