2002-04-07 20:53:41 +00:00
|
|
|
// All funcs in this file are used for item/char distance related situations
|
|
|
|
|
// There's a chance that a number of these could become inline
|
|
|
|
|
#include "uox3.h"
|
Added:
-JS Get/Set "vulnerable" handlers for character properties (Abaddon)
-willHunger with Get/Set HungerStatus() wrappers to CChar class (can now
selectively stop a character/creature from continuing to hunger)
-JS Get/Set "willhunger" handlers for character properties Changed:
Linux compile fixes (thanks Malketh)
Hash.h warning fixed (thanks Philantrop)
Fixes to getRootPack() and getPackOwner()
Removed many #includes from the global scope, including them in the specific files that need them
This should greatly reduce compile time and filesize, along with the need to recompile after altering most headers
Removed the linux ifdefs around typedefd function declarations, this should work with gcc 3.2
Moved global loading functions into a new cFileIO() class to take them out of global scope
Fixed an issue causing items to not be sent to the client (thanks Malketh)
Moved some global structs into the CWorldMain class
Fixed a bug causing a crash on character / item creation
Moved all effects stuff into its own class to take it out of global scope
Changed the variable CChar::region to CChar::regionNum to avoid conflicts with the cTownRegion region[] indexes
Moved getbestskill(), isHuman(), and inDungeon() into the CChar class to remove them from global scope
Took npcSimpleAttackTarget() out of global scope
Rewrote restock() to make use of restockNPC()
Changed the typedef'd iterator in hash.h to HASHITERATOR to kill a Linux warning
Renamed cEffects::soundeffect() to PlaySound() and removed unneeded overloads
Fixed a bug causing executebatch to be set with locationcount data
Rewrote cEffects::bgsound()
Documented sounds.cpp
Misc minor cleanups / fixes
Removed:
sendItemsInRange() (CChar::Teleport() does the same thing)
Many #includes that were not being used
deathMenu()
respawnnow() and moved all of its code into command_respawn()
one instance of cEffects::scpSoundEffect() and renamed the other to PlaySound()
3/13/2003
Changed
Fixed an issue allowing the server to not have a dictionary.ZRO (which would cause a crash when a dictionary entry was called with no language)
Fixed an issue causing the server to puke when it attempted a restart
Moved SpawnRandomItem() into cItem class
Moved SpawnRandomMonster() into cCharHandle class
Broke necro.dfn into fishing.dfn and digging.dfn
Made better use of SpawnRandomItem() and SpawnRandomMonster()
3/12/2003
Added:
CPOpenGump and CPSpeech packet class to remove some global vars (Note these are pretty basic classes and someone
with a better understanding of how we handle sending/recieving packets could probably expand these to make better use of them)
Changed:
Moved many global vars into the CWorldMain() class
Cleaned ResetVars() in uox3.cpp as ResetDefaults() in CWorldMain() now handles much of that
Added a check to ensure text wasn't sent twice in talking(), should fix double-speech
Cleaned up cmdtable.cpp removing a couple duplicate entries, etc
Changed target() to only require 4 values (as the first two were always 0 and 1)
Removed many unneeded typedefs and globals
Went through cServerData() and noted unused server.ini entries
Moved title1(), title2(), and title3() to cClick.cpp since that is their only usage, made use
of MAX_TITLE to ensure we wouldn't overrun the buffers, and renamed them matching what title they were
3/11/2003
Changed:
Fixed a potentially very serious bugs with how containers were being set upon loading the world
Fixed possible re-adding of weight to containers and characters at load
Fixed a bug causing equipped items that were not weapons to take damage in combat
Minor cleanups / warning fixes / Linux compatability issues (punt)
3/7/2003
Overhauls/Additions/Major Changes
Changed:
Tweaks/Object Conversions/Misc Small Changes
Changed:
Changed CItem::Get/SetLayer() to a UI08
Fixed a bug in speech causing you to see your own text twice
Fixed a nasty crash bug
2003-03-23 10:18:02 +00:00
|
|
|
#include "cRaces.h"
|
2012-11-03 18:11:04 +00:00
|
|
|
#include "regions.h"
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CheckItemRange()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Purpose - Checks if an item is within reach
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
bool CheckItemRange( CChar *mChar, CItem *i )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( mChar->IsGM() || mChar->IsCounselor() )
|
|
|
|
|
return true;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
CBaseObject *itemOwner = i;
|
|
|
|
|
bool checkRange = false;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2021-06-12 07:30:23 -04:00
|
|
|
if( i->GetCont() != nullptr ) // It's inside another container, we need root container to calculate distance
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
ObjectType objType = OT_CBO;
|
|
|
|
|
CBaseObject *iOwner = FindItemOwner( i, objType );
|
2021-06-12 07:30:23 -04:00
|
|
|
if( iOwner != nullptr )
|
2022-10-24 18:39:33 +08:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
itemOwner = iOwner;
|
2022-10-24 18:39:33 +08:00
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
if( itemOwner == mChar )
|
2022-10-24 18:39:33 +08:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
checkRange = true;
|
2022-10-24 18:39:33 +08:00
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
else
|
2020-10-19 19:00:38 +08:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
if( ValidateObject( itemOwner ))
|
2020-10-19 19:00:38 +08:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
if( mChar->GetInstanceId() != itemOwner->GetInstanceId() || mChar->WorldNumber() != itemOwner->WorldNumber() )
|
2020-10-19 19:00:38 +08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
if( mChar->GetInstanceId() != i->GetInstanceId() || mChar->WorldNumber() != i->WorldNumber() )
|
2020-10-19 19:00:38 +08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
checkRange = ObjInRange( mChar, itemOwner, DIST_NEARBY );
|
2020-10-19 19:00:38 +08:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
return checkRange;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - ObjInRange()
|
2003-03-05 00:04:26 +00:00
|
|
|
//| Date - 2/12/2003
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
2003-03-05 00:04:26 +00:00
|
|
|
//| Purpose - Check if BaseObject obj is within a certain distance
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
bool ObjInRange( CSocket *mSock, CBaseObject *obj, UI16 distance )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2003-03-05 00:04:26 +00:00
|
|
|
CChar *mChar = mSock->CurrcharObj();
|
2022-10-24 18:39:33 +08:00
|
|
|
return ObjInRange( mChar, obj, distance );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - ObjInRange()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
Instance-support and misc code cleanup
Misc code and documentation cleanup:
Updated and standardized function comment blocks throughout entire codebase
Grouped getters and setters together in pairs and documented them as one
Removed empty and/or non-useful information from comment blocks
Removed unused function from cItem.cpp/h - IncID() - formerly used to change IDs for doors
Added new feature - Instances
Objects (characters, items, multis, spawnregions) can now make use of a 5th parameter to determine their location in the game world. In addition to the traditional X, Y, Z and WORLDNUMBER parameters, a new one has been added - INSTANCEID - that allows objects to exist at the same coordinates in the same world, but in different "dimensions". Code has been updated in multiple places to support this, and a default instanceID of 0 is assumed if nothing else is specified.
Added support for new DFN tag in town regions, spawn regions and locations - INSTANCEID (defaults to 0 if not present)
Added support for another start location parameter after worldNum in UOX.INI representing instanceID (defaults to 0 if not present)
Updated TWEAK menu to include WorldNumber and instanceID
Fixed BaseWeight option in TWEAK menu
Updated CBase_Teleport - now takes an optional 5th parameter instanceID
Updated SE_SpawnNPC now takes an optional 5th parameter - instanceID
Updated SE_FindMulti now takes an optional 5th parameter - instanceID
Updated SE_GetItem now takes an optional 5th parameter - instanceID
Updated SE_FindItem now takes an optional 6th parameter - instanceID
Added new JS property for Items, Characters, Regions: .instanceID
Added JS property for Regions: .members - returns comma-separated list of town member serials
Updated JS scripts making use of the above-mentioned JS Methods/Functions
Updated dictionaries with new tweak menu entry texts
Exposed SpawnRegions to JS engine, and updated JS docs with details:
SpawnRegion JS Functions
IterateOverSpawnRegions()
GetSpawnRegion( spawnRegNum )
GetSpawnRegionCount()
SpawnRegion JS Properties
name
regionNum
itemList
npcList
item
npc
maxItems
maxNpcs
itemCount
npcCount
onlyOutside
prefZ
x1
y1
x2
y2
world
instanceID
minTime
maxTime
call
2020-08-08 13:57:15 +08:00
|
|
|
//| Purpose - Check if an object is within a certain distance of another object
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
bool ObjInRange( CBaseObject *a, CBaseObject *b, UI16 distance )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
return ( GetDist( a, b ) <= distance );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - ObjInRangeSquare()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
2021-05-25 19:57:39 +08:00
|
|
|
//| Purpose - Check if an object's location is within a certain distance of another
|
|
|
|
|
//| object, but checking using a square instead of a radius
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
bool ObjInRangeSquare( CBaseObject *a, CBaseObject *b, UI16 distance )
|
2021-05-25 19:57:39 +08:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !ValidateObject( a ) || !ValidateObject( b ))
|
Various fixes
Added some error-checking to JS function AreaItemFunction() to avoid potential server crash
Fixed an issue introduced in 0.99.4m, where objects being added to/moved to specific worlds or instances were still visible to players in other worlds/instances
Fixed issue with loading SCPTRIG tag with value 65535 in older worldfiles, now treats these as if the value was 0
Updated JS Methods .AddCheckbox() and .AddRadio() to support specifying the gumpImageID to display when button is checked/selected.
Updated syntaxes:
.AddCheckbox( topHeight, topLeft, checkImage, defaultStatus, unk2 )
.AddCheckbox( topHeight, topLeft, checkImageOff, checkImageOn, defaultStatus, unk2 )
.AddRadio( topHeight, topLeft, radioImage, pressed, id )
.AddRadio( topHeight, topLeft, radioImageOff, radioImageOn, pressed, id )
Added new Socket JS Method to close a specific generic gump:
.CloseGump( gumpID, buttonID ) // gumpID is normally equal to 0xffff + scripttrigger of script gump is created in, while buttonID is the buttonID response we want the client to send when gump closes
Added new Gump JS Method to end a group of radio buttons started with AddGroup():
.EndGroup() // Ends previously started group element
Re-enabled Gump JS Method MasterGump(), in case someone can use it for something
.MasterGump( masterGumpID ) // Define master gump of gump?
Added facet support for 'wipe and 'iwipe commands (js/commands/targeting/wipe.js). Updated syntax:
'wipe/iwipe
Brings up target cursors. Wipes all objects in area between target locations, on same facet as user
'wipe/iwipe x1 y1 x2 y2
Wipes all objects in specified area, on same facet as user
'wipe [objType] [facet]
Wipes all objects of specified type. If facet is specified, wipes only on that facet.
objTypes: items, multis, boats, npcs, spawners or all
'wipe all
Wipes ALL objects, on ALL facets, regardless of object type
'wipe all force
Wipes ALL objects, on ALL facets, regardless of object type and whether wipeable flag is set
2021-06-11 05:37:25 +08:00
|
|
|
return false;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
Various fixes
Added some error-checking to JS function AreaItemFunction() to avoid potential server crash
Fixed an issue introduced in 0.99.4m, where objects being added to/moved to specific worlds or instances were still visible to players in other worlds/instances
Fixed issue with loading SCPTRIG tag with value 65535 in older worldfiles, now treats these as if the value was 0
Updated JS Methods .AddCheckbox() and .AddRadio() to support specifying the gumpImageID to display when button is checked/selected.
Updated syntaxes:
.AddCheckbox( topHeight, topLeft, checkImage, defaultStatus, unk2 )
.AddCheckbox( topHeight, topLeft, checkImageOff, checkImageOn, defaultStatus, unk2 )
.AddRadio( topHeight, topLeft, radioImage, pressed, id )
.AddRadio( topHeight, topLeft, radioImageOff, radioImageOn, pressed, id )
Added new Socket JS Method to close a specific generic gump:
.CloseGump( gumpID, buttonID ) // gumpID is normally equal to 0xffff + scripttrigger of script gump is created in, while buttonID is the buttonID response we want the client to send when gump closes
Added new Gump JS Method to end a group of radio buttons started with AddGroup():
.EndGroup() // Ends previously started group element
Re-enabled Gump JS Method MasterGump(), in case someone can use it for something
.MasterGump( masterGumpID ) // Define master gump of gump?
Added facet support for 'wipe and 'iwipe commands (js/commands/targeting/wipe.js). Updated syntax:
'wipe/iwipe
Brings up target cursors. Wipes all objects in area between target locations, on same facet as user
'wipe/iwipe x1 y1 x2 y2
Wipes all objects in specified area, on same facet as user
'wipe [objType] [facet]
Wipes all objects of specified type. If facet is specified, wipes only on that facet.
objTypes: items, multis, boats, npcs, spawners or all
'wipe all
Wipes ALL objects, on ALL facets, regardless of object type
'wipe all force
Wipes ALL objects, on ALL facets, regardless of object type and whether wipeable flag is set
2021-06-11 05:37:25 +08:00
|
|
|
if( a == b )
|
|
|
|
|
return true;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
|
|
|
|
if( a->WorldNumber() != b->WorldNumber() || a->GetInstanceId() != b->GetInstanceId() )
|
Various fixes
Added some error-checking to JS function AreaItemFunction() to avoid potential server crash
Fixed an issue introduced in 0.99.4m, where objects being added to/moved to specific worlds or instances were still visible to players in other worlds/instances
Fixed issue with loading SCPTRIG tag with value 65535 in older worldfiles, now treats these as if the value was 0
Updated JS Methods .AddCheckbox() and .AddRadio() to support specifying the gumpImageID to display when button is checked/selected.
Updated syntaxes:
.AddCheckbox( topHeight, topLeft, checkImage, defaultStatus, unk2 )
.AddCheckbox( topHeight, topLeft, checkImageOff, checkImageOn, defaultStatus, unk2 )
.AddRadio( topHeight, topLeft, radioImage, pressed, id )
.AddRadio( topHeight, topLeft, radioImageOff, radioImageOn, pressed, id )
Added new Socket JS Method to close a specific generic gump:
.CloseGump( gumpID, buttonID ) // gumpID is normally equal to 0xffff + scripttrigger of script gump is created in, while buttonID is the buttonID response we want the client to send when gump closes
Added new Gump JS Method to end a group of radio buttons started with AddGroup():
.EndGroup() // Ends previously started group element
Re-enabled Gump JS Method MasterGump(), in case someone can use it for something
.MasterGump( masterGumpID ) // Define master gump of gump?
Added facet support for 'wipe and 'iwipe commands (js/commands/targeting/wipe.js). Updated syntax:
'wipe/iwipe
Brings up target cursors. Wipes all objects in area between target locations, on same facet as user
'wipe/iwipe x1 y1 x2 y2
Wipes all objects in specified area, on same facet as user
'wipe [objType] [facet]
Wipes all objects of specified type. If facet is specified, wipes only on that facet.
objTypes: items, multis, boats, npcs, spawners or all
'wipe all
Wipes ALL objects, on ALL facets, regardless of object type
'wipe all force
Wipes ALL objects, on ALL facets, regardless of object type and whether wipeable flag is set
2021-06-11 05:37:25 +08:00
|
|
|
return false;
|
|
|
|
|
|
2021-05-25 19:57:39 +08:00
|
|
|
auto aX = a->GetX();
|
|
|
|
|
auto aY = a->GetY();
|
|
|
|
|
auto bX = b->GetX();
|
|
|
|
|
auto bY = b->GetY();
|
|
|
|
|
return ( aX >= ( bX - distance ) && aX <= ( bX + distance )
|
2022-10-24 18:39:33 +08:00
|
|
|
&& aY >= ( bY - distance ) && aY <= ( bY + distance ));
|
2021-05-25 19:57:39 +08:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - ObjInOldRange()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
Instance-support and misc code cleanup
Misc code and documentation cleanup:
Updated and standardized function comment blocks throughout entire codebase
Grouped getters and setters together in pairs and documented them as one
Removed empty and/or non-useful information from comment blocks
Removed unused function from cItem.cpp/h - IncID() - formerly used to change IDs for doors
Added new feature - Instances
Objects (characters, items, multis, spawnregions) can now make use of a 5th parameter to determine their location in the game world. In addition to the traditional X, Y, Z and WORLDNUMBER parameters, a new one has been added - INSTANCEID - that allows objects to exist at the same coordinates in the same world, but in different "dimensions". Code has been updated in multiple places to support this, and a default instanceID of 0 is assumed if nothing else is specified.
Added support for new DFN tag in town regions, spawn regions and locations - INSTANCEID (defaults to 0 if not present)
Added support for another start location parameter after worldNum in UOX.INI representing instanceID (defaults to 0 if not present)
Updated TWEAK menu to include WorldNumber and instanceID
Fixed BaseWeight option in TWEAK menu
Updated CBase_Teleport - now takes an optional 5th parameter instanceID
Updated SE_SpawnNPC now takes an optional 5th parameter - instanceID
Updated SE_FindMulti now takes an optional 5th parameter - instanceID
Updated SE_GetItem now takes an optional 5th parameter - instanceID
Updated SE_FindItem now takes an optional 6th parameter - instanceID
Added new JS property for Items, Characters, Regions: .instanceID
Added JS property for Regions: .members - returns comma-separated list of town member serials
Updated JS scripts making use of the above-mentioned JS Methods/Functions
Updated dictionaries with new tweak menu entry texts
Exposed SpawnRegions to JS engine, and updated JS docs with details:
SpawnRegion JS Functions
IterateOverSpawnRegions()
GetSpawnRegion( spawnRegNum )
GetSpawnRegionCount()
SpawnRegion JS Properties
name
regionNum
itemList
npcList
item
npc
maxItems
maxNpcs
itemCount
npcCount
onlyOutside
prefZ
x1
y1
x2
y2
world
instanceID
minTime
maxTime
call
2020-08-08 13:57:15 +08:00
|
|
|
//| Purpose - Check if an object is within a certain distance of another object
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
bool ObjInOldRange( CBaseObject *a, CBaseObject *b, UI16 distance )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
return ( GetOldDist( a, b ) <= distance );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - ObjInOldRangeSquare()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
2021-05-25 19:57:39 +08:00
|
|
|
//| Purpose - Check if an object's old location is within a certain distance of another
|
|
|
|
|
//| object, but checking using a square instead of a radius
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
bool ObjInOldRangeSquare( CBaseObject *a, CBaseObject *b, UI16 distance )
|
2021-05-25 19:57:39 +08:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !ValidateObject( a ) || !ValidateObject( b ))
|
Various fixes
Added some error-checking to JS function AreaItemFunction() to avoid potential server crash
Fixed an issue introduced in 0.99.4m, where objects being added to/moved to specific worlds or instances were still visible to players in other worlds/instances
Fixed issue with loading SCPTRIG tag with value 65535 in older worldfiles, now treats these as if the value was 0
Updated JS Methods .AddCheckbox() and .AddRadio() to support specifying the gumpImageID to display when button is checked/selected.
Updated syntaxes:
.AddCheckbox( topHeight, topLeft, checkImage, defaultStatus, unk2 )
.AddCheckbox( topHeight, topLeft, checkImageOff, checkImageOn, defaultStatus, unk2 )
.AddRadio( topHeight, topLeft, radioImage, pressed, id )
.AddRadio( topHeight, topLeft, radioImageOff, radioImageOn, pressed, id )
Added new Socket JS Method to close a specific generic gump:
.CloseGump( gumpID, buttonID ) // gumpID is normally equal to 0xffff + scripttrigger of script gump is created in, while buttonID is the buttonID response we want the client to send when gump closes
Added new Gump JS Method to end a group of radio buttons started with AddGroup():
.EndGroup() // Ends previously started group element
Re-enabled Gump JS Method MasterGump(), in case someone can use it for something
.MasterGump( masterGumpID ) // Define master gump of gump?
Added facet support for 'wipe and 'iwipe commands (js/commands/targeting/wipe.js). Updated syntax:
'wipe/iwipe
Brings up target cursors. Wipes all objects in area between target locations, on same facet as user
'wipe/iwipe x1 y1 x2 y2
Wipes all objects in specified area, on same facet as user
'wipe [objType] [facet]
Wipes all objects of specified type. If facet is specified, wipes only on that facet.
objTypes: items, multis, boats, npcs, spawners or all
'wipe all
Wipes ALL objects, on ALL facets, regardless of object type
'wipe all force
Wipes ALL objects, on ALL facets, regardless of object type and whether wipeable flag is set
2021-06-11 05:37:25 +08:00
|
|
|
return false;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
Various fixes
Added some error-checking to JS function AreaItemFunction() to avoid potential server crash
Fixed an issue introduced in 0.99.4m, where objects being added to/moved to specific worlds or instances were still visible to players in other worlds/instances
Fixed issue with loading SCPTRIG tag with value 65535 in older worldfiles, now treats these as if the value was 0
Updated JS Methods .AddCheckbox() and .AddRadio() to support specifying the gumpImageID to display when button is checked/selected.
Updated syntaxes:
.AddCheckbox( topHeight, topLeft, checkImage, defaultStatus, unk2 )
.AddCheckbox( topHeight, topLeft, checkImageOff, checkImageOn, defaultStatus, unk2 )
.AddRadio( topHeight, topLeft, radioImage, pressed, id )
.AddRadio( topHeight, topLeft, radioImageOff, radioImageOn, pressed, id )
Added new Socket JS Method to close a specific generic gump:
.CloseGump( gumpID, buttonID ) // gumpID is normally equal to 0xffff + scripttrigger of script gump is created in, while buttonID is the buttonID response we want the client to send when gump closes
Added new Gump JS Method to end a group of radio buttons started with AddGroup():
.EndGroup() // Ends previously started group element
Re-enabled Gump JS Method MasterGump(), in case someone can use it for something
.MasterGump( masterGumpID ) // Define master gump of gump?
Added facet support for 'wipe and 'iwipe commands (js/commands/targeting/wipe.js). Updated syntax:
'wipe/iwipe
Brings up target cursors. Wipes all objects in area between target locations, on same facet as user
'wipe/iwipe x1 y1 x2 y2
Wipes all objects in specified area, on same facet as user
'wipe [objType] [facet]
Wipes all objects of specified type. If facet is specified, wipes only on that facet.
objTypes: items, multis, boats, npcs, spawners or all
'wipe all
Wipes ALL objects, on ALL facets, regardless of object type
'wipe all force
Wipes ALL objects, on ALL facets, regardless of object type and whether wipeable flag is set
2021-06-11 05:37:25 +08:00
|
|
|
if( a == b )
|
|
|
|
|
return true;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
|
|
|
|
if( a->WorldNumber() != b->WorldNumber() || a->GetInstanceId() != b->GetInstanceId() )
|
Various fixes
Added some error-checking to JS function AreaItemFunction() to avoid potential server crash
Fixed an issue introduced in 0.99.4m, where objects being added to/moved to specific worlds or instances were still visible to players in other worlds/instances
Fixed issue with loading SCPTRIG tag with value 65535 in older worldfiles, now treats these as if the value was 0
Updated JS Methods .AddCheckbox() and .AddRadio() to support specifying the gumpImageID to display when button is checked/selected.
Updated syntaxes:
.AddCheckbox( topHeight, topLeft, checkImage, defaultStatus, unk2 )
.AddCheckbox( topHeight, topLeft, checkImageOff, checkImageOn, defaultStatus, unk2 )
.AddRadio( topHeight, topLeft, radioImage, pressed, id )
.AddRadio( topHeight, topLeft, radioImageOff, radioImageOn, pressed, id )
Added new Socket JS Method to close a specific generic gump:
.CloseGump( gumpID, buttonID ) // gumpID is normally equal to 0xffff + scripttrigger of script gump is created in, while buttonID is the buttonID response we want the client to send when gump closes
Added new Gump JS Method to end a group of radio buttons started with AddGroup():
.EndGroup() // Ends previously started group element
Re-enabled Gump JS Method MasterGump(), in case someone can use it for something
.MasterGump( masterGumpID ) // Define master gump of gump?
Added facet support for 'wipe and 'iwipe commands (js/commands/targeting/wipe.js). Updated syntax:
'wipe/iwipe
Brings up target cursors. Wipes all objects in area between target locations, on same facet as user
'wipe/iwipe x1 y1 x2 y2
Wipes all objects in specified area, on same facet as user
'wipe [objType] [facet]
Wipes all objects of specified type. If facet is specified, wipes only on that facet.
objTypes: items, multis, boats, npcs, spawners or all
'wipe all
Wipes ALL objects, on ALL facets, regardless of object type
'wipe all force
Wipes ALL objects, on ALL facets, regardless of object type and whether wipeable flag is set
2021-06-11 05:37:25 +08:00
|
|
|
return false;
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
Point3_st aOldLoc = a->GetOldLocation();
|
2021-05-25 19:57:39 +08:00
|
|
|
auto aX = aOldLoc.x;
|
|
|
|
|
auto aY = aOldLoc.y;
|
|
|
|
|
auto bX = b->GetX();
|
|
|
|
|
auto bY = b->GetY();
|
|
|
|
|
return ( aX >= ( bX - distance ) && aX <= ( bX + distance )
|
2022-10-24 18:39:33 +08:00
|
|
|
&& aY >= ( bY - distance ) && aY <= ( bY + distance ));
|
2021-05-25 19:57:39 +08:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - CharInRange()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
//| Purpose - Check if characters a and b are in visual range
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
bool CharInRange( CChar *a, CChar *b )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !ValidateObject( a ))
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
0.99.4v
Added JS command to reload dictionaries
'reloaddictionaries
Fixed a server crash related to casting of spells
Fixed some issues with Line-of-Sight checks related to items under/above ground, LoS checks between different floors of buildings, etc.
Updated handling of skill-training keywords to be based on language-independent keyword IDs rather than trying to match player-input text to specific skill-names
Updated animal-trainer/stablemasterscript (js/npc/ai/stablemaster.js) with several changes:
Fixed an issue where the same pet would be stabled in all available slots if payment was taken from player's bank account instead of their backpack
Fixed an issue where stablemaster would not pause walking for a while when a player interacts with them
Converted all system messages and text messages in stablemaster script to dictionary entries
Added new NPC AI type to source - AI_STABLEMASTER (9) - and assigned this to animal trainers. This is used to identify this type of NPCs for the purpose of displaying relevant context menus
Reworked banker AI script (js/npc/ai/banker.js) to use triggerwords from client instead of hard-defined strings, to work better with multiple languages (and work with all relevant triggerwords)
Fixed a bug with banker AI script (js/npc/ai/banker.js) that prevented players from using the "withdraw" command
Re-added NPC AI 8 to banker NPCs (dfndata/npc/male_vendors.dfn and female_vendors.dfn) so code can check for presence of this AI when handling context menus
Removed remaining hard-coded banking functionality - all handled by script anyway
Added new context menu option for NPC bankers - Open Bankbox
Updated code handling of context menus to only show context menus when relevant:
Open Paperdoll - Shows for all characters with a paperdoll
Open Backpack - Shows for player's character, pack animals and hirelings
Open Bankbox - Shows for banker NPCs (if within 8 tiles)
Buy/Sell - Shows for vendor NPCs (if within 8 tiles, and if they have anything for sale/are buying anything)
Added new context menu entries for pets, which can be used if player is within 12 tiles of pet:
Command: Kill
Command: Stop
Command: Follow
Command: Stay
Command: Guard
Add Friend
Remove Friend
Transfer
Release
Added new context menu entries for stablemasters/animal trainers:
Claim All Pets
Stable Pet
Added new context menu entries for Escort Quest NPCs
Ask Destination (if within 3 tiles)
Accept Escort (if within 3 tiles)
Abandon Escort
Added new context menus for NPCs that can teach skills to players (limited to max 10 per NPC)
Train [skillName]
Added new AI script for NPC hirelings (3204=js/npc/ai/hireling.js), who can be hired to follow the player around for a limited amount of time, and function the same way as pets. In addition to the regular pet commands, these speech commands are supported:
hire // The hireling will respond with the cost to hire them
dismiss // Replaces the "release" command for pets; will dismiss the hireling
patrol // The hireling will patrol between it's current location and a second targeted location nearby
move // The hireling will try to shuffle out of the way
fetch // The hireling will try to fetch a targeted item
drop // The hireling will drop to the ground all loot they're currently carrying
report // The hireling will report on the remaining time they're hired for
Added new NPC DFN tag used by code to detect hireling NPCs for the purpose of displaying context menus:
HIRELING // No additional value/data needed for tag
Added new context menu entries for Hireling NPCs, in addition to the ones for regular pets:
Hire // Can be used within 3 steps of the hireling, who will respond with cost to hire them
Dismiss // Replaces the "release" command for pets, will dismiss the hireling
Added HIRELING tag and SCRIPT=3204 to and updated stats of various NPCs that will be hireable:
m_fighter, f_fighter, m_beggar, f_beggar, m_peasant, f_peasant, m_sailor, f_sailor, m_pirate, f_pirate
Added new hireling NPC:
m_paladin, f_paladin
Added new UOX ini setting to enable/disable context menus
CONTEXTMENUS=1/0 (defaults to 1)
Added new Item JS Method to check if an item's ID is on a specified food list
.IsOnFoodList( foodList ) // Returns true/false if item's ID is on specified foodList
Added new OMNIVORE food list and assigned it to [basehuman] DFN section
Added new Character JS Properties
.isGuarded // Gets/Sets whether character is guarded by a pet/hireling
.guarding // Gets/Sets the object (if any) being guarded by a pet/hireling
Fixed multiple issues with health bars, flagging and character highlighting
Added some crash protection for invalid data used with CUSTOMINTTAG and CUSTOMSTRINGTAG DFN tags for Items, NPCs and Multis
Fixed an issue which prevented hard-coded checks from running when using items
Added new global js object (Timer) to make the use of character timers in JS more robust, with properties matching timer names from enum in source.
Properties:
.TIMEOUT // Time until next attack can be done in combat
.INVIS // Time until invisible character becomes visible
.HUNGER // Time until character grows more hungry
.THIRST // Time until character grows more thirsty
.POISONTIME // Time until next tick of poison damage
.POISONTEXT // Time until next message about suffering from poison
.POISONWEAROFF // Time until poison wears off
.SPELLTIME // Time until spell cast is completed. Can be set to 0 to interrupt
.ANTISPAM // Time until next speech message can be sent (for anti spam purposes)
.CRIMFLAG // Time until criminal flag runs out
.MURDERRATE // Time until next murder count decay
.PEACETIMER // Time until character can re-enter combat after being affected by peacemaking
.FLYINGTOGGLE // Time until next time flying ability can be toggled for gargoyles
.MOVETIME // Time until NPC can move again
.SPATIMER // Time until next time NPC can cast a spell
.SUMMONTIME // Time until a summoned NPC will vanish
.EVADETIME // Time until an NPC will exit evade state
.LOGOUT // Time it takes for a player char to vanish after logout
Examples of use:
var hungerTimer = myChar.GetTimer( Timer.HUNGER )
myChar.SetTimer( Timer.HUNGER, 15000 )
Added new Character JS Methods to add, remove and list friends of a pet/hireling:
.AddFriend( playerToAdd ) // Adds player to friend list
.RemoveFriend( playerToRemove ) // Removes player from friend list
.GetFriendList() // Gets list of friends
.ClearFriendList() // Clears list of friends
Added new Character JS Method to fetch a player character's list of pets/followers
.GetPetList() // Gets list of pets/followers
Added new persistent NPC property to keep track of a pet's previous owners, whether those tamed the pet or had it transferred to them. Every time a pet is tamed, or is transferred to a new owner, this list is updated:
GenericList< CChar * > petOwnerList
Added new Character JS Method to check if a player is on a pet's owner list as a previous owner:
.HasBeenOwner( mChar )
Previous owners of a pet can re-tame it with guaranteed chance of success
Updated JS Method Refresh() to be usable with both items or characters, to send updated state of object to nearby players
Added character tooltip [Guarded] for characters being guarded by a pet/hireling
Pets/hirelings that are transferred will now immediately start following their new master instead of wandering freely
Pets/hirelings can no longer be transferred between players as long as either party is flagged as a criminal
Pets/hirelings can no longer be transferred to dead players
Pets/hirelings can no longer be transferred to NPCs
Summoned creatures can no longer be transferred to other players
Summoned creatures can no longer have friends
Friend lists of pets/hirelings are now cleared when the pet/hireling is transferred to another player
Added new UOX.INI settings to control how many pets players can have active:
MAXCONTROLSLOTS=0 // Maximum number of pet control slots available to player. Disabled if 0
MAXFOLLOWERS=5 // Maximum pets/followers a player can have active at the same time. Used if control slots are disabled
MAXPETOWNERS=5 // Maximum number of different owners a pet can have over its lifetime before it becomes impossible to retame
Added new NPC property and NPC DFN tag that keeps track of how many pet control slots an NPC would take up if owned by a player:
UI08 controlSlots // source property
CONTROLSLOTS=# // DFN tag
Added new Character JS properties:
.ownerCount // Get the total number of owners a pet/hireling has had, based on NPC's petOwnerList
.controlSlots // Get/Set number of pet control slots an NPC will occupy
.controlSlotsUsed // Get/Set the number of control slots used by a player
Updated get (js/commands/targeting/get.js) and set (js/commands/targeting/set.js) commands to support getting/setting the following character properties:
deaths
ownerCount (read only)
controlSlots
controlSlotsUsed
Updated NPC DFNs with default CONTROLSLOT=# tags
Increased the max distance from player that onSpeech JS event will trigger from 7 to 12
Updated how "all attack" and "all follow" commands for pets are handled. Now loops through all pets owned by character and executes command for each eligible pet
Fixed an issue where NPCs could follow characters in different worlds/instances than them selves
Updated default max amount of items that can be sold to NPC vendors from 5 to 250
Guards can no longer train players in skills
Updated equipment itemlists (dfndata/items/itemlists/itemlists.dfn) with blank entries to introduce some more variety in the type of clothes NPCs wear in general
Added new NPCs to DFNs (dfndata/npc/undead.dfn) and added them to undead npclist:
[skeletalmage] // variation of [bonemage]
[skeletalknight] // variation of [boneknight]
Updated Titles (dfndata/titles/titles.dfn) with up-to-date titles for skills around Pub 15, and added titles for skills added after that. Also added "Elder" and "Legendary" titles for 110 and 120 skillpoints
Updated EQUIPITEM tag in newbie.dfn (dfndata/newbie/newbie.dfn) to support an optional hue parameter (EQUIPITEM=id,hue)
Updated starting equipment for new characters (dfndata/newbie/newbie.dfn), with commented out practice weapons. Uncomment to use
Added item definitions for practice weapons (dfndata/items/gear/weapons/practice_weapons.dfn):
practice_skinning_knife
practice_hatchet
practice_axe
practice_mace
practice_longsword
practice_spear
practice_bow
practice_club
practice_crook
practice_gnarled_staff
Updated mount statues DFN (dfndata/items/misc/mount-statues.dfn) and JS (js/npc/pets/*.js) files to include pet control slot related stuff
Pets now inherit the karma of their owners, but revert to their original karma upon release
Pets and hirelings will no longer follow the ghosts of their dead owners, but stay to guard their corpse
Added optional 9th parameter for JS Function CreateDFNItem to specify a color for item created. This comes before the other optional parameters - worldNumber and instanceID (which are only used if character is NULL):
CreateDFNItem( mSock, mChar, sectionName, inPack, iAmount, itemType, iColor, worldNumber, instanceID )
Added ID of Giant Beetle to various pack animal checks
Pack animals will now drop any newbie/blessed items stored in their packs upon death
Added new NPC properties to track pet loyalty, and exposed these as Character JS properties, and NPC DFN tags:
JS Properties
.maxLoyalty // Defaults to 100
.loyalty // Starts at 25
DFN Tags
MAXLOYALTY=# // Defaults to 100
LOYALTY=# // Starts at 25
Updated TriggerEvent JS function to support return values (int, bool, string, object) from called script
Updated various JS scripts to make use of new TriggerEvent functionality and reduce reliance on custom tags:
js/item/archerybutte.js
js/item/trainingdummy.js
js/server/data/combatanims.js
js/server/data/weapontypes.js
Updated archerybutte script to use dictionary for system and text messages
Updated archerybutte script to support increased range, distance penalty and dex/str bonuses when calculating score
Added new UOX.INI settings under [pets and hirelings] section related to pet control and loyalty:
CHECKPETCONTROLDIFFICULTY=1 // Enable/Disable pet control difficulty system
PETLOYALTYGAINONSUCCESS=1 // Amount of pet loyalty gained on successful pet command use
PETLOYALTYLOSSONFAILURE=3 // Amount of pet loyalty lost on failed pet command use
PETLOYALTYRATE=900 // Amount of seconds between each time pet loyalty is automatically reduced by 1. Takes 25 hours to deplete completely from max
Added new persistent NPC property that keeps track of the difficulty of taming and controlling a pet, and exposed it as a Character JS property:
.orneriness
Every time a tamed pet is released or goes wild, its "orneriness" increases, making it more difficult for other players to tame, and more difficult for anyone to control.
Updated CBasePetResponse::canControlPet() function to use pet control difficulty system if enabled, which checks player's animal taming/animal lore skill vs a pet's "orneriness" to determine chance of pet accepting a given pet command
On successful use of pet command, increases pet loyalty by value defined in PETLOYALTYGAINONSUCCESS ini setting
On failed use of pet command, decreases pet loyalty by value defined in PETLOYALTYLOSSONFAILURE ini setting
Added new Character JS Method to calculate chance of a player successfully controlling the pet:
.CalculateControlChance( mChar ) // Returns value between 0 and 1000 indicating chance of success
Feeding a pet will now restore its loyalty to maximum
Pets will now lose loyalty on hunger checks when at maximum hunger
Pets that are maximum hungry will now only have a chance to go wild if loyalty has dropped to zero
Added new DFN tag for creatures.dfn - TYPE - which contains a string describing the type of creature
Added secure pet trading. Players who trade pets will now see a pet transfer deed appear in a secure trade window with the name and type of creature, and upon completion of the trade the associated pet will be instantly transferred to the other player
Updated resource JS scripts (js/server/resource/*) to use dictionaries for all system messages
Updated skill JS scripts (js/skill/*) to use dictionaries for all system messages
Updated housing JS scripts (js/server/house/*) to use dictionaries for all system messages
Updated item JS scripts (js/item/*) to use dictionaries for all system messages
Updated magic JS scripts (js/magic/*) to use dictionaries for all system messages
Updated NPC AI JS scripts (js/npc/ai/*) to use dictionaries for all system messages
Updated command JS scripts (js/commands/*) to use dictionaries for all system messages, gump tooltips, etc
Updated code to use dictionaries for all system messages
Fixed incorrect spelling for UOX.INI setting HIDEW(H)ILEMOUNTED and updated hiding skill (js/skill/hiding.js) to actually allow/disallow hiding while mounted based on this setting
Added new Character JS Method to make it easier to make one NPC initiate combat with another:
.InitiateCombat( targetChar ) // Character attempts to initiate combat with target character
Updated parrying portion of combat code to be in line with Pub15/pre-AoS parrying mechanics. High AR shields now absorb more damage on a successful parry, while low AR shields have a higher chance of parrying. Shields are also now more effective against archery attacks (full absorption potential) than melee attacks (half absorption potential).
Updated combat damage calculations to be in line with Pub15/pre-AoS damage calculations
Adjusted default value of COMBATNPCDAMAGERATE ini setting (damage divisor when target is a player) from 2 to 1 to account for these changes.
Removed dictionary.UNK, and made dictionary.ZRO the default dictionary used for all unsupported languages
Added dictionary support for additional languages: Portuguese, Italian, Czech
Updated default dictionaries for the following languages: English, French
Added default dictionaries for the following languages: German, Spanish, Portuguese, Italian, Czech (note that translations have been provided by automatic services and will contain inaccuracies!)
Added new UOX.INI setting to allow specifying a default dictionary language for server, which if set will force that language for all dictionary messages, regardless of client settings:
SERVERLANGUAGE=0 // Set default server dictionary language. Supported languages: 0 - None/language used by each client, 1 - English, 2 - German, 3 - Spanish, 5 - French, 6 - Portuguese, 7 - Italian, 8 - Czech
Added new function in combat.cpp - AdjustArmorClassDamage() - which adjusts the damage dealt in combat based on whether armour class (AC DFN tag or .ac JS property) of weapon and armour equipped on hit location of target match up. A weapon with armour class 1 would essentially be doubly effective against armour of armour class 1. Allows setting up things like piercing weapons being better against some armor types than mace weapons, etc.
Added new UOX.INI setting under [combat] to enable/disable double damage from armour class bonuses:
ARMORCLASSDAMAGEBONUS=0/1 //defaults to 0)
2021-07-28 16:02:56 +08:00
|
|
|
|
|
|
|
|
SI16 visRange = MAX_VISRANGE;
|
|
|
|
|
if( a->GetSocket() != nullptr )
|
|
|
|
|
{
|
|
|
|
|
visRange = a->GetSocket()->Range() + Races->VisRange( a->GetRace() );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
visRange += Races->VisRange( a->GetRace() );
|
|
|
|
|
}
|
2022-10-24 18:39:33 +08:00
|
|
|
return ObjInRangeSquare( a, b, static_cast<UI16>( visRange ));
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - GetDist()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
//| Purpose - Get the distance between two objects
|
2022-10-24 18:39:33 +08:00
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
UI16 GetDist( CBaseObject *a, CBaseObject *b )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !ValidateObject( a ) || !ValidateObject( b ))
|
2012-11-03 18:11:04 +00:00
|
|
|
return DIST_OUTOFRANGE;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
if( a == b )
|
|
|
|
|
return DIST_SAMETILE;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
|
|
|
|
if( a->WorldNumber() != b->WorldNumber() || a->GetInstanceId() != b->GetInstanceId() )
|
2012-11-03 18:11:04 +00:00
|
|
|
return DIST_OUTOFRANGE;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
|
|
|
|
return GetDist( a->GetLocation(), b->GetLocation() );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
UI16 GetDist( Point3_st a, Point3_st b )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
Point3_st difference = a - b;
|
|
|
|
|
return static_cast<UI16>( difference.Mag() );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
UI16 GetDist3D( Point3_st a, Point3_st b )
|
Various changes
Fixed an issue with JS Function DeleteFile(), which would stop calling script from working if no file was found for deletion. Could break demolishing of houses, amongst other things
Fixed an issue with DoSEErrorMessage() function that prevented JS function error messages from being displayed in UOX3 console if message size was below 512
Fixed a bug that allowed players to place items on the same slot of walls when using a client that doesn't automatically restrict this
When dropping items, UOX3 will now look for a valid surface to drop them on, and move the item to said valid surface if applicable
Fixed an issue with loading of MultiCollections.uop where max boundaries of each multi was not set on load, preventing features that relied on finding corners of building from working (like automatic ban location detection for houses)
Added new function in mapstuff.cpp to check flags on dynamic items, and exposed it as a JS Function with same name and parameters:
CheckDynamicFlag( SI16 x, SI16 y, SI08 oldz, UI08 worldNumber, UI16 instanceID, TileFlags toCheck );
Fixed an issue where items were not always properly added to/removed from map regions when picked up or dropped
Added new helper function in dist.cpp to find 3D distance between two points:
getDist3D( point a, point b )
Added JS Function - DistanceBetween() - to find distance between two sets of coordinates, or two objects:
DistanceBetween( x1, y1, x2, y2 )
DistanceBetween( x1, y1, z1, x2, y2, z2 )
DistanceBetween( sourceObject, targObject )
DistanceBetween( sourceObject, targObject, checkZ )
Added Item JS Method - GetTileName() - to get name of an item directly from tiledata
Added new UOX.INI setting that defines the lower limit for when a purchase will withdraw money from bank instead of backpack:
BANKBUYTHRESHOLD=2000
Split the UOX.INI setting CONSOLELOG into three parts, to enable/disable different forms of logging:
CONSOLELOG=1/0 // Toggles logging of console messages, warnings and errors
NETWORKLOG=1/0 // Toggles logging of network traffic
SPEECHLOG=1/0 // Toggles logging of player/staff speech
2021-06-27 23:23:31 +08:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
Point3_st difference = a - b;
|
Various changes
Fixed an issue with JS Function DeleteFile(), which would stop calling script from working if no file was found for deletion. Could break demolishing of houses, amongst other things
Fixed an issue with DoSEErrorMessage() function that prevented JS function error messages from being displayed in UOX3 console if message size was below 512
Fixed a bug that allowed players to place items on the same slot of walls when using a client that doesn't automatically restrict this
When dropping items, UOX3 will now look for a valid surface to drop them on, and move the item to said valid surface if applicable
Fixed an issue with loading of MultiCollections.uop where max boundaries of each multi was not set on load, preventing features that relied on finding corners of building from working (like automatic ban location detection for houses)
Added new function in mapstuff.cpp to check flags on dynamic items, and exposed it as a JS Function with same name and parameters:
CheckDynamicFlag( SI16 x, SI16 y, SI08 oldz, UI08 worldNumber, UI16 instanceID, TileFlags toCheck );
Fixed an issue where items were not always properly added to/removed from map regions when picked up or dropped
Added new helper function in dist.cpp to find 3D distance between two points:
getDist3D( point a, point b )
Added JS Function - DistanceBetween() - to find distance between two sets of coordinates, or two objects:
DistanceBetween( x1, y1, x2, y2 )
DistanceBetween( x1, y1, z1, x2, y2, z2 )
DistanceBetween( sourceObject, targObject )
DistanceBetween( sourceObject, targObject, checkZ )
Added Item JS Method - GetTileName() - to get name of an item directly from tiledata
Added new UOX.INI setting that defines the lower limit for when a purchase will withdraw money from bank instead of backpack:
BANKBUYTHRESHOLD=2000
Split the UOX.INI setting CONSOLELOG into three parts, to enable/disable different forms of logging:
CONSOLELOG=1/0 // Toggles logging of console messages, warnings and errors
NETWORKLOG=1/0 // Toggles logging of network traffic
SPEECHLOG=1/0 // Toggles logging of player/staff speech
2021-06-27 23:23:31 +08:00
|
|
|
return static_cast<UI16>( difference.Mag3D() );
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
UI16 GetOldDist( CBaseObject *a, CBaseObject *b )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !ValidateObject( a ) || !ValidateObject( b ))
|
2012-11-03 18:11:04 +00:00
|
|
|
return DIST_OUTOFRANGE;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
if( a == b )
|
|
|
|
|
return DIST_SAMETILE;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
|
|
|
|
if( a->WorldNumber() != b->WorldNumber() || a->GetInstanceId() != b->GetInstanceId() )
|
2012-11-03 18:11:04 +00:00
|
|
|
return DIST_OUTOFRANGE;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
|
|
|
|
Point3_st distA;
|
|
|
|
|
Point3_st distB;
|
2012-11-03 18:11:04 +00:00
|
|
|
distA = a->GetOldLocation();
|
|
|
|
|
distB = b->GetLocation();
|
2022-10-24 18:39:33 +08:00
|
|
|
Point3_st difference = distA - distB;
|
|
|
|
|
return static_cast<UI16>( difference.Mag() );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-24 18:39:33 +08:00
|
|
|
UI16 GetDist3D( CBaseObject *a, CBaseObject *b )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
2022-10-24 18:39:33 +08:00
|
|
|
if( !ValidateObject( a ) || !ValidateObject( b ))
|
2012-11-03 18:11:04 +00:00
|
|
|
return DIST_OUTOFRANGE;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
if( a == b )
|
|
|
|
|
return DIST_SAMETILE;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
|
|
|
|
if( a->WorldNumber() != b->WorldNumber() || a->GetInstanceId() != b->GetInstanceId() )
|
2012-11-03 18:11:04 +00:00
|
|
|
return DIST_OUTOFRANGE;
|
2022-10-24 18:39:33 +08:00
|
|
|
|
|
|
|
|
Point3_st difference = a->GetLocation() - b->GetLocation();
|
|
|
|
|
return static_cast<UI16>( difference.Mag3D() );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
0.99.6d
Cleaned up an issue with last commit where wrong npclists were used in some spawn regions
Made a few additional adjustments to the new spawn regions in Lost Lands/New Haven
Included more changes related to poison updates that should've been in previous commit (like the complete UOX.INI support for POISONCORROSIONSYSTEM setting)
Adjusted region setup for New Haven to set the individual "building" regions within as a sub-region of the main town (regions.dfn)
Fixed an issue where the displayed HP of an equipped item would not update correctly
Further updates to convert timers 32-bit to 64-bit. This affects and addresses some potential issues with: Character creation/NPC guild-join timestamps, NPC movement, combat timers, idle timeouts, item decay, spellcasting
Added support for new JS Events that can trigger from global script, and can be used to store persistent custom entries in players' paperdoll profiles:
onProfileRequest( socket, profileOwnerChar ) - Triggers when client requests data for a paperdoll profile
onProfileUpdate( socket, updatedText ) - Triggers when client sends updated data from paperdoll profile
Added two new helper functions in code that allows faster (but very slightly less accurate) distance checks between two points: GetApproxDist( Point3_st a, Point3_st b )
GetApproxDist( CBaseObject *a, CBaseObject *b )
Improved pathfinding for NPCs attempting to follow another character, by adopting a system of weighted variables to help the NPC determine when to recalculate the path vs when to stick with the old, combined with faster distance checks via GetApproxDist(). The end result of this is faster, smarter and more responsive NPC followers and NPC opponents in combat. The variables influencing this include: how far the target has moved from last pathfind target location, whether NPC is heading in the overall right direction or not, time since last path calculation and some small randomization to avoid edge case jitters.
Updated default command levels in commands.dfn, code and scripts to support the Seer role and make space for some custom roles. These are the new defaults as listed in commands.dfn, which should not be changed as they are linked to specific enums in code. Do take note that this might invalidate command levels for existing GMs/Seers/Counselors, who might need another round of 'make gm/seer/cns from an admin:
ADMIN - command level 10
GM - command level 9
SEER - command level 7
CNS - command level 4
PLAYER - command level 0
Updated how UOX3 makes use of the account-level flags 0x2000 (Seer) and 0x4000 (Counselor). If either of these flags are set on an account, all new characters created on the accounts will automatically receive the relevant command privileges.
Fixed an issue with 'wholist command that prevented admin characters from seeing characters with lower privilege levels in the list (js/commands/wholist.js)
Fixed an issue with hiding/GM hide that prevented admin characters from seeing hidden characters with lower privilege levels in the world
UOX3 now includes the cross-platform, header-only utf8cpp library found at https://github.com/nemtrif/utfcpp and freely available under Boost Software License v1.0. The immediate use-case for this is in code right now is to better handle strings related to custom paperdoll profiles, but will also look to make more heavy use of this in future updates
2025-06-28 22:37:42 +08:00
|
|
|
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - GetApproxDist()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Calculates the shortest grid-path distance (Octile) between
|
|
|
|
|
//| - two points. Much faster than GetDist() as it avoids sqrt()
|
|
|
|
|
//o------------------------------------------------------------------------------------------------o
|
|
|
|
|
R32 GetApproxDist( Point3_st a, Point3_st b )
|
|
|
|
|
{
|
|
|
|
|
const R32 dx = fabs( a.x - b.x );
|
|
|
|
|
const R32 dy = fabs( a.y - b.y );
|
|
|
|
|
|
|
|
|
|
// The constant 0.414f (sqrt(2) - 1) is chosen to approximate the cost of diagonal movement.
|
|
|
|
|
return ( dx > dy ) ? ( dx + 0.414f * dy ) : ( dy + 0.414f * dx );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
R32 GetApproxDist( CBaseObject *a, CBaseObject *b )
|
|
|
|
|
{
|
|
|
|
|
if( !ValidateObject( a ) || !ValidateObject( b ))
|
|
|
|
|
return static_cast<R32>( DIST_OUTOFRANGE );
|
|
|
|
|
|
|
|
|
|
if( a == b )
|
|
|
|
|
return static_cast<R32>( DIST_SAMETILE );
|
|
|
|
|
|
|
|
|
|
if( a->WorldNumber() != b->WorldNumber() || a->GetInstanceId() != b->GetInstanceId() )
|
|
|
|
|
return static_cast<R32>( DIST_OUTOFRANGE );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const R32 dx = fabs( a->GetX() - b->GetX() );
|
|
|
|
|
const R32 dy = fabs( a->GetY() - b->GetY() );
|
|
|
|
|
|
|
|
|
|
// The constant 0.414f (sqrt(2) - 1) is chosen to approximate the cost of diagonal movement.
|
|
|
|
|
return ( dx > dy ) ? ( dx + 0.414f * dy ) : ( dy + 0.414f * dx );
|
|
|
|
|
}
|