mirror of
https://github.com/UOX3DevTeam/UOX3
synced 2026-08-13 12:27:04 -04:00
Added support for MAXWEIGHTBONUS DFN tag for races, to allow increasing weight that can be carried by specific race, and a new GetWeightMax() code function to do the necessary calculations on demand Updated [default race bonuses] UOX.INI section with the following new settings for the 3 default playable races (only used if nothing else specified in races.dfn): HUMANMAXWEIGHTBONUS=0 ELFMAXWEIGHTBONUS=0 GARGOYLEMAXWEIGHTBONUS=0 Added support for ALLSKILLSG and ALLSKILLSL DFN tags for races, which allow defining skill bonus or loss across all skills for a given race Added new Character JS Method for adding skill points without triggering skillchange JS Events: .AddSkill( skillID, skillAmt, triggerEvents[true/false] ) Added new Boat JS Property to allow getting/setting movement types for Boats via scripts: .moveType // See UOX3 JS Engine Docs > JS Object Properties > Multi Properties for a detailed list of all supported movement types Added new Boat JS Method to allow turning boats via scripts: .TurnBoat( turnDir ) // 0 = straight (no turning), 1 = turn left, 2 = turn right, 3 = flip around Updated IterateOver/OnIterate JS Function/Event to support passing in optional socket parameter. New syntax: IterateOver( objectType[, socket ]); .OnIterate( sourceObject, targetObject, socket ) Updated Character/Item JS Method .Refresh() to support an optional socket argument, to specify which player to refresh the object for. New syntax: .Refresh( [socket] ) Added support for new region setting that can define a region as disabled/enabled via DFN (tag) or script (JS property). Disabled regions will be ignored by UOX3: DISABLED=0/1 // Region DFN tag .isDisabled // Region JS Property Fixed issue where JS tags and temporary JS tags would not be copied over when duplicating a character or item Removed strength requirements from base shield definitions - stats like these are handled per era (dfndata/items/gear/armor/base_armor.dfn) Fixed an issue where necromancer newbie armor would incorrectly inherit base versions of leather armor without stats (dfndata/items/gear/armor/leather_armor/leather.dfn) Fixed an issue where players would not correctly leave combat after hiding (js/skill/hiding.js) Fixed an issue with Healing skill where skill-checks for healing/veterinary would fail due to a misspelled variable (js/skill/healing.js) Updated smart-turn furniture script to prevent players from being able to turn furnitures that are occupied by characters (js/server/misc/furniture_smartturn.js) Updated Buff-bar script to only add buffs for client versions higher than 5.0.2, the client patch where this feature was added (js/server/network/0xDF_buffBar.js) Updated Vendor BDO Dispenser script to add alternative reward-table for AoS era (js/npc/ai/vendor_bdo_dispenser.js) Cleaned up some code (spaces to tabs, indentation, spacing)
121 lines
4.2 KiB
C++
121 lines
4.2 KiB
C++
//o------------------------------------------------------------------------------------------------o
|
|
//| File - calcfuncs.cpp
|
|
//o------------------------------------------------------------------------------------------------o
|
|
//| Purpose - Various functions to calculate objects from serials
|
|
//o------------------------------------------------------------------------------------------------o
|
|
#include "uox3.h"
|
|
#include "townregion.h"
|
|
#include "network.h"
|
|
#include "ObjectFactory.h"
|
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
//| Function - CalcCharObjFromSer()
|
|
//o------------------------------------------------------------------------------------------------o
|
|
//| Purpose - Calculate the character object based on the calling serial
|
|
//o------------------------------------------------------------------------------------------------o
|
|
CChar *CalcCharObjFromSer( SERIAL targSerial )
|
|
{
|
|
CBaseObject *findItem = ObjectFactory::GetSingleton().FindObject( targSerial );
|
|
CChar *toRet = nullptr;
|
|
if( findItem != nullptr )
|
|
{
|
|
if( findItem->CanBeObjType( OT_CHAR ))
|
|
{
|
|
toRet = static_cast<CChar *>( findItem );
|
|
}
|
|
}
|
|
return toRet;
|
|
}
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
//| Function - CalcItemObjFromSer()
|
|
//o------------------------------------------------------------------------------------------------o
|
|
//| Purpose - Calculate the item object based on the calling serial
|
|
//o------------------------------------------------------------------------------------------------o
|
|
CItem *CalcItemObjFromSer( SERIAL targSerial )
|
|
{
|
|
CBaseObject *findItem = ObjectFactory::GetSingleton().FindObject( targSerial );
|
|
CItem *toRet = nullptr;
|
|
if( findItem != nullptr )
|
|
{
|
|
if( findItem->CanBeObjType( OT_ITEM ))
|
|
{
|
|
toRet = static_cast<CItem *>( findItem );
|
|
}
|
|
}
|
|
return toRet;
|
|
}
|
|
|
|
CMultiObj *CalcMultiFromSer( SERIAL targSerial )
|
|
{
|
|
CBaseObject *findMulti = ObjectFactory::GetSingleton().FindObject( targSerial );
|
|
CMultiObj *toRet = nullptr;
|
|
if( findMulti != nullptr )
|
|
{
|
|
if( findMulti->CanBeObjType( OT_MULTI ))
|
|
{
|
|
toRet = static_cast<CMultiObj *>( findMulti );
|
|
}
|
|
}
|
|
return toRet;
|
|
}
|
|
|
|
//o--------------------------------------------------------------------------
|
|
//| Function - CalcRegionFromXY()
|
|
//o--------------------------------------------------------------------------
|
|
//| Purpose - Find what region x and y are in. This should be done for all items on world load, and when any of the
|
|
//| item's location and/or container properties change
|
|
//o--------------------------------------------------------------------------
|
|
CTownRegion *CalcRegionFromXY( SI16 x, SI16 y, UI08 worldNumber, UI16 instanceId, CBaseObject *mObj )
|
|
{
|
|
// Reset sub region of character
|
|
if( ValidateObject( mObj ))
|
|
{
|
|
mObj->SetSubRegion( 0 );
|
|
|
|
// Check if object is an item, and if it's in a container
|
|
if( mObj->GetObjType() == OT_ITEM && static_cast<CItem *>( mObj )->GetContSerial() != INVALIDSERIAL )
|
|
{
|
|
// Item is in a container, so find the root container (whether character or item) and use its coordinates to calculate region
|
|
CBaseObject *rootContainer = FindItemOwner( static_cast<CItem *>( mObj ));
|
|
if( ValidateObject( rootContainer ))
|
|
{
|
|
x = rootContainer->GetX();
|
|
y = rootContainer->GetY();
|
|
worldNumber = rootContainer->WorldNumber();
|
|
instanceId = rootContainer->GetInstanceId();
|
|
}
|
|
}
|
|
}
|
|
|
|
const RegLocs_st *getLoc = nullptr;
|
|
for( auto &[townId, myReg] : cwmWorldState->townRegions )
|
|
{
|
|
if( myReg != nullptr && !myReg->IsDisabled() && myReg->WorldNumber() == worldNumber && myReg->GetInstanceId() == instanceId )
|
|
{
|
|
for( size_t j = 0; j < myReg->GetNumLocations(); ++j )
|
|
{
|
|
getLoc = myReg->GetLocation( j );
|
|
if( getLoc != nullptr )
|
|
{
|
|
// Calculate the region/subregion of the object
|
|
if( getLoc->x1 <= x && getLoc->y1 <= y && getLoc->x2 >= x && getLoc->y2 >= y )
|
|
{
|
|
// If object is in a subregion, store a reference to it
|
|
if( myReg->IsSubRegion() && ValidateObject( mObj ))
|
|
{
|
|
mObj->SetSubRegion( myReg->GetRegionNum() );
|
|
continue;
|
|
}
|
|
return myReg;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
return cwmWorldState->townRegions[0xFF];
|
|
}
|
|
|
|
|