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

Lower Requirements Propertie #278

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/js/commands/targeting/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ function HandleGetItem( socket, ourItem, uKey )
case "RESISTPOISON":
socket.SysMessage( ourObj.Resist( 7 ));
break;
case "LOWERSTATREQ":
socket.SysMessage( ourObj.lowerStatReq );
break;
case "ARMORCLASS":
case "ARMOURCLASS":
case "AC":
Expand Down
4 changes: 4 additions & 0 deletions data/js/commands/targeting/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ function onCallback0( socket, ourObj )
ourObj.Resist( 7, nVal );
okMsg( socket );
break;
case "LOWERSTATREQ":
ourItem.lowerStatReq = nVal;
okMsg( socket );
break;
case "HP":
case "HEALTH":
ourObj.health = nVal;
Expand Down
11 changes: 10 additions & 1 deletion source/CPacketSend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7657,12 +7657,21 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
FinalizeData( tempEntry, totalStringLen );
}

if( cItem.GetStrength() > 1 )
const SI16 strReq = (cItem.GetStrength() * (100 - cItem.GetLowerStatReq())) / 100;

if( strReq > 0 )
{
tempEntry.stringNum = 1061170; // strength requirement ~1_val~
tempEntry.ourText = oldstrutil::number( cItem.GetStrength() );
FinalizeData( tempEntry, totalStringLen );
}

if( cItem.GetLowerStatReq() > 0 )
{
tempEntry.stringNum = 1060435; // lower requirements ~1_val~%
tempEntry.ourText = oldstrutil::number( cItem.GetLowerStatReq() );
FinalizeData( tempEntry, totalStringLen );
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions source/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
30/04/2024 - Dragon Slayer/Xuri/Maarc
Added Support for new AOS property tag.
-LOWERSTATREQ - Lowers the strength requirements to wear an object.

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
1 change: 1 addition & 0 deletions source/UOXJSPropertyEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ enum CI_Properties
CIP_DECAYTIME,
CIP_LODAMAGE,
CIP_HIDAMAGE,
CIP_LOWERSTATREQ,
CIP_AC,
CIP_DEF,
CIP_RESISTCOLD,
Expand Down
2 changes: 2 additions & 0 deletions source/UOXJSPropertyFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_LOWERSTATREQ: *vp = INT_TO_JSVAL( gPriv->GetLowerStatReq() ); break;
case CIP_NAME2:
tString = JS_NewStringCopyZ( cx, gPriv->GetName2().c_str() );
*vp = STRING_TO_JSVAL( tString );
Expand Down Expand Up @@ -1321,6 +1322,7 @@ 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<UI08>( encaps.toInt() )); break;
case CIP_LOWERSTATREQ: gPriv->SetLowerStatReq( static_cast<SI16>( encaps.toInt() )); break;
case CIP_NAME2: gPriv->SetName2( encaps.toString() ); break;
case CIP_RACE: gPriv->SetRace( static_cast<RACEID>( encaps.toInt() )); break;
case CIP_MAXHP: gPriv->SetMaxHP( static_cast<SI16>( encaps.toInt() )); break;
Expand Down
1 change: 1 addition & 0 deletions source/UOXJSPropertySpecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ inline JSPropertySpec CItemProps[] =
{ "damagePoison", CIP_DAMAGEPOISON, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "damageRain", CIP_DAMAGERAIN, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "damageSnow", CIP_DAMAGESNOW, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "lowerStateReq", CIP_LOWERSTATREQ, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "name2", CIP_NAME2, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "isChar", CIP_ISCHAR, JSPROP_ENUMPERMRO, nullptr, nullptr },
{ "isItem", CIP_ISITEM, JSPROP_ENUMPERMRO, nullptr, nullptr },
Expand Down
25 changes: 24 additions & 1 deletion source/cBaseObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const SI16 DEFBASE_KILLS = 0;
const UI16 DEFBASE_RESIST = 0;
const bool DEFBASE_NAMEREQUESTACTIVE = 0;
const ExpansionRuleset DEFBASE_ORIGIN = ER_UO;
const SI16 DEFBASE_LOWERSTATREQ = 0;

//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject constructor
Expand All @@ -110,7 +111,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 ),
lowerStatReq( DEFBASE_LOWERSTATREQ )
{
multis = nullptr;
tempMulti = INVALIDSERIAL;
Expand Down Expand Up @@ -1036,6 +1038,27 @@ void CBaseObject::IncHP( SI16 amtToChange )
SetHP( hitpoints + amtToChange );
}

//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject::GetLowerStatReq()
//| CBaseObject::GetLowerStatReq()
//| Date - 30 April, 2024
//o------------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the Stat Requirements of the object
//o------------------------------------------------------------------------------------------------o
SI16 CBaseObject::GetLowerStatReq( void ) const
{
return lowerStatReq;
}
void CBaseObject::SetLowerStatReq( SI16 newValue )
{
lowerStatReq = newValue;

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

//o------------------------------------------------------------------------------------------------o
//| Function - CBaseObject::GetDir()
//| CBaseObject::SetDir()
Expand Down
4 changes: 4 additions & 0 deletions source/cBaseObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class CBaseObject
SI16 dexterity;
SI16 intelligence;
SI16 hitpoints;
SI16 lowerStatReq;
VisibleTypes visible;
SI16 hiDamage;
SI16 loDamage;
Expand Down Expand Up @@ -256,6 +257,9 @@ class CBaseObject
void IncDexterity( SI16 toInc = 1 );
void IncIntelligence( SI16 toInc = 1 );

virtual SI16 GetLowerStatReq( void ) const;
virtual void SetLowerStatReq( SI16 newValue );

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

Expand Down
7 changes: 7 additions & 0 deletions source/cItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,7 @@ auto CItem::CopyData( CItem *target ) -> void
target->SetMaxRange( GetMaxRange() );
target->SetMaxUses( GetMaxUses() );
target->SetUsesLeft( GetUsesLeft() );
target->SetLowerStatReq( GetLowerStatReq() );
target->SetStealable( GetStealable() );

// Set damage types on new item
Expand Down Expand Up @@ -1739,6 +1740,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 << "LowerStatReq=" + std::to_string( GetLowerStatReq() ) + 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;
Expand Down Expand Up @@ -1922,6 +1924,11 @@ bool CItem::HandleLine( std::string &UTag, std::string &data )
SetWeatherDamage( LIGHTNING, static_cast<UI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 )) == 1 );
rValue = true;
}
else if( UTag == "LOWERSTATREQ" )
{
SetLowerStatReq( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 )));
rValue = true;
}
break;
case 'M':
if( UTag == "MAXITEMS" )
Expand Down
3 changes: 2 additions & 1 deletion source/cPlayerAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,8 @@ bool CPIEquipItem::Handle( void )
if( k == ourChar )
{
bool canWear = false;
if( i->GetStrength() > k->GetStrength() )
const SI16 scaledStrength = ( i->GetStrength() * ( 100 - i->GetLowerStatReq() )) / 100;
if( scaledStrength > k->GetStrength() )
{
tSock->SysMessage( 1188 ); // You are not strong enough to use that. (NOTE: Should these messages use color 0x096a to stand out and replicate hard coded client message?)
}
Expand Down
4 changes: 3 additions & 1 deletion source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ auto ApplyItemSection( CItem *applyTo, CScriptSection *toApply, std::string sect
case DFNTAG_LAYER: applyTo->SetLayer( static_cast<ItemLayers>( ndata )); break;
case DFNTAG_LIGHT: applyTo->SetWeatherDamage( LIGHT, ndata != 0 ); break;
case DFNTAG_LIGHTNING: applyTo->SetWeatherDamage( LIGHTNING, ndata != 0 ); break;
case DFNTAG_LOWERSTATREQ: applyTo->SetLowerStatReq( static_cast<SI16>( ndata )); break;
case DFNTAG_MAXHP: applyTo->SetMaxHP( static_cast<UI16>( ndata )); break;
case DFNTAG_MAXITEMS: applyTo->SetMaxItems( static_cast<UI16>( ndata )); break;
case DFNTAG_MAXRANGE: applyTo->SetMaxRange( static_cast<UI08>( ndata )); break;
Expand Down Expand Up @@ -1820,7 +1821,8 @@ void cItem::CheckEquipment( CChar *p )
{
if( ValidateObject( i ))
{
if( i->GetStrength() > StrengthToCompare )//if strength required > character's strength
const SI16 scaledStrength = ( i->GetStrength() * ( 100 - i->GetLowerStatReq() )) / 100;
if( scaledStrength > StrengthToCompare )//if strength required > character's strength
{
itemsToUnequip.push_back( i );
}
Expand Down
2 changes: 2 additions & 0 deletions source/ssection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const UI08 dfnDataTypes[DFNTAG_COUNTOFTAGS] =
DFN_NUMERIC, // DFNTAG_LAYER,
DFN_NUMERIC, // DFNTAG_LIGHT,
DFN_NUMERIC, // DFNTAG_LIGHTNING,
DFN_NUMERIC, // DFNTAG_LOWERSTATREQ,
DFN_NUMERIC, // DFNTAG_LOCKPICKING,
DFN_NUMERIC, // DFNTAG_LODAMAGE,
DFN_UPPERSTRING, // DFNTAG_LOOT,
Expand Down Expand Up @@ -389,6 +390,7 @@ const std::map<std::string, DFNTAGS> strToDFNTag
{"LAYER"s, DFNTAG_LAYER},
{"LIGHT"s, DFNTAG_LIGHT},
{"LIGHTNING"s, DFNTAG_LIGHTNING},
{"LOWERSTATREQ"s, DFNTAG_LOWERSTATREQ},
{"LOCKPICKING"s, DFNTAG_LOCKPICKING},
{"LODAMAGE"s, DFNTAG_LODAMAGE},
{"LOOT"s, DFNTAG_LOOT},
Expand Down
1 change: 1 addition & 0 deletions source/ssection.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ enum DFNTAGS
DFNTAG_LAYER,
DFNTAG_LIGHT,
DFNTAG_LIGHTNING,
DFNTAG_LOWERSTATREQ,
DFNTAG_LOCKPICKING,
DFNTAG_LODAMAGE,
DFNTAG_LOOT,
Expand Down