Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Updated so they work directly on chars for the DCI and HCI just like retail AOS
  • Loading branch information
DragonSlayer62 committed Jan 15, 2025
1 parent c6c8569 commit cd35741
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions source/UOXJSPropertyEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ enum CC_Properties
CCP_SPAWNSERIAL,
CCP_SPATTACK,
CCP_SPDELAY,
CCP_HITCHANCE,
CCP_DEFENSECHANCE,
CCP_AITYPE,
CCP_SPLIT,
CCP_SPLITCHANCE,
Expand Down
4 changes: 4 additions & 0 deletions source/UOXJSPropertyFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,8 @@ JSBool CCharacterProps_getProperty( JSContext *cx, JSObject *obj, jsval id, jsva
case CCP_HOUSEICONS: *vp = BOOLEAN_TO_JSVAL( gPriv->ViewHouseAsIcon() ); break;
case CCP_SPATTACK: *vp = INT_TO_JSVAL( gPriv->GetSpAttack() ); break;
case CCP_SPDELAY: *vp = INT_TO_JSVAL( gPriv->GetSpDelay() ); break;
case CCP_HITCHANCE: *vp = INT_TO_JSVAL( gPriv->GetHitChance() ); break;
case CCP_DEFENSECHANCE: *vp = INT_TO_JSVAL( gPriv->GetDefenseChance() ); break;
case CCP_AITYPE: *vp = INT_TO_JSVAL( gPriv->GetNpcAiType() ); break;
case CCP_SPLIT: *vp = INT_TO_JSVAL( gPriv->GetSplit() ); break;
case CCP_SPLITCHANCE: *vp = INT_TO_JSVAL( gPriv->GetSplitChance() ); break;
Expand Down Expand Up @@ -2503,6 +2505,8 @@ JSBool CCharacterProps_setProperty( JSContext *cx, JSObject *obj, jsval id, jsva
case CCP_HOUSEICONS: gPriv->SetViewHouseAsIcon( encaps.toBool() ); break;
case CCP_SPATTACK: gPriv->SetSpAttack( static_cast<SI16>( encaps.toInt() )); break;
case CCP_SPDELAY: gPriv->SetSpDelay( static_cast<SI08>( encaps.toInt() )); break;
case CCP_HITCHANCE: gPriv->SetHitChance( static_cast<SI16>( encaps.toInt() )); break;
case CCP_DEFENSECHANCE: gPriv->SetDefenseChance( static_cast<SI16>( encaps.toInt() )); break;
case CCP_AITYPE: gPriv->SetNPCAiType( static_cast<SI16>( encaps.toInt() )); break;
case CCP_SPLIT: gPriv->SetSplit( static_cast<UI08>( encaps.toInt() )); break;
case CCP_SPLITCHANCE: gPriv->SetSplitChance( static_cast<UI08>( encaps.toInt() ));break;
Expand Down
2 changes: 2 additions & 0 deletions source/UOXJSPropertySpecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ inline JSPropertySpec CCharacterProps[] =
{ "houseicons", CCP_HOUSEICONS, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "spattack", CCP_SPATTACK, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "spdelay", CCP_SPDELAY, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "hitChance", CCP_HITCHANCE, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "defenseChance", CCP_DEFENSECHANCE, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "aitype", CCP_AITYPE, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "split", CCP_SPLIT, JSPROP_ENUMANDPERM, nullptr, nullptr },
{ "splitchance", CCP_SPLITCHANCE, JSPROP_ENUMANDPERM, nullptr, nullptr },
Expand Down
16 changes: 15 additions & 1 deletion source/cChar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,8 @@ void CChar::CopyData( CChar *target )
target->SetNextAct( nextAct );
target->SetSquelched( GetSquelched() );
target->SetMeditating( IsMeditating() );
target->SetHitChance( GetHitChance() );
target->SetDefenseChance( GetDefenseChance() );
target->SetStealth( stealth );
target->SetRunning( running );
target->SetRace( GetRace() );
Expand Down Expand Up @@ -3141,6 +3143,8 @@ bool CChar::DumpBody( std::ostream &outStream ) const
//-------------------------------------------------------------------------------------------
outStream << "CanRun=" + std::to_string((( CanRun() && IsNpc() ) ? 1 : 0 )) + newLine;
outStream << "CanAttack=" + std::to_string(( GetCanAttack() ? 1 : 0 )) + newLine;
outStream << "HitChance=" + std::to_string( GetHitChance() ) + newLine;
outStream << "DefChance=" + std::to_string( GetDefenseChance() ) + newLine;
outStream << "AllMove=" + std::to_string(( AllMove() ? 1 : 0 )) + newLine;
outStream << "IsNpc=" + std::to_string(( IsNpc() ? 1 : 0 )) + newLine;
outStream << "IsShop=" + std::to_string(( IsShop() ? 1 : 0 )) + newLine;
Expand Down Expand Up @@ -4379,6 +4383,11 @@ bool CChar::HandleLine( std::string &UTag, std::string &data )
SetDead(( static_cast<UI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 )) == 1 ));
rValue = true;
}
else if( UTag == "DEFCHANCE" )
{
SetDefenseChance( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 )));
rValue = true;
}
break;
case 'E':
if( UTag == "EMOTION" )
Expand Down Expand Up @@ -4467,7 +4476,12 @@ bool CChar::HandleLine( std::string &UTag, std::string &data )
}
break;
case 'H':
if( UTag == "HUNGER" )
if( UTag == "HITCHANCE" )
{
SetHitChance( static_cast<SI16>( std::stoul( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 )));
rValue = true;
}
else if( UTag == "HUNGER" )
{
SetHunger( static_cast<SI16>( std::stoi( oldstrutil::trim( oldstrutil::removeTrailing( data, "//" )), nullptr, 0 )));
rValue = true;
Expand Down

0 comments on commit cd35741

Please sign in to comment.