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

Merged
Merged
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( ourItem.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
31 changes: 28 additions & 3 deletions source/CPacketSend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7702,7 +7702,7 @@ void CPToolTip::CopyItemData( CItem& cItem, size_t &totalStringLen, bool addAmou
FinalizeData( tempEntry, totalStringLen );
}

if( cItem.GetHitChance() > 0 )
if( cItem.GetHitChance() > 0 )
{
tempEntry.stringNum = 1060415; // hit chance increase ~1_val~%
tempEntry.ourText = oldstrutil::number( cItem.GetHitChance() );
Expand Down Expand Up @@ -7737,10 +7737,35 @@ 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;
const SI16 dexReq = ( cItem.GetDexterity() * ( 100 - cItem.GetLowerStatReq() )) / 100;
const SI16 intReq = ( cItem.GetIntelligence() * ( 100 - cItem.GetLowerStatReq() )) / 100;

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

if( dexReq > 0 )
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
tempEntry.ourText = oldstrutil::format( "dexterity requirement %s", oldstrutil::number( dexReq ).c_str() );
FinalizeData( tempEntry, totalStringLen );
}

if( intReq > 0 )
{
tempEntry.stringNum = 1042971; // ~1_NOTHING~
tempEntry.ourText = oldstrutil::format( "intelligence requirement %s", oldstrutil::number( intReq ).c_str() );
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
Expand Up @@ -72,6 +72,10 @@
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 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 @@ -448,6 +448,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 @@ -677,6 +677,7 @@ JSBool CItemProps_getProperty( JSContext *cx, JSObject *obj, jsval id, jsval *vp
case CIP_DAMAGESNOW: *vp = BOOLEAN_TO_JSVAL( gPriv->GetWeatherDamage( SNOW )); break;
case CIP_SWINGSPEEDINCREASE: *vp = INT_TO_JSVAL( gPriv->GetSwingSpeedIncrease() ); break;
case CIP_SPEED: *vp = INT_TO_JSVAL( gPriv->GetSpeed() ); break;
case CIP_LOWERSTATREQ: *vp = INT_TO_JSVAL( gPriv->GetLowerStatReq() ); 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;
Expand Down Expand Up @@ -1332,6 +1333,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_SWINGSPEEDINCREASE: gPriv->SetSwingSpeedIncrease( static_cast<SI16>( encaps.toInt() )); break;
case CIP_HEALTHLEECH: gPriv->SetHealthLeech( static_cast<SI16>( encaps.toInt() )); break;
case CIP_STAMINALEECH: gPriv->SetStaminaLeech( 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 @@ -480,6 +480,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
33 changes: 29 additions & 4 deletions source/cItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_LOWERSTATREQ = 0;

//o------------------------------------------------------------------------------------------------o
//| Function - CItem()
Expand All @@ -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 ), lowerStatReq( DEFITEM_LOWERSTATREQ )
{
spells[0] = spells[1] = spells[2] = 0;
value[0] = value[1] = value[2] = 0;
Expand Down Expand Up @@ -560,6 +561,23 @@ void CItem::SetArtifactRarity( SI16 newValue )
UpdateRegion();
}

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

//o------------------------------------------------------------------------------------------------o
//| Function - CItem::GetName2()
//| CItem::SetName2()
Expand Down Expand Up @@ -1687,6 +1705,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 @@ -1770,6 +1789,7 @@ bool CItem::DumpBody( std::ostream &outStream ) const
outStream << "ArtifactRarity=" + std::to_string( GetArtifactRarity() ) + newLine;
outStream << "Movable=" + std::to_string( GetMovable() ) + newLine;
outStream << "Priv=" + std::to_string( GetPriv() ) + newLine;
outStream << "LowerStatReq=" + std::to_string( GetLowerStatReq() ) + 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;
Expand Down Expand Up @@ -1976,12 +1996,17 @@ 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;
}
else if( UTag == "LEECHSTATS" )
{
SetHealthLeech( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[0], "//" )), nullptr, 0 )));
SetStaminaLeech( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 )));
SetManaLeech( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[2], "//" )), nullptr, 0 )));
rValue = true;
SetStaminaLeech( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[1], "//" )), nullptr, 0 )));
SetManaLeech( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( csecs[2], "//" )), nullptr, 0 )));
rValue = true;
}
break;
case 'M':
Expand Down
4 changes: 4 additions & 0 deletions source/cItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class CItem : public CBaseObject
SERIAL creator; // Store the serial of the player made this item
SI08 gridLoc;
SI16 artifactRarity;
SI16 lowerStatReq;
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
Expand Down Expand Up @@ -114,6 +115,9 @@ class CItem : public CBaseObject
virtual SI16 GetArtifactRarity(void) const;
virtual void SetArtifactRarity(SI16 newValue);

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

auto GetStealable() const -> UI08;
auto SetStealable( UI08 newValue ) -> void;

Expand Down
10 changes: 7 additions & 3 deletions source/cPlayerAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,15 +698,19 @@ bool CPIEquipItem::Handle( void )
if( k == ourChar )
{
bool canWear = false;
if( i->GetStrength() > k->GetStrength() )
const SI16 scaledStrength = ( i->GetStrength() * ( 100 - i->GetLowerStatReq() )) / 100;
const SI16 scaledDexterity = ( i->GetDexterity() * ( 100 - i->GetLowerStatReq() )) / 100;
const SI16 scaledIntelligence = ( i->GetIntelligence() * ( 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?)
}
else if( i->GetDexterity() > k->GetDexterity() )
else if( scaledDexterity > k->GetDexterity() )
{
tSock->SysMessage( 1189 ); // You are not agile enough to use that.
}
else if( i->GetIntelligence() > k->GetIntelligence() )
else if( scaledIntelligence > k->GetIntelligence() )
{
tSock->SysMessage( 1190 ); // You are not smart enough to use that.
}
Expand Down
4 changes: 3 additions & 1 deletion source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,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 @@ -1830,7 +1831,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 @@ -134,6 +134,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 @@ -406,6 +407,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 @@ -141,6 +141,7 @@ enum DFNTAGS
DFNTAG_LAYER,
DFNTAG_LIGHT,
DFNTAG_LIGHTNING,
DFNTAG_LOWERSTATREQ,
DFNTAG_LOCKPICKING,
DFNTAG_LODAMAGE,
DFNTAG_LOOT,
Expand Down
Loading