2002-04-07 20:53:41 +00:00
|
|
|
#include "uox3.h"
|
|
|
|
|
#include "cScript.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 "power.h"
|
2002-04-07 20:53:41 +00:00
|
|
|
#include "UOXJSClasses.h"
|
|
|
|
|
#include "SEFunctions.h"
|
|
|
|
|
#include "UOXJSMethods.h"
|
|
|
|
|
#include "UOXJSPropertySpecs.h"
|
2012-11-03 18:11:04 +00:00
|
|
|
#include "CJSMapping.h"
|
|
|
|
|
#include "CPacketReceive.h"
|
|
|
|
|
#include "CJSEngine.h"
|
|
|
|
|
#include "JSEncapsulate.h"
|
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
|
|
|
#include "cSpawnRegion.h"
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
#include "StringUtility.hpp"
|
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
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| File - cScript.cpp
|
|
|
|
|
//| Date - August 26th, 2000
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Handles JS events
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Changes - Version History
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| 1.0 26th August, 2000
|
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
|
|
|
//| Initial implementation
|
|
|
|
|
//| The basic event model is in, along with some fairly simple error handling
|
|
|
|
|
//| Note that parameters for each event is NOT correct at all, it was just to get the basic layout right
|
|
|
|
|
//| Support for CS type stuff with IsFiring(), Firing(), and Stop()
|
|
|
|
|
//|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| 1.1 6th September, 2000
|
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
|
|
|
//| Each function has params and passes it along into the the script as required
|
|
|
|
|
//|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| 1.2 18th September, 2000
|
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
|
|
|
//| Addition of a number of more events, not all with params
|
|
|
|
|
//| More functions added to the functions table
|
|
|
|
|
//| Support for dynamic reloading of scripts
|
|
|
|
|
//|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| 1.3 2nd November, 2000
|
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
|
|
|
//| Addition of a number of events. Caching of function presence added
|
|
|
|
|
//| All functions assumed present, only failure on a call will flag not present
|
|
|
|
|
//|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| 1.4 1st July, 2004
|
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
|
|
|
//| Added private property of SCRIPTTYPE to store which type of script we've got
|
|
|
|
|
//| Preparation for JS scriptable spells
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
static JSFunctionSpec my_functions[] =
|
|
|
|
|
{ // ScriptName, Func Ptr, num args, ?, ?
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "StringToNum", SE_StringToNum, 1, 0, 0 }, // This function will be depreciated
|
|
|
|
|
{ "NumToString", SE_NumToString, 1, 0, 0 }, // This function will be depreciated
|
|
|
|
|
{ "NumToHexString", SE_NumToHexString, 1, 0, 0 }, // This function will be depreciated
|
2003-03-04 14:55:47 +00:00
|
|
|
{ "DoMovingEffect", SE_DoMovingEffect, 6, 0, 0 },
|
Minor explosion potion revamp
Re-implemented DoStaticEffect() as a stand-alone JS function that takes a location as a target instead of an object
Fixed an issue with potions where entire stacks of potions would get consumed instead of just one potion
Added missing entries for normal and greater explosion potions to dfndata/items/magic/potions.dfn, and added them to the item menu
Potions are now marked as stackable in dfndata/items/magic/potions.dfn
Moved countdown and explosion handling of explosion potions from code to JS (js/item/potion.js)
Added LoS and Z distance checking for explosion potions
Added optional randomization of countdown timer for explosion potions. Can be enabled via a boolean at the top of the potions script
Damage of explosion potions is now defined via DAMAGE/LODAMAGE/HIDAMAGE tags in Item DFNs, and the time before exploding is defined via the SPEED tag
Added optional Alchemy skill bonus damage modifier for explosion potions, defaults to 1 additional damage per 5 skillpoints
Added new UOX.INI settings under [combat] to control the bonus damage modifier in explosion potions:
ALCHEMYBONUSENABLED=0/1 // enable/disable bonus damage, defaults to disabled
ALCHEMYBONUSMODIFIER=5 // bonusDamage = alchemySkill / alchemyBonusModifier
Exposed speechType as an additional 7th optional parameter for the JS TextMessage function, and the other optional parameters (speechTarget, speechTargetSerial, speechFontType) can now be supplied as -1 if one just want to use the default values. Supported speechTypes:
TALK = 0, // normal system message
PROMPT = 1, // Display as system prompt
EMOTE = 2, // : text
SAY = 3, // character speaking
OBJ = 4, // at object
NOTHING = 5, // does not display
SYSTEM = 6, // text labelling an item
NOSCROLL = 7, // status msg, does not scroll
WHISPER = 8, // only those close can here
YELL = 9, // can be heard 2 screens away
2021-03-26 03:53:55 +08:00
|
|
|
{ "DoStaticEffect", SE_DoStaticEffect, 7, 0, 0 },
|
2002-04-07 20:53:41 +00:00
|
|
|
{ "BroadcastMessage", SE_BroadcastMessage, 1, 0, 0 },
|
|
|
|
|
{ "RandomNumber", SE_RandomNumber, 2, 0, 0 },
|
|
|
|
|
{ "CalcCharFromSer", SE_CalcCharFromSer, 1, 0, 0 },
|
|
|
|
|
{ "CalcItemFromSer", SE_CalcItemFromSer, 1, 0, 0 },
|
Exposed various map and statics related functions to JS engine
Updated JS item properties MORE, MOREX, MOREY, MOREZ and SERIAL, and character property SERIAL, to pass values to JS scripts using JS_NewNumberValue() instead of INT_TO_JSVAL if the property value cannot fit inside JSVAL (checked with INT_FITS_IN_JSVAL)
Added support in CResponse.cpp for client trigger word for securing containers in houses - TW_HOUSESECURE
Updated CMulHandler::CheckStaticFlag() to match with statics that cover/extend across the specified Z coordinate, not just ones that have the same base Z level
Updated CMulHandler::DoesMapBlock() to not deem map tiles as blocking if they are more than 16 Z (height of a character) higher than the specified Z coordinate to check
Exposed method for finding corners of a multi to JS engine:
.GetMultiCorner( cornerID ) - Gets coordinates for specified corner of multi (0 = NW, 1 = NE, 2 = SW, 3 = SE)
Exposed various functions related to map, statics and multis to JS engine:
CalcMultiFromSer( serial ) - Find a multi from a provided serial
GetMapElevation( x, y, z, world) - Returns the map elevation at specified coordinates
IsInBuilding( x, y, z, world, instance, checkHeight ) - Returns true if the specified location is inside a static building (underneath static items), or if player is inside a multi. If the checkHeight argument is true, player is only deemed inside a multi if there are multi-items above the player's head. If player is in a courtyard/on a rooftop, they will be deemed to be NOT in the building. checkHeight is not used for the static part of the function.
CheckStaticFlag( x, y, z, world, tileFlagID ) - Checks to see if any statics at given coordinates has specified tile flag
DoesStaticBlock( x, y, z, world, checkWater ) - Checks if statics at/above given location blocks characters
DoesDynamicBlock( x, y, z, world, instance, checkWater, waterWalk ) - Checks if dynamics at/above given location blocks characters
DoesMapBlock( x, y, z, world, checkWater, waterWalk ) - Checks if map tile at/above given location blocks characters
2020-10-05 23:12:34 +08:00
|
|
|
{ "CalcMultiFromSer", SE_CalcMultiFromSer, 1, 0, 0 },
|
2002-04-07 20:53:41 +00:00
|
|
|
{ "GetHour", SE_GetHour, 0, 0, 0 },
|
|
|
|
|
{ "GetMinute", SE_GetMinute, 0, 0, 0 },
|
|
|
|
|
{ "GetDay", SE_GetDay, 0, 0, 0 },
|
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
|
|
|
{ "SecondsPerUOMinute", SE_SecondsPerUOMinute, 0, 0, 0 },
|
2002-04-07 20:53:41 +00:00
|
|
|
{ "GetCurrentClock", SE_GetCurrentClock, 0, 0, 0 },
|
|
|
|
|
{ "GetMurderThreshold", SE_GetMurderThreshold, 0, 0, 0 },
|
|
|
|
|
{ "RollDice", SE_RollDice, 3, 0, 0 },
|
|
|
|
|
{ "RaceCompareByRace", SE_RaceCompareByRace, 2, 0, 0 },
|
Fishing revamp
Extended Character JS Method DoAction() to support two additional parameters - frameCount and playBackwards - which define the length of the animation (defaults to 7) and whether the animation should be played backwards (defaults to false). Note that this only works for old-style animations, and thus is not available for Gargoyle characters. Updated method syntax:
.DoAction( actionID ) // Old animation packet
.DoAction( actionID, null, frameCount) // Old animation packet with frameCount
.DoAction( actionID, null, frameCount, frameDelay ) // Old animation packet with frameCount, frameDelay
.DoAction( actionID, null, frameCount, frameDelay, playBackwards) // Old animation packet with frameCount, frameDelay, playBackwards
.DoAction( actionID, subActionID ) // New animation packet
Extended fishing JS script to include:
Fishing special fishing nets, big fish, messages in a bottle/SOS messages and associated shipwreck treasures, with chances of attracting sea serpents, deep sea serpents, water elementals and krakens while fishing.
Enhanced detection of fishing in shallow vs deep water, with deep water now being defined as any water tile that's 16 or more tiles away from the nearest land area.
Updated timer system, LoS checks,
Implemented SOS messages and shipwreck locations, with areas valid for potential shipwreck locations being defined in a new section of regions.dfn named [SOSAREAS], which follows the same syntax as the INSTALOG section in the same file. Once a message in a bottle is opened, a SOS message is generated with coordinates for a random shipwreck location, which players can sail to and fish near in order to find a sunken treasure (and other items).
Implemented shipwreck treasures, which come in 3 levels of quality (with an optional 4th quality level available), with increasing amount of gold, gems, scrolls, reagents and magic items (coming in next commit!) per quality level of treasure
Implemented special fishing nets, which can be used to fish up a variety of sea creatures (sea serpents, deep sea serpents, water elementals, kraken), which have a high chance of having SOS bottles on their corpses when defeated
Updated fishinglist.dfn, itemlist.dfn and lootlist.dfn to support new fishing updates
Updated movable state of various items that can be fished up (pillows, some pieces of furniture) to ensure players can move them!
Renamed ORERESPAWNAREA ini setting to RESOURCEAREASIZE (it's also used for ore, and logs) and reduced it from 10 to 8 to divide each world into 8x8 sized resource areas
Fixed a bug where the new fish resource type was not getting regenerated or saved properly
Added INSTANCEID support to INSTALOG section of regions.dfn, and added default WORLD and INSTANCEID entries to all areas
Fixed an issue with Runebooks (js/item/runebook.js) where the coordinates of a rune location would not be displayed properly
Separated map coordinate function from Runebook script to its own script (js/server/data/map_coordinates.js), which other scripts can call upon to get map coords using TriggerEvent() JS function
Ported sextant implementation from code to JS (5033=js/item/sextant.js), and removed the hard-coded version of this.
Updated Item DFN entry for sextants to include script=5033 tag
Fixed a bug in handling of the LOOT tag for NPCs where server would crash if a number was specified behind the item/itemlist to add as loot
The DFN tags PACKITEM and LOOT are now handled similarly when used for NPCs and Items respectively. PACKITEM can be used for adding items with specific IDs, or "list objects" from itemlists.dfn, while LOOT can be used to add items from lootlists.dfn. One big difference between these is that if the optional amount parameter is specified for either tag when used with itemlists/lootlists (PACKITEM=listObject,amount vs LOOT=lootlist,amount), PACKITEM will add the specified amount of the specified/randomly chosen item, while LOOT will add X amount of random items.
Updated implementation of ITEMLISTs and LOOTLISTs to support an optional weighting system, which can be used to adjust the probability of some items being chosen from these lists over other items. In the below example, specialfishingnet has a weight of 10, while the blank entry has a weight of 90, making it 9 times more likely for the blank entry to be chosen than the specialfishingnet! Note that higher weighted items should be sorted first for this to be accurate:
[LOOTLIST shipwreck_treasure_special]
{
90|blank
10|specialfishingnet
}
Using bladed weapons on stacks of fish will now cut the entire stack at once, instead of one fish at a time
Updated DFN entries for various sea creatures (dfndata/npc/seacreatures.dfn) to adjust color of NPCs, loot and NPC AI
Extended functionality of JS Function DoMovingEffect() to allow a set of coordinates as source location, without having to specify a character as either the source or target of the effect
Fixed an issue with sea creatures being unable to pathfind in shallow water due to underwater land tiles being treated as blocking
Moved fishing skill out of code and into js for more user friendly control
Added js/item/magicfish.js for the magic fish food
2021-09-20 18:47:54 +08:00
|
|
|
{ "GetRandomSOSArea", SE_GetRandomSOSArea, 2, 0, 0 },
|
2002-04-07 20:53:41 +00:00
|
|
|
{ "DoTempEffect", SE_DoTempEffect, 7, 0, 0 },
|
|
|
|
|
{ "MakeItem", SE_MakeItem, 3, 0, 0 },
|
|
|
|
|
{ "FindMulti", SE_FindMulti, 4, 0, 0 },
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "GetItem", SE_GetItem, 4, 0, 0 },
|
|
|
|
|
{ "FindItem", SE_FindItem, 5, 0, 0 },
|
2002-04-07 20:53:41 +00:00
|
|
|
{ "PossessTown", SE_PossessTown, 2, 0, 0 },
|
|
|
|
|
{ "IsRaceWeakToWeather", SE_IsRaceWeakToWeather, 2, 0, 0 },
|
|
|
|
|
{ "GetRaceSkillAdjustment", SE_GetRaceSkillAdjustment, 2, 0, 0 },
|
2020-11-13 01:58:48 +08:00
|
|
|
{ "UseItem", SE_UseItem, 2, 0, 0 },
|
2021-07-06 07:28:19 +08:00
|
|
|
{ "TriggerTrap", SE_TriggerTrap, 2, 0, 0 },
|
2002-04-07 20:53:41 +00:00
|
|
|
{ "CompareGuildByGuild", SE_CompareGuildByGuild, 2, 0, 0 },
|
|
|
|
|
{ "CommandLevelReq", SE_CommandLevelReq, 1, 0, 0 },
|
|
|
|
|
{ "CommandExists", SE_CommandExists, 1, 0, 0 },
|
|
|
|
|
{ "FirstCommand", SE_FirstCommand, 0, 0, 0 },
|
|
|
|
|
{ "NextCommand", SE_NextCommand, 0, 0, 0 },
|
|
|
|
|
{ "FinishedCommandList", SE_FinishedCommandList, 0, 0, 0 },
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "CreateDFNItem", SE_CreateDFNItem, 3, 0, 0 },
|
|
|
|
|
{ "CreateBlankItem", SE_CreateBlankItem, 8, 0, 0 },
|
|
|
|
|
{ "SpawnNPC", SE_SpawnNPC, 5, 0, 0 },
|
2002-04-07 20:53:41 +00:00
|
|
|
{ "GetPackOwner", SE_GetPackOwner, 2, 0, 0 },
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
{ "FindRootContainer", SE_FindRootContainer, 2, 0, 0 },
|
2002-04-07 20:53:41 +00:00
|
|
|
{ "CalcTargetedItem", SE_CalcTargetedItem, 1, 0, 0 },
|
|
|
|
|
{ "CalcTargetedChar", SE_CalcTargetedChar, 1, 0, 0 },
|
|
|
|
|
{ "GetTileIDAtMapCoord", SE_GetTileIDAtMapCoord, 3, 0, 0 },
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "GetDictionaryEntry", SE_GetDictionaryEntry, 2, 0, 0 },
|
|
|
|
|
{ "Yell", SE_Yell, 3, 0, 0 },
|
2002-04-07 20:53:41 +00:00
|
|
|
{ "GetRaceCount", SE_GetRaceCount, 0, 0, 0 },
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "WorldBrightLevel", SE_WorldBrightLevel, 0, 0, 0 },
|
|
|
|
|
{ "WorldDarkLevel", SE_WorldDarkLevel, 0, 0, 0 },
|
|
|
|
|
{ "WorldDungeonLevel", SE_WorldDungeonLevel, 0, 0, 0 },
|
2003-03-04 14:55:47 +00:00
|
|
|
{ "AreaCharacterFunction", SE_AreaCharacterFunction, 3, 0, 0 },
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "AreaItemFunction", SE_AreaItemFunction, 3, 0, 0 },
|
2003-03-04 14:55:47 +00:00
|
|
|
{ "TriggerEvent", SE_TriggerEvent, 3, 0, 0 },
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "Reload", SE_Reload, 1, 0, 0 },
|
|
|
|
|
{ "SendStaticStats", SE_SendStaticStats, 1, 0, 0 },
|
|
|
|
|
{ "GetTileHeight", SE_GetTileHeight, 1, 0, 0 },
|
|
|
|
|
{ "IterateOver", SE_IterateOver, 1, 0, 0 },
|
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
|
|
|
{ "IterateOverSpawnRegions", SE_IterateOverSpawnRegions, 1, 0, 0 },
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "GetSocketFromIndex", SE_GetSocketFromIndex, 1, 0, 0 },
|
|
|
|
|
{ "StaticAt", SE_StaticAt, 4, 0, 0 },
|
|
|
|
|
{ "StaticInRange", SE_StaticInRange, 5, 0, 0 },
|
Exposed various map and statics related functions to JS engine
Updated JS item properties MORE, MOREX, MOREY, MOREZ and SERIAL, and character property SERIAL, to pass values to JS scripts using JS_NewNumberValue() instead of INT_TO_JSVAL if the property value cannot fit inside JSVAL (checked with INT_FITS_IN_JSVAL)
Added support in CResponse.cpp for client trigger word for securing containers in houses - TW_HOUSESECURE
Updated CMulHandler::CheckStaticFlag() to match with statics that cover/extend across the specified Z coordinate, not just ones that have the same base Z level
Updated CMulHandler::DoesMapBlock() to not deem map tiles as blocking if they are more than 16 Z (height of a character) higher than the specified Z coordinate to check
Exposed method for finding corners of a multi to JS engine:
.GetMultiCorner( cornerID ) - Gets coordinates for specified corner of multi (0 = NW, 1 = NE, 2 = SW, 3 = SE)
Exposed various functions related to map, statics and multis to JS engine:
CalcMultiFromSer( serial ) - Find a multi from a provided serial
GetMapElevation( x, y, z, world) - Returns the map elevation at specified coordinates
IsInBuilding( x, y, z, world, instance, checkHeight ) - Returns true if the specified location is inside a static building (underneath static items), or if player is inside a multi. If the checkHeight argument is true, player is only deemed inside a multi if there are multi-items above the player's head. If player is in a courtyard/on a rooftop, they will be deemed to be NOT in the building. checkHeight is not used for the static part of the function.
CheckStaticFlag( x, y, z, world, tileFlagID ) - Checks to see if any statics at given coordinates has specified tile flag
DoesStaticBlock( x, y, z, world, checkWater ) - Checks if statics at/above given location blocks characters
DoesDynamicBlock( x, y, z, world, instance, checkWater, waterWalk ) - Checks if dynamics at/above given location blocks characters
DoesMapBlock( x, y, z, world, checkWater, waterWalk ) - Checks if map tile at/above given location blocks characters
2020-10-05 23:12:34 +08:00
|
|
|
|
|
|
|
|
{ "GetMapElevation", SE_GetMapElevation, 3, 0, 0 },
|
|
|
|
|
{ "IsInBuilding", SE_IsInBuilding, 6, 0, 0 },
|
|
|
|
|
{ "CheckStaticFlag", SE_CheckStaticFlag, 5, 0, 0 },
|
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
|
|
|
{ "CheckDynamicFlag", SE_CheckDynamicFlag, 6, 0, 0 },
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
{ "CheckTileFlag", SE_CheckTileFlag, 2, 0, 0 },
|
|
|
|
|
{ "DoesDynamicBlock", SE_DoesDynamicBlock, 7, 0, 0 },
|
Exposed various map and statics related functions to JS engine
Updated JS item properties MORE, MOREX, MOREY, MOREZ and SERIAL, and character property SERIAL, to pass values to JS scripts using JS_NewNumberValue() instead of INT_TO_JSVAL if the property value cannot fit inside JSVAL (checked with INT_FITS_IN_JSVAL)
Added support in CResponse.cpp for client trigger word for securing containers in houses - TW_HOUSESECURE
Updated CMulHandler::CheckStaticFlag() to match with statics that cover/extend across the specified Z coordinate, not just ones that have the same base Z level
Updated CMulHandler::DoesMapBlock() to not deem map tiles as blocking if they are more than 16 Z (height of a character) higher than the specified Z coordinate to check
Exposed method for finding corners of a multi to JS engine:
.GetMultiCorner( cornerID ) - Gets coordinates for specified corner of multi (0 = NW, 1 = NE, 2 = SW, 3 = SE)
Exposed various functions related to map, statics and multis to JS engine:
CalcMultiFromSer( serial ) - Find a multi from a provided serial
GetMapElevation( x, y, z, world) - Returns the map elevation at specified coordinates
IsInBuilding( x, y, z, world, instance, checkHeight ) - Returns true if the specified location is inside a static building (underneath static items), or if player is inside a multi. If the checkHeight argument is true, player is only deemed inside a multi if there are multi-items above the player's head. If player is in a courtyard/on a rooftop, they will be deemed to be NOT in the building. checkHeight is not used for the static part of the function.
CheckStaticFlag( x, y, z, world, tileFlagID ) - Checks to see if any statics at given coordinates has specified tile flag
DoesStaticBlock( x, y, z, world, checkWater ) - Checks if statics at/above given location blocks characters
DoesDynamicBlock( x, y, z, world, instance, checkWater, waterWalk ) - Checks if dynamics at/above given location blocks characters
DoesMapBlock( x, y, z, world, checkWater, waterWalk ) - Checks if map tile at/above given location blocks characters
2020-10-05 23:12:34 +08:00
|
|
|
{ "DoesStaticBlock", SE_DoesStaticBlock, 7, 0, 0 },
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
{ "DoesMapBlock", SE_DoesMapBlock, 8, 0, 0 },
|
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
|
|
|
{ "DistanceBetween", SE_DistanceBetween, 4, 0, 0 },
|
Exposed various map and statics related functions to JS engine
Updated JS item properties MORE, MOREX, MOREY, MOREZ and SERIAL, and character property SERIAL, to pass values to JS scripts using JS_NewNumberValue() instead of INT_TO_JSVAL if the property value cannot fit inside JSVAL (checked with INT_FITS_IN_JSVAL)
Added support in CResponse.cpp for client trigger word for securing containers in houses - TW_HOUSESECURE
Updated CMulHandler::CheckStaticFlag() to match with statics that cover/extend across the specified Z coordinate, not just ones that have the same base Z level
Updated CMulHandler::DoesMapBlock() to not deem map tiles as blocking if they are more than 16 Z (height of a character) higher than the specified Z coordinate to check
Exposed method for finding corners of a multi to JS engine:
.GetMultiCorner( cornerID ) - Gets coordinates for specified corner of multi (0 = NW, 1 = NE, 2 = SW, 3 = SE)
Exposed various functions related to map, statics and multis to JS engine:
CalcMultiFromSer( serial ) - Find a multi from a provided serial
GetMapElevation( x, y, z, world) - Returns the map elevation at specified coordinates
IsInBuilding( x, y, z, world, instance, checkHeight ) - Returns true if the specified location is inside a static building (underneath static items), or if player is inside a multi. If the checkHeight argument is true, player is only deemed inside a multi if there are multi-items above the player's head. If player is in a courtyard/on a rooftop, they will be deemed to be NOT in the building. checkHeight is not used for the static part of the function.
CheckStaticFlag( x, y, z, world, tileFlagID ) - Checks to see if any statics at given coordinates has specified tile flag
DoesStaticBlock( x, y, z, world, checkWater ) - Checks if statics at/above given location blocks characters
DoesDynamicBlock( x, y, z, world, instance, checkWater, waterWalk ) - Checks if dynamics at/above given location blocks characters
DoesMapBlock( x, y, z, world, checkWater, waterWalk ) - Checks if map tile at/above given location blocks characters
2020-10-05 23:12:34 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "ResourceArea", SE_ResourceArea, 2, 0, 0 },
|
|
|
|
|
{ "ResourceAmount", SE_ResourceAmount, 2, 0, 0 },
|
|
|
|
|
{ "ResourceTime", SE_ResourceTime, 2, 0, 0 },
|
|
|
|
|
{ "ResourceRegion", SE_ResourceRegion, 3, 0, 0 },
|
|
|
|
|
{ "Moon", SE_Moon, 2, 0, 0 },
|
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
|
|
|
|
2021-04-19 01:11:25 +08:00
|
|
|
{ "GetTownRegion", SE_GetTownRegion, 1, 0, 0 },
|
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
|
|
|
{ "GetSpawnRegion", SE_GetSpawnRegion, 1, 0, 0 },
|
|
|
|
|
{ "GetSpawnRegionCount", SE_GetSpawnRegionCount, 0, 0, 0 },
|
|
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "RegisterCommand", SE_RegisterCommand, 3, 0, 0 },
|
|
|
|
|
{ "DisableCommand", SE_DisableCommand, 1, 0, 0 },
|
|
|
|
|
{ "EnableCommand", SE_EnableCommand, 1, 0, 0 },
|
|
|
|
|
|
|
|
|
|
{ "RegisterKey", SE_RegisterKey, 2, 0, 0 },
|
|
|
|
|
{ "DisableKey", SE_DisableKey, 1, 0, 0 },
|
|
|
|
|
{ "EnableKey", SE_EnableKey, 1, 0, 0 },
|
|
|
|
|
|
|
|
|
|
{ "RegisterConsoleFunc", SE_RegisterConsoleFunc, 2, 0, 0 },
|
|
|
|
|
{ "DisableConsoleFunc", SE_DisableConsoleFunc, 1, 0, 0 },
|
|
|
|
|
{ "EnableConsoleFunc", SE_EnableConsoleFunc, 1, 0, 0 },
|
|
|
|
|
|
|
|
|
|
{ "RegisterSpell", SE_RegisterSpell, 2, 0, 0 },
|
|
|
|
|
{ "DisableSpell", SE_DisableSpell, 1, 0, 0 },
|
|
|
|
|
{ "EnableSpell", SE_EnableSpell, 1, 0, 0 },
|
|
|
|
|
|
|
|
|
|
{ "RegisterSkill", SE_RegisterSkill, 2, 0, 0 },
|
|
|
|
|
{ "RegisterPacket", SE_RegisterPacket, 2, 0, 0 },
|
|
|
|
|
{ "ReloadJSFile", SE_ReloadJSFile, 1, 0, 0 },
|
|
|
|
|
|
|
|
|
|
{ "ValidateObject", SE_ValidateObject, 1, 0, 0 },
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
{ "ApplyDamageBonuses", SE_ApplyDamageBonuses, 6, 0, 0 },
|
|
|
|
|
{ "ApplyDefenseModifiers", SE_ApplyDefenseModifiers, 7, 0, 0 },
|
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
|
|
|
{ "WillResultInCriminal", SE_WillResultInCriminal, 2, 0, 0 },
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
{ "CreateParty", SE_CreateParty, 1, 0, 0 },
|
|
|
|
|
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
{ "GetClientFeature", SE_GetClientFeature, 1, 0, 0 },
|
|
|
|
|
{ "GetServerFeature", SE_GetServerFeature, 1, 0, 0 },
|
|
|
|
|
{ "GetServerSetting", SE_GetServerSetting, 1, 0, 0 },
|
|
|
|
|
|
|
|
|
|
{ "DeleteFile", SE_DeleteFile, 2, 0, 0 },
|
|
|
|
|
|
0.99.4d
Added new option in UOX.INI under [settings] section:
MAPDIFFSENABLED=0/1 // If enabled, server will attempt to load diff files, and send "Enable Map-diff files" packet to client to also load these. Disabled by default.
Server no longer loads map/statics diff files by default, nor does it send packet to client to request loading these files, as only client versions below 7.0.8.2 will actively load these files. Can be re-enabled with new UOX.INI setting mentioned above!
Fixed incorrect ID for gargish dagger in CHandleCombat::getWeaponType()
Added missing weapon entries in CHandleCombat::getWeaponType(): bladed whip, barbed whip, spiked whip, gargish talwar
Fixed an issue that would show the end part of some tiledata names as garbled text instead of cutting off the text(!) at 20 characters
Fixed an issue with advanced character creation template when using ClassicUO client, which sends a profession value of 255 instead of 0 when no profession template has been selected.
Fixed an issue where clones of NPCs that can split in combat didn't get the NPC flag correctly set
Guild titles are now removed for players who leave their guilds
Enabled closing some hard-coded gump menus using right-click (howto, guild, towns, wholist, addmenu, craftmenu, info)
Fixed an issue where adding base items using 'add [itemID] would sometimes get false positive hits from harditems.dfn, depending on the length of the itemID
Fixed an issue where items added using 'add [itemID] would not get names applied properly from harditems.dfn
Item/NPC DFN tag GET can now inherit a random parent by adding additional values separated by spaces. Syntax:
GET=parent1 parent2 parent3 (etc)
Fixed an issue where NPC backpacks would not have the max item capacity set properly
Added new properties for CItem objects (also exposed as JS Item Properties):
maxRange // max distance a ranged weapon can fire at (replaces ARCHERRANGE ini setting)
baseRange // base distance throwing weapons (when implemented) can be used at
Added support for new Item DFN tag that replaces global UOX.INI setting ARCHERRANGE:
MAXRANGE=# // Specifies max range of ranged weapon
Added support for new Item/NPC DFN tags to support randomizing elemental resistances:
RESISTFIRE=#/# # // Set NPC's poison resistance; fixed or random value
RESISTCOLD=#/# # // Set NPC's poison resistance; fixed or random value
RESISTLIGHTNING=#/# # // Set NPC's poison resistance; fixed or random value
RESISTPOISON=#/# # // Set NPC's poison resistance; fixed or random value
Added support for two new DFN tags in dfndata/race/races.dfn that can be used to allow/ban lists of equipment for specific races
ALLOWEQUIPLIST=#
BANEQUIPLIST=#
Added support for new section in dfndata/race/races.dfn - [EQUIPLIST #], which can be used to define lists of equipment that is whitelisted or banned for specific races.
Fixed a bug that would report incorrect weight in tooltips for Item/NPC spawner objects
ScriptSections are now reapplied for items bought by players from NPC vendors
Fixed an issue where players could drop an item on the ground and other players would still see the item after it was picked up, because of a failed distance check vs old location coordinates (in pack) instead of vs current location on ground
Fixed a bug with players being able to use last-target macro to target objects picked up and held by other players on their cursor
Updated all references to "devinelock" to be "divinelock" instead - this includes the name of the JS Item property
Fixed house commands triggering (useless) targeting cursors for players onboard boats
Changed default statcap in UOX.INI from 325 to 225
Fixed a out-of-range error for players attempting to combine ore inside their own backpack
Fixed various issues with distance checks and container checks when using/target objects
Added optional 4th "hue" parameter to AddGump JS method
Added JS Function to get total amount of accounts on server - GetAccountCount()
Added JS Function to get total amount of players online - GetPlayerCount()
onSwing JS Event can now trigger in scripts attached to items, not just items attached to characters
Added some JS Functions to expose some hard-coded constants to JS scripts:
BASEITEMSERIAL() // Base item serial
INVALIDSERIAL() // Invalid serial
INVALIDID() // Invalid ID
INVALIDCOLOUR() // Invalid colour
Fixed an issue where JS character property .colour would modify origSkin property instead of colour
Fixed an issue where JS character property .guildTitle returned the name of the character instead of the guild title
Character JS property .poison can now also be used to set a character's poisoned level, not just read it
Exposed Item property to JS engine:
.ac // armour class for item (0-128). Primarily used for setting race-restrictions for equippable items, i.e. race X cannot equip items of armour class Y.
.def // defensive value of item (Physical resistance post-AoS, AR in older UO)
// NOTE: The following properties don't actually do anything yet, but can still be used in custom JS scripts if desired
.resistCold // Cold resistance of item 0-1000, where 1000 equals 100.0%
.resistHeat // Heat/Fire resistance of item 0-1000, where 1000 equals 100.0%
.resistLight // Light resistance of item 0-1000, where 1000 equals 100.0%
.resistLightning // Energy/Lightning resistance of item 0-1000, where 1000 equals 100.0%
.resistPoison // Poison resistance of item 0-1000, where 1000 equals 100.0%
.resistRain // Rain resistance of item 0-1000, where 1000 equals 100.0%
.resistSnow // Snow resistance of item 0-1000, where 1000 equals 100.0%
.damageHeat // Weapon deals Heat/Fire elemental damage (true/false)
.damageCold // Weapon deals Cold elemental damage (true/false)
.damageLight // Weapon deals Light elemental damage (true/false)
.damageLightning // Weapon deals Lightning elemental damage (true/false)
.damagePoison // Weapon deals Poison elemental damage (true/false)
.damageRain // Weapon deals Rain/Water elemental damage (true/false)
.damageSnow // Weapon deals Snow/Ice elemental damage (true/false)
Added new UOX.INI setting under [server] to enable/disable shard response to ConnectUO server polling (disabled by default)
Sub-commands are no longer included when registering packets to be overloaded via RegisterPacket function, as that part was never fully implemented. Packet-hook scripts can be setup for specific packet IDs, but any sub-command checking will need to be done in the script itself
JS Packet Method GetDWord() now uses JS_NewNumberValue instead of INT_TO_JSVAL to read from the socket buffer, to better handle large numbers, which could previously be returned with wrong values.
JS Function CalcItemFromSer() now uses a JS_GetStringBytes() and str_value() combo instead of JSVAL_TO_INT() to read the data provided in the function argument. This allows JS scripts to provide item serials to the function directly without needing to split it into four parts first (though that still works)
Fixed issue where JS properties for multis didn't always return correct values
The 'set command can now be used to set the armour class of items ('set ac #)
Reimplemented 'tweak command in JS engine (js/commands/targeting/tweak.js) - can be used to view and modify properties of characters, character skills, items, multis and regions (target ground)
Added placeholder packet-hook script (js/server/network/0xf1_connectUoServerPoll.js) to handle responses to ConnectUO server polling. By default this script does nothing, but serves as a placeholder for drop-in replacement scripts generated specifically for each shard by the ConnectUO service.
Updated some commands to support an alternate STATIC keyword (can also be ommitted) to add base items:
'add static itemID
'tile static itemID
Updated some commands with support for randomization. Provided itemID will be randomized based on provided rndValue:
/js/commands/targeting/add.js:
'add itemID rndValue
cmdtable.cpp and targeting.cpp:
'tile itemID rndValue
'tile itemID x1 x2 y1 y2 z rndValue
Updated js/commands/custom/repeatingcmds.js to support 'm delete as an alias for 'rremove
Added 'props as an alias for the 'tweak command
Added 'teleport as an alias for the 'tele command (js/commands/targeting/tele.js)
Added 'shavehair and 'shavebeard as aliases for 'kill hair and 'kill beard (js/commands/targeting/kill.js)
Added 'noinvul and 'mortal aliases for the 'invul false command (js/commands/custom/misc-cmds.js)
Added 'immortal and 'invul (without parameter) as aliases for the 'invul true command
Added 'bringtopack as an alias of 'movetobag command (js/commands/targeting/movetobag.js)
Updated check for cancelling of target cursor in various JS scripts
Minor updates to various JS scripts
Fixed issue where some item definitions in dfndata/harditems/harditems.dfn and dfndata/items/building/lighting.dfn used comma instead of space as delimiter for the VALUE tag, which thus never got applied
Updated all NPC definitions to let NPCs spawn facing in random directions
2021-03-22 05:59:20 +08:00
|
|
|
{ "GetAccountCount", SE_GetAccountCount, 0, 0, 0 },
|
|
|
|
|
{ "GetPlayerCount", SE_GetPlayerCount, 0, 0, 0 },
|
|
|
|
|
|
|
|
|
|
{ "BASEITEMSERIAL", SE_BASEITEMSERIAL, 0, 0, 0 },
|
|
|
|
|
{ "INVALIDSERIAL", SE_INVALIDSERIAL, 0, 0, 0 },
|
|
|
|
|
{ "INVALIDID", SE_INVALIDID, 0, 0, 0 },
|
|
|
|
|
{ "INVALIDCOLOUR", SE_INVALIDCOLOUR, 0, 0, 0 },
|
|
|
|
|
|
Blood, bleeding, tracking fixes, forensics fix, race combat mods
Added cEffects::SpawnBloodEffect( UI08 worldNum, UI16 instanceID, UI16 bloodColour, BloodTypes bloodType ), which can be called upon to create blood splatter effects for things like death, bleeding, combat hits, etc.
Added random blood effects that spawn when a character dies, and decays according to new ini setting
Added new UOX.INI settings under [timers] to define how long blood effects take to decay:
BLOODDECAYTIMER=3 // Smaller blood effects spawned during combat, defaults to 3 seconds
BLOODDECAYCORPSETIMER=450 // Larger blood effects spawned upon death, defaults to half the duration of the default corpse decay timer
Fixed an issue with Forensic Evaluation skill (js/skills/forensics.js) not giving correct info on age of a corpse, because it incorrectly tried to check a .tempTime property instead of .tempTimer
Changed default value of MSGREDISPLAYTIME in [tracking] section of UOX.INI from 30 to 3, so tracking arrow will actually follow the target when it moves (every 3 seconds)
Fixed an issue with the Tracking skill where attempting to left-click on the tracking arrow would cause client to freeze up
Fixed an issue with the Tracking skill where right-clicking tracking arrow to dismiss it would not always work, especially if target had been killed/deleted
Fixed an issue with the Tracking skill where the tracking arrow would not be automatically dismissed if the tracked target was killed/deleted
Fixed an issue that prevented clients in 6.0.5 - 6.0.14.1 range from connecting even though CLIENTSUPPORT6050 was enabled in ini
Fixed an issue where client 6.0.14.2 was being mis-classified as a T2A client, and not the first of the SA clients as it should be
Changed how Race damage modifier is applied to damage dealt in combat - it's now a direct percentage bonus (or penalty) applied to the base damage dealt
Added in missing default [COMBAT MODS] section to dfndata/race/races.dfn. Each MOD# entry in this section represents a percentage modifier applied to skill checks for members of a race that subscribes to that MOD entry via skill tags like [SKILLNAME]G=# (bonus) or [SKILLNAME]L=# (penalty). These modifiers are also applied to base damage in combat, before other damage modifiers.
Example1: SWORDSMANSHIPG=3 would apply a 20% bonus to swordsmanship skill checks for race the tag was added to, as well as a 20% bonus to base damage dealt in combat
Example2: MACEFIGHTINGL=3 would apply a 20% penalty to macefighting skill checks for race the tag was added to, as well as a 20% penalty to base damage dealt in combat
2021-06-15 02:19:47 +08:00
|
|
|
{ nullptr, nullptr, 0, 0, 0 },
|
2002-04-07 20:53:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void UOX3ErrorReporter( JSContext *cx, const char *message, JSErrorReport *report )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
UI16 scriptNum = JSMapping->GetScriptID( JS_GetGlobalObject( cx ) );
|
2002-04-07 20:53:41 +00:00
|
|
|
// If we're loading the world then do NOT print out anything!
|
2021-05-27 05:42:35 +08:00
|
|
|
Console.error( strutil::format("JS script failure: Script Number (%u) Message (%s)", scriptNum, message ));
|
2021-06-12 07:30:23 -04:00
|
|
|
if( report == nullptr || report->filename == nullptr )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
Console.error( "No detailed data" );
|
2002-04-07 20:53:41 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2021-05-27 05:42:35 +08:00
|
|
|
Console.error( strutil::format("Filename: %s\n| Line Number: %i", report->filename, report->lineno) );
|
|
|
|
|
Console.error( strutil::format("Erroneous Line: %s\n| Token Ptr: %s", report->linebuf, report->tokenptr ));
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
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
|
|
|
//| Function - SI32 TryParseJSVal( jsval toParse )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Helper function to parse jsval returned from script
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
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
|
|
|
SI32 TryParseJSVal( jsval toParse )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
|
|
|
|
if( JSVAL_IS_NULL( toParse ) || ( !JSVAL_IS_BOOLEAN( toParse ) && !JSVAL_IS_INT( toParse ) ))
|
|
|
|
|
{
|
|
|
|
|
// jsval is neither a bool nor an int - possibly an object!
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if( JSVAL_IS_BOOLEAN( toParse ) == JS_FALSE && JSVAL_IS_INT( toParse ) )
|
|
|
|
|
{
|
|
|
|
|
// jsval is an int!
|
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
|
|
|
return static_cast<SI32>(JSVAL_TO_INT( toParse ));
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
}
|
|
|
|
|
else if( JSVAL_IS_BOOLEAN( toParse ) == JS_TRUE )
|
|
|
|
|
{
|
|
|
|
|
// jsval is a bool! convert it to int
|
|
|
|
|
if( JSVAL_TO_BOOLEAN( toParse ) == JS_TRUE )
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
cScript::cScript( std::string targFile, UI08 rT ) : isFiring( false ), runTime( rT )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Code cleanup
Embraced the usage of R32, R64, SI16, UI16, SI32, UI32, SI64 and UI64 typedef aliases as replacement for built-in types throughout the sourcecode:
typedef float R32;
typedef double R64;
typedef signed char SI08;
typedef unsigned char UI08;
typedef signed short int SI16;
typedef unsigned short int UI16;
typedef signed int SI32;
typedef unsigned int UI32;
typedef signed long long SI64;
typedef unsigned long long UI64;
As part of this process, UI32 was redefined from unsigned long int to unsigned int, and SI32 from signed long int to signed int to ensure the size of variables using these remain the same (32bit) across both Windows, Linux and MacOS for both 32bit and 64bit platforms
Replaced instances of toLong() with toInt(), and toULong() to toUInt()
Replaced instances of "long" and "int" with SI32 where possible
Replaced instances of "unsigned long" and "unsigned int" with UI32 where possible
Replaced instances of "float" with R32 where possible
2020-08-12 23:46:33 +08:00
|
|
|
for( SI32 i = 0; i < 3; ++i )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
|
|
|
|
eventPresence[i].set();
|
|
|
|
|
needsChecking[i].set();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
targContext = JSEngine->GetContext( runTime ); //JS_NewContext( JSEngine->GetRuntime( runTime ), 0x2000 );
|
2021-06-12 07:30:23 -04:00
|
|
|
if( targContext == nullptr )
|
2002-04-07 20:53:41 +00:00
|
|
|
return;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2021-06-12 07:30:23 -04:00
|
|
|
targObject = JS_NewObject( targContext, &uox_class, nullptr, nullptr );
|
|
|
|
|
if( targObject == nullptr )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
JS_LockGCThing( targContext, targObject );
|
|
|
|
|
//JS_AddRoot( targContext, &targObject );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
// Moved here so it reports errors during script-startup too
|
|
|
|
|
JS_SetErrorReporter( targContext, UOX3ErrorReporter );
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JS_SetGlobalObject( targContext, targObject );
|
|
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
JS_InitStandardClasses( targContext, targObject );
|
|
|
|
|
JS_DefineFunctions( targContext, targObject, my_functions );
|
|
|
|
|
targScript = JS_CompileFile( targContext, targObject, targFile.c_str() );
|
2021-06-12 07:30:23 -04:00
|
|
|
if( targScript == nullptr )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
throw std::runtime_error( "Compilation failed" );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
jsval rval;
|
|
|
|
|
JSBool ok = JS_ExecuteScript( targContext, targObject, targScript, &rval );
|
|
|
|
|
if( ok != JS_TRUE )
|
|
|
|
|
{
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
JSString *str = JS_ValueToString( targContext, rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
Console << "script result: " << JS_GetStringBytes( str ) << myendl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
void cScript::Cleanup( void )
|
|
|
|
|
{
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
for( i = 0; i < gumpDisplays.size(); ++i )
|
|
|
|
|
delete gumpDisplays[i];
|
|
|
|
|
gumpDisplays.resize( 0 );
|
|
|
|
|
|
|
|
|
|
JS_UnlockGCThing( targContext, targObject );
|
|
|
|
|
//JS_RemoveRoot( targContext, &targObject );
|
|
|
|
|
}
|
|
|
|
|
void cScript::CollectGarbage( void )
|
|
|
|
|
{
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
// if( JS_IsRunning( targContext ) == JS_FALSE )
|
|
|
|
|
// {
|
|
|
|
|
Cleanup();
|
|
|
|
|
JS_LockGCThing( targContext, targObject );
|
|
|
|
|
//JS_AddRoot( targContext, &targObject );
|
|
|
|
|
// }
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
cScript::~cScript()
|
|
|
|
|
{
|
|
|
|
|
JS_GC( targContext );
|
2021-06-12 07:30:23 -04:00
|
|
|
if( targScript != nullptr )
|
2002-04-07 20:53:41 +00:00
|
|
|
JS_DestroyScript( targContext, targScript );
|
2012-11-03 18:11:04 +00:00
|
|
|
Cleanup();
|
2002-04-07 20:53:41 +00:00
|
|
|
JS_GC( targContext );
|
2021-06-12 07:30:23 -04:00
|
|
|
// if( targContext != nullptr )
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
// JS_DestroyContext( targContext );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool cScript::IsFiring( void )
|
|
|
|
|
{
|
|
|
|
|
return isFiring;
|
|
|
|
|
}
|
|
|
|
|
void cScript::Firing( void )
|
|
|
|
|
{
|
|
|
|
|
isFiring = true;
|
|
|
|
|
}
|
|
|
|
|
void cScript::Stop( void )
|
|
|
|
|
{
|
|
|
|
|
isFiring = false;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool cScript::OnStart( void )
|
|
|
|
|
//| Date - 8/16/2003 3:44:50 AM
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - The OnStart event is provided to allow a script to process
|
|
|
|
|
//| and read in any state information that has been saved from
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| a previous server shut down. If a a script come with an
|
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
|
|
|
//| OnStart event the code that is provided will be executed
|
|
|
|
|
//| just following the loading of the script.
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnStart( void )
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool cScript::OnStop( void )
|
|
|
|
|
//| Date - 8/16/2003 3:44:44 AM
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - The OnStop event is provided to allow a script to perform
|
|
|
|
|
//| any special cleanup, or state saving as a server shuts
|
|
|
|
|
//| down. If a script has an OnStop event then any code that
|
|
|
|
|
//| is provided will be executed just prior to the JSE shut
|
|
|
|
|
//| down.
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnStop( void )
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnCreate( CBaseObject *thingCreated, bool dfnCreated )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Runs when an object is added/created
|
|
|
|
|
//| Notes - Checks for the presence of onCreateDFN by default, but onCreateTile can also
|
|
|
|
|
//| be used to intercept creation of items directly from tiles/harditems.dfn
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnCreate( CBaseObject *thingCreated, bool dfnCreated )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( thingCreated ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
std::string functionName = "onCreateDFN";
|
|
|
|
|
if( !dfnCreated )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
functionName = "onCreateTile";
|
|
|
|
|
if( !ExistAndVerify( seOnCreateTile, functionName ) )
|
|
|
|
|
return false;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
else
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnCreateDFN, functionName ) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
UI08 paramType = 0;
|
|
|
|
|
JSObject *myObj;
|
|
|
|
|
if( thingCreated->GetObjType() == OT_CHAR )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, thingCreated, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
paramType = 1;
|
|
|
|
|
}
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
else {
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, thingCreated, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( paramType );
|
2012-11-03 18:11:04 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, functionName.c_str(), 2, params, &rval );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
if( retVal == JS_FALSE ){
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !dfnCreated )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnCreateTile, false );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnCreateDFN, false );
|
|
|
|
|
}
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnDelete( CBaseObject *thingDestroyed )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Runs when an object is deleted
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnDelete( CBaseObject *thingDestroyed )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( thingDestroyed ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnDelete, "onDelete" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
UI08 paramType = 0;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj;
|
2002-04-07 20:53:41 +00:00
|
|
|
if( thingDestroyed->GetObjType() != OT_CHAR )
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, thingDestroyed, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
else
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, thingDestroyed, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
paramType = 1;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( paramType );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onDelete", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnDelete, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnSpeech( const char *speech, CChar *personTalking, CChar *talkingTo )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers when a character talks in range of the character with event attached
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Notes - The function returns 4 possible values
|
|
|
|
|
//| -1 => No such function or bad call
|
|
|
|
|
//| 0 => Let other NPCs and PCs see it
|
|
|
|
|
//| 1 => Let other PCs see it
|
|
|
|
|
//| 2 => Let no one else see it
|
|
|
|
|
//| If JS returns non-int and non-bool, default to 0
|
|
|
|
|
//| If JS returns bool, true == 2, false == 0
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Changes - 22 June, 2003 17:30 (making it version 3)
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Changed return values from bool to SI08
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
SI08 cScript::OnSpeech( const char *speech, CChar *personTalking, CBaseObject *talkingTo )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2021-06-12 07:30:23 -04:00
|
|
|
if( speech == nullptr || !ValidateObject( personTalking ) || !ValidateObject( talkingTo ) )
|
2012-11-03 18:11:04 +00:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSpeech, "onSpeech" ) )
|
2012-11-03 18:11:04 +00:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
2021-06-12 07:30:23 -04:00
|
|
|
JSString *strSpeech = nullptr;
|
2021-04-25 05:01:06 +08:00
|
|
|
std::string lwrSpeech = speech;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2021-07-19 13:41:59 -04:00
|
|
|
strSpeech = JS_NewStringCopyZ( targContext, strutil::lower( lwrSpeech ).c_str() );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *ptObj = JSEngine->AcquireObject( IUE_CHAR, personTalking, runTime );
|
2021-06-12 07:30:23 -04:00
|
|
|
JSObject *ttObj = nullptr;
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
if( talkingTo->CanBeObjType( OT_CHAR ) )
|
2021-04-25 05:01:06 +08:00
|
|
|
{
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
ttObj = JSEngine->AcquireObject( IUE_CHAR, talkingTo, runTime );
|
2021-04-25 05:01:06 +08:00
|
|
|
}
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
else if( talkingTo->CanBeObjType( OT_ITEM ) )
|
2021-04-25 05:01:06 +08:00
|
|
|
{
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
ttObj = JSEngine->AcquireObject( IUE_ITEM, talkingTo, runTime );
|
2021-04-25 05:01:06 +08:00
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
params[0] = STRING_TO_JSVAL( strSpeech );
|
2012-11-03 18:11:04 +00:00
|
|
|
params[1] = OBJECT_TO_JSVAL( ptObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( ttObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSpeech", 3, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnSpeech, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !( JSVAL_IS_NULL( rval ) ) ) // They returned some sort of value
|
|
|
|
|
{
|
|
|
|
|
if( JSVAL_IS_INT( rval ) )
|
|
|
|
|
return static_cast< SI08 >(JSVAL_TO_INT( rval ));
|
|
|
|
|
else if( JSVAL_IS_BOOLEAN( rval ) )
|
|
|
|
|
{
|
|
|
|
|
if( JSVAL_TO_BOOLEAN( rval ) == JS_TRUE )
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-04 07:57:42 +08:00
|
|
|
return 0; // return default
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool InRange( CChar *person, CBaseObject *objInRange )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers when an object comes in range of a character with the event attached
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Notes - A third parameter is provided to let script know whether object that comes into
|
|
|
|
|
//| range is a character or an item (Multi not supported yet)
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::InRange( CChar *person, CBaseObject *objInRange )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( person ) || !ValidateObject( objInRange ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seInRange, "inRange" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_CHAR, person, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj2;
|
|
|
|
|
if( objInRange->CanBeObjType( OT_CHAR ) )
|
|
|
|
|
myObj2 = JSEngine->AcquireObject( IUE_CHAR, objInRange, runTime );
|
|
|
|
|
else
|
|
|
|
|
myObj2 = JSEngine->AcquireObject( IUE_ITEM, objInRange, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( myObj2 );
|
|
|
|
|
if( objInRange->CanBeObjType( OT_CHAR ) )
|
|
|
|
|
params[2] = INT_TO_JSVAL( 0 );
|
|
|
|
|
else
|
|
|
|
|
params[2] = INT_TO_JSVAL( 1 );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
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
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "inRange", 2, params, &rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seInRange, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnCollide( CSocket *tSock, CChar *objColliding, CBaseObject *objCollideWith )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for object event is attached to when a character collides with it
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnCollide( CSocket *tSock, CChar *objColliding, CBaseObject *objCollideWith )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( objColliding ) || !ValidateObject( objCollideWith ))
|
|
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnCollide, "onCollide" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, tSock, runTime );
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, objColliding, runTime );
|
2021-06-12 07:30:23 -04:00
|
|
|
JSObject *myObj2 = nullptr;
|
2002-04-07 20:53:41 +00:00
|
|
|
if( objCollideWith->GetObjType() == OT_CHAR )
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj2 = JSEngine->AcquireObject( IUE_CHAR, objCollideWith, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
else
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj2 = JSEngine->AcquireObject( IUE_ITEM, objCollideWith, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( myObj2 );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
if( JS_CallFunctionName( targContext, targObject, "onCollide", 3, params, &rval ) == JS_FALSE )
|
|
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnCollide, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnSteal( CChar *thief, CItem *theft )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item with event attached when stolen
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnSteal( CChar *thief, CItem *theft, CChar *victim )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( thief ) || !ValidateObject( theft ) || !ValidateObject( victim ))
|
|
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSteal, "onSteal" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
JSObject *thiefCharObj = JSEngine->AcquireObject( IUE_CHAR, thief, runTime );
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, theft, runTime );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
JSObject *victimCharObj = JSEngine->AcquireObject( IUE_CHAR, victim, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
jsval params[3], rval;
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( thiefCharObj );
|
2012-11-03 18:11:04 +00:00
|
|
|
params[1] = OBJECT_TO_JSVAL( itemObj );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
params[2] = OBJECT_TO_JSVAL( victimCharObj );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSteal", 3, params, &rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnSteal, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnDispel( CBaseObject *dispelled )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for object with event attached when dispelled
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnDispel( CBaseObject *dispelled )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( dispelled ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnDispel, "onDispel" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj;
|
2002-04-07 20:53:41 +00:00
|
|
|
if( dispelled->GetObjType() == OT_CHAR )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, dispelled, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( 0 );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, dispelled, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( 1 );
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onDispel", 2, params, &rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
if( retVal == JS_FALSE )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnDispel, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnSkill( CBaseObject *skillUse, SI08 skillUsed )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for object with event attached when using a skill
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Notes - If used WITH RegisterSkill() in a script listed under SKILLUSE_SCRIPTS in
|
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
|
|
|
//| JSE_FILEASSOCIATIONS.SCP, event will trigger for only the specified skill.
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| If used WITHOUT RegisterSkill() in a general purpose script listed under
|
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
|
|
|
//| SCRIPT_LIST instead, event will be a global listener for ALL skills used
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnSkill( CBaseObject *skillUse, SI08 skillUsed )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( skillUse ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSkill, "onSkill" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj;
|
2002-04-07 20:53:41 +00:00
|
|
|
if( skillUse->GetObjType() == OT_CHAR )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, skillUse, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[2] = INT_TO_JSVAL( 0 );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, skillUse, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[2] = INT_TO_JSVAL( 1 );
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( skillUsed );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSkill", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnSkill, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
0.99.4x
Fixed an issue where the color of NPC corpse names would not always match up with the NPC's flag color
Fixed a bug where the baseRange and maxRange properties of ranged weapons would not get saved to world files. These values are now saved in the format of RANGE=baseRange,maxRange
Changed the way items are added to containers, to ensure that the order in which the items are displayed to the player always reflects the order in which they were added; now the most recent item added/moved in a container will always be rendered on top of older items.
Made adjustments to how items are randomly added to containers; should use more of a given container gump's available area now
Exposed Item property to JS engine, which contains serial of the creator of an item:
.creator // contains serial of the creator of an item. If set, maker's marks will show up in the item's tooltip
Fixed an issue where JS engine would lose track of script context if one script used CreateDFNItem() or SpawnNPC() functions and the new objects had events that triggered upon creation. UOX3 now restores the original script context at the tail end of these functions.
Added new JS Event to allow inserting custom tooltip text for objects, which will be displayed in tooltips right after the object name. Any text returned from the event will be displayed, and the text can make use of the same HTML tags as gumps to make changes to color, font, etc.
onTooltip( myObj ) // Triggers for objects right before the object's tooltip properties are sent to client
Updated 'tweak and 'set commands to refresh item being modified if movable state of item changes, so the change is reflected in nearby clients
Fixed an issue with NPC vendors and items bought from players not being properly removed from the vendor's "bought container" when players buy them again
Ported Item Identification skill from code to JS (js/skill/itemid.js) and removed hard-coded version
Implemented magic item generator in JS (js/item/magic_item.js). When this script is attached to an NPC, it has a chance to generate magic weapons, armors, wands/staffs and rings as loot on the NPC's corpse when slain. The chance of getting quality magical items increases with the fame level of the NPC in question. The types of magical items generated follows the pattern of such items as implemented in UO prior to the AoS expansion.
Examples:
exceedingly accurate war hammer of vanquishing
substantial, accurate axe of power and Daemon's Breath
silver long sword
massive platemail arms of Protection
metal shield of defense
durable ringmail tunic of guarding
All magic items have a chance to have spell effects attached (with rings/wands being guaranteed to have these), with a limited amount of charges available. For weapons, these effects activate on successful hits in combat, while for armors they activate on equip, and then periodically as long as the item is worn. Rings and wands/staffs have to be manually activated and targeted - with the exception of rings of invisibility, which activate the moment you equip them!
Related scripts:
js/item/magic_armor_equipeffects.js
js/item/magic_weapon_accbonus.js
js/item/magic_weapon_equip.js
js/item/magic_weapon_spell_attack.js
The magic item loot generation script has been attached to a number of different NPCs, all of which now have a chance to drop magic items as loot when defeated.
A bonus magical item - the glacial staff - has also been implemented (js/item/magic_glacial_staff.js), and has a chance to drop as loot from Giant Ice Serpents!
Fixed an issue with CustomTarget where the target message would not be displayed if the cursorType parameter was provided
Fixed bug with 'rename command, which referenced a non-existing variable that caused a script crash
Added additional object properties to 'get and 'set commands:
.shouldSave // Determines if an item should be saved in worldfiles or not
.baseRange // Determines the base range of a ranged weapon, less than which it becomes less effective
.maxRange // Determines the max range of a ranged weapon, beyond which it cannot reach its target
The feature that allows stats like Strength, Dexterity and Intelligence to provide bonuses to skill checks has been turned into a UOX.INI setting, which is disabled by default. The bonuses have also been nerfed; they will no longer contribute more to the success of a skill check than the actual skill being checked!
STATSAFFECTSKILLCHECKS=0/1 // If enabled, stats can provide bonuses to skill checks based on the weighting for those stats as setup in dfndata/skills/skills.dfn
Updated damage tracking code to include the type of damage that was dealt (PHYSICAl vs HEAT vs COLD, etc)
Updated Character JS Method Damage() to include a new parameter that can specify the type of damage that was dealt to the character. The new parameter must always be included if other optional parameters are used. Note that updates might be required for scripts making use of this method.Updated syntax:
.Damage( amount )
.Damage( amount, damageType )
.Damage( amount, damageType, attacker )
.Damage( amount, damageType, attacker, doRepsys )
Supported damageTypes:
PHYSICAL = 1
LIGHT = 2
RAIN = 3
COLD = 4
HEAT = 5
LIGHTNING = 6 // magic damage
POISON = 7
SNOW = 8
Updated JS Event OnDamage to include an additional parameter that describes the type of damage that was dealt. New syntax:
onDamage( damaged, attacker, damageValue, damageType )
Updated JS Event OnSpellTarget to allow rejecting a spell being cast on a target by returning a value of 2 from the script
Split the character priv flag for magic reflection into a temporary one (one-time magic reflection spell) and a permanent one (innate permanent reflection ability). The temporary effect is put in place by Magic Reflection spell, and is removed after a successful spell reflect. The permanent one is an innate ability of a character and is not removed even after a spell is reflected.
Added new Character JS property to get/set state of a character's permanent magic reflect ability:
.permanentMagicReflect // 0 = disable, 1 = enable
Added special abilities/effects for the following NPCs:
Acid Elementals now have a chance to damage the melee weapons of their attackers
Dull Copper Elementals now explode on death
Shadow Iron Elemental is immune to targeted spell damage
Copper Elementals have permanent magic reflect, and reflect some physical damage back at their attacker
Bronze Elementals deal passive area damage to nearby players every 5 to 10 seconds
Valorite Elementals have permanent magic reflect, reflect some physical damage back at their attacker
Snow/Ice Elementals deal passive area damage to nearby players every 5 to 10 seconds
Lava Serpents deal passive area damage to nearby players every 5 to 10 seconds
Phoenixes deal passive area damage to nearby players every 5 to 10 seconds
Pixies have a chance to cast a random spell upon receiving a death blow:
Bless (target)
Curse (target)
Explosion (target)
Greater Poison (target)
Greater Heal (self, prevents death)
Ethereal Warriors will now resurrect dead players with positive karma
Ethereal Warriors now have a chance to drain target's health, stamina or mana on hit
Fire Breath special ability added to the following NPCs, with the random ability damage scaling with the NPCs current health:
Hell Cat, 5 to 8 dmg at max health
Fire Steed, 6 to 9 dmg at max health
Hell Hounds, 8 to 11 dmg at max health
Lava Lizard, 8 to 11 dmg at max health
Predator Hell Cat, 9 to 14 dmg at max health
Sea Serpent, 11 to 17 dmg at max health
Swamp Dragon, 15 to 22 dmg at max health
Armored Swamp Dragon, 15 to 22 dmg at max health
Fire Gargoyle, 20 to 30 dmg at max health
Deep Sea Serpent, 21 to 32 dmg at max health
Serpentine Dragon, 22 to 32 dmg at max health
Drake (Gray), 22 to 32 dmg at max health
Drake (Red), 22 to 32 dmg at max health
Nightmare, 26 to 39 dmg at max health
Dark Steed, 26 to 39 dmg at max health
Silver Steed, 26 to 39 dmg at max health
Kraken, 39 to 59 dmg at max health
Dragon (Red), 41 to 62 dmg at max health
Dragon (Gray), 41 to 62 dmg at max health
Shadow Wyrm, 50 to 75 dmg at max health
Reptalon, 51 to 77 dmg at max health
Skeletal Dragon, 52 to 77 dmg at max health
Ancient Wyrm, 60 to 90 dmg at max health
Update stats, skills and loot for all currently implemented NPCs
Removed an ancient piece of code that prevented corpses from being generated for various elementals and blade spirits on death. This was originally put in place because these creatures had no corpses, and would replace it with a backpack instead, but these creatures now all have corpses in all client versions supported by UOX3
Updated potions script (js/item/potion.js) with updated formula for amount of hitpoints healed by healing potions, and added restrictions for using them when at full health and/or if poisoned (Dragon Slayer)
Fixed a bug where creatures (and humans, if FORCENEWANIMATIONPACKET was disabled in uox.ini) would play animations with wrong frame count, causing the animations to either freeze for a few frames at the end, or get cut off a couple of frames early
Implemented bonus hit chance for Archery skill, based on mention of such a bonus in Publish 5 patch notes and related UO House of Commons chat. This has been exposed as a UOX.INI setting where this bonus can be tweaked:
ARCHERYHITBONUS=10 // Bonus hit chance for Archery skill added to regular hit chance in combat. Defaults to 10%
Implemented optional extra delay between moving and being able to shoot with ranged weapons in combat (in addition to whatever delay is there due to speed of the ranged weapon). This is exposed as a UOX.INI setting:
ARCHERYSHOOTDELAY=0.5 // Minimum delay in seconds from a player stops moving until they can start to fire their ranged weapon. Defaults to 0.5s
Fixed a bug where players who never entered combat mode could fire ranged weapons while moving
Updated Add-menu with some improvements for usability:
Menu now directly on the Objects (previously "Shard") tab for quicker access, with a small welcome text and quick-link button for UOX3 docs
Settings tab contains some (persistent, will be saved with character) options for how the Add-menu behaves, along with a few quick-access buttons to some useful commands. Available options:
Option to add chosen item at specific location instead of in GM's backpack
Option to add chosen item repeatedly until cancelled
Option to automatically reopen Add-menu on last menu that was open when a selection is made
Option to force decayable state of all added items to either off (doesn't decay), on (decays) or nothing (use item default)
Option to force movable state of all added items to either off (not movable), on (movable) or nothing (use item default)
Added a Home button at the bottom of the menu, that takes the user back to the front page of the Add-menu regardless of which menu page they're on
Updated Character/Socket JS Method SysMessage() with an optional parameter to specify the color used to display the system message. Updated syntax:
.SysMessage( "Text" ) // Display "Text" to user as a system message with default system message color from ini
.SysMessage( "Text %s %s", txtArg1, txtArg2 ) // Display "Text" to player with string arguments injected into text
.SysMessage( txtColor, "Text" ) // Display "Text" to user with a specified color
.SysMessage( txtColor, "Text %s %s", txtArg1, txtArg2 ) // Combination of text color, text and string arguments
Fixed a bug where hair/beard items could show up inside corpses
Fixed a bug where items could sometimes vanish (visually) from containers when bouncing back because player was not able to pick them up
Fixed a bug where players would be unable to pick up a freely movable item from a locked down container
Updated handling of item bouncing on pickup to use UOX3 dictionary messages instead of hard-coded client messages
Added support for new Dictionary language:
dictionary.POL - Polish (SERVERLANGUAGE=8 in uox.ini, or client language 83 if SERVERLANGUAGE is set to 0)
Added taming restrictions for Unicorn, Ki-Rin and Cu Sidhe (js/skill/taming.js)
Added modification of some creatures stats after they've been tamed (js/skill/taming.js)
Added restrictions for who can ride certain creatures (Unicorn, Ki-Rin, Cu Sidhe)
Updated words of power for Meteor Swarm spell to follow the same logic as other spells using Kal (Summon): Kal Des Flam Ylem
Added new Item/Character JS Methods to get/set temporary custom tags which don't persist across worldsaves (or across reconnects, for players):
.GetTempTag( "tagName" )
.SetTempTag( "tagName", tagValue )
When applying HPMAX, STAMINAMAX AND MANAMAX DFN tags to new NPCs, their current HP, STAMINA and MANA properties will now be automatically updated to match
Fixed a server crash caused by empty speech messages sent from certain clients
Fixed a bug that prevented teleport locations in Felucca/Trammel from working properly
Updated calculations in code for duration and damage of existing poison strengths (1 - Lesser, 2 - Normal, 3 - Greater, 4 - Deadly) to match with ~Publish 15 (LBR/pre-AoS), and added another poison strength for monster usage (5 - Lethal)
The strength of the Poison and Poison Field spells is now based on the average of the caster's Magery and Poisoning skills, the distance from the target (Poison spell only) and the target's Resisting Spells skill. If caster is further away than 2 tiles from target, the poison strength always equals Lesser Poison, otherwise the following rules apply:
If caster's combined skill is higher than 100.0, poison strength equals Greater Poison, with 5% chance of Deadly Poison (if Poison spell) or Deadly Poison (if Poison Field spell)
If caster's combined skill is higher than 70.2, poison strength equals Greater Poison
If caster's combined skill is higher than 30.2, poison strength equals Normal Poison
If caster's combined skill is 30.2 or lower, poison strength equals Lesser Poison
If target resists spell, poison strength is reduced by 1 level, unless it's already at the lowest level
Fixed an issue that would would let players move faster than they should have been allowed to
Fixed misc issues with Party System:
Mana and Stamina should now update for Party Members when added to the party, when going in/out of range and when their stats update while in range
Players who get disconnected or relog should now find themselves back in the same party they were in previously
Added system messages to inform party members about updates to their party, and to let invited players know they've successfully joined a party (or rejoined, if relogging)
World saves now operate on the principle of only saving changes done since the last world save. Combined with the fact that NPCs in UOX3 are only active if there are players in the same/neighbouring map regions, shard owners may expect to see a decrease in world save times ranging from ~11% to ~99%, depending on how active and how spread out their player base is. If no changes have taken place since last save, saves are virtually instantaneous!
2021-09-20 21:35:17 +08:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - std::string OnTooltip( CBaseObject *myObj )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for objects which server is about to send tooltip to client for
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
std::string cScript::OnTooltip( CBaseObject *myObj )
|
|
|
|
|
{
|
|
|
|
|
if( !ValidateObject( myObj ))
|
|
|
|
|
return "";
|
|
|
|
|
if( !ExistAndVerify( seOnTooltip, "onTooltip" ) )
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
jsval rval, params[1];
|
|
|
|
|
JSObject *tooltipObj = nullptr;
|
|
|
|
|
if( myObj->CanBeObjType( OT_CHAR ))
|
|
|
|
|
tooltipObj = JSEngine->AcquireObject( IUE_CHAR, myObj, runTime );
|
|
|
|
|
else if( myObj->CanBeObjType( OT_ITEM ))
|
|
|
|
|
tooltipObj = JSEngine->AcquireObject( IUE_ITEM, myObj, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( tooltipObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onTooltip", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnTooltip, false );
|
|
|
|
|
|
|
|
|
|
JSString *str = JS_ValueToString( targContext, rval );
|
|
|
|
|
std::string returnString = JS_GetStringBytes( str );
|
|
|
|
|
|
|
|
|
|
return returnString;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnAttack( CChar *attacker, CChar *defender )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when attacking someone
|
|
|
|
|
//| Will also trigger the onDefense event for the character being attacked
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
bool cScript::OnAttack( CChar *attacker, CChar *defender )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( attacker ) || !ValidateObject( defender ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnAttack, "onAttack" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *attObj = JSEngine->AcquireObject( IUE_CHAR, attacker, runTime );
|
|
|
|
|
JSObject *defObj = JSEngine->AcquireObject( IUE_CHAR, defender, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( attObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( defObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onAttack", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnAttack, false );
|
|
|
|
|
|
|
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnDefense( CChar *attacker, CChar *defender )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when being attacked
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
bool cScript::OnDefense( CChar *attacker, CChar *defender )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( attacker ) || !ValidateObject( defender ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnDefense, "onDefense" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *attObj = JSEngine->AcquireObject( IUE_CHAR, attacker, runTime );
|
|
|
|
|
JSObject *defObj = JSEngine->AcquireObject( IUE_CHAR, defender, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( attObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( defObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onDefense", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnDefense, false );
|
|
|
|
|
|
|
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
//| Function - SI08 OnSkillGain( CChar *player, SI08 skill, UI32 skillGainAmount )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when gaining skillpoints
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
SI08 cScript::OnSkillGain( CChar *player, SI08 skill, UI32 skillGainAmount )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( player ))
|
|
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSkillGain, "onSkillGain" ) )
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
jsval params[3], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, player, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( skill );
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
params[2] = INT_TO_JSVAL( skillGainAmount );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSkillGain", 3, params, &rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
if( retVal == JS_FALSE )
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnSkillGain, false );
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnStatGained( CChar *player, UI32 stat, SI08 skill )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when gaining stats
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
bool cScript::OnStatGained( CChar *player, UI32 stat, SI08 skill )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( player ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnStatGained, "onStatGained" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, player, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( stat );
|
|
|
|
|
params[2] = INT_TO_JSVAL( skill );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onStatGained", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnStatGained, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnStatGain( CChar *player, UI32 stat, SI08 skill )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - UNUSED
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
bool cScript::OnStatGain( CChar *player, UI32 stat, SI08 skill )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( player ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnStatGain, "onStatGain" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, player, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( stat );
|
|
|
|
|
params[2] = INT_TO_JSVAL( skill );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onStatGain", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnStatGain, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnVirtueGumpPress( CChar *mChar, CChar *tChar, UI16 buttonID )
|
|
|
|
|
//| Date - 19/01/2020
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when activating Virtue Gump icon
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnVirtueGumpPress( CChar *mChar, CChar *tChar, UI16 buttonID )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( mChar ) || !ValidateObject( tChar ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnVirtueGumpPress, "onVirtueGumpPress" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, mChar, runTime );
|
|
|
|
|
JSObject *targObj = JSEngine->AcquireObject( IUE_CHAR, tChar, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( targObj );
|
|
|
|
|
params[2] = INT_TO_JSVAL( buttonID );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onVirtueGumpPress", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
SetEventExists( seOnVirtueGumpPress, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnQuestGump( CChar *mChar )
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character who activate Quest button in paperdoll
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Return true to prevent additional onQuestGump events from triggering
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnQuestGump( CChar *mChar )
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
if( !ValidateObject( mChar ))
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
if( !ExistAndVerify( seOnQuestGump, "onQuestGump" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
|
|
|
|
|
jsval rval, params[1];
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, mChar, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onQuestGump", 1, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
SetEventExists( seOnQuestGump, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - bool SI08( CChar *mChar, UI08 abilityID )
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character who activate special abilities in combat books etc
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnSpecialMove( CChar *mChar, UI08 abilityID )
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
if( !ValidateObject( mChar ))
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
if( !ExistAndVerify( seOnSpecialMove, "onSpecialMove" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, mChar, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = INT_TO_JSVAL( abilityID );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSpecialMove", 2, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
SetEventExists( seOnSpecialMove, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
0.99.4h
Exposed a (read-only) JS property for characters to fetch their hunger rate. Uses race's hunger rate if defined, otherwise uses HUNGERRATE form uox.ini:
.hungerRate // Seconds between becoming hungrier
Updated 'get command to allow retrieving a character's hungerRate property
Added some details to console during UOX3 startup about which IPs and Ports UOX3 is listening to
Added new JS event that triggers when a player clicks on the Quest button in the paperdoll. Triggers from character script if present, or global script if not:
onQuestGump( pUser )
Added new JS event that triggers when player toggles a special move from a combat book. See packet 0xBF, subCmd 0x19 in packet guides for details on the special moves, whose IDs range from 0x00 to 0x1D:
onSpecialMove( pUser, abilityID )
Fixed invalid ID for items [0x0174] and [0x0175] in dfndata/items/building/walls/stone_walls.dfn
Updated FileSize() function in regions.cpp to fetch file size using std::filesystem::file_size() instead of creating an input stream, opening a file and then trying to seek the last position in the file
Added findNearbyObjects() function to findfuncs.cpp, to find all objects (characters and items) of CBaseObject class near a specified location
Improved performance when initializing multis on startup; now checks for items near multis, instead of checking for multis near every single item!
Improved performance when loading items and characters from worldfiles during startup; around 33% faster for release builds, around ~50% faster when running in debug mode through visual studio (punt)
Updated createSection() in ssection.cpp to use std::string and StringUtility functions instead of UString, and added some error handling (punt)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2021-04-23 02:13:17 +08:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnDrop( CItem *item, CChar *dropper )
|
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
|
|
|
//| Date - 02/07/2004
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item with event attached when dropped by character
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnDrop( CItem *item, CChar *dropper )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( item ) || !ValidateObject( dropper ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnDrop, "onDrop" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, dropper, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, item, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( itemObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onDrop", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
0.99.4e
Added support for packet 0xE2 (New Character Animation, used to play animations in client v7.0.0.0+) via cEffects::PlayNewCharacterAnimation( CChar *mChar, UI16 actionID, UI16 subActionID, UI08 subSubActionID )
Added support for new animation packet in JS Character method DoAction() using a second parameter that specifies animation variation, which if present forces server to send new animation packet instead of old. This means the 'action/npcaction commands can now be used to play animations on gargoyles/humans in client v7.0.0.0+ using the following syntax: 'action [action subAction]
Created new enums for character actions and sub-actions, and updated code to refer to these instead of using "magic" numbers
Added new options in UOX.INI under [settings] section:
FORCENEWANIMATIONPACKET=0/1 // If enabled (default), forces the use of the new animation packet for playing various character animations for both NPCs in general and for player characters connected with client v7.0.0.0+
Updated various actions performed by players and NPCs to use new animation packet (combat, spellcasting, mining) if connected with client v7.0.0.0+ and ini setting to force new animation packet is enabled
Added basic support for gargoyle flying ability. Can now use flying ability itself to enter/exit flying state, and the state change will also get sent to nearby players. Flying players are treated the same way as mounted players; polymorph spells will auto-dismounts mounted/flying player, same rules for stealth applies to flying as riding, etc.
Exposed Character property to JS engine:
.isFlying // returns true if character is flying
Moved Orc and Ratman races from RACE 1 and 2 to RACE 22 and 23 in dfndata/race/races.dfn to make room for two new player races, that are applied to new player characters during character creation:
[RACE 1] - Elf
[RACE 2] - Gargoyle
Updated orcs and ratmen in dfndata/npc/humanoids.dfn with race IDs 22 and 23 respectively
Added items in dfndata/items/skills/tools/cooking.dfn to item menu under Skills > Tools > Cooking
Fixed an issue where moving items around within a container at max item capacity was not allowed
The GM command 'set can now modify a character's current mana using 'set mana #
Added JS command to get specific object property values (using same property names as 'set command):
'get [objectProperty]
Exposed Item/Character properties to JS:
.oldX // Previous X coordinate for object
.oldY // Previous Y coordinate for object
.oldZ // Previous Z coordinate for object
Exposed Character properties to JS:
.mana // Character's current amount of mana
Updated version of Winsock requested by UOX3 from 2.0 to 2.2
Exposed timer for updating NPC flags to [timers] section of UOX.INI:
NPCFLAGUPDATETIMER=5 // Interval in seconds between each time NPC flags are updated. Default adjusted down from 30 to 5 seconds
Fixed an issue where UOX3 was trying to output some debug/warning messages to console using the wrong console method
Made some small tweaks to NPC pathfinding to make NPCs more likely to pick a new target location when their old one is blocked
Added HP DFN tag to guard NPCs to prevent them from spawning with half health
Removed -lstdc++fs from Makefile and replaced with special instructions for users of gcc below v9.x
Fixed a buffer overrun issue with tiledata item names
Eliminated a bunch of compilation warnings in VS2017
Updated JS Method CreateDFNItem to allow creating items without referencing a socket/character. Syntax:
var myItem = CreateDFNItem( null, null, itemSectionID, amount, "ITEM", false, worldNumber, instanceID );
Added functional chessboard that operates on standard chess rules. Pieces cannot be removed from the board, snap to the chessboard grid when dropped, are subject to movement restrictions per chesspiece, will capture opponent pieces if landing on their square. Board can be reset by dragging king-piece off to the side of the board (js/item/gameboards.js and js/item/chesspiece.js)
Added functional checkerboard, with pieces that cannot be removed, can only move in diagonals, can jump across opponent pieces to capture them. Board can be reset by ??? (js/item/gameboards.js and js/item/checkerpiece.js)
Using the 'go command without any additional parameters will now open the GM travel menu (js/commands/go.js)
2021-04-08 18:54:15 +08:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnDrop, false );
|
|
|
|
|
return RV_NOFUNC;
|
0.99.4e
Added support for packet 0xE2 (New Character Animation, used to play animations in client v7.0.0.0+) via cEffects::PlayNewCharacterAnimation( CChar *mChar, UI16 actionID, UI16 subActionID, UI08 subSubActionID )
Added support for new animation packet in JS Character method DoAction() using a second parameter that specifies animation variation, which if present forces server to send new animation packet instead of old. This means the 'action/npcaction commands can now be used to play animations on gargoyles/humans in client v7.0.0.0+ using the following syntax: 'action [action subAction]
Created new enums for character actions and sub-actions, and updated code to refer to these instead of using "magic" numbers
Added new options in UOX.INI under [settings] section:
FORCENEWANIMATIONPACKET=0/1 // If enabled (default), forces the use of the new animation packet for playing various character animations for both NPCs in general and for player characters connected with client v7.0.0.0+
Updated various actions performed by players and NPCs to use new animation packet (combat, spellcasting, mining) if connected with client v7.0.0.0+ and ini setting to force new animation packet is enabled
Added basic support for gargoyle flying ability. Can now use flying ability itself to enter/exit flying state, and the state change will also get sent to nearby players. Flying players are treated the same way as mounted players; polymorph spells will auto-dismounts mounted/flying player, same rules for stealth applies to flying as riding, etc.
Exposed Character property to JS engine:
.isFlying // returns true if character is flying
Moved Orc and Ratman races from RACE 1 and 2 to RACE 22 and 23 in dfndata/race/races.dfn to make room for two new player races, that are applied to new player characters during character creation:
[RACE 1] - Elf
[RACE 2] - Gargoyle
Updated orcs and ratmen in dfndata/npc/humanoids.dfn with race IDs 22 and 23 respectively
Added items in dfndata/items/skills/tools/cooking.dfn to item menu under Skills > Tools > Cooking
Fixed an issue where moving items around within a container at max item capacity was not allowed
The GM command 'set can now modify a character's current mana using 'set mana #
Added JS command to get specific object property values (using same property names as 'set command):
'get [objectProperty]
Exposed Item/Character properties to JS:
.oldX // Previous X coordinate for object
.oldY // Previous Y coordinate for object
.oldZ // Previous Z coordinate for object
Exposed Character properties to JS:
.mana // Character's current amount of mana
Updated version of Winsock requested by UOX3 from 2.0 to 2.2
Exposed timer for updating NPC flags to [timers] section of UOX.INI:
NPCFLAGUPDATETIMER=5 // Interval in seconds between each time NPC flags are updated. Default adjusted down from 30 to 5 seconds
Fixed an issue where UOX3 was trying to output some debug/warning messages to console using the wrong console method
Made some small tweaks to NPC pathfinding to make NPCs more likely to pick a new target location when their old one is blocked
Added HP DFN tag to guard NPCs to prevent them from spawning with half health
Removed -lstdc++fs from Makefile and replaced with special instructions for users of gcc below v9.x
Fixed a buffer overrun issue with tiledata item names
Eliminated a bunch of compilation warnings in VS2017
Updated JS Method CreateDFNItem to allow creating items without referencing a socket/character. Syntax:
var myItem = CreateDFNItem( null, null, itemSectionID, amount, "ITEM", false, worldNumber, instanceID );
Added functional chessboard that operates on standard chess rules. Pieces cannot be removed from the board, snap to the chessboard grid when dropped, are subject to movement restrictions per chesspiece, will capture opponent pieces if landing on their square. Board can be reset by dragging king-piece off to the side of the board (js/item/gameboards.js and js/item/chesspiece.js)
Added functional checkerboard, with pieces that cannot be removed, can only move in diagonals, can jump across opponent pieces to capture them. Board can be reset by ??? (js/item/gameboards.js and js/item/checkerpiece.js)
Using the 'go command without any additional parameters will now open the GM travel menu (js/commands/go.js)
2021-04-08 18:54:15 +08:00
|
|
|
}
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnDropItemOnItem( CItem *item, CChar *dropper, CItem *dest )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item with event attached when dropping it on another item, or when
|
|
|
|
|
//| another item is dropped on said item
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnDropItemOnItem( CItem *item, CChar *dropper, CItem *dest )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( item ) || !ValidateObject( dropper ) || !ValidateObject( dest ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnDropItemOnItem, "onDropItemOnItem" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, dropper, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, item, runTime );
|
|
|
|
|
JSObject *destObj = JSEngine->AcquireObject( IUE_ITEM, dest, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( itemObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( destObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onDropItemOnItem", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnDropItemOnItem, false );
|
|
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnPickup( CItem *item, CChar *pickerUpper )
|
|
|
|
|
//| Date - 25/01/2007
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item with event attached when picked up by character
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Changes - 16/07/2008
|
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
|
|
|
//| Adjustments made to fix event, which didn't trigger
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnPickup( CItem *item, CChar *pickerUpper )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( item ) || !ValidateObject( pickerUpper ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnPickup, "onPickup" ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, pickerUpper, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, item, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( itemObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onPickup", 2, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnPickup, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnSwing( CItem *swinging, CChar *swinger, CChar *swingTarg )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item event is attached to when swung in combat
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnSwing( CItem *swinging, CChar *swinger, CChar *swingTarg )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( swinging ) || !ValidateObject( swinger ) || !ValidateObject( swingTarg ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSwing, "onSwing" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, swinging, runTime );
|
|
|
|
|
JSObject *attObj = JSEngine->AcquireObject( IUE_CHAR, swinger, runTime );
|
|
|
|
|
JSObject *defObj = JSEngine->AcquireObject( IUE_CHAR, swingTarg, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( itemObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( attObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( defObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSwing", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnSwing, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnDecay( CItem *decaying )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item event is attached to when about to decay
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnDecay( CItem *decaying )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( decaying ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnDecay, "onDecay" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[1], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_ITEM, decaying, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onDecay", 1, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
2021-04-19 01:11:25 +08:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnDecay, false );
|
|
|
|
|
return RV_NOFUNC;
|
2021-04-19 01:11:25 +08:00
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnLeaving( CMultiObj *left, CBaseObject *leaving )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when leaving a multi
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnLeaving( CMultiObj *left, CBaseObject *leaving )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( left ) || !ValidateObject( leaving ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnLeaving, "onLeaving" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj;
|
|
|
|
|
JSObject *myItem = JSEngine->AcquireObject( IUE_ITEM, left, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
if( leaving->GetObjType() == OT_CHAR )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, leaving, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[2] = INT_TO_JSVAL( 0 );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, leaving, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[2] = INT_TO_JSVAL( 1 );
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( myItem );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( myObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onLeaving", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnLeaving, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnEquipAttempt( CChar *equipper, CItem *equipping )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item with event attached when character tries to equip it
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
SI08 cScript::OnEquipAttempt( CChar *equipper, CItem *equipping )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( equipper ) || !ValidateObject( equipping ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
|
|
|
|
|
if( !ExistAndVerify( seOnEquipAttempt, "onEquipAttempt" ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, equipper, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, equipping, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( itemObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onEquipAttempt", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnEquipAttempt, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnEquip( CChar *equipper, CItem *equipping )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item with event attached when equipped by a character
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnEquip( CChar *equipper, CItem *equipping )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( equipper ) || !ValidateObject( equipping ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnEquip, "onEquip" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, equipper, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, equipping, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( itemObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onEquip", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnEquip, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnUnequipAttempt( CChar *equipper, CItem *equipping )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item with event attached when unequipped by a character
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnUnequipAttempt( CChar *equipper, CItem *equipping )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( equipper ) || !ValidateObject( equipping ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnUnequipAttempt, "onUnequipAttempt" ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, equipper, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, equipping, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( itemObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onUnequipAttempt", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnUnequipAttempt, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnUnequip( CChar *equipper, CItem *equipping )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item with event attached when unequipped by a character
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
SI08 cScript::OnUnequip( CChar *equipper, CItem *equipping )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( equipper ) || !ValidateObject( equipping ) )
|
|
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnUnequip, "onUnequip" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, equipper, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, equipping, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( itemObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onUnequip", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnUnequip, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnUseChecked( CChar *user, CItem *iUsing )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers (after hardcoded checks) for item with event attached, when used
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Notes - The function returns 3 possible values
|
|
|
|
|
//| -1 => No such function or bad call
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| 0 => Don't execute hard coded implementation
|
|
|
|
|
//| 1 => Execute hard coded implementations as well
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Changes - 31 July, 2003 15:39 ( making it version 3)
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Changed return values from bool to SI08
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| 27 October, 2007
|
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
|
|
|
//| Split onUse into onUseChecked and onUseUnChecked
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnUseChecked( CChar *user, CItem *iUsing )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( user ) || !ValidateObject( iUsing ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnUseChecked, "onUseChecked" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, user, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, iUsing, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( itemObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onUseChecked", 2, params, &rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
if( retVal == JS_FALSE )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnUseChecked, false );
|
|
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnUseUnChecked( CChar *user, CItem *iUsing )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers (before hardcoded checks) for item with event attached, when used
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//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
|
|
|
//| Notes - The function returns 3 possible values
|
|
|
|
|
//| -1 => No such function or bad call
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| 0 => Don't execute hard coded implementation
|
|
|
|
|
//| 1 => Execute hard coded implementations as well
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Changes - 31 July, 2003 15:39 ( making it version 3)
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Changed return values from bool to SI08
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| 27 October, 2007
|
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
|
|
|
//| Split onUse into onUseChecked and onUseUnChecked
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnUseUnChecked( CChar *user, CItem *iUsing )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( user ) || !ValidateObject( iUsing ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnUseUnChecked, "onUseUnChecked" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, user, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, iUsing, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( itemObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onUseUnChecked", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnUseUnChecked, false );
|
|
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnDropItemOnNpc( CChar *srcChar, CChar *dstChar, CItem *item )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item with event attached when dropped on an NPC, and for NPC with
|
|
|
|
|
//| event attached if item is dropped on it and doesn't bounce in item's script
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Changes - V2 -
|
|
|
|
|
//| Returns
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| -1 if no function exists
|
|
|
|
|
//| 0 if should bounce
|
|
|
|
|
//| 1 if should not bounce and use code
|
|
|
|
|
//| 2 if should not bounce and not use code
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnDropItemOnNpc( CChar *srcChar, CChar *dstChar, CItem *item )
|
2002-09-23 05:26:26 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( srcChar ) || !ValidateObject( dstChar ) || !ValidateObject( item ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnDropItemOnNpc, "onDropItemOnNpc" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
jsval rval, params[3];
|
2002-09-23 05:26:26 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *srcObj = JSEngine->AcquireObject( IUE_CHAR, srcChar, runTime );
|
|
|
|
|
JSObject *dstObj = JSEngine->AcquireObject( IUE_CHAR, dstChar, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, item, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( srcObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( dstObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( itemObj );
|
2002-09-23 05:26:26 +00:00
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onDropItemOnNpc", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnDropItemOnNpc, false );
|
|
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2002-09-23 05:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnEntrance( CMultiObj *left, CBaseObject *leaving )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when entering a multi
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnEntrance( CMultiObj *left, CBaseObject *leaving )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( left ) || !ValidateObject( leaving ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnEntrance, "onEntrance" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
jsval params[3], rval;
|
|
|
|
|
JSObject *myObj;
|
|
|
|
|
JSObject *myItem = JSEngine->AcquireObject( IUE_ITEM, left, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
if( leaving->GetObjType() == OT_CHAR )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, leaving, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[2] = INT_TO_JSVAL( 0 );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, leaving, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[2] = INT_TO_JSVAL( 1 );
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( myItem );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( myObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onEntrance", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnEntrance, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OutOfRange( CChar *person, CBaseObject *objVanish )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when objects go out of range
|
|
|
|
|
//| Notes - A third parameter in the event can be used to determine whether the object
|
|
|
|
|
//| going out of range is an ITEM or a CHARACTER
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OutOfRange( CChar *person, CBaseObject *objVanish )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( person ) || !ValidateObject( objVanish ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOutOfRange, "outOfRange" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj;
|
2002-04-07 20:53:41 +00:00
|
|
|
if( objVanish->GetObjType() == OT_CHAR )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, objVanish, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[2] = INT_TO_JSVAL( 0 );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, objVanish, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[2] = INT_TO_JSVAL( 1 );
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, person, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( myObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "outOfRange", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOutOfRange, false );
|
|
|
|
|
|
|
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnLogin( CSocket *sockPlayer, CChar *pPlayer )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when logging on to server
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnLogin( CSocket *sockPlayer, CChar *pPlayer )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( pPlayer ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnLogin, "onLogin" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *sockObj = JSEngine->AcquireObject( IUE_SOCK, sockPlayer, runTime );
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, pPlayer, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( sockObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onLogin", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnLogin, false );
|
|
|
|
|
|
|
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnLogout( CSocket *sockPlayer, CChar *pPlayer )
|
|
|
|
|
//| Date - 10/06/2002
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when logging out of server
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
bool cScript::OnLogout( CSocket *sockPlayer, CChar *pPlayer )
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
{
|
|
|
|
|
if( !ValidateObject( pPlayer ) )
|
|
|
|
|
return false;
|
|
|
|
|
if( !ExistAndVerify( seOnLogout, "onLogout" ) )
|
2002-10-06 17:18:21 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *sockObj = JSEngine->AcquireObject( IUE_SOCK, sockPlayer, runTime );
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, pPlayer, runTime );
|
2002-10-06 17:18:21 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( sockObj );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onLogout", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
2002-10-06 17:18:21 +00:00
|
|
|
SetEventExists( seOnLogout, false );
|
|
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
return ( retVal == JS_TRUE );
|
2002-10-06 17:18:21 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnClick( CSocket *sockPlayer, CBaseObject *objClicked )
|
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
|
|
|
//| Date - 10/06/2002
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for item with event attached when a player single-clicks on it
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnClick( CSocket *sockPlayer, CBaseObject *objClicked )
|
2002-10-06 17:18:21 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( objClicked ) )
|
2002-10-06 17:18:21 +00:00
|
|
|
return false;
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
if( !ExistAndVerify( seOnClick, "onClick" ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *sockObj = JSEngine->AcquireObject( IUE_SOCK, sockPlayer, runTime );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
JSObject *myObj;
|
|
|
|
|
if( objClicked->GetObjType() == OT_CHAR )
|
|
|
|
|
{
|
|
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, objClicked, runTime );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, objClicked, runTime );
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( sockObj );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
params[1] = OBJECT_TO_JSVAL( myObj );
|
2003-03-04 14:55:47 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onClick", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
SetEventExists( seOnClick, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-10-06 17:18:21 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnFall( CChar *pFall, SI08 fallDistance )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when fallDistance is over 20
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
bool cScript::OnFall( CChar *pFall, SI08 fallDistance )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( pFall ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnFall, "onFall" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, pFall, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( fallDistance );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onFall", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnFall, false );
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnAISliver( CChar *pSliver )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers on every AI loop for character with event attached
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnAISliver( CChar *pSliver )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( pSliver ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnAISliver, "onAISliver" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[1], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, pSliver, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onAISliver", 1, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnAISliver, false );
|
|
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnSystemSlice( void )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - UNUSED
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
bool cScript::OnSystemSlice( void )
|
|
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSystemSlice, "onSystemSlice" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval;
|
2021-06-12 07:30:23 -04:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSystemSlice", 0, nullptr, &rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnSystemSlice, false );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnLightChange( CBaseObject *tObject, UI08 lightLevel )
|
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
|
|
|
//| Date - 17/02/2006
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for object with event attached when lightlevel changes
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnLightChange( CBaseObject *tObject, UI08 lightLevel )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
if( !ValidateObject( tObject ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
if( !ExistAndVerify( seOnLightChange, "onLightChange" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
JSObject *myObj;
|
|
|
|
|
if( tObject->GetObjType() == OT_CHAR )
|
|
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, tObject, runTime );
|
|
|
|
|
else
|
|
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, tObject, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = INT_TO_JSVAL( lightLevel );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onLightChange", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
SetEventExists( seOnLightChange, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnWeatherChange( CBaseObject *tObject, WeatherType element )
|
|
|
|
|
//| Date - 17/02/2006
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for object with event attached when weather changes
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnWeatherChange( CBaseObject *tObject, WeatherType element )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
if( !ValidateObject( tObject ) )
|
|
|
|
|
return false;
|
|
|
|
|
if( !ExistAndVerify( seOnWeatherChange, "onWeatherChange" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
JSObject *myObj;
|
|
|
|
|
if( tObject->GetObjType() == OT_CHAR )
|
|
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, tObject, runTime );
|
|
|
|
|
else
|
|
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, tObject, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = INT_TO_JSVAL( element );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onWeatherChange", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnWeatherChange, false );
|
|
|
|
|
|
|
|
|
|
return ( retVal == JS_TRUE );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool cScript::OnTempChange( CBaseObject *tObject, SI08 temp )
|
|
|
|
|
//| Date - 17/02/2006
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for object with event attached when temperature changes
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnTempChange( CBaseObject *tObject, SI08 temp )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
if( !ValidateObject( tObject ) )
|
|
|
|
|
return false;
|
|
|
|
|
if( !ExistAndVerify( seOnTempChange, "onTempChange" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
JSObject *myObj;
|
|
|
|
|
if( tObject->GetObjType() == OT_CHAR )
|
|
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, tObject, runTime );
|
|
|
|
|
else
|
|
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, tObject, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = INT_TO_JSVAL( temp );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onTempChange", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnTempChange, false );
|
|
|
|
|
|
|
|
|
|
return ( retVal == JS_TRUE );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnTimer( CBaseObject *tObject, UI08 timerID )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for object with event attached, when custom timers started on said
|
|
|
|
|
//| object using StartTimer function update
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnTimer( CBaseObject *tObject, UI08 timerID )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( tObject ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnTimer, "onTimer" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj;
|
2002-04-07 20:53:41 +00:00
|
|
|
if( tObject->GetObjType() == OT_CHAR )
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, tObject, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
else
|
2012-11-03 18:11:04 +00:00
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, tObject, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( timerID );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onTimer", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnTimer, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnStatLoss( CChar *player, UI32 stat )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for characters with event attached when losing stats
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
bool cScript::OnStatLoss( CChar *player, UI32 stat )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( player ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnStatLoss, "onStatLoss" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, player, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( stat );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onStatLoss", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnStatLoss, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnStatChange( CChar *player, UI32 stat )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for characters with event attached when stats change
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
bool cScript::OnStatChange( CChar *player, UI32 stat )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( player ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnStatChange, "onStatChange" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, player, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( stat );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onStatChange", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnStatChange, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
//| Function - SI08 OnSkillLoss( CChar *player, SI08 skill, UI32 skillLossAmount )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for characters with event attached when losing skillpoints
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
SI08 cScript::OnSkillLoss( CChar *player, SI08 skill, UI32 skillLossAmount )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( player ))
|
|
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSkillLoss, "onSkillLoss" ) )
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
jsval params[3], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, player, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( skill );
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
params[2] = INT_TO_JSVAL( skillLossAmount );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSkillLoss", 3, params, &rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
if( retVal == JS_FALSE )
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnSkillLoss, false );
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
//| Function - bool OnSkillChange( CChar *player, SI08 skill, SI32 skillChangeAmount )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for characters with event attached when skillpoints change
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
bool cScript::OnSkillChange( CChar *player, SI08 skill, SI32 skillChangeAmount )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( player ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSkillChange, "onSkillChange" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
jsval params[3], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, player, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( skill );
|
Updated onSkillGain, onSkillLoss and onSkillChange JS events
Updated onSkillGain, onSkillLoss and onSkillChange JS events:
Additional parameters now supported by events - skillGainAmount and skillLossAmount
onSkillGain( player, skillID, skillGainAmount ) // skillGainAmount is always positive
onSkillLoss( player, skillID, skillLossAmount ) // skillLossAmount is always positive
onSkillChange( player, skillID, skillChangeAmount ) // skillChangeAmount can be negative or positive
The return value from onSkillGain and onSkillLoss events can now be used to control behavior:
return true - skill gain/loss is allowed, and server will go through with the skill update
return false - skill gain/loss is not allowed, and server will prevent the skill update, but will not block additional scripts with same event from running
onSkillChange will now run as long as onSkillGain or onSkillLoss events return true, and if those events are not defined
Updated JS Docs
2021-10-17 08:08:19 +08:00
|
|
|
params[2] = INT_TO_JSVAL( skillChangeAmount );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSkillChange", 3, params, &rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnSkillChange, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnDeath( CChar *pDead, CItem *iCorpse )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached after dying
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnDeath( CChar *pDead, CItem *iCorpse )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
Misc fixes and changes
Added new JS Gump Methods:
AddPicInPic( x, y, gumpID, width, height, spriteX, spriteY ) // Add sprite image in dialogs, requires client v7.0.80.0 or above
AddImageProperty( serial ) // Add properties(?) of a specific item
Fixed a server crash related to world saves, where items being cleaned up were not being removed properly from the MapRegions they were in, resulting in a crash when attempting to save non-existent items out to the worldfiles.
Fixed an issue that could cause GMs to become permanently squelched
Fixed an issue where the newStatus parameter for the onFlagChange JS event was overwritten with oldStatus, and oldStatus parameter was never set
Updated onDeath JS Event to include a second parameter - iCorpse:
onDeath( pDeath, iCorpse ) // iCorpse is a reference to the newly created corpse of pDead
Disabled detailed logging of spells loaded from spells.dfn on startup - was causing unnecessary slowdown
Removed void Wiping( CSocket *s ) from cmdtable.cpp - unused and unreferenced function without a definition
Removed handling of IT_KEY doubleclicking in code, as this is now handled in JS
Removed bool isDoorBlocked( CItem *door ) from cPlayerAction.cpp - unused and unreferenced function without a definition
Removed void CorpseTarget( CSocket *s ) from targeting.cpp - now handled in JS
Removed broken cannon loading and spelldamage code - this should be done in JS instead
Items that initiate a target cursor on use are now stored in tempObj property of player's socket, and distance to these items are checked again after player targets something
House and boat deeds must now be in the player's inventory in order to successfully place a house or boat
Fixed superfluous arugment passed to switchGobletID function in js/server/resource/pitchers.js
Removed some duplicate/unused local variables in js/commands/custom/misc-cmd.js
Removed an unused local variable in js/commands/targeting/dupe.js
Fixed an issue with setting item type through the SET command
Fixed an issue where the number of arrows or bolts in player's inventory was potentially miscalculated in js/item/archerybutte.js
Fixed issue where pickpocket-dummy item visuals potentially didn't get updated properly in js/item/pickpocketdip.js
Fixed an unreachable return statement in js/npc/ai/stablemaster.js
Fixed incorrect ID for gargish maul in js/server/data/weapontypes.js
Added some missing variable declarations in js/commands/custom/repeatingcmds.js, js/commands/delid.js, js/commands/targeting/hide.js, js/item/food.js, js/item/key.js, js/npc/ai/stablemaster.js
2020-07-06 07:55:52 +08:00
|
|
|
if( !ValidateObject( pDead ) || !ValidateObject( iCorpse ))
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnDeath, "onDeath" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Misc fixes and changes
Added new JS Gump Methods:
AddPicInPic( x, y, gumpID, width, height, spriteX, spriteY ) // Add sprite image in dialogs, requires client v7.0.80.0 or above
AddImageProperty( serial ) // Add properties(?) of a specific item
Fixed a server crash related to world saves, where items being cleaned up were not being removed properly from the MapRegions they were in, resulting in a crash when attempting to save non-existent items out to the worldfiles.
Fixed an issue that could cause GMs to become permanently squelched
Fixed an issue where the newStatus parameter for the onFlagChange JS event was overwritten with oldStatus, and oldStatus parameter was never set
Updated onDeath JS Event to include a second parameter - iCorpse:
onDeath( pDeath, iCorpse ) // iCorpse is a reference to the newly created corpse of pDead
Disabled detailed logging of spells loaded from spells.dfn on startup - was causing unnecessary slowdown
Removed void Wiping( CSocket *s ) from cmdtable.cpp - unused and unreferenced function without a definition
Removed handling of IT_KEY doubleclicking in code, as this is now handled in JS
Removed bool isDoorBlocked( CItem *door ) from cPlayerAction.cpp - unused and unreferenced function without a definition
Removed void CorpseTarget( CSocket *s ) from targeting.cpp - now handled in JS
Removed broken cannon loading and spelldamage code - this should be done in JS instead
Items that initiate a target cursor on use are now stored in tempObj property of player's socket, and distance to these items are checked again after player targets something
House and boat deeds must now be in the player's inventory in order to successfully place a house or boat
Fixed superfluous arugment passed to switchGobletID function in js/server/resource/pitchers.js
Removed some duplicate/unused local variables in js/commands/custom/misc-cmd.js
Removed an unused local variable in js/commands/targeting/dupe.js
Fixed an issue with setting item type through the SET command
Fixed an issue where the number of arrows or bolts in player's inventory was potentially miscalculated in js/item/archerybutte.js
Fixed issue where pickpocket-dummy item visuals potentially didn't get updated properly in js/item/pickpocketdip.js
Fixed an unreachable return statement in js/npc/ai/stablemaster.js
Fixed incorrect ID for gargish maul in js/server/data/weapontypes.js
Added some missing variable declarations in js/commands/custom/repeatingcmds.js, js/commands/delid.js, js/commands/targeting/hide.js, js/item/food.js, js/item/key.js, js/npc/ai/stablemaster.js
2020-07-06 07:55:52 +08:00
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, pDead, runTime );
|
Misc fixes and changes
Added new JS Gump Methods:
AddPicInPic( x, y, gumpID, width, height, spriteX, spriteY ) // Add sprite image in dialogs, requires client v7.0.80.0 or above
AddImageProperty( serial ) // Add properties(?) of a specific item
Fixed a server crash related to world saves, where items being cleaned up were not being removed properly from the MapRegions they were in, resulting in a crash when attempting to save non-existent items out to the worldfiles.
Fixed an issue that could cause GMs to become permanently squelched
Fixed an issue where the newStatus parameter for the onFlagChange JS event was overwritten with oldStatus, and oldStatus parameter was never set
Updated onDeath JS Event to include a second parameter - iCorpse:
onDeath( pDeath, iCorpse ) // iCorpse is a reference to the newly created corpse of pDead
Disabled detailed logging of spells loaded from spells.dfn on startup - was causing unnecessary slowdown
Removed void Wiping( CSocket *s ) from cmdtable.cpp - unused and unreferenced function without a definition
Removed handling of IT_KEY doubleclicking in code, as this is now handled in JS
Removed bool isDoorBlocked( CItem *door ) from cPlayerAction.cpp - unused and unreferenced function without a definition
Removed void CorpseTarget( CSocket *s ) from targeting.cpp - now handled in JS
Removed broken cannon loading and spelldamage code - this should be done in JS instead
Items that initiate a target cursor on use are now stored in tempObj property of player's socket, and distance to these items are checked again after player targets something
House and boat deeds must now be in the player's inventory in order to successfully place a house or boat
Fixed superfluous arugment passed to switchGobletID function in js/server/resource/pitchers.js
Removed some duplicate/unused local variables in js/commands/custom/misc-cmd.js
Removed an unused local variable in js/commands/targeting/dupe.js
Fixed an issue with setting item type through the SET command
Fixed an issue where the number of arrows or bolts in player's inventory was potentially miscalculated in js/item/archerybutte.js
Fixed issue where pickpocket-dummy item visuals potentially didn't get updated properly in js/item/pickpocketdip.js
Fixed an unreachable return statement in js/npc/ai/stablemaster.js
Fixed incorrect ID for gargish maul in js/server/data/weapontypes.js
Added some missing variable declarations in js/commands/custom/repeatingcmds.js, js/commands/delid.js, js/commands/targeting/hide.js, js/item/food.js, js/item/key.js, js/npc/ai/stablemaster.js
2020-07-06 07:55:52 +08:00
|
|
|
JSObject *corpseObj = JSEngine->AcquireObject( IUE_ITEM, iCorpse, runTime );
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
Misc fixes and changes
Added new JS Gump Methods:
AddPicInPic( x, y, gumpID, width, height, spriteX, spriteY ) // Add sprite image in dialogs, requires client v7.0.80.0 or above
AddImageProperty( serial ) // Add properties(?) of a specific item
Fixed a server crash related to world saves, where items being cleaned up were not being removed properly from the MapRegions they were in, resulting in a crash when attempting to save non-existent items out to the worldfiles.
Fixed an issue that could cause GMs to become permanently squelched
Fixed an issue where the newStatus parameter for the onFlagChange JS event was overwritten with oldStatus, and oldStatus parameter was never set
Updated onDeath JS Event to include a second parameter - iCorpse:
onDeath( pDeath, iCorpse ) // iCorpse is a reference to the newly created corpse of pDead
Disabled detailed logging of spells loaded from spells.dfn on startup - was causing unnecessary slowdown
Removed void Wiping( CSocket *s ) from cmdtable.cpp - unused and unreferenced function without a definition
Removed handling of IT_KEY doubleclicking in code, as this is now handled in JS
Removed bool isDoorBlocked( CItem *door ) from cPlayerAction.cpp - unused and unreferenced function without a definition
Removed void CorpseTarget( CSocket *s ) from targeting.cpp - now handled in JS
Removed broken cannon loading and spelldamage code - this should be done in JS instead
Items that initiate a target cursor on use are now stored in tempObj property of player's socket, and distance to these items are checked again after player targets something
House and boat deeds must now be in the player's inventory in order to successfully place a house or boat
Fixed superfluous arugment passed to switchGobletID function in js/server/resource/pitchers.js
Removed some duplicate/unused local variables in js/commands/custom/misc-cmd.js
Removed an unused local variable in js/commands/targeting/dupe.js
Fixed an issue with setting item type through the SET command
Fixed an issue where the number of arrows or bolts in player's inventory was potentially miscalculated in js/item/archerybutte.js
Fixed issue where pickpocket-dummy item visuals potentially didn't get updated properly in js/item/pickpocketdip.js
Fixed an unreachable return statement in js/npc/ai/stablemaster.js
Fixed incorrect ID for gargish maul in js/server/data/weapontypes.js
Added some missing variable declarations in js/commands/custom/repeatingcmds.js, js/commands/delid.js, js/commands/targeting/hide.js, js/item/food.js, js/item/key.js, js/npc/ai/stablemaster.js
2020-07-06 07:55:52 +08:00
|
|
|
params[1] = OBJECT_TO_JSVAL( corpseObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onDeath", 2, params, &rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnDeath, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnResurrect( CChar *pAlive )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when being resurrected
|
|
|
|
|
//| Notes - If script returns false when event triggers, resurrection is blocked
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnResurrect( CChar *pAlive )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( pAlive ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnResurrect, "onResurrect" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[1], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, pAlive, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onResurrect", 1, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnResurrect, false );
|
|
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnFlagChange( CChar *pChanging, UI08 newStatus, UI08 oldStatus )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when the flag status changes
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnFlagChange( CChar *pChanging, UI08 newStatus, UI08 oldStatus )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( pChanging ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnFlagChange, "onFlagChange" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, pChanging, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( newStatus );
|
Misc fixes and changes
Added new JS Gump Methods:
AddPicInPic( x, y, gumpID, width, height, spriteX, spriteY ) // Add sprite image in dialogs, requires client v7.0.80.0 or above
AddImageProperty( serial ) // Add properties(?) of a specific item
Fixed a server crash related to world saves, where items being cleaned up were not being removed properly from the MapRegions they were in, resulting in a crash when attempting to save non-existent items out to the worldfiles.
Fixed an issue that could cause GMs to become permanently squelched
Fixed an issue where the newStatus parameter for the onFlagChange JS event was overwritten with oldStatus, and oldStatus parameter was never set
Updated onDeath JS Event to include a second parameter - iCorpse:
onDeath( pDeath, iCorpse ) // iCorpse is a reference to the newly created corpse of pDead
Disabled detailed logging of spells loaded from spells.dfn on startup - was causing unnecessary slowdown
Removed void Wiping( CSocket *s ) from cmdtable.cpp - unused and unreferenced function without a definition
Removed handling of IT_KEY doubleclicking in code, as this is now handled in JS
Removed bool isDoorBlocked( CItem *door ) from cPlayerAction.cpp - unused and unreferenced function without a definition
Removed void CorpseTarget( CSocket *s ) from targeting.cpp - now handled in JS
Removed broken cannon loading and spelldamage code - this should be done in JS instead
Items that initiate a target cursor on use are now stored in tempObj property of player's socket, and distance to these items are checked again after player targets something
House and boat deeds must now be in the player's inventory in order to successfully place a house or boat
Fixed superfluous arugment passed to switchGobletID function in js/server/resource/pitchers.js
Removed some duplicate/unused local variables in js/commands/custom/misc-cmd.js
Removed an unused local variable in js/commands/targeting/dupe.js
Fixed an issue with setting item type through the SET command
Fixed an issue where the number of arrows or bolts in player's inventory was potentially miscalculated in js/item/archerybutte.js
Fixed issue where pickpocket-dummy item visuals potentially didn't get updated properly in js/item/pickpocketdip.js
Fixed an unreachable return statement in js/npc/ai/stablemaster.js
Fixed incorrect ID for gargish maul in js/server/data/weapontypes.js
Added some missing variable declarations in js/commands/custom/repeatingcmds.js, js/commands/delid.js, js/commands/targeting/hide.js, js/item/food.js, js/item/key.js, js/npc/ai/stablemaster.js
2020-07-06 07:55:52 +08:00
|
|
|
params[2] = INT_TO_JSVAL( oldStatus );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onFlagChange", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnFlagChange, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool DoCallback( CSocket *tSock, SERIAL targeted, UI08 callNum )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Handles callbacks for custom target cursors triggered from scripts
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::DoCallback( CSocket *tSock, SERIAL targeted, UI08 callNum )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2021-06-12 07:30:23 -04:00
|
|
|
if( tSock == nullptr )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
jsval params[2], rval;
|
Code cleanup
Embraced the usage of R32, R64, SI16, UI16, SI32, UI32, SI64 and UI64 typedef aliases as replacement for built-in types throughout the sourcecode:
typedef float R32;
typedef double R64;
typedef signed char SI08;
typedef unsigned char UI08;
typedef signed short int SI16;
typedef unsigned short int UI16;
typedef signed int SI32;
typedef unsigned int UI32;
typedef signed long long SI64;
typedef unsigned long long UI64;
As part of this process, UI32 was redefined from unsigned long int to unsigned int, and SI32 from signed long int to signed int to ensure the size of variables using these remain the same (32bit) across both Windows, Linux and MacOS for both 32bit and 64bit platforms
Replaced instances of toLong() with toInt(), and toULong() to toUInt()
Replaced instances of "long" and "int" with SI32 where possible
Replaced instances of "unsigned long" and "unsigned int" with UI32 where possible
Replaced instances of "float" with R32 where possible
2020-08-12 23:46:33 +08:00
|
|
|
SI32 objType = 2; // 2 == null, 1 == char, 0 == item
|
2021-06-12 07:30:23 -04:00
|
|
|
CBaseObject *mObj = nullptr;
|
|
|
|
|
JSObject *myObj2 = nullptr;
|
2012-11-03 18:11:04 +00:00
|
|
|
try
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, tSock, runTime );
|
2021-06-12 07:30:23 -04:00
|
|
|
if(myObj == nullptr)
|
2012-11-03 18:11:04 +00:00
|
|
|
return false;
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
if( targeted >= BASEITEMSERIAL )
|
|
|
|
|
{
|
|
|
|
|
mObj = calcItemObjFromSer( targeted );
|
|
|
|
|
objType = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mObj = calcCharObjFromSer( targeted );
|
|
|
|
|
objType = 1;
|
|
|
|
|
}
|
|
|
|
|
if( !ValidateObject( mObj ) )
|
|
|
|
|
{
|
|
|
|
|
objType = 2;
|
|
|
|
|
params[1] = JSVAL_NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( objType == 0 )
|
|
|
|
|
myObj2 = JSEngine->AcquireObject( IUE_ITEM, mObj, runTime );
|
|
|
|
|
else
|
|
|
|
|
myObj2 = JSEngine->AcquireObject( IUE_CHAR, mObj, runTime );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( myObj2 );
|
|
|
|
|
}
|
|
|
|
|
// ExistAndVerify() normally sets our Global Object, but not on custom named functions.
|
|
|
|
|
JS_SetGlobalObject( targContext, targObject );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
|
|
|
|
|
2021-05-27 05:42:35 +08:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, strutil::format( "onCallback%i", callNum ).c_str(), 2, params, &rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
catch( ... )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
Console.error( "Handled exception in cScript.cpp DoCallback()");
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
return false;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSObject *cScript::Object( void ) const
|
|
|
|
|
{
|
|
|
|
|
return targObject;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnLoyaltyChange( CChar *pChanging, SI08 newStatus )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for NPC character with event attached when loyalty level changes
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
SI08 cScript::OnLoyaltyChange( CChar *pChanging, SI08 newStatus )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( pChanging ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnLoyaltyChange, "onLoyaltyChange" ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, pChanging, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = INT_TO_JSVAL( newStatus );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onLoyaltyChange", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnLoyaltyChange, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnHungerChange( CChar *pChanging, SI08 newStatus )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when hunger level changes
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnHungerChange( CChar *pChanging, SI08 newStatus )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( pChanging ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnHungerChange, "onHungerChange" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, pChanging, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( newStatus );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onHungerChange", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnHungerChange, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
2021-06-07 21:05:50 -05:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnThirstChange( CChar *pChanging, SI08 newStatus )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
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
|
|
|
//| Purpose - Triggers for character with event attached when thirst level changes
|
2021-06-07 21:05:50 -05:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
bool cScript::OnThirstChange( CChar* pChanging, SI08 newStatus )
|
|
|
|
|
{
|
2021-06-11 04:03:16 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( pChanging ))
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnThirstChange, "onThirstChange") )
|
|
|
|
|
return RV_NOFUNC;
|
2021-06-07 21:05:50 -05:00
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
|
|
|
|
JSObject* charObj = JSEngine->AcquireObject( IUE_CHAR, pChanging, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = INT_TO_JSVAL( newStatus );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onThirstChange", 2, params, &rval );
|
2021-06-11 04:03:16 +08:00
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
2021-06-07 21:05:50 -05:00
|
|
|
SetEventExists( seOnThirstChange, false );
|
2021-06-11 04:03:16 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2021-06-07 21:05:50 -05:00
|
|
|
|
2021-06-11 04:03:16 +08:00
|
|
|
return TryParseJSVal( rval );
|
2021-06-07 21:05:50 -05:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnStolenFrom( CChar *stealing, CChar *stolenFrom, CItem *stolen )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when being stolen from
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnStolenFrom( CChar *stealing, CChar *stolenFrom, CItem *stolen )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( stealing ) || !ValidateObject( stolenFrom ) || !ValidateObject( stolen ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnStolenFrom, "onStolenFrom" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *thiefObj = JSEngine->AcquireObject( IUE_CHAR, stealing, runTime );
|
|
|
|
|
JSObject *victimObj = JSEngine->AcquireObject( IUE_CHAR, stolenFrom, runTime );
|
|
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, stolen, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( thiefObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( victimObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( itemObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onStolenFrom", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnStolenFrom, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnSnooped( CChar *snooped, CChar *snooper, bool success )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when someone snoops their backpack
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnSnooped( CChar *snooped, CChar *snooper, bool success )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( snooped ) || !ValidateObject( snooper ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSnooped, "onSnooped" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *thiefObj = JSEngine->AcquireObject( IUE_CHAR, snooped, runTime );
|
|
|
|
|
JSObject *victimObj = JSEngine->AcquireObject( IUE_CHAR, snooper, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( thiefObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( victimObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[2] = BOOLEAN_TO_JSVAL( success );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSnooped", 3, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnSnooped, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2002-04-07 20:53:41 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnSnoopAttempt( CChar *snooped, CChar *snooper )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached if they attempt to snoop someone's backpack
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
SI08 cScript::OnSnoopAttempt( CChar *snooped, CChar *snooper )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( snooped ) || !ValidateObject( snooper ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnSnoopAttempt, "onSnoopAttempt" ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
|
|
|
|
|
|
|
|
|
JSObject *thiefObj = JSEngine->AcquireObject( IUE_CHAR, snooped, runTime );
|
|
|
|
|
JSObject *victimObj = JSEngine->AcquireObject( IUE_CHAR, snooper, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( thiefObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( victimObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSnoopAttempt", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnSnoopAttempt, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - size_t NewGumpList( void )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - UNUSED
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
size_t cScript::NewGumpList( void )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
size_t retVal = gumpDisplays.size();
|
|
|
|
|
SEGump *toAdd = new SEGump;
|
|
|
|
|
toAdd->one = new STRINGLIST;
|
|
|
|
|
toAdd->two = new STRINGLIST;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
gumpDisplays.push_back( toAdd );
|
|
|
|
|
return retVal;
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SEGump * GetGumpList( SI32 index )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - UNUSED
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
SEGump * cScript::GetGumpList( SI32 index )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( index < 0 || (size_t)index >= gumpDisplays.size() )
|
2021-06-12 07:30:23 -04:00
|
|
|
return nullptr;
|
2002-04-07 20:53:41 +00:00
|
|
|
return gumpDisplays[index];
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - void RemoveGumpList( SI32 index )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - UNUSED
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
void cScript::RemoveGumpList( SI32 index )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( index < 0 || (size_t)index >= gumpDisplays.size() )
|
2002-04-07 20:53:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
delete gumpDisplays[index]->one;
|
|
|
|
|
delete gumpDisplays[index]->two;
|
|
|
|
|
delete gumpDisplays[index];
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
gumpDisplays.erase( gumpDisplays.begin() + index );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - void SendGumpList( SI32 index, CSocket *toSendTo )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - UNUSED
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
void cScript::SendGumpList( SI32 index, CSocket *toSendTo )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( index < 0 || (size_t)index >= gumpDisplays.size() )
|
2002-04-07 20:53:41 +00:00
|
|
|
return;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
UI32 gumpID = (0xFFFF + JSMapping->GetScriptID( targObject ));
|
|
|
|
|
SendVecsAsGump( toSendTo, *(gumpDisplays[index]->one), *(gumpDisplays[index]->two), gumpID, INVALIDSERIAL );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - void HandleGumpPress( CPIGumpMenuSelect *packet )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Process a gump button press
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Changes - 1/21/2003 - Implemented the code needed to support enhanced
|
2003-01-21 15:59:30 +00:00
|
|
|
//| gump response processing
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2003-03-04 14:55:47 +00:00
|
|
|
void cScript::HandleGumpPress( CPIGumpMenuSelect *packet )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnGumpPress, "onGumpPress" ) )
|
|
|
|
|
return;
|
|
|
|
|
|
2021-06-12 07:30:23 -04:00
|
|
|
if( packet == nullptr )
|
2003-03-04 14:55:47 +00:00
|
|
|
return;
|
2012-11-03 18:11:04 +00:00
|
|
|
CSocket *pressing = packet->GetSocket();
|
2021-06-12 07:30:23 -04:00
|
|
|
if( pressing == nullptr )
|
2002-04-07 20:53:41 +00:00
|
|
|
return;
|
2003-01-21 15:59:30 +00:00
|
|
|
|
2003-03-04 14:55:47 +00:00
|
|
|
UI32 button = packet->ButtonID();
|
|
|
|
|
UI16 nButtons = static_cast<UI16>(packet->SwitchCount());
|
|
|
|
|
UI16 nText = static_cast<UI16>(packet->TextCount());
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
SEGumpData *segdGumpData = new SEGumpData;
|
2021-06-12 07:30:23 -04:00
|
|
|
JSObject *jsoObject = JS_NewObject( targContext, &UOXGumpData_class, nullptr, nullptr );
|
2003-01-21 15:59:30 +00:00
|
|
|
JS_DefineFunctions( targContext, jsoObject, CGumpData_Methods );
|
2003-03-04 14:55:47 +00:00
|
|
|
JS_DefineProperties( targContext, jsoObject, CGumpDataProperties );
|
|
|
|
|
JS_SetPrivate( targContext, jsoObject, segdGumpData );
|
2012-11-03 18:11:04 +00:00
|
|
|
JS_LockGCThing( targContext, jsoObject );
|
|
|
|
|
//JS_AddRoot( targContext, &jsoObject );
|
2003-03-04 14:55:47 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
UI16 i;
|
2003-01-21 15:59:30 +00:00
|
|
|
// Loop through Buttons
|
2012-11-03 18:11:04 +00:00
|
|
|
for( i = 0; i < nButtons; ++i )
|
2003-03-04 14:55:47 +00:00
|
|
|
segdGumpData->nButtons.push_back( packet->SwitchValue( i ) );
|
2003-01-21 15:59:30 +00:00
|
|
|
// Process text for the buttons?
|
|
|
|
|
// Loop grabbing text
|
2012-11-03 18:11:04 +00:00
|
|
|
for( i = 0; i < nText; ++i )
|
2003-01-21 15:59:30 +00:00
|
|
|
{
|
2003-03-04 14:55:47 +00:00
|
|
|
segdGumpData->nIDs.push_back( packet->GetTextID( i ) );
|
2021-04-28 19:19:05 +08:00
|
|
|
segdGumpData->sEdits.push_back( packet->GetTextString( i ) );
|
2003-01-21 15:59:30 +00:00
|
|
|
}
|
|
|
|
|
jsval jsvParams[3], jsvRVal;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, pressing, runTime );
|
|
|
|
|
jsvParams[0] = OBJECT_TO_JSVAL( myObj );
|
2003-03-04 14:55:47 +00:00
|
|
|
jsvParams[1] = INT_TO_JSVAL( button );
|
|
|
|
|
jsvParams[2] = OBJECT_TO_JSVAL( jsoObject );
|
2021-07-04 02:26:43 +08:00
|
|
|
[[maybe_unused]] JSBool retVal = JS_CallFunctionName( targContext, targObject, "onGumpPress", 3, jsvParams, &jsvRVal );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2003-01-21 15:59:30 +00:00
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - void HandleGumpInput( CPIGumpInput *pressing )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Handle gump inputs?
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
void cScript::HandleGumpInput( CPIGumpInput *pressing )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2021-06-12 07:30:23 -04:00
|
|
|
if( pressing == nullptr )
|
2002-04-07 20:53:41 +00:00
|
|
|
return;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnGumpInput, "onGumpInput" ) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, pressing->GetSocket(), runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = INT_TO_JSVAL( pressing->Index() );
|
2021-07-04 02:26:43 +08:00
|
|
|
[[maybe_unused]] JSBool retVal = JS_CallFunctionName( targContext, targObject, "onGumpInput", 2, params, &rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnEnterRegion( CChar *entering, UI16 region )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when entering a region
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnEnterRegion( CChar *entering, UI16 region )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( entering ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnEnterRegion, "onEnterRegion" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, entering, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( region );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onEnterRegion", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnEnterRegion, false );
|
|
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnLeaveRegion( CChar *leaving, UI16 region )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when leaving a region
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnLeaveRegion( CChar *leaving, UI16 region )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( leaving ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnLeaveRegion, "onLeaveRegion" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, leaving, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( region );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onLeaveRegion", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnLeaveRegion, false );
|
|
|
|
|
|
|
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnSpellTarget( CBaseObject *target, CChar *caster, UI08 spellNum )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when targeting something with a spell
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnSpellTarget( CBaseObject *target, CChar *caster, UI08 spellNum )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( target ) || !ValidateObject( caster ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSpellTarget, "onSpellTarget" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[4], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *castObj = JSEngine->AcquireObject( IUE_CHAR, caster, runTime );
|
|
|
|
|
JSObject *targObj;
|
|
|
|
|
if( target->CanBeObjType( OT_CHAR ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
targObj = JSEngine->AcquireObject( IUE_CHAR, target, runTime );
|
|
|
|
|
params[1] = INT_TO_JSVAL( 0 );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
targObj = JSEngine->AcquireObject( IUE_ITEM, target, runTime );
|
|
|
|
|
params[1] = INT_TO_JSVAL( 1 );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( targObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( castObj );
|
|
|
|
|
params[3] = INT_TO_JSVAL( spellNum );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSpellTarget", 4, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
SetEventExists( seOnSpellTarget, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Function - bool CallParticularEvent( const char *eventToCall, jsval *params, SI32 numParams )
|
2002-04-07 20:53:41 +00:00
|
|
|
//| Date - 20th December, 2001
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
//| Purpose - Calls a particular script event, passing parameters
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
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
|
|
|
bool cScript::CallParticularEvent( const char *eventToCall, jsval *params, SI32 numParams, jsval *eventRetVal )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
2021-06-12 07:30:23 -04:00
|
|
|
if( eventToCall == nullptr )
|
2002-04-07 20:53:41 +00:00
|
|
|
return false;
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
// ExistAndVerify() normally sets our Global Object, but not on custom named functions.
|
|
|
|
|
JS_SetGlobalObject( targContext, targObject );
|
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
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, eventToCall, numParams, params, eventRetVal );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnSpellSuccess, false );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI16 OnSpellCast( CChar *tChar, UI08 SpellID )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers when character with event attached casts a spell
|
|
|
|
|
//| Notes - Return value table
|
|
|
|
|
//| -2: use NORMAL non-JS casting
|
|
|
|
|
//| -1: CANCEL spellcasting
|
|
|
|
|
//| 0->inf: Spell delay in ms
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
SI16 cScript::OnSpellCast( CChar *tChar, UI08 SpellID )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( tChar ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return -2;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSpellCast, "onSpellCast" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return -2;
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, tChar, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( SpellID );
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSpellCast", 2, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnSpellCast, false );
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return (SI16)JSVAL_TO_INT( rval );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI16 OnScrollCast( CChar *tChar, UI08 SpellID )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers when character with event attached casts a spell through a scroll
|
|
|
|
|
//| Notes - Return value table
|
|
|
|
|
//| -2: use NORMAL non-JS casting
|
|
|
|
|
//| -1: CANCEL spellcasting
|
|
|
|
|
//| 0->inf: Spell delay in ms
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
SI16 cScript::OnScrollCast( CChar *tChar, UI08 SpellID )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( tChar ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return -2;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnScrollCast, "onScrollCast" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return -2;
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, tChar, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( SpellID );
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onScrollCast", 2, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnScrollCast, false );
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
return (SI16)JSVAL_TO_INT( rval );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnSpellSuccess( CChar *tChar, UI08 SpellID )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers after character with event attached successfully casts a spell
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnSpellSuccess( CChar *tChar, UI08 SpellID )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( tChar ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSpellSuccess, "onSpellSuccess" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, tChar, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( SpellID );
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSpellSuccess", 2, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnSpellSuccess, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnTalk( CChar *myChar, const char *mySpeech )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers when character with event attached says something
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnTalk( CChar *myChar, const char *mySpeech )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( myChar ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnTalk, "onTalk" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2021-06-12 07:30:23 -04:00
|
|
|
JSString *strSpeech = nullptr;
|
2021-04-25 05:01:06 +08:00
|
|
|
std::string lwrSpeech = mySpeech;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2021-07-19 13:41:59 -04:00
|
|
|
strSpeech = JS_NewStringCopyZ( targContext, strutil::lower( lwrSpeech ).c_str() );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, myChar, runTime );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = STRING_TO_JSVAL( strSpeech );
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onTalk", 2, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnTalk, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnSpeechInput( CChar *myChar, CItem *myItem, const char *mySpeech )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Purpose - Triggers after player with event attached inputs speech after a request for
|
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
|
|
|
//| speech input has been made.
|
|
|
|
|
//| Notes - This function is called out of network.cpp if a speechmode(9) was previously set
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2002-04-07 20:53:41 +00:00
|
|
|
bool cScript::OnSpeechInput( CChar *myChar, CItem *myItem, const char *mySpeech )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( myChar ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return true;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSpeechInput, "onSpeechInput" ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
jsval params[4], rval;
|
2021-06-12 07:30:23 -04:00
|
|
|
JSString *strSpeech = nullptr;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
char *lwrSpeech = new char[strlen(mySpeech)+1];
|
|
|
|
|
strcpy( lwrSpeech, mySpeech );
|
|
|
|
|
strSpeech = JS_NewStringCopyZ( targContext, lwrSpeech );
|
2012-11-03 18:11:04 +00:00
|
|
|
delete[] lwrSpeech;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, myChar, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( myItem ) )
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = JSVAL_NULL;
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, myItem, runTime );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( itemObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2002-04-07 20:53:41 +00:00
|
|
|
params[2] = STRING_TO_JSVAL( strSpeech );
|
|
|
|
|
params[3] = INT_TO_JSVAL( myChar->GetSpeechID() );
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSpeechInput", 4, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnSpeechInput, false );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
return ( rval == JSVAL_TRUE );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnSpellGain( CItem *book, const UI08 spellNum )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for spellbooks with event attached when spells are added to them
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnSpellGain( CItem *book, const UI08 spellNum )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( book ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSpellGain, "onSpellGain" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, book, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( itemObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( spellNum );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSpellGain", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnSpellGain, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnSpellLoss( CItem *book, const UI08 spellNum )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for spellbooks with event attached when spells are removed from them
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnSpellLoss( CItem *book, const UI08 spellNum )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( book ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSpellLoss, "onSpellLoss" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *itemObj = JSEngine->AcquireObject( IUE_ITEM, book, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( itemObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( spellNum );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSpellLoss", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnSpellLoss, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnSkillCheck( CChar *myChar, const UI08 skill, const UI16 lowSkill, const UI16 highSkill )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for character with event attached when a skillcheck is performed
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnSkillCheck( CChar *myChar, const UI08 skill, const UI16 lowSkill, const UI16 highSkill )
|
2002-04-07 20:53:41 +00:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ValidateObject( myChar ) || skill > ALLSKILLS )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnSkillCheck, "onSkillCheck" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2002-04-07 20:53:41 +00:00
|
|
|
|
|
|
|
|
jsval params[4], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, myChar, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2002-04-07 20:53:41 +00:00
|
|
|
params[1] = INT_TO_JSVAL( skill );
|
|
|
|
|
params[2] = INT_TO_JSVAL( lowSkill );
|
|
|
|
|
params[3] = INT_TO_JSVAL( highSkill );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSkillCheck", 4, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2002-04-07 20:53:41 +00:00
|
|
|
SetEventExists( seOnSkillCheck, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2002-04-07 20:53:41 +00:00
|
|
|
}
|
2003-01-20 16:24:24 +00:00
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool AreaObjFunc( char *funcName, CBaseObject *srcObject, CBaseObject *tmpObject, CSocket *s )
|
2003-03-04 14:55:47 +00:00
|
|
|
//| Date - January 27, 2003
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Changes - August 17 2005
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Renamed to AreaObjFunc from AreaCharFunc
|
|
|
|
|
//| Added support for other object types
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2003-03-04 14:55:47 +00:00
|
|
|
//| Purpose - Calls the function represented in funcName for the script
|
|
|
|
|
//| - passing in two character parameters
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::AreaObjFunc( char *funcName, CBaseObject *srcObject, CBaseObject *tmpObject, CSocket *s )
|
2003-03-04 14:55:47 +00:00
|
|
|
{
|
2021-06-12 07:30:23 -04:00
|
|
|
if( !ValidateObject( srcObject ) || !ValidateObject( tmpObject ) || funcName == nullptr )
|
2003-03-04 14:55:47 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[3], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
JSObject *srcObj = nullptr;
|
|
|
|
|
JSObject *tmpObj = nullptr;
|
|
|
|
|
|
2021-07-04 07:57:42 +08:00
|
|
|
if( srcObject == nullptr || tmpObject == nullptr )
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( srcObject->CanBeObjType( OT_ITEM ) )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
srcObj = JSEngine->AcquireObject( IUE_ITEM, srcObject, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
}
|
2021-07-04 07:57:42 +08:00
|
|
|
else if( srcObject->CanBeObjType( OT_CHAR ) )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
srcObj = JSEngine->AcquireObject( IUE_CHAR, srcObject, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2021-07-04 07:57:42 +08:00
|
|
|
if( tmpObject->CanBeObjType( OT_ITEM ) )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
tmpObj = JSEngine->AcquireObject( IUE_ITEM, tmpObject, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
}
|
2021-07-04 07:57:42 +08:00
|
|
|
else if( tmpObject->CanBeObjType( OT_CHAR ) )
|
|
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
tmpObj = JSEngine->AcquireObject( IUE_CHAR, tmpObject, runTime );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
}
|
|
|
|
|
|
2021-07-04 07:57:42 +08:00
|
|
|
if( srcObj == nullptr || tmpObj == nullptr )
|
|
|
|
|
{
|
|
|
|
|
return false;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
}
|
|
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[0] = OBJECT_TO_JSVAL( srcObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( tmpObj );
|
2003-03-04 14:55:47 +00:00
|
|
|
|
2021-06-12 07:30:23 -04:00
|
|
|
if( s != nullptr )
|
2003-03-04 14:55:47 +00:00
|
|
|
{
|
2021-06-12 07:30:23 -04:00
|
|
|
JSObject *sockObj = nullptr;
|
2012-11-03 18:11:04 +00:00
|
|
|
sockObj = JSEngine->AcquireObject( IUE_SOCK, s, runTime );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( sockObj );
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
|
|
|
|
else
|
2012-11-03 18:11:04 +00:00
|
|
|
params[2] = JSVAL_NULL;
|
|
|
|
|
// ExistAndVerify() normally sets our Global Object, but not on custom named functions.
|
|
|
|
|
JS_SetGlobalObject( targContext, targObject );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
|
|
|
|
//FIXME === do we need this retvalue?
|
|
|
|
|
//JSBool retVal = JS_CallFunctionName( targContext, targObject, funcName, 3, params, &rval );
|
2021-07-04 02:26:43 +08:00
|
|
|
[[maybe_unused]] JSBool retVal = JS_CallFunctionName( targContext, targObject, funcName, 3, params, &rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
return ( JSVAL_TO_BOOLEAN( rval ) == JS_TRUE );
|
2003-03-04 14:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnCommand( CSocket *mSock, std::string command )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Purpose - Quick and dirty way to setup custom commands
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnCommand( CSocket *mSock, std::string command )
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2021-06-12 07:30:23 -04:00
|
|
|
if( mSock == nullptr || command == "" )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
if( !ExistAndVerify( seOnCommand, "onCommand" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2003-03-04 14:55:47 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
jsval params[2], rval;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, mSock, runTime );
|
2021-06-12 07:30:23 -04:00
|
|
|
JSString *strCmd = nullptr;
|
2021-07-19 13:41:59 -04:00
|
|
|
strCmd = JS_NewStringCopyZ( targContext, strutil::lower( command ).c_str() );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = STRING_TO_JSVAL( strCmd );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onCommand", 2, params, &rval );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
SetEventExists( seOnCommand, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2003-01-26 22:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool ExistAndVerify( ScriptEvent eventNum, std::string functionName )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - ???
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2003-03-04 14:55:47 +00:00
|
|
|
bool cScript::ExistAndVerify( ScriptEvent eventNum, std::string functionName )
|
|
|
|
|
{
|
|
|
|
|
if( !EventExists( eventNum ) )
|
|
|
|
|
return false;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2003-03-04 14:55:47 +00:00
|
|
|
if( NeedsChecking( eventNum ) )
|
|
|
|
|
{
|
|
|
|
|
SetNeedsChecking( eventNum, false );
|
|
|
|
|
jsval Func = JSVAL_NULL;
|
|
|
|
|
JS_GetProperty( targContext, targObject, functionName.c_str(), &Func );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
if( Func == JSVAL_VOID )
|
2003-03-04 14:55:47 +00:00
|
|
|
{
|
|
|
|
|
SetEventExists( eventNum, false );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
JS_SetGlobalObject( targContext, targObject );
|
2003-03-04 14:55:47 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2012-11-03 18:11:04 +00:00
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool ScriptRegistration( std::string scriptType )
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Date - 20th December, 2001
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Registers a script with the JS engine
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Notes - Also requires a <scriptType>Registration() event with a Register<scriptType>()
|
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
|
|
|
//| function, and an onSkill() event, both in the same script
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::ScriptRegistration( std::string scriptType )
|
|
|
|
|
{
|
|
|
|
|
scriptType += "Registration";
|
|
|
|
|
jsval params[1], rval;
|
|
|
|
|
// ExistAndVerify() normally sets our Global Object, but not on custom named functions.
|
|
|
|
|
JS_SetGlobalObject( targContext, targObject );
|
|
|
|
|
|
|
|
|
|
jsval Func = JSVAL_NULL;
|
|
|
|
|
JS_GetProperty( targContext, targObject, scriptType.c_str(), &Func );
|
|
|
|
|
if( Func == JSVAL_VOID )
|
|
|
|
|
{
|
2021-05-27 05:42:35 +08:00
|
|
|
Console.warning( strutil::format("Script Number (%u) does not have a %s function", JSMapping->GetScriptID( targObject ), scriptType.c_str() ));
|
2012-11-03 18:11:04 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, scriptType.c_str(), 0, params, &rval );
|
|
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool executeCommand( CSocket *s, std::string funcName, std::string executedString )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Execute a player-initiated JS-based command
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::executeCommand( CSocket *s, std::string funcName, std::string executedString )
|
|
|
|
|
{
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
jsval params[2], rval;
|
2012-11-03 18:11:04 +00:00
|
|
|
JSString *execString = JS_NewStringCopyZ( targContext, executedString.c_str() );
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, s, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = STRING_TO_JSVAL( execString );
|
|
|
|
|
// ExistAndVerify() normally sets our Global Object, but not on custom named functions.
|
|
|
|
|
JS_SetGlobalObject( targContext, targObject );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, funcName.c_str(), 2, params, &rval );
|
|
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
return ( retVal == JS_TRUE );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Code cleanup
Embraced the usage of R32, R64, SI16, UI16, SI32, UI32, SI64 and UI64 typedef aliases as replacement for built-in types throughout the sourcecode:
typedef float R32;
typedef double R64;
typedef signed char SI08;
typedef unsigned char UI08;
typedef signed short int SI16;
typedef unsigned short int UI16;
typedef signed int SI32;
typedef unsigned int UI32;
typedef signed long long SI64;
typedef unsigned long long UI64;
As part of this process, UI32 was redefined from unsigned long int to unsigned int, and SI32 from signed long int to signed int to ensure the size of variables using these remain the same (32bit) across both Windows, Linux and MacOS for both 32bit and 64bit platforms
Replaced instances of toLong() with toInt(), and toULong() to toUInt()
Replaced instances of "long" and "int" with SI32 where possible
Replaced instances of "unsigned long" and "unsigned int" with UI32 where possible
Replaced instances of "float" with R32 where possible
2020-08-12 23:46:33 +08:00
|
|
|
//| Function - bool MagicSpellCast( CSocket *mSock, CChar *tChar, bool directCast, SI32 spellNum )
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers before a spellcast attempt for characters with onSpellCast event attached
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Code cleanup
Embraced the usage of R32, R64, SI16, UI16, SI32, UI32, SI64 and UI64 typedef aliases as replacement for built-in types throughout the sourcecode:
typedef float R32;
typedef double R64;
typedef signed char SI08;
typedef unsigned char UI08;
typedef signed short int SI16;
typedef unsigned short int UI16;
typedef signed int SI32;
typedef unsigned int UI32;
typedef signed long long SI64;
typedef unsigned long long UI64;
As part of this process, UI32 was redefined from unsigned long int to unsigned int, and SI32 from signed long int to signed int to ensure the size of variables using these remain the same (32bit) across both Windows, Linux and MacOS for both 32bit and 64bit platforms
Replaced instances of toLong() with toInt(), and toULong() to toUInt()
Replaced instances of "long" and "int" with SI32 where possible
Replaced instances of "unsigned long" and "unsigned int" with UI32 where possible
Replaced instances of "float" with R32 where possible
2020-08-12 23:46:33 +08:00
|
|
|
bool cScript::MagicSpellCast( CSocket *mSock, CChar *tChar, bool directCast, SI32 spellNum )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
|
|
|
|
if( !ValidateObject( tChar ) )
|
|
|
|
|
return false;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnSpellCast, "onSpellCast" ) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[4], rval;
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, tChar, runTime );
|
|
|
|
|
JSObject *sockObj = JSEngine->AcquireObject( IUE_SOCK, mSock, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( sockObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[2] = BOOLEAN_TO_JSVAL( directCast );
|
|
|
|
|
params[3] = INT_TO_JSVAL( spellNum );
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSpellCast", 4, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnSpellCast, false );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
return ( JSVAL_TO_BOOLEAN( rval ) == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnIterate( CBaseObject *a, UI32 &b )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Called after IterateOver JS function is used, and iterates over all items or
|
|
|
|
|
//| characters (as specified) in the game
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
bool cScript::OnIterate( CBaseObject *a, UI32 &b )
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
{
|
|
|
|
|
if( !ValidateObject( a ) )
|
2012-11-03 18:11:04 +00:00
|
|
|
return true;
|
|
|
|
|
if( !ExistAndVerify( seOnIterate, "onIterate" ) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[1], rval;
|
|
|
|
|
|
2021-06-12 07:30:23 -04:00
|
|
|
JSObject *myObj = nullptr;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( a->GetObjType() == OT_CHAR )
|
|
|
|
|
myObj = JSEngine->AcquireObject( IUE_CHAR, a, runTime );
|
|
|
|
|
else
|
|
|
|
|
myObj = JSEngine->AcquireObject( IUE_ITEM, a, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onIterate", 1, params, &rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
/* if( ValidateObject( a ) )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
|
|
|
|
if( a->GetObjType() == OT_CHAR )
|
|
|
|
|
JSEngine->ReleaseObject( IUE_CHAR, a );
|
|
|
|
|
else
|
|
|
|
|
JSEngine->ReleaseObject( IUE_ITEM, a );
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
if( retVal == JS_FALSE )
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
SetEventExists( seOnIterate, false );
|
2012-11-03 18:11:04 +00:00
|
|
|
else if( JSVAL_TO_BOOLEAN( rval ) )
|
|
|
|
|
++b;
|
|
|
|
|
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
return ( retVal == JS_TRUE );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnIterateSpawnRegions( CSpawnRegion *a, UI32 &b )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Called after IterateOverSpawnRegions JS function is used, and iterates over
|
|
|
|
|
//| all spawn regions in game
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
bool cScript::OnIterateSpawnRegions( CSpawnRegion *a, UI32 &b )
|
|
|
|
|
{
|
2021-06-12 07:30:23 -04:00
|
|
|
if( a == nullptr )
|
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
|
|
|
return true;
|
|
|
|
|
if( !ExistAndVerify( seOnIterateSpawnRegions, "onIterateSpawnRegions" ) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval params[1], rval;
|
|
|
|
|
|
2021-06-12 07:30:23 -04:00
|
|
|
JSObject *myObj = nullptr;
|
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
|
|
|
myObj = JSEngine->AcquireObject( IUE_SPAWNREGION, a, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onIterateSpawnRegions", 1, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnIterateSpawnRegions, false );
|
|
|
|
|
else if( JSVAL_TO_BOOLEAN( rval ) )
|
|
|
|
|
++b;
|
|
|
|
|
|
|
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnPacketReceive( CSocket *mSock, UI16 packetNum )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - "Packet hook" event that allows interception of incoming network packets
|
|
|
|
|
//| Notes - Requires OVERLOADPACKETS ini setting to be enabled, and incoming packet must
|
|
|
|
|
//| be registered in JSE_FILEASSOCIATIONS.SCP under the [PACKET_SCRIPTS] section
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
bool cScript::OnPacketReceive( CSocket *mSock, UI16 packetNum )
|
|
|
|
|
{
|
2021-06-12 07:30:23 -04:00
|
|
|
if( mSock == nullptr )
|
2012-11-03 18:11:04 +00:00
|
|
|
return false;
|
|
|
|
|
if( !ExistAndVerify( seOnPacketReceive, "onPacketReceive" ) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, mSock, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = INT_TO_JSVAL( (UI08)(packetNum%256) );
|
|
|
|
|
params[2] = INT_TO_JSVAL( (UI08)(packetNum>>8) );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onPacketReceive", 3, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnPacketReceive, false );
|
|
|
|
|
|
|
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Function - SI08 OnCharDoubleClick( CChar *currChar, CChar *targChar )
|
|
|
|
|
//| Date - 23rd January, 2006
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Purpose - Allows overriding events that happen when doubleclicking characters, such as
|
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
|
|
|
//| open paperdoll, mounting horses, etc
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnCharDoubleClick( CChar *currChar, CChar *targChar )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( currChar ) || !ValidateObject( targChar ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnCharDoubleClick, "onCharDoubleClick" ) )
|
|
|
|
|
return RV_NOFUNC;
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
jsval params[2], rval;
|
|
|
|
|
JSObject *srcObj = JSEngine->AcquireObject( IUE_CHAR, currChar, runTime );
|
|
|
|
|
JSObject *trgObj = JSEngine->AcquireObject( IUE_CHAR, targChar, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( srcObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( trgObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onCharDoubleClick", 2, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnCharDoubleClick, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Function - SI08 OnSkillGump( CSocket *mSock )
|
|
|
|
|
//| Date - 23rd January, 2006
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
//| Purpose - Allows overriding the client's request to open the default skillgump, and
|
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
|
|
|
//| instead do something else (like opening a custom skillgump instead).
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnSkillGump( CChar *currChar )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( currChar ))
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnSkillGump, "onSkillGump" ) )
|
|
|
|
|
return RV_NOFUNC;
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
jsval params[1], rval;
|
|
|
|
|
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, currChar, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSkillGump", 1, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnSkillGump, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2020-06-02 21:38:57 +08:00
|
|
|
//| Function - SI08 OnUseBandageMacro( CSocket *mSock, CChar *targChar, CItem *bandageItem )
|
|
|
|
|
//| Date - 12th May, 2020
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Expose bandage macro usage to JS engine so server admins can override the effects
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2020-06-02 21:38:57 +08:00
|
|
|
SI08 cScript::OnUseBandageMacro( CSocket *mSock, CChar *targChar, CItem *bandageItem )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
2021-06-12 07:30:23 -04:00
|
|
|
if( !ValidateObject( targChar ) || mSock == nullptr )
|
2020-06-02 21:38:57 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnUseBandageMacro, "onUseBandageMacro" ) )
|
|
|
|
|
return RV_NOFUNC;
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
2020-06-02 21:38:57 +08:00
|
|
|
jsval params[3], rval;
|
|
|
|
|
|
|
|
|
|
JSObject *mSockObj = JSEngine->AcquireObject( IUE_SOCK, mSock, runTime );
|
|
|
|
|
JSObject *targCharObj = JSEngine->AcquireObject( IUE_CHAR, targChar, runTime );
|
|
|
|
|
JSObject *bandageItemObj = JSEngine->AcquireObject( IUE_ITEM, bandageItem, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( mSockObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( targCharObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( bandageItemObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onUseBandageMacro", 3, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnUseBandageMacro, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2020-06-02 21:38:57 +08:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnCombatStart( CChar *attacker, CChar *defender )
|
|
|
|
|
//| Date - 23rd January, 2006
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for characters with event attached when initiating combat
|
|
|
|
|
//| Notes - Returning FALSE will also run hard code for this scenario
|
|
|
|
|
//| Returning TRUE will override code's default handling of this scenario
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnCombatStart( CChar *attacker, CChar *defender )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( attacker ) || !ValidateObject( defender ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnCombatStart, "onCombatStart" ) )
|
|
|
|
|
return RV_NOFUNC;
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
jsval params[2], rval;
|
|
|
|
|
|
|
|
|
|
JSObject *attObj = JSEngine->AcquireObject( IUE_CHAR, attacker, runTime );
|
|
|
|
|
JSObject *defObj = JSEngine->AcquireObject( IUE_CHAR, defender, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( attObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( defObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onCombatStart", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnCombatStart, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnCombatEnd( CChar *currChar, CChar *targChar )
|
|
|
|
|
//| Date - 23rd January, 2006
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for characters with event attached when combat ends
|
|
|
|
|
//| Notes - Returning FALSE will also run hard code for this scenario
|
|
|
|
|
//| Returning TRUE will override code's default handling of this scenario
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnCombatEnd( CChar *currChar, CChar *targChar )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( currChar ))
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnCombatEnd, "onCombatEnd" ) )
|
|
|
|
|
return RV_NOFUNC;
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
jsval params[2], rval;
|
|
|
|
|
|
|
|
|
|
JSObject *attObj = JSEngine->AcquireObject( IUE_CHAR, currChar, runTime );
|
|
|
|
|
JSObject *defObj = JSEngine->AcquireObject( IUE_CHAR, targChar, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( attObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( defObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onCombatEnd", 2, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnCombatEnd, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnDeathBlow( CChar *mKilled, CChar *mKiller )
|
|
|
|
|
//| Date - 8th February, 2006
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for characters with event attached when performing a death blow in combat
|
|
|
|
|
//| Notes - Returning FALSE will also run hard code for this scenario
|
|
|
|
|
//| Returning TRUE will override code's default handling of this scenario
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnDeathBlow( CChar *mKilled, CChar *mKiller )
|
|
|
|
|
{
|
|
|
|
|
const SI08 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( mKilled ) ) // || !ValidateObject( mKiller ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnDeathBlow, "onDeathBlow" ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
|
|
|
|
|
jsval rval, params[2];
|
|
|
|
|
JSObject *killedObj = JSEngine->AcquireObject( IUE_CHAR, mKilled, runTime );
|
|
|
|
|
JSObject *killerObj = JSEngine->AcquireObject( IUE_CHAR, mKiller, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( killedObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( killerObj );
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onDeathBlow", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnDeathBlow, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2021-06-17 16:52:49 +08:00
|
|
|
//| Function - SI16 OnCombatDamageCalc( CChar *attacker, CChar *defender, UI08 getFightSkill, UI08 hitLoc )
|
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
|
|
|
//| Date - 21st March, 2006
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for characters with event attached every time combat damage is calculated
|
|
|
|
|
//| Notes - Returning -1 will default to hard code handling of event
|
|
|
|
|
//| Returning another value will override code's default handling of event
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2021-06-17 16:52:49 +08:00
|
|
|
SI16 cScript::OnCombatDamageCalc( CChar *attacker, CChar *defender, UI08 getFightSkill, UI08 hitLoc )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
|
|
|
|
const SI16 RV_NOFUNC = -1;
|
|
|
|
|
if( !ValidateObject( attacker ) || !ValidateObject( defender ) )
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
if( !ExistAndVerify( seOnCombatDamageCalc, "onCombatDamageCalc" ) )
|
|
|
|
|
return RV_NOFUNC;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
SI16 funcRetVal = -1;
|
|
|
|
|
|
2021-06-17 16:52:49 +08:00
|
|
|
jsval rval, params[4];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *attackerObj = JSEngine->AcquireObject( IUE_CHAR, attacker, runTime );
|
|
|
|
|
JSObject *defenderObj = JSEngine->AcquireObject( IUE_CHAR, defender, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( attackerObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( defenderObj );
|
|
|
|
|
params[2] = INT_TO_JSVAL( getFightSkill );
|
2021-06-17 16:52:49 +08:00
|
|
|
params[3] = INT_TO_JSVAL( hitLoc );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
2021-06-17 16:52:49 +08:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onCombatDamageCalc", 4, params, &rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
|
|
|
|
SetEventExists( seOnCombatDamageCalc, false );
|
|
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
JSEncapsulate damage( targContext, &rval );
|
|
|
|
|
|
|
|
|
|
if( damage.isType( JSOT_INT ) || damage.isType( JSOT_DOUBLE ) ) // They returned some sort of value
|
|
|
|
|
{
|
|
|
|
|
return (SI16)damage.toInt();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
funcRetVal = -1; // default to hard code
|
|
|
|
|
|
|
|
|
|
return funcRetVal;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - bool OnDamage( CChar *damaged, CChar *attacker, SI16 damageValue )
|
|
|
|
|
//| Date - 22nd March, 2006
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers when character with event attached takes damage
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
0.99.4x
Fixed an issue where the color of NPC corpse names would not always match up with the NPC's flag color
Fixed a bug where the baseRange and maxRange properties of ranged weapons would not get saved to world files. These values are now saved in the format of RANGE=baseRange,maxRange
Changed the way items are added to containers, to ensure that the order in which the items are displayed to the player always reflects the order in which they were added; now the most recent item added/moved in a container will always be rendered on top of older items.
Made adjustments to how items are randomly added to containers; should use more of a given container gump's available area now
Exposed Item property to JS engine, which contains serial of the creator of an item:
.creator // contains serial of the creator of an item. If set, maker's marks will show up in the item's tooltip
Fixed an issue where JS engine would lose track of script context if one script used CreateDFNItem() or SpawnNPC() functions and the new objects had events that triggered upon creation. UOX3 now restores the original script context at the tail end of these functions.
Added new JS Event to allow inserting custom tooltip text for objects, which will be displayed in tooltips right after the object name. Any text returned from the event will be displayed, and the text can make use of the same HTML tags as gumps to make changes to color, font, etc.
onTooltip( myObj ) // Triggers for objects right before the object's tooltip properties are sent to client
Updated 'tweak and 'set commands to refresh item being modified if movable state of item changes, so the change is reflected in nearby clients
Fixed an issue with NPC vendors and items bought from players not being properly removed from the vendor's "bought container" when players buy them again
Ported Item Identification skill from code to JS (js/skill/itemid.js) and removed hard-coded version
Implemented magic item generator in JS (js/item/magic_item.js). When this script is attached to an NPC, it has a chance to generate magic weapons, armors, wands/staffs and rings as loot on the NPC's corpse when slain. The chance of getting quality magical items increases with the fame level of the NPC in question. The types of magical items generated follows the pattern of such items as implemented in UO prior to the AoS expansion.
Examples:
exceedingly accurate war hammer of vanquishing
substantial, accurate axe of power and Daemon's Breath
silver long sword
massive platemail arms of Protection
metal shield of defense
durable ringmail tunic of guarding
All magic items have a chance to have spell effects attached (with rings/wands being guaranteed to have these), with a limited amount of charges available. For weapons, these effects activate on successful hits in combat, while for armors they activate on equip, and then periodically as long as the item is worn. Rings and wands/staffs have to be manually activated and targeted - with the exception of rings of invisibility, which activate the moment you equip them!
Related scripts:
js/item/magic_armor_equipeffects.js
js/item/magic_weapon_accbonus.js
js/item/magic_weapon_equip.js
js/item/magic_weapon_spell_attack.js
The magic item loot generation script has been attached to a number of different NPCs, all of which now have a chance to drop magic items as loot when defeated.
A bonus magical item - the glacial staff - has also been implemented (js/item/magic_glacial_staff.js), and has a chance to drop as loot from Giant Ice Serpents!
Fixed an issue with CustomTarget where the target message would not be displayed if the cursorType parameter was provided
Fixed bug with 'rename command, which referenced a non-existing variable that caused a script crash
Added additional object properties to 'get and 'set commands:
.shouldSave // Determines if an item should be saved in worldfiles or not
.baseRange // Determines the base range of a ranged weapon, less than which it becomes less effective
.maxRange // Determines the max range of a ranged weapon, beyond which it cannot reach its target
The feature that allows stats like Strength, Dexterity and Intelligence to provide bonuses to skill checks has been turned into a UOX.INI setting, which is disabled by default. The bonuses have also been nerfed; they will no longer contribute more to the success of a skill check than the actual skill being checked!
STATSAFFECTSKILLCHECKS=0/1 // If enabled, stats can provide bonuses to skill checks based on the weighting for those stats as setup in dfndata/skills/skills.dfn
Updated damage tracking code to include the type of damage that was dealt (PHYSICAl vs HEAT vs COLD, etc)
Updated Character JS Method Damage() to include a new parameter that can specify the type of damage that was dealt to the character. The new parameter must always be included if other optional parameters are used. Note that updates might be required for scripts making use of this method.Updated syntax:
.Damage( amount )
.Damage( amount, damageType )
.Damage( amount, damageType, attacker )
.Damage( amount, damageType, attacker, doRepsys )
Supported damageTypes:
PHYSICAL = 1
LIGHT = 2
RAIN = 3
COLD = 4
HEAT = 5
LIGHTNING = 6 // magic damage
POISON = 7
SNOW = 8
Updated JS Event OnDamage to include an additional parameter that describes the type of damage that was dealt. New syntax:
onDamage( damaged, attacker, damageValue, damageType )
Updated JS Event OnSpellTarget to allow rejecting a spell being cast on a target by returning a value of 2 from the script
Split the character priv flag for magic reflection into a temporary one (one-time magic reflection spell) and a permanent one (innate permanent reflection ability). The temporary effect is put in place by Magic Reflection spell, and is removed after a successful spell reflect. The permanent one is an innate ability of a character and is not removed even after a spell is reflected.
Added new Character JS property to get/set state of a character's permanent magic reflect ability:
.permanentMagicReflect // 0 = disable, 1 = enable
Added special abilities/effects for the following NPCs:
Acid Elementals now have a chance to damage the melee weapons of their attackers
Dull Copper Elementals now explode on death
Shadow Iron Elemental is immune to targeted spell damage
Copper Elementals have permanent magic reflect, and reflect some physical damage back at their attacker
Bronze Elementals deal passive area damage to nearby players every 5 to 10 seconds
Valorite Elementals have permanent magic reflect, reflect some physical damage back at their attacker
Snow/Ice Elementals deal passive area damage to nearby players every 5 to 10 seconds
Lava Serpents deal passive area damage to nearby players every 5 to 10 seconds
Phoenixes deal passive area damage to nearby players every 5 to 10 seconds
Pixies have a chance to cast a random spell upon receiving a death blow:
Bless (target)
Curse (target)
Explosion (target)
Greater Poison (target)
Greater Heal (self, prevents death)
Ethereal Warriors will now resurrect dead players with positive karma
Ethereal Warriors now have a chance to drain target's health, stamina or mana on hit
Fire Breath special ability added to the following NPCs, with the random ability damage scaling with the NPCs current health:
Hell Cat, 5 to 8 dmg at max health
Fire Steed, 6 to 9 dmg at max health
Hell Hounds, 8 to 11 dmg at max health
Lava Lizard, 8 to 11 dmg at max health
Predator Hell Cat, 9 to 14 dmg at max health
Sea Serpent, 11 to 17 dmg at max health
Swamp Dragon, 15 to 22 dmg at max health
Armored Swamp Dragon, 15 to 22 dmg at max health
Fire Gargoyle, 20 to 30 dmg at max health
Deep Sea Serpent, 21 to 32 dmg at max health
Serpentine Dragon, 22 to 32 dmg at max health
Drake (Gray), 22 to 32 dmg at max health
Drake (Red), 22 to 32 dmg at max health
Nightmare, 26 to 39 dmg at max health
Dark Steed, 26 to 39 dmg at max health
Silver Steed, 26 to 39 dmg at max health
Kraken, 39 to 59 dmg at max health
Dragon (Red), 41 to 62 dmg at max health
Dragon (Gray), 41 to 62 dmg at max health
Shadow Wyrm, 50 to 75 dmg at max health
Reptalon, 51 to 77 dmg at max health
Skeletal Dragon, 52 to 77 dmg at max health
Ancient Wyrm, 60 to 90 dmg at max health
Update stats, skills and loot for all currently implemented NPCs
Removed an ancient piece of code that prevented corpses from being generated for various elementals and blade spirits on death. This was originally put in place because these creatures had no corpses, and would replace it with a backpack instead, but these creatures now all have corpses in all client versions supported by UOX3
Updated potions script (js/item/potion.js) with updated formula for amount of hitpoints healed by healing potions, and added restrictions for using them when at full health and/or if poisoned (Dragon Slayer)
Fixed a bug where creatures (and humans, if FORCENEWANIMATIONPACKET was disabled in uox.ini) would play animations with wrong frame count, causing the animations to either freeze for a few frames at the end, or get cut off a couple of frames early
Implemented bonus hit chance for Archery skill, based on mention of such a bonus in Publish 5 patch notes and related UO House of Commons chat. This has been exposed as a UOX.INI setting where this bonus can be tweaked:
ARCHERYHITBONUS=10 // Bonus hit chance for Archery skill added to regular hit chance in combat. Defaults to 10%
Implemented optional extra delay between moving and being able to shoot with ranged weapons in combat (in addition to whatever delay is there due to speed of the ranged weapon). This is exposed as a UOX.INI setting:
ARCHERYSHOOTDELAY=0.5 // Minimum delay in seconds from a player stops moving until they can start to fire their ranged weapon. Defaults to 0.5s
Fixed a bug where players who never entered combat mode could fire ranged weapons while moving
Updated Add-menu with some improvements for usability:
Menu now directly on the Objects (previously "Shard") tab for quicker access, with a small welcome text and quick-link button for UOX3 docs
Settings tab contains some (persistent, will be saved with character) options for how the Add-menu behaves, along with a few quick-access buttons to some useful commands. Available options:
Option to add chosen item at specific location instead of in GM's backpack
Option to add chosen item repeatedly until cancelled
Option to automatically reopen Add-menu on last menu that was open when a selection is made
Option to force decayable state of all added items to either off (doesn't decay), on (decays) or nothing (use item default)
Option to force movable state of all added items to either off (not movable), on (movable) or nothing (use item default)
Added a Home button at the bottom of the menu, that takes the user back to the front page of the Add-menu regardless of which menu page they're on
Updated Character/Socket JS Method SysMessage() with an optional parameter to specify the color used to display the system message. Updated syntax:
.SysMessage( "Text" ) // Display "Text" to user as a system message with default system message color from ini
.SysMessage( "Text %s %s", txtArg1, txtArg2 ) // Display "Text" to player with string arguments injected into text
.SysMessage( txtColor, "Text" ) // Display "Text" to user with a specified color
.SysMessage( txtColor, "Text %s %s", txtArg1, txtArg2 ) // Combination of text color, text and string arguments
Fixed a bug where hair/beard items could show up inside corpses
Fixed a bug where items could sometimes vanish (visually) from containers when bouncing back because player was not able to pick them up
Fixed a bug where players would be unable to pick up a freely movable item from a locked down container
Updated handling of item bouncing on pickup to use UOX3 dictionary messages instead of hard-coded client messages
Added support for new Dictionary language:
dictionary.POL - Polish (SERVERLANGUAGE=8 in uox.ini, or client language 83 if SERVERLANGUAGE is set to 0)
Added taming restrictions for Unicorn, Ki-Rin and Cu Sidhe (js/skill/taming.js)
Added modification of some creatures stats after they've been tamed (js/skill/taming.js)
Added restrictions for who can ride certain creatures (Unicorn, Ki-Rin, Cu Sidhe)
Updated words of power for Meteor Swarm spell to follow the same logic as other spells using Kal (Summon): Kal Des Flam Ylem
Added new Item/Character JS Methods to get/set temporary custom tags which don't persist across worldsaves (or across reconnects, for players):
.GetTempTag( "tagName" )
.SetTempTag( "tagName", tagValue )
When applying HPMAX, STAMINAMAX AND MANAMAX DFN tags to new NPCs, their current HP, STAMINA and MANA properties will now be automatically updated to match
Fixed a server crash caused by empty speech messages sent from certain clients
Fixed a bug that prevented teleport locations in Felucca/Trammel from working properly
Updated calculations in code for duration and damage of existing poison strengths (1 - Lesser, 2 - Normal, 3 - Greater, 4 - Deadly) to match with ~Publish 15 (LBR/pre-AoS), and added another poison strength for monster usage (5 - Lethal)
The strength of the Poison and Poison Field spells is now based on the average of the caster's Magery and Poisoning skills, the distance from the target (Poison spell only) and the target's Resisting Spells skill. If caster is further away than 2 tiles from target, the poison strength always equals Lesser Poison, otherwise the following rules apply:
If caster's combined skill is higher than 100.0, poison strength equals Greater Poison, with 5% chance of Deadly Poison (if Poison spell) or Deadly Poison (if Poison Field spell)
If caster's combined skill is higher than 70.2, poison strength equals Greater Poison
If caster's combined skill is higher than 30.2, poison strength equals Normal Poison
If caster's combined skill is 30.2 or lower, poison strength equals Lesser Poison
If target resists spell, poison strength is reduced by 1 level, unless it's already at the lowest level
Fixed an issue that would would let players move faster than they should have been allowed to
Fixed misc issues with Party System:
Mana and Stamina should now update for Party Members when added to the party, when going in/out of range and when their stats update while in range
Players who get disconnected or relog should now find themselves back in the same party they were in previously
Added system messages to inform party members about updates to their party, and to let invited players know they've successfully joined a party (or rejoined, if relogging)
World saves now operate on the principle of only saving changes done since the last world save. Combined with the fact that NPCs in UOX3 are only active if there are players in the same/neighbouring map regions, shard owners may expect to see a decrease in world save times ranging from ~11% to ~99%, depending on how active and how spread out their player base is. If no changes have taken place since last save, saves are virtually instantaneous!
2021-09-20 21:35:17 +08:00
|
|
|
bool cScript::OnDamage( CChar *damaged, CChar *attacker, SI16 damageValue, WeatherType damageType )
|
2012-11-03 18:11:04 +00:00
|
|
|
{
|
|
|
|
|
if( !ValidateObject( damaged ) )
|
|
|
|
|
return false;
|
|
|
|
|
if( !ExistAndVerify( seOnDamage, "onDamage" ) )
|
|
|
|
|
return false;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
0.99.4x
Fixed an issue where the color of NPC corpse names would not always match up with the NPC's flag color
Fixed a bug where the baseRange and maxRange properties of ranged weapons would not get saved to world files. These values are now saved in the format of RANGE=baseRange,maxRange
Changed the way items are added to containers, to ensure that the order in which the items are displayed to the player always reflects the order in which they were added; now the most recent item added/moved in a container will always be rendered on top of older items.
Made adjustments to how items are randomly added to containers; should use more of a given container gump's available area now
Exposed Item property to JS engine, which contains serial of the creator of an item:
.creator // contains serial of the creator of an item. If set, maker's marks will show up in the item's tooltip
Fixed an issue where JS engine would lose track of script context if one script used CreateDFNItem() or SpawnNPC() functions and the new objects had events that triggered upon creation. UOX3 now restores the original script context at the tail end of these functions.
Added new JS Event to allow inserting custom tooltip text for objects, which will be displayed in tooltips right after the object name. Any text returned from the event will be displayed, and the text can make use of the same HTML tags as gumps to make changes to color, font, etc.
onTooltip( myObj ) // Triggers for objects right before the object's tooltip properties are sent to client
Updated 'tweak and 'set commands to refresh item being modified if movable state of item changes, so the change is reflected in nearby clients
Fixed an issue with NPC vendors and items bought from players not being properly removed from the vendor's "bought container" when players buy them again
Ported Item Identification skill from code to JS (js/skill/itemid.js) and removed hard-coded version
Implemented magic item generator in JS (js/item/magic_item.js). When this script is attached to an NPC, it has a chance to generate magic weapons, armors, wands/staffs and rings as loot on the NPC's corpse when slain. The chance of getting quality magical items increases with the fame level of the NPC in question. The types of magical items generated follows the pattern of such items as implemented in UO prior to the AoS expansion.
Examples:
exceedingly accurate war hammer of vanquishing
substantial, accurate axe of power and Daemon's Breath
silver long sword
massive platemail arms of Protection
metal shield of defense
durable ringmail tunic of guarding
All magic items have a chance to have spell effects attached (with rings/wands being guaranteed to have these), with a limited amount of charges available. For weapons, these effects activate on successful hits in combat, while for armors they activate on equip, and then periodically as long as the item is worn. Rings and wands/staffs have to be manually activated and targeted - with the exception of rings of invisibility, which activate the moment you equip them!
Related scripts:
js/item/magic_armor_equipeffects.js
js/item/magic_weapon_accbonus.js
js/item/magic_weapon_equip.js
js/item/magic_weapon_spell_attack.js
The magic item loot generation script has been attached to a number of different NPCs, all of which now have a chance to drop magic items as loot when defeated.
A bonus magical item - the glacial staff - has also been implemented (js/item/magic_glacial_staff.js), and has a chance to drop as loot from Giant Ice Serpents!
Fixed an issue with CustomTarget where the target message would not be displayed if the cursorType parameter was provided
Fixed bug with 'rename command, which referenced a non-existing variable that caused a script crash
Added additional object properties to 'get and 'set commands:
.shouldSave // Determines if an item should be saved in worldfiles or not
.baseRange // Determines the base range of a ranged weapon, less than which it becomes less effective
.maxRange // Determines the max range of a ranged weapon, beyond which it cannot reach its target
The feature that allows stats like Strength, Dexterity and Intelligence to provide bonuses to skill checks has been turned into a UOX.INI setting, which is disabled by default. The bonuses have also been nerfed; they will no longer contribute more to the success of a skill check than the actual skill being checked!
STATSAFFECTSKILLCHECKS=0/1 // If enabled, stats can provide bonuses to skill checks based on the weighting for those stats as setup in dfndata/skills/skills.dfn
Updated damage tracking code to include the type of damage that was dealt (PHYSICAl vs HEAT vs COLD, etc)
Updated Character JS Method Damage() to include a new parameter that can specify the type of damage that was dealt to the character. The new parameter must always be included if other optional parameters are used. Note that updates might be required for scripts making use of this method.Updated syntax:
.Damage( amount )
.Damage( amount, damageType )
.Damage( amount, damageType, attacker )
.Damage( amount, damageType, attacker, doRepsys )
Supported damageTypes:
PHYSICAL = 1
LIGHT = 2
RAIN = 3
COLD = 4
HEAT = 5
LIGHTNING = 6 // magic damage
POISON = 7
SNOW = 8
Updated JS Event OnDamage to include an additional parameter that describes the type of damage that was dealt. New syntax:
onDamage( damaged, attacker, damageValue, damageType )
Updated JS Event OnSpellTarget to allow rejecting a spell being cast on a target by returning a value of 2 from the script
Split the character priv flag for magic reflection into a temporary one (one-time magic reflection spell) and a permanent one (innate permanent reflection ability). The temporary effect is put in place by Magic Reflection spell, and is removed after a successful spell reflect. The permanent one is an innate ability of a character and is not removed even after a spell is reflected.
Added new Character JS property to get/set state of a character's permanent magic reflect ability:
.permanentMagicReflect // 0 = disable, 1 = enable
Added special abilities/effects for the following NPCs:
Acid Elementals now have a chance to damage the melee weapons of their attackers
Dull Copper Elementals now explode on death
Shadow Iron Elemental is immune to targeted spell damage
Copper Elementals have permanent magic reflect, and reflect some physical damage back at their attacker
Bronze Elementals deal passive area damage to nearby players every 5 to 10 seconds
Valorite Elementals have permanent magic reflect, reflect some physical damage back at their attacker
Snow/Ice Elementals deal passive area damage to nearby players every 5 to 10 seconds
Lava Serpents deal passive area damage to nearby players every 5 to 10 seconds
Phoenixes deal passive area damage to nearby players every 5 to 10 seconds
Pixies have a chance to cast a random spell upon receiving a death blow:
Bless (target)
Curse (target)
Explosion (target)
Greater Poison (target)
Greater Heal (self, prevents death)
Ethereal Warriors will now resurrect dead players with positive karma
Ethereal Warriors now have a chance to drain target's health, stamina or mana on hit
Fire Breath special ability added to the following NPCs, with the random ability damage scaling with the NPCs current health:
Hell Cat, 5 to 8 dmg at max health
Fire Steed, 6 to 9 dmg at max health
Hell Hounds, 8 to 11 dmg at max health
Lava Lizard, 8 to 11 dmg at max health
Predator Hell Cat, 9 to 14 dmg at max health
Sea Serpent, 11 to 17 dmg at max health
Swamp Dragon, 15 to 22 dmg at max health
Armored Swamp Dragon, 15 to 22 dmg at max health
Fire Gargoyle, 20 to 30 dmg at max health
Deep Sea Serpent, 21 to 32 dmg at max health
Serpentine Dragon, 22 to 32 dmg at max health
Drake (Gray), 22 to 32 dmg at max health
Drake (Red), 22 to 32 dmg at max health
Nightmare, 26 to 39 dmg at max health
Dark Steed, 26 to 39 dmg at max health
Silver Steed, 26 to 39 dmg at max health
Kraken, 39 to 59 dmg at max health
Dragon (Red), 41 to 62 dmg at max health
Dragon (Gray), 41 to 62 dmg at max health
Shadow Wyrm, 50 to 75 dmg at max health
Reptalon, 51 to 77 dmg at max health
Skeletal Dragon, 52 to 77 dmg at max health
Ancient Wyrm, 60 to 90 dmg at max health
Update stats, skills and loot for all currently implemented NPCs
Removed an ancient piece of code that prevented corpses from being generated for various elementals and blade spirits on death. This was originally put in place because these creatures had no corpses, and would replace it with a backpack instead, but these creatures now all have corpses in all client versions supported by UOX3
Updated potions script (js/item/potion.js) with updated formula for amount of hitpoints healed by healing potions, and added restrictions for using them when at full health and/or if poisoned (Dragon Slayer)
Fixed a bug where creatures (and humans, if FORCENEWANIMATIONPACKET was disabled in uox.ini) would play animations with wrong frame count, causing the animations to either freeze for a few frames at the end, or get cut off a couple of frames early
Implemented bonus hit chance for Archery skill, based on mention of such a bonus in Publish 5 patch notes and related UO House of Commons chat. This has been exposed as a UOX.INI setting where this bonus can be tweaked:
ARCHERYHITBONUS=10 // Bonus hit chance for Archery skill added to regular hit chance in combat. Defaults to 10%
Implemented optional extra delay between moving and being able to shoot with ranged weapons in combat (in addition to whatever delay is there due to speed of the ranged weapon). This is exposed as a UOX.INI setting:
ARCHERYSHOOTDELAY=0.5 // Minimum delay in seconds from a player stops moving until they can start to fire their ranged weapon. Defaults to 0.5s
Fixed a bug where players who never entered combat mode could fire ranged weapons while moving
Updated Add-menu with some improvements for usability:
Menu now directly on the Objects (previously "Shard") tab for quicker access, with a small welcome text and quick-link button for UOX3 docs
Settings tab contains some (persistent, will be saved with character) options for how the Add-menu behaves, along with a few quick-access buttons to some useful commands. Available options:
Option to add chosen item at specific location instead of in GM's backpack
Option to add chosen item repeatedly until cancelled
Option to automatically reopen Add-menu on last menu that was open when a selection is made
Option to force decayable state of all added items to either off (doesn't decay), on (decays) or nothing (use item default)
Option to force movable state of all added items to either off (not movable), on (movable) or nothing (use item default)
Added a Home button at the bottom of the menu, that takes the user back to the front page of the Add-menu regardless of which menu page they're on
Updated Character/Socket JS Method SysMessage() with an optional parameter to specify the color used to display the system message. Updated syntax:
.SysMessage( "Text" ) // Display "Text" to user as a system message with default system message color from ini
.SysMessage( "Text %s %s", txtArg1, txtArg2 ) // Display "Text" to player with string arguments injected into text
.SysMessage( txtColor, "Text" ) // Display "Text" to user with a specified color
.SysMessage( txtColor, "Text %s %s", txtArg1, txtArg2 ) // Combination of text color, text and string arguments
Fixed a bug where hair/beard items could show up inside corpses
Fixed a bug where items could sometimes vanish (visually) from containers when bouncing back because player was not able to pick them up
Fixed a bug where players would be unable to pick up a freely movable item from a locked down container
Updated handling of item bouncing on pickup to use UOX3 dictionary messages instead of hard-coded client messages
Added support for new Dictionary language:
dictionary.POL - Polish (SERVERLANGUAGE=8 in uox.ini, or client language 83 if SERVERLANGUAGE is set to 0)
Added taming restrictions for Unicorn, Ki-Rin and Cu Sidhe (js/skill/taming.js)
Added modification of some creatures stats after they've been tamed (js/skill/taming.js)
Added restrictions for who can ride certain creatures (Unicorn, Ki-Rin, Cu Sidhe)
Updated words of power for Meteor Swarm spell to follow the same logic as other spells using Kal (Summon): Kal Des Flam Ylem
Added new Item/Character JS Methods to get/set temporary custom tags which don't persist across worldsaves (or across reconnects, for players):
.GetTempTag( "tagName" )
.SetTempTag( "tagName", tagValue )
When applying HPMAX, STAMINAMAX AND MANAMAX DFN tags to new NPCs, their current HP, STAMINA and MANA properties will now be automatically updated to match
Fixed a server crash caused by empty speech messages sent from certain clients
Fixed a bug that prevented teleport locations in Felucca/Trammel from working properly
Updated calculations in code for duration and damage of existing poison strengths (1 - Lesser, 2 - Normal, 3 - Greater, 4 - Deadly) to match with ~Publish 15 (LBR/pre-AoS), and added another poison strength for monster usage (5 - Lethal)
The strength of the Poison and Poison Field spells is now based on the average of the caster's Magery and Poisoning skills, the distance from the target (Poison spell only) and the target's Resisting Spells skill. If caster is further away than 2 tiles from target, the poison strength always equals Lesser Poison, otherwise the following rules apply:
If caster's combined skill is higher than 100.0, poison strength equals Greater Poison, with 5% chance of Deadly Poison (if Poison spell) or Deadly Poison (if Poison Field spell)
If caster's combined skill is higher than 70.2, poison strength equals Greater Poison
If caster's combined skill is higher than 30.2, poison strength equals Normal Poison
If caster's combined skill is 30.2 or lower, poison strength equals Lesser Poison
If target resists spell, poison strength is reduced by 1 level, unless it's already at the lowest level
Fixed an issue that would would let players move faster than they should have been allowed to
Fixed misc issues with Party System:
Mana and Stamina should now update for Party Members when added to the party, when going in/out of range and when their stats update while in range
Players who get disconnected or relog should now find themselves back in the same party they were in previously
Added system messages to inform party members about updates to their party, and to let invited players know they've successfully joined a party (or rejoined, if relogging)
World saves now operate on the principle of only saving changes done since the last world save. Combined with the fact that NPCs in UOX3 are only active if there are players in the same/neighbouring map regions, shard owners may expect to see a decrease in world save times ranging from ~11% to ~99%, depending on how active and how spread out their player base is. If no changes have taken place since last save, saves are virtually instantaneous!
2021-09-20 21:35:17 +08:00
|
|
|
jsval rval, params[4];
|
2012-11-03 18:11:04 +00:00
|
|
|
JSObject *damagedObj = JSEngine->AcquireObject( IUE_CHAR, damaged, runTime );
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( damagedObj );
|
|
|
|
|
|
|
|
|
|
if( ValidateObject( attacker ) )
|
|
|
|
|
{
|
|
|
|
|
JSObject *attackerObj = JSEngine->AcquireObject( IUE_CHAR, attacker, runTime );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( attackerObj );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
params[1] = JSVAL_NULL;
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
params[2] = INT_TO_JSVAL( damageValue );
|
0.99.4x
Fixed an issue where the color of NPC corpse names would not always match up with the NPC's flag color
Fixed a bug where the baseRange and maxRange properties of ranged weapons would not get saved to world files. These values are now saved in the format of RANGE=baseRange,maxRange
Changed the way items are added to containers, to ensure that the order in which the items are displayed to the player always reflects the order in which they were added; now the most recent item added/moved in a container will always be rendered on top of older items.
Made adjustments to how items are randomly added to containers; should use more of a given container gump's available area now
Exposed Item property to JS engine, which contains serial of the creator of an item:
.creator // contains serial of the creator of an item. If set, maker's marks will show up in the item's tooltip
Fixed an issue where JS engine would lose track of script context if one script used CreateDFNItem() or SpawnNPC() functions and the new objects had events that triggered upon creation. UOX3 now restores the original script context at the tail end of these functions.
Added new JS Event to allow inserting custom tooltip text for objects, which will be displayed in tooltips right after the object name. Any text returned from the event will be displayed, and the text can make use of the same HTML tags as gumps to make changes to color, font, etc.
onTooltip( myObj ) // Triggers for objects right before the object's tooltip properties are sent to client
Updated 'tweak and 'set commands to refresh item being modified if movable state of item changes, so the change is reflected in nearby clients
Fixed an issue with NPC vendors and items bought from players not being properly removed from the vendor's "bought container" when players buy them again
Ported Item Identification skill from code to JS (js/skill/itemid.js) and removed hard-coded version
Implemented magic item generator in JS (js/item/magic_item.js). When this script is attached to an NPC, it has a chance to generate magic weapons, armors, wands/staffs and rings as loot on the NPC's corpse when slain. The chance of getting quality magical items increases with the fame level of the NPC in question. The types of magical items generated follows the pattern of such items as implemented in UO prior to the AoS expansion.
Examples:
exceedingly accurate war hammer of vanquishing
substantial, accurate axe of power and Daemon's Breath
silver long sword
massive platemail arms of Protection
metal shield of defense
durable ringmail tunic of guarding
All magic items have a chance to have spell effects attached (with rings/wands being guaranteed to have these), with a limited amount of charges available. For weapons, these effects activate on successful hits in combat, while for armors they activate on equip, and then periodically as long as the item is worn. Rings and wands/staffs have to be manually activated and targeted - with the exception of rings of invisibility, which activate the moment you equip them!
Related scripts:
js/item/magic_armor_equipeffects.js
js/item/magic_weapon_accbonus.js
js/item/magic_weapon_equip.js
js/item/magic_weapon_spell_attack.js
The magic item loot generation script has been attached to a number of different NPCs, all of which now have a chance to drop magic items as loot when defeated.
A bonus magical item - the glacial staff - has also been implemented (js/item/magic_glacial_staff.js), and has a chance to drop as loot from Giant Ice Serpents!
Fixed an issue with CustomTarget where the target message would not be displayed if the cursorType parameter was provided
Fixed bug with 'rename command, which referenced a non-existing variable that caused a script crash
Added additional object properties to 'get and 'set commands:
.shouldSave // Determines if an item should be saved in worldfiles or not
.baseRange // Determines the base range of a ranged weapon, less than which it becomes less effective
.maxRange // Determines the max range of a ranged weapon, beyond which it cannot reach its target
The feature that allows stats like Strength, Dexterity and Intelligence to provide bonuses to skill checks has been turned into a UOX.INI setting, which is disabled by default. The bonuses have also been nerfed; they will no longer contribute more to the success of a skill check than the actual skill being checked!
STATSAFFECTSKILLCHECKS=0/1 // If enabled, stats can provide bonuses to skill checks based on the weighting for those stats as setup in dfndata/skills/skills.dfn
Updated damage tracking code to include the type of damage that was dealt (PHYSICAl vs HEAT vs COLD, etc)
Updated Character JS Method Damage() to include a new parameter that can specify the type of damage that was dealt to the character. The new parameter must always be included if other optional parameters are used. Note that updates might be required for scripts making use of this method.Updated syntax:
.Damage( amount )
.Damage( amount, damageType )
.Damage( amount, damageType, attacker )
.Damage( amount, damageType, attacker, doRepsys )
Supported damageTypes:
PHYSICAL = 1
LIGHT = 2
RAIN = 3
COLD = 4
HEAT = 5
LIGHTNING = 6 // magic damage
POISON = 7
SNOW = 8
Updated JS Event OnDamage to include an additional parameter that describes the type of damage that was dealt. New syntax:
onDamage( damaged, attacker, damageValue, damageType )
Updated JS Event OnSpellTarget to allow rejecting a spell being cast on a target by returning a value of 2 from the script
Split the character priv flag for magic reflection into a temporary one (one-time magic reflection spell) and a permanent one (innate permanent reflection ability). The temporary effect is put in place by Magic Reflection spell, and is removed after a successful spell reflect. The permanent one is an innate ability of a character and is not removed even after a spell is reflected.
Added new Character JS property to get/set state of a character's permanent magic reflect ability:
.permanentMagicReflect // 0 = disable, 1 = enable
Added special abilities/effects for the following NPCs:
Acid Elementals now have a chance to damage the melee weapons of their attackers
Dull Copper Elementals now explode on death
Shadow Iron Elemental is immune to targeted spell damage
Copper Elementals have permanent magic reflect, and reflect some physical damage back at their attacker
Bronze Elementals deal passive area damage to nearby players every 5 to 10 seconds
Valorite Elementals have permanent magic reflect, reflect some physical damage back at their attacker
Snow/Ice Elementals deal passive area damage to nearby players every 5 to 10 seconds
Lava Serpents deal passive area damage to nearby players every 5 to 10 seconds
Phoenixes deal passive area damage to nearby players every 5 to 10 seconds
Pixies have a chance to cast a random spell upon receiving a death blow:
Bless (target)
Curse (target)
Explosion (target)
Greater Poison (target)
Greater Heal (self, prevents death)
Ethereal Warriors will now resurrect dead players with positive karma
Ethereal Warriors now have a chance to drain target's health, stamina or mana on hit
Fire Breath special ability added to the following NPCs, with the random ability damage scaling with the NPCs current health:
Hell Cat, 5 to 8 dmg at max health
Fire Steed, 6 to 9 dmg at max health
Hell Hounds, 8 to 11 dmg at max health
Lava Lizard, 8 to 11 dmg at max health
Predator Hell Cat, 9 to 14 dmg at max health
Sea Serpent, 11 to 17 dmg at max health
Swamp Dragon, 15 to 22 dmg at max health
Armored Swamp Dragon, 15 to 22 dmg at max health
Fire Gargoyle, 20 to 30 dmg at max health
Deep Sea Serpent, 21 to 32 dmg at max health
Serpentine Dragon, 22 to 32 dmg at max health
Drake (Gray), 22 to 32 dmg at max health
Drake (Red), 22 to 32 dmg at max health
Nightmare, 26 to 39 dmg at max health
Dark Steed, 26 to 39 dmg at max health
Silver Steed, 26 to 39 dmg at max health
Kraken, 39 to 59 dmg at max health
Dragon (Red), 41 to 62 dmg at max health
Dragon (Gray), 41 to 62 dmg at max health
Shadow Wyrm, 50 to 75 dmg at max health
Reptalon, 51 to 77 dmg at max health
Skeletal Dragon, 52 to 77 dmg at max health
Ancient Wyrm, 60 to 90 dmg at max health
Update stats, skills and loot for all currently implemented NPCs
Removed an ancient piece of code that prevented corpses from being generated for various elementals and blade spirits on death. This was originally put in place because these creatures had no corpses, and would replace it with a backpack instead, but these creatures now all have corpses in all client versions supported by UOX3
Updated potions script (js/item/potion.js) with updated formula for amount of hitpoints healed by healing potions, and added restrictions for using them when at full health and/or if poisoned (Dragon Slayer)
Fixed a bug where creatures (and humans, if FORCENEWANIMATIONPACKET was disabled in uox.ini) would play animations with wrong frame count, causing the animations to either freeze for a few frames at the end, or get cut off a couple of frames early
Implemented bonus hit chance for Archery skill, based on mention of such a bonus in Publish 5 patch notes and related UO House of Commons chat. This has been exposed as a UOX.INI setting where this bonus can be tweaked:
ARCHERYHITBONUS=10 // Bonus hit chance for Archery skill added to regular hit chance in combat. Defaults to 10%
Implemented optional extra delay between moving and being able to shoot with ranged weapons in combat (in addition to whatever delay is there due to speed of the ranged weapon). This is exposed as a UOX.INI setting:
ARCHERYSHOOTDELAY=0.5 // Minimum delay in seconds from a player stops moving until they can start to fire their ranged weapon. Defaults to 0.5s
Fixed a bug where players who never entered combat mode could fire ranged weapons while moving
Updated Add-menu with some improvements for usability:
Menu now directly on the Objects (previously "Shard") tab for quicker access, with a small welcome text and quick-link button for UOX3 docs
Settings tab contains some (persistent, will be saved with character) options for how the Add-menu behaves, along with a few quick-access buttons to some useful commands. Available options:
Option to add chosen item at specific location instead of in GM's backpack
Option to add chosen item repeatedly until cancelled
Option to automatically reopen Add-menu on last menu that was open when a selection is made
Option to force decayable state of all added items to either off (doesn't decay), on (decays) or nothing (use item default)
Option to force movable state of all added items to either off (not movable), on (movable) or nothing (use item default)
Added a Home button at the bottom of the menu, that takes the user back to the front page of the Add-menu regardless of which menu page they're on
Updated Character/Socket JS Method SysMessage() with an optional parameter to specify the color used to display the system message. Updated syntax:
.SysMessage( "Text" ) // Display "Text" to user as a system message with default system message color from ini
.SysMessage( "Text %s %s", txtArg1, txtArg2 ) // Display "Text" to player with string arguments injected into text
.SysMessage( txtColor, "Text" ) // Display "Text" to user with a specified color
.SysMessage( txtColor, "Text %s %s", txtArg1, txtArg2 ) // Combination of text color, text and string arguments
Fixed a bug where hair/beard items could show up inside corpses
Fixed a bug where items could sometimes vanish (visually) from containers when bouncing back because player was not able to pick them up
Fixed a bug where players would be unable to pick up a freely movable item from a locked down container
Updated handling of item bouncing on pickup to use UOX3 dictionary messages instead of hard-coded client messages
Added support for new Dictionary language:
dictionary.POL - Polish (SERVERLANGUAGE=8 in uox.ini, or client language 83 if SERVERLANGUAGE is set to 0)
Added taming restrictions for Unicorn, Ki-Rin and Cu Sidhe (js/skill/taming.js)
Added modification of some creatures stats after they've been tamed (js/skill/taming.js)
Added restrictions for who can ride certain creatures (Unicorn, Ki-Rin, Cu Sidhe)
Updated words of power for Meteor Swarm spell to follow the same logic as other spells using Kal (Summon): Kal Des Flam Ylem
Added new Item/Character JS Methods to get/set temporary custom tags which don't persist across worldsaves (or across reconnects, for players):
.GetTempTag( "tagName" )
.SetTempTag( "tagName", tagValue )
When applying HPMAX, STAMINAMAX AND MANAMAX DFN tags to new NPCs, their current HP, STAMINA and MANA properties will now be automatically updated to match
Fixed a server crash caused by empty speech messages sent from certain clients
Fixed a bug that prevented teleport locations in Felucca/Trammel from working properly
Updated calculations in code for duration and damage of existing poison strengths (1 - Lesser, 2 - Normal, 3 - Greater, 4 - Deadly) to match with ~Publish 15 (LBR/pre-AoS), and added another poison strength for monster usage (5 - Lethal)
The strength of the Poison and Poison Field spells is now based on the average of the caster's Magery and Poisoning skills, the distance from the target (Poison spell only) and the target's Resisting Spells skill. If caster is further away than 2 tiles from target, the poison strength always equals Lesser Poison, otherwise the following rules apply:
If caster's combined skill is higher than 100.0, poison strength equals Greater Poison, with 5% chance of Deadly Poison (if Poison spell) or Deadly Poison (if Poison Field spell)
If caster's combined skill is higher than 70.2, poison strength equals Greater Poison
If caster's combined skill is higher than 30.2, poison strength equals Normal Poison
If caster's combined skill is 30.2 or lower, poison strength equals Lesser Poison
If target resists spell, poison strength is reduced by 1 level, unless it's already at the lowest level
Fixed an issue that would would let players move faster than they should have been allowed to
Fixed misc issues with Party System:
Mana and Stamina should now update for Party Members when added to the party, when going in/out of range and when their stats update while in range
Players who get disconnected or relog should now find themselves back in the same party they were in previously
Added system messages to inform party members about updates to their party, and to let invited players know they've successfully joined a party (or rejoined, if relogging)
World saves now operate on the principle of only saving changes done since the last world save. Combined with the fact that NPCs in UOX3 are only active if there are players in the same/neighbouring map regions, shard owners may expect to see a decrease in world save times ranging from ~11% to ~99%, depending on how active and how spread out their player base is. If no changes have taken place since last save, saves are virtually instantaneous!
2021-09-20 21:35:17 +08:00
|
|
|
params[3] = INT_TO_JSVAL( damageType );
|
2012-11-03 18:11:04 +00:00
|
|
|
|
0.99.4x
Fixed an issue where the color of NPC corpse names would not always match up with the NPC's flag color
Fixed a bug where the baseRange and maxRange properties of ranged weapons would not get saved to world files. These values are now saved in the format of RANGE=baseRange,maxRange
Changed the way items are added to containers, to ensure that the order in which the items are displayed to the player always reflects the order in which they were added; now the most recent item added/moved in a container will always be rendered on top of older items.
Made adjustments to how items are randomly added to containers; should use more of a given container gump's available area now
Exposed Item property to JS engine, which contains serial of the creator of an item:
.creator // contains serial of the creator of an item. If set, maker's marks will show up in the item's tooltip
Fixed an issue where JS engine would lose track of script context if one script used CreateDFNItem() or SpawnNPC() functions and the new objects had events that triggered upon creation. UOX3 now restores the original script context at the tail end of these functions.
Added new JS Event to allow inserting custom tooltip text for objects, which will be displayed in tooltips right after the object name. Any text returned from the event will be displayed, and the text can make use of the same HTML tags as gumps to make changes to color, font, etc.
onTooltip( myObj ) // Triggers for objects right before the object's tooltip properties are sent to client
Updated 'tweak and 'set commands to refresh item being modified if movable state of item changes, so the change is reflected in nearby clients
Fixed an issue with NPC vendors and items bought from players not being properly removed from the vendor's "bought container" when players buy them again
Ported Item Identification skill from code to JS (js/skill/itemid.js) and removed hard-coded version
Implemented magic item generator in JS (js/item/magic_item.js). When this script is attached to an NPC, it has a chance to generate magic weapons, armors, wands/staffs and rings as loot on the NPC's corpse when slain. The chance of getting quality magical items increases with the fame level of the NPC in question. The types of magical items generated follows the pattern of such items as implemented in UO prior to the AoS expansion.
Examples:
exceedingly accurate war hammer of vanquishing
substantial, accurate axe of power and Daemon's Breath
silver long sword
massive platemail arms of Protection
metal shield of defense
durable ringmail tunic of guarding
All magic items have a chance to have spell effects attached (with rings/wands being guaranteed to have these), with a limited amount of charges available. For weapons, these effects activate on successful hits in combat, while for armors they activate on equip, and then periodically as long as the item is worn. Rings and wands/staffs have to be manually activated and targeted - with the exception of rings of invisibility, which activate the moment you equip them!
Related scripts:
js/item/magic_armor_equipeffects.js
js/item/magic_weapon_accbonus.js
js/item/magic_weapon_equip.js
js/item/magic_weapon_spell_attack.js
The magic item loot generation script has been attached to a number of different NPCs, all of which now have a chance to drop magic items as loot when defeated.
A bonus magical item - the glacial staff - has also been implemented (js/item/magic_glacial_staff.js), and has a chance to drop as loot from Giant Ice Serpents!
Fixed an issue with CustomTarget where the target message would not be displayed if the cursorType parameter was provided
Fixed bug with 'rename command, which referenced a non-existing variable that caused a script crash
Added additional object properties to 'get and 'set commands:
.shouldSave // Determines if an item should be saved in worldfiles or not
.baseRange // Determines the base range of a ranged weapon, less than which it becomes less effective
.maxRange // Determines the max range of a ranged weapon, beyond which it cannot reach its target
The feature that allows stats like Strength, Dexterity and Intelligence to provide bonuses to skill checks has been turned into a UOX.INI setting, which is disabled by default. The bonuses have also been nerfed; they will no longer contribute more to the success of a skill check than the actual skill being checked!
STATSAFFECTSKILLCHECKS=0/1 // If enabled, stats can provide bonuses to skill checks based on the weighting for those stats as setup in dfndata/skills/skills.dfn
Updated damage tracking code to include the type of damage that was dealt (PHYSICAl vs HEAT vs COLD, etc)
Updated Character JS Method Damage() to include a new parameter that can specify the type of damage that was dealt to the character. The new parameter must always be included if other optional parameters are used. Note that updates might be required for scripts making use of this method.Updated syntax:
.Damage( amount )
.Damage( amount, damageType )
.Damage( amount, damageType, attacker )
.Damage( amount, damageType, attacker, doRepsys )
Supported damageTypes:
PHYSICAL = 1
LIGHT = 2
RAIN = 3
COLD = 4
HEAT = 5
LIGHTNING = 6 // magic damage
POISON = 7
SNOW = 8
Updated JS Event OnDamage to include an additional parameter that describes the type of damage that was dealt. New syntax:
onDamage( damaged, attacker, damageValue, damageType )
Updated JS Event OnSpellTarget to allow rejecting a spell being cast on a target by returning a value of 2 from the script
Split the character priv flag for magic reflection into a temporary one (one-time magic reflection spell) and a permanent one (innate permanent reflection ability). The temporary effect is put in place by Magic Reflection spell, and is removed after a successful spell reflect. The permanent one is an innate ability of a character and is not removed even after a spell is reflected.
Added new Character JS property to get/set state of a character's permanent magic reflect ability:
.permanentMagicReflect // 0 = disable, 1 = enable
Added special abilities/effects for the following NPCs:
Acid Elementals now have a chance to damage the melee weapons of their attackers
Dull Copper Elementals now explode on death
Shadow Iron Elemental is immune to targeted spell damage
Copper Elementals have permanent magic reflect, and reflect some physical damage back at their attacker
Bronze Elementals deal passive area damage to nearby players every 5 to 10 seconds
Valorite Elementals have permanent magic reflect, reflect some physical damage back at their attacker
Snow/Ice Elementals deal passive area damage to nearby players every 5 to 10 seconds
Lava Serpents deal passive area damage to nearby players every 5 to 10 seconds
Phoenixes deal passive area damage to nearby players every 5 to 10 seconds
Pixies have a chance to cast a random spell upon receiving a death blow:
Bless (target)
Curse (target)
Explosion (target)
Greater Poison (target)
Greater Heal (self, prevents death)
Ethereal Warriors will now resurrect dead players with positive karma
Ethereal Warriors now have a chance to drain target's health, stamina or mana on hit
Fire Breath special ability added to the following NPCs, with the random ability damage scaling with the NPCs current health:
Hell Cat, 5 to 8 dmg at max health
Fire Steed, 6 to 9 dmg at max health
Hell Hounds, 8 to 11 dmg at max health
Lava Lizard, 8 to 11 dmg at max health
Predator Hell Cat, 9 to 14 dmg at max health
Sea Serpent, 11 to 17 dmg at max health
Swamp Dragon, 15 to 22 dmg at max health
Armored Swamp Dragon, 15 to 22 dmg at max health
Fire Gargoyle, 20 to 30 dmg at max health
Deep Sea Serpent, 21 to 32 dmg at max health
Serpentine Dragon, 22 to 32 dmg at max health
Drake (Gray), 22 to 32 dmg at max health
Drake (Red), 22 to 32 dmg at max health
Nightmare, 26 to 39 dmg at max health
Dark Steed, 26 to 39 dmg at max health
Silver Steed, 26 to 39 dmg at max health
Kraken, 39 to 59 dmg at max health
Dragon (Red), 41 to 62 dmg at max health
Dragon (Gray), 41 to 62 dmg at max health
Shadow Wyrm, 50 to 75 dmg at max health
Reptalon, 51 to 77 dmg at max health
Skeletal Dragon, 52 to 77 dmg at max health
Ancient Wyrm, 60 to 90 dmg at max health
Update stats, skills and loot for all currently implemented NPCs
Removed an ancient piece of code that prevented corpses from being generated for various elementals and blade spirits on death. This was originally put in place because these creatures had no corpses, and would replace it with a backpack instead, but these creatures now all have corpses in all client versions supported by UOX3
Updated potions script (js/item/potion.js) with updated formula for amount of hitpoints healed by healing potions, and added restrictions for using them when at full health and/or if poisoned (Dragon Slayer)
Fixed a bug where creatures (and humans, if FORCENEWANIMATIONPACKET was disabled in uox.ini) would play animations with wrong frame count, causing the animations to either freeze for a few frames at the end, or get cut off a couple of frames early
Implemented bonus hit chance for Archery skill, based on mention of such a bonus in Publish 5 patch notes and related UO House of Commons chat. This has been exposed as a UOX.INI setting where this bonus can be tweaked:
ARCHERYHITBONUS=10 // Bonus hit chance for Archery skill added to regular hit chance in combat. Defaults to 10%
Implemented optional extra delay between moving and being able to shoot with ranged weapons in combat (in addition to whatever delay is there due to speed of the ranged weapon). This is exposed as a UOX.INI setting:
ARCHERYSHOOTDELAY=0.5 // Minimum delay in seconds from a player stops moving until they can start to fire their ranged weapon. Defaults to 0.5s
Fixed a bug where players who never entered combat mode could fire ranged weapons while moving
Updated Add-menu with some improvements for usability:
Menu now directly on the Objects (previously "Shard") tab for quicker access, with a small welcome text and quick-link button for UOX3 docs
Settings tab contains some (persistent, will be saved with character) options for how the Add-menu behaves, along with a few quick-access buttons to some useful commands. Available options:
Option to add chosen item at specific location instead of in GM's backpack
Option to add chosen item repeatedly until cancelled
Option to automatically reopen Add-menu on last menu that was open when a selection is made
Option to force decayable state of all added items to either off (doesn't decay), on (decays) or nothing (use item default)
Option to force movable state of all added items to either off (not movable), on (movable) or nothing (use item default)
Added a Home button at the bottom of the menu, that takes the user back to the front page of the Add-menu regardless of which menu page they're on
Updated Character/Socket JS Method SysMessage() with an optional parameter to specify the color used to display the system message. Updated syntax:
.SysMessage( "Text" ) // Display "Text" to user as a system message with default system message color from ini
.SysMessage( "Text %s %s", txtArg1, txtArg2 ) // Display "Text" to player with string arguments injected into text
.SysMessage( txtColor, "Text" ) // Display "Text" to user with a specified color
.SysMessage( txtColor, "Text %s %s", txtArg1, txtArg2 ) // Combination of text color, text and string arguments
Fixed a bug where hair/beard items could show up inside corpses
Fixed a bug where items could sometimes vanish (visually) from containers when bouncing back because player was not able to pick them up
Fixed a bug where players would be unable to pick up a freely movable item from a locked down container
Updated handling of item bouncing on pickup to use UOX3 dictionary messages instead of hard-coded client messages
Added support for new Dictionary language:
dictionary.POL - Polish (SERVERLANGUAGE=8 in uox.ini, or client language 83 if SERVERLANGUAGE is set to 0)
Added taming restrictions for Unicorn, Ki-Rin and Cu Sidhe (js/skill/taming.js)
Added modification of some creatures stats after they've been tamed (js/skill/taming.js)
Added restrictions for who can ride certain creatures (Unicorn, Ki-Rin, Cu Sidhe)
Updated words of power for Meteor Swarm spell to follow the same logic as other spells using Kal (Summon): Kal Des Flam Ylem
Added new Item/Character JS Methods to get/set temporary custom tags which don't persist across worldsaves (or across reconnects, for players):
.GetTempTag( "tagName" )
.SetTempTag( "tagName", tagValue )
When applying HPMAX, STAMINAMAX AND MANAMAX DFN tags to new NPCs, their current HP, STAMINA and MANA properties will now be automatically updated to match
Fixed a server crash caused by empty speech messages sent from certain clients
Fixed a bug that prevented teleport locations in Felucca/Trammel from working properly
Updated calculations in code for duration and damage of existing poison strengths (1 - Lesser, 2 - Normal, 3 - Greater, 4 - Deadly) to match with ~Publish 15 (LBR/pre-AoS), and added another poison strength for monster usage (5 - Lethal)
The strength of the Poison and Poison Field spells is now based on the average of the caster's Magery and Poisoning skills, the distance from the target (Poison spell only) and the target's Resisting Spells skill. If caster is further away than 2 tiles from target, the poison strength always equals Lesser Poison, otherwise the following rules apply:
If caster's combined skill is higher than 100.0, poison strength equals Greater Poison, with 5% chance of Deadly Poison (if Poison spell) or Deadly Poison (if Poison Field spell)
If caster's combined skill is higher than 70.2, poison strength equals Greater Poison
If caster's combined skill is higher than 30.2, poison strength equals Normal Poison
If caster's combined skill is 30.2 or lower, poison strength equals Lesser Poison
If target resists spell, poison strength is reduced by 1 level, unless it's already at the lowest level
Fixed an issue that would would let players move faster than they should have been allowed to
Fixed misc issues with Party System:
Mana and Stamina should now update for Party Members when added to the party, when going in/out of range and when their stats update while in range
Players who get disconnected or relog should now find themselves back in the same party they were in previously
Added system messages to inform party members about updates to their party, and to let invited players know they've successfully joined a party (or rejoined, if relogging)
World saves now operate on the principle of only saving changes done since the last world save. Combined with the fact that NPCs in UOX3 are only active if there are players in the same/neighbouring map regions, shard owners may expect to see a decrease in world save times ranging from ~11% to ~99%, depending on how active and how spread out their player base is. If no changes have taken place since last save, saves are virtually instantaneous!
2021-09-20 21:35:17 +08:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onDamage", 4, params, &rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
SetEventExists( seOnDamage, false );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
return ( retVal == JS_TRUE );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Function - SI08 OnBuy( CSocket *tSock, CChar *objVendor )
|
|
|
|
|
//| Date - 26th November, 2011
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Purpose - Runs on vendors, triggered before vendor trade-gump is opened
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnBuy( CSocket *tSock, CChar *objVendor )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2021-06-12 07:30:23 -04:00
|
|
|
if( !ValidateObject( objVendor ) || tSock == nullptr )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnBuy, "onBuy" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, tSock, runTime );
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, objVendor, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onBuy", 2, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnBuy, false );
|
|
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Function - SI08 OnSell( CSocket *tSock, CChar *objVendor )
|
|
|
|
|
//| Date - 26th November, 2011
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Purpose - Runs on vendors, triggered before vendor trade-gump is opened
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnSell( CSocket *tSock, CChar *objVendor )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2021-06-12 07:30:23 -04:00
|
|
|
if( !ValidateObject( objVendor ) || tSock == nullptr )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnSell, "onSell" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, tSock, runTime );
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, objVendor, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSell", 2, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnSell, false );
|
|
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Function - SI08 OnBuyFromVendor( CSocket *tSock, CChar *objVendor, CBaseObject *objItemBought )
|
|
|
|
|
//| Date - 26th November, 2011
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Purpose - Allows determining what happens when an item is in the process of being bought
|
|
|
|
|
//| from an NPC vendor. Returning false/0 from the script will halt the purchase
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnBuyFromVendor( CSocket *tSock, CChar *objVendor, CBaseObject *objItemBought )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2021-06-12 07:30:23 -04:00
|
|
|
if( !ValidateObject( objVendor ) || !ValidateObject( objItemBought ) || tSock == nullptr )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnBuyFromVendor, "onBuyFromVendor" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, tSock, runTime );
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, objVendor, runTime );
|
2021-06-12 07:30:23 -04:00
|
|
|
JSObject *myObj2 = nullptr;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( objItemBought->GetObjType() == OT_ITEM )
|
|
|
|
|
myObj2 = JSEngine->AcquireObject( IUE_ITEM, objItemBought, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( myObj2 );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onBuyFromVendor", 3, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnBuyFromVendor, false );
|
|
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Function - SI08 OnSellToVendor( CSocket *tSock, CChar *objVendor, CBaseObject *objItemSold )
|
|
|
|
|
//| Date - 26th November, 2011
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Purpose - Allows determining what happens when an item is in the process of being sold to
|
|
|
|
|
//| an NPC vendor. Returning false/0 from script will halt the sale
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnSellToVendor( CSocket *tSock, CChar *objVendor, CBaseObject *objItemSold )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2021-06-12 07:30:23 -04:00
|
|
|
if( !ValidateObject( objVendor ) || !ValidateObject( objItemSold ) || tSock == nullptr )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnSellToVendor, "onSellToVendor" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, tSock, runTime );
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, objVendor, runTime );
|
2021-06-12 07:30:23 -04:00
|
|
|
JSObject *myObj2 = nullptr;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( objItemSold->GetObjType() == OT_ITEM )
|
|
|
|
|
myObj2 = JSEngine->AcquireObject( IUE_ITEM, objItemSold, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( myObj2 );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSellToVendor", 3, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SetEventExists( seOnSellToVendor, false );
|
|
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Function - SI08 OnBoughtFromVendor( CSocket *tSock, CChar *objVendor, CBaseObject *objItemBought )
|
|
|
|
|
//| Date - 26th November, 2011
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Purpose - Allows determining what happens AFTER an item has been
|
|
|
|
|
//| bought from an NPC vendor
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnBoughtFromVendor( CSocket *tSock, CChar *objVendor, CBaseObject *objItemBought )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2021-06-12 07:30:23 -04:00
|
|
|
if( !ValidateObject( objVendor ) || !ValidateObject( objItemBought ) || tSock == nullptr )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnBoughtFromVendor, "onBoughtFromVendor" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, tSock, runTime );
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, objVendor, runTime );
|
2021-06-12 07:30:23 -04:00
|
|
|
JSObject *myObj2 = nullptr;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( objItemBought->GetObjType() == OT_ITEM )
|
|
|
|
|
myObj2 = JSEngine->AcquireObject( IUE_ITEM, objItemBought, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( myObj2 );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onBoughtFromVendor", 3, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
SetEventExists( seOnBoughtFromVendor, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Function - SI08 OnSoldToVendor( CSocket *tSock, CChar *objVendor, CBaseObject *objItemSold )
|
|
|
|
|
//| Date - 26th November, 2011
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
//| Purpose - Allows determining what happens AFTER an item has been
|
|
|
|
|
//| sold to an NPC vendor
|
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
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
2012-11-03 18:11:04 +00:00
|
|
|
SI08 cScript::OnSoldToVendor( CSocket *tSock, CChar *objVendor, CBaseObject *objItemSold )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2021-06-12 07:30:23 -04:00
|
|
|
if( !ValidateObject( objVendor ) || !ValidateObject( objItemSold ) || tSock == nullptr )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( !ExistAndVerify( seOnSoldToVendor, "onSoldToVendor" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2012-11-03 18:11:04 +00:00
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, tSock, runTime );
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, objVendor, runTime );
|
2021-06-12 07:30:23 -04:00
|
|
|
JSObject *myObj2 = nullptr;
|
2012-11-03 18:11:04 +00:00
|
|
|
if( objItemSold->GetObjType() == OT_ITEM )
|
|
|
|
|
myObj2 = JSEngine->AcquireObject( IUE_ITEM, objItemSold, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[2] = OBJECT_TO_JSVAL( myObj2 );
|
Numerous changes with focus on feature and stability parity across Windows, Linux and MacOS platforms
Added new Makefile that handles compiling UOX3 and Spidermonkey on both Linux and MacOS (punt)
Added VS solution (SpiderMonkey.sln) and VC++ project files for compiling SpiderMonkey on Windows (Xuri)
Updated SpiderMonkey from v1.6.0 to v1.7.0
Added optimization flag -O2 for release build in CMakeLists.txt in project root (Xuri)
Added StringUtility file with general common string manipulation functions (punt)
Updated RandomNum function to use a "seedless" random number generator from C++11 instead of the old C rand() function. (punt)
Overall code cleanup to remove/replace platform-dependent code (punt)
Replaced potentially unsafe usage of C string stuff like sprintf, vsprintf, vsnprintf, strncat, strcpy and strlen throughout the code with calls to a format() function containing only a single, safe use of vsnprintf, ensuring there's a single place of failure if there's anything to fix and and making it easy to potentially replace this with std::format from C++20 when the time comes. (punt)
Replaced usage of char in many places with std::string (punt)
Started process of replacing UString usage with functions provided through StringUtility instead (punt)
Replaced platform specific fileIO handling in Windows/Linux with cross-platform C++17 standard std::filesystem (punt)
Replaced platform specific time handling by using cross-platform chrono library (punt)
Removed UOX namespace to reduce complexity (punt)
Elimitated template code approach to singletons for more modern c++ constructs, removing dependices in the process (punt)
Removed ODBC support; it hasn't been touched since the initial implementation in 2008, and there is a lack of someone to maintain the code. (punt)
Removed some platform specific files like uoxlinux.h, which is no longer required (punt)
Removed legacy crash protection code, and removed support for cluox (punt)
Removed legacy "support" for Borland compiler (punt)
Removed legacy VC++ 6 Workspace/Project files, VS2005 Solution/Project files, as these are no longer supported (Xuri)
Removed legacy BUILD folder with outdated compilation instructions (Xuri)
Removed old Changelog file (merged into Changelog.txt) (Xuri)
Fixed a pointer bug for items in multis on world load (punt)
Fixed a dictionary related issue that caused segmentation faults on Linux/MacOS (punt)
Fixed an issue with callbacks to JS scripts that caused segmentation faults on Linux/MacOS (punt)
Paths in uox.ini should now load properly on all platforms regardless of whether those paths use slashes or backslashes, and whether or not they end in a slash/backslash. (punt)
Moved to c++17 style of threading, and got rid of threadsafeobject.cpp/h (punt)
Replaced parsing of UOX.INI tags with a system that's more easily maintainable (punt)
Added some new commands to js/commands/custom/misc-cmd.js (Xuri)
cont // Targeted item will be made a container, set to nondecay and movable 2
endfight // Targeted character (and character being fought) will stop fighting
getmulti // Get multiObject for targeted item
finditem // Find item at layer X
movespeed // Set movement speed of target player (0x0 Normal, 0x1 Mounted, 0x2 Slow (walk only), 0x3 Hybrid ("jog"?), 0x4 Frozen)
Added new HTML based documentation in docs folder, and removed many old legacy docs that are either incorporated into this document already or no longer relevant for the current UOX3 version (Xuri)
Co-Authored-By: Charles Kerr <punt1959@users.noreply.github.com>
2020-09-07 18:09:55 +08:00
|
|
|
|
2012-11-03 18:11:04 +00:00
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onSoldToVendor", 3, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2012-11-03 18:11:04 +00:00
|
|
|
SetEventExists( seOnSoldToVendor, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2012-11-03 18:11:04 +00:00
|
|
|
}
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Function - SI08 OnHouseCommand( CSocket *tSock, CMultiObj *objMulti )
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Allows overriding house commands via JS script attached to multi
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
SI08 cScript::OnHouseCommand( CSocket *tSock, CMultiObj *objMulti, UI08 cmdID )
|
|
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2021-06-12 07:30:23 -04:00
|
|
|
if( !ValidateObject( objMulti ) || tSock == nullptr )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
if( !ExistAndVerify( seOnHouseCommand, "onHouseCommand" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
|
|
|
|
|
jsval rval, params[3];
|
|
|
|
|
JSObject *myObj = JSEngine->AcquireObject( IUE_SOCK, tSock, runTime );
|
|
|
|
|
JSObject *multiObj = JSEngine->AcquireObject( IUE_ITEM, objMulti, runTime );
|
|
|
|
|
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( myObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( multiObj );
|
|
|
|
|
params[2] = INT_TO_JSVAL( cmdID );
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onHouseCommand", 3, params, &rval );
|
|
|
|
|
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
Housing Revamp and more
Updated JS SysMessage function to accept up to 10 extra, optional arguments, which can be used with dictionary messages that require additional parameters like %s or %i
Added new type of house privilege in cMultiObj.cpp to keep track of friends of the multi - HOUSEPRIV_FRIEND - which is stored during worldsaves as one or more Friend=<player serial> tags in house.wsc
Added new type of house privilege in cMultiObj.cpp to keep track of guests of the multi - HOUSEPRIV_GUEST - which is stored during worldsaves as one or more Guest=<player serial> tags in house.wsc
When items are created for houses upon house placement, a reference to the multi's serial is now stored in the house sign's MORE property to allow easier tracking of which house a particular sign belongs to
Added tracking of new, persistent properties for houses via cMultiObj.cpp/h:
lockdowns, secure containers, vendors, guests, friends, owners, ban location, public status, number of visits, timestamps
Added a multitude of new methods in cMultiObj.cpp/h to assist in improving the functionality of houses
Added new tags for houses in house.dfn (default values applied if tag not specified):
MAXSECURECONTAINERS=4 - Max amount of secure containers allowed in a multi
MAXLOCKDOWNS=256 - Max amount of lockdowns allowed in a multi
MAXVENDORS=10 - Max amount of vendors allowed in a multi
MAXBANS=50 - Max amount of bans in a multi's ban list
MAXFRIENDS=50 - Max amount of friends in a multi's friend list
MAXGUESTS=50 - Max amount of guests in a multi's guest list
MAXOWNERS=8 - Max amount of owners and co-owners in a multi's owner list
MAXTRASHCONTAINERS=1 - Max amount of trash containers allowed in multi
SCRIPT=<scriptID> - Assign a JS script-ID directly to a multi
FRONTDOOR - indicates that a door is the front door of a house. Cannot be locked in public houses!
INTERIORDOOR - indicates that a door is an interior door of a house. Can be locked in public houses.
BANX - Location X offset for multi's ban location, if not used, will try to use SE corner of multi instead
BANY - Location Y offset for multi's ban location, if not used, will try to use SE corner of multi instead
Added JS Event:
onHouseCommand( tSock, multiObj, cmdID ) - For handling spoken house commands via JS scripts attached to multi.
Updated JS Events:
onEntrance() - can now trigger both for multi being entered and/or object entering
onLeaving() - can now trigger both for multi being left and/or object entering
onSpeech() - can now also trigger for items (in addition to chars) with event & script attached, if UOX.INI setting ITEMSDETECTSPEECH is enabled
Added JS Multi methods:
.IsBoat() - Returns whether the item (or multi) is a boat
.IsOwner( playerToCheck ) - Returns whether a player is the owner of a multi
.IsOnOwnerList( playerToCheck ) - Returns whether a player is on the (co-)owner list of a multi
.IsOnFriendList( playerToCheck ) - Returns whether a player is on the friend list of a multi
.IsOnGuestList( playerToCheck ) - Returns whether a player is on the guest list of a multi
.IsOnBanList( playerToCheck ) - Returns whether a player is on the ban list of a multi
.AddToFriendList( playertoAdd ) - Adds player to the friend list of a multi
.RemoveFromFriendList( playertoRemove ) - Removes player from the friend list of a multi
.AddToGuestList( playertoAdd ) - Adds player to the guest list of a multi
.RemoveFromGuestList( playertoRemove ) - Removes player from the guest list of a multi
.ClearOwnerList() - Clears all entries from a multi's (co-)owner list
.ClearFriendList() - Clears all entries from a multi's friend list
.ClearGuestList() - Clears all entries from a multi's guest list
.ClearBanList() - Clears all entries from a multi's ban list
.SecureContainer( itemToSecure ) - Secures a container in a multi
.UnsecureContainer( itemToUnsecure ) - Unsecures a container in a multi
.IsSecureContainer( itemToCheck ) - Checks if specified item is a secure container in a multi
.LockDownItem( itemToLockDown) - Locks down an item in a multi
.ReleaseItem( itemToRelease ) - Releases a locked down item in a multi
.KillKeys() - Deletes ALL keys associated with a multi
.AddTrashCont( itemToAdd ) - Add trash container to multi's list of trash containers
.RemoveTrashCont( itemToRemove ) - Remove trash container from multi's list of trash containers
Added JS Item (Multi only) properties:
.lockdowns - Get the number of lockdowns in a multi
.maxLockdowns - Get/Set the max number of lockdowns allowed in a multi
.secureContainers - Get the number of secure containers in a multi
.maxSecureContainers - Get/Set the max number of secure containers allowed in a multi
.trashContainers - Get the number of trash containers in a multi
.maxTrashContainers - Get/Set the max number of trash containers allowed in a multi
.friends - Get the number of friends in a multi's friend list
.maxFriends - Get/Set the max number of friends allowed in a multi's friend list
.guests - Get the number of guests in a multi's guest list
.maxGuests - Get/Set the max number of guests allowed in a multi's guest list
.owners - Get the number of owners in a multi's owner list
.maxOwners - Get/Set the max number of owners allowed in a multi's owner list
.bans - Get the number of banned players in a multi's ban list
.maxBans - Get/Set the max number of banned players allowed in a multi's ban list
.vendors - Get the number of player vendors in a multi
.maxVendors - Get the max number of player vendors allowed in a multi
.deed - Get the item sectionID for deed used to place multi
.isPublic - Get/Set the private/public state of a multi
.buildTimestamp - Get the timestamp for when the house was originally placed
.tradeTimestamp - Get the timestamp for when the house was last traded to another player
.banX - Get/Set the ban location X offset for the multi
.banY - Get/Set the ban location Y offset for the multi
Added JS Character properties:
.multi = Get/Set the multi object the character is in
.accountNum = Get the account number the character belongs to
.housesOwned = Get a count of houses owned by the character
.housesCoOwned = Get a count of houses co-owned by the character
Updated JS cBaseObject Methods .FirstItem(), .NextItem() and .FinishedItems() to also support iterating through items in multis
Updated JS multi Methods .FirstChar(), .NextChar() and .FinishedChars() to support an additional parameter to specify what kind of characters to loop through:
"default" or no parameter - all characters inside the multi
"owner" - players on multi's owner list
"friend" - players on multi's friend list
"guest" - players on multi's guest list
"banned" - players on multi's ban list
Added new INI tags to a new section of uox.ini called [houses]
DECAYTIMERINHOUSE=3600 // Decay timer in seconds for non-locked down items inside houses
PROTECTPRIVATEHOUSES=1 // Toggles whether private houses will automatically boot unauthorized visitors (1) or not (0)
TRACKHOUSESPERACCOUNT=1 // Toggles whether to track (and restrict) house ownership per account (1) or per character (0)
MAXHOUSESOWNABLE=1 // Specifies the max amount of houses a player can own per account/char, depending on how house ownership is tracked
MAXHOUSESCOOWNABLE=10 // Specifies the max amount of houses a player can co-own per character
CANOWNANDCOOWNHOUSES=1 // Toggles whether players can own and co-own houses at the same time
COOWNHOUSESONSAMEACCOUNT=1 // Toggles whether characters on same account as house owner will be treated as co-owners
Added new INI tags in [settings] section of uox.ini:
ITEMSDETECTSPEECH=0 // If enabled, server will search for nearby items with onSpeech JS event running whenever a character speaks. Disabled by default.
MAXPLAYERPACKITEMS=125 // Defines max item capacity for player (and NPC) backpacks. Defaults to 125.
Moved most of the existing house functionality to JS and expanded upon it to reach feature parity with houses in regular UO around Publish 15/16, with various extras thrown in for good measure and all functionality being customizable:
js/server/house/house.js (15000) - handles detection of house commands and characters entering/leaving houses
js/server/house/houseSign.js (15001) - contains and handles all house-related gumps/menus and what is shown when players interact with house sign
js/server/house/houseCommands.js (15002) - handles functionality of house commands and other functionality such as transfer of ownership, demolishing house, etc.
js/server/house/houseDeed.js (15003) - handles initial rules that allow/disallow placement of additional houses for players
All house-related menus now fully handled through JS
All house commands and other functionality now fully handled through JS
Removed redundant hard-coded house functionality
Implemented Co-owners, friends, guests for houses, with access rules in place for entry, lockdowns, house commands, etc.
Implemented Private and Public houses
Implemented Secure Containers and Trash Barrels
Definable max lockdowns, secure containers, player vendors, bans, friends, guests, owners, trash containers and more - per house type
JS scripts can now be attached directly to houses
Doors in houses can be marked as front doors or interior doors, and will be treated differently with regards to private and public houses
Added new item to dfndata/items/containers/misc.dfn - [trashbarrel]
Added new JS script (js/items/trashbarrel.js) with trash barrel functionality for houses. Trash barrels that are marked as secure containers are only accessible by owners, co-owners and friends of the house. Various options available at top of script.
Updated js/items/axe.js to support chopping up trash barrels and house add-ons in houses owned by the player
Fixed an issue with house doors being left behind after demolishing houses while their doors were open
Fixed an issue where GMs could be banned from player houses
Added Line of Sight checks to speech, to give players some privacy in their own homes
Updated house placement code to more accurately check for other multis, dynamic and static objects when placing houses; now requires free space around each house that cannot be blocked by other houses or items that can block player movement, and disallows placement of houses on roads
Updated house placement code to move characters blocking house placement to SE corner of the house
Updated house placement code to disallow placing houses in guarded regions, or in dungeons
Added new DFN tag for regions to enable/disable player houses in specific regions: HOUSING=0/1
Added new region (247) that covers path to Valley of Eodon in Felucca
Added new region (248) that covers Valley of Eodon in Ter-Mur, with player housing disabled
Added new region (249) that covers entire T2A lands, with player housing disabled
Updated SPACEX and SPACEY values for all houses in dfndata/house/house.dfn to match updated house placement code
Added new JS property to Regions that can be used to determine or change state of player housing in a region: .canPlaceHouse()
Updated rules for usage of dye tubs to dye locked down items; now only house owners or co-owners may dye locked down items
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners and co-owners
Dyes, Guildstone Deeds, Recall Runes (renaming), Rename Deeds, Townstone Deeds, House Deeds, Boat Models, Player Vendor Deeds, Ore, Hair Dye
Updated rules for usage of the following locked down items in a house, which are now only usable by house owners, co-owners and friends:
Keys, Dye Tubs, Magic Scrolls, Fireworks Wands, Magic Wands, Smithing Tools, Mining Tools, Fishing Poles
Updated item lockdown rules to allow locking down (and releasing) items in a container as long as the container is locked down, and to only allow releasing a locked down container if it's empty of locked down items
Updated item lockdown rules to only allow locking down movement-blocking items further than 2 tiles away from doors
Updated rules for releasing items in houses - now the house owner can release any locked down items, co-owners can release items locked down by themselves or by friends, while friends can release only items locked down by themselves
Added some feedback to player about why their attempted house placement failed
Items added by GMs directly into multis will now decay based on the house-specific decay timer instead of the regular one
Fixed an issue that could cause items to almost instantly decay after being released from lockdown in a house
Placing house add-ons now properly takes into account SPACEX and SPACEY values when checking if they can fit in selected area of houses
Re-added SPACEX and SPACEY values for Pentagram and Loom house add-ons
House add-ons can now be converted back into house add-on deeds by chopping them with an axe
Added new item type - IT_HOUSEADDON (201) - used by house add-ons placed in player houses
Fixed a bug where keys would stop working after being added to a keyring, and would turn into blank keys upon release from the keyring
Added visitor count for public player houses, which keeps track of how many visits a public house has received, with each player counted max 1 time every 24 hours
Fixed an issue with FindPlayersInOldVisrange() where it didn't take into account that players could see buildings further away than the standard update range. This could cause players to see ghost images of buildings if they were at the "right" distance when the building was being demolished
Added NODECAY tag to all signs and doors in dfndata/house/house.dfn
Added FRONTDOOR or INTERIORDOOR (as appropriate) to all doors in dfndata/house/house.dfn
Added BANX and BANY to specify ban location for some houses in dfndata/house/house.dfn instead of relying on finding SE corner automatically
Implemented strongboxes (js/server/house/strongbox.js) for co-owners of a house, which can be placed with the house command "i wish to place a strongbox". Max capacity is 25 items
Updated 'REMOVE command to take an optional parameter - itemID. If supplied, the command will remove all items with this itemID from a targeted container
Fixed a bug when checking if dynamic items were blocking valid spawn locations for NPCs, some function arguments were in the wrong order!
Improved code that finds valid spawn locations for items and NPCs spawned via spawn regions. As server gradually builds up lists of valid spawn locations per region over time, it will start using these lists more often, rather than always look for brand new spawn locations.
Fixed a bug with CMulHandler::CheckStaticFlag() that prevented NPCs from spawning inside buildings with no static floors!
Fixed an issue with repeating commands that prevented GMs from being able to cancel them when using the ClassicUO client
Exposed character property .accountNum to JS engine
Extended CDataList class to include a Clear() method for clearing lists
Updated JS File method .Open() to support an optional, third argument - subFolderName - that defines in which sub-folder of UOX3/shared/ to store/look for a file. If no third argument is supplied, UOX3 will default to using the shared folder itself.
Updated JS File method .Length() to return a value of -1 for files that don't exist
Added new code function, exposed to JS engine with same parameters, which simply checks if a given tile ID has a specific flag
bool CheckTileFlag( UI16 itemID, TILEFLAG flagToCheck )
Added JS function used to find the root container of an item (if any)
FindRootContainer( itemSerial )
FindRootContainer( item )
Added new JS function that allows deleting files from UOX3/shared/ folder or subfolders of shared folder. If no subFolderName is provided, looks for file directly in shared folder itself. Restrictions on file- and folder-names apply.
bool DeleteFile( fileName, subFolderName )
Added new JS functions for checking if a specific client or server feature is enabled. See documentation for full list of client/server features.
GetClientFeature( bitNum ) // Returns true if specified client feature is enabled on server
GetServerFeature( bitNum ) // Returns true if specified server feature is enabled on server
Added new JS function for returning the value of almost any server setting from UOX.INI
GetServerSetting( settingNameInDoubleQuotes )
Updated JS function DoesDynamicBlock() with two new parameters - checkOnlyMultis and checkOnlyNonMultis
Updated JS function DoesMapBlock() with two new parameters - checkMultiPlacement and checkForRoad
Fixed an issue where a LoS check would prevent players from accessing containers in their own backpack
Added new functions in findfuncs.cpp to make it easier to find items near another object or location:
findNearbyItems( object, distance )
findNearbyItems( x, y, worldNumber, instanceID, distance )
Added new Item property - maxItems - used by containers to determine their max item capacity
Added new Item property - totalItemCount - used to get total item count in a container (including sub-containers)
Added check for max item capacity when creating new items that are added to a character's backpack - items will be created below character's feet if backpack is full!
Added new DFN tag for items, used by containers to determine item capacity for a given container:
MAXITEMS=# // 125 is the default for all containers if not set
Added new JS Item properties:
.maxItems // gets/sets item capacity for a given container
.totalItemCount // gets total item count in a container, including sub-containers
Updated item tooltips for containers to show accurate total item count, as well as to display max item capacity
Fixed a bug where picking up items from a non-locked down pile of items on the floor inside a multi could cause the remaining pile to be seen as no longer inside the multi, disallowing locking it back down and causing it to decay based on regular decay timer instead of house-specific one
Updated JS command set to allow setting poison-level on items ('set poison #) and hunger-level on characters ('set hunger #)
Fixed an issue with js/item/food.js that prevented poisoned food from poisoning characters when eaten
Fixed an issue with js/skill/poisoning.js that prevented players from poisoning food!
Updated various JS scripts and hardcoded targeting functions to disallow the targeting of locked down resources using skills and tools
Updated JS Method TextMessage() to support three extra, optional parameters. Note that if one optional parameter is included, all preceding optional parameters are also required!
speechTarget - What kind of target is this message intended for?
0 - Only visible for sender and receiver of message
1 - Visible to all players in range
2 - Visible to all NPCs and players in range
3 - Visible to all PCs everywhere + NPCs in range
4 - Visible to all PCs everywhere (broadcast)
5 - Only visible for the receiver of the message
speechTargetSerial - The serial of the receiver of the message, used if speechTarget is 0 or 5
speechFontType - The type of font to display the text in. Defaults to normal.
0 - Bold
1 - Normal with shadow
2 - Bold with shadow
3 - Normal
4 - Gothic
5 - Italic
6 - Small, dark
7 - Colourful
8 - Runic (only works with CAPS)
9 - Small, light
Added timestamp to worldsaves in console, to make it easier to see when a particular world-save was done
Added info about compiler/environment displayed at the top of the UOX3 console during startup
Updated dictionary files with new messages primarily related to housing
2020-11-04 02:00:37 +08:00
|
|
|
SetEventExists( seOnHouseCommand, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TryParseJSVal( rval );
|
2020-11-14 02:46:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnPathfindEnd( CChar *ncp, SI08 pathfindResult )
|
2020-11-14 02:46:08 +08:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for NPCs after their pathfinding efforts come to and end
|
|
|
|
|
//| Notes - pathfindResult gives a value that represents how the pathfinding ended
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnPathfindEnd( CChar *npc, SI08 pathfindResult )
|
2020-11-14 02:46:08 +08:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2020-11-14 02:46:08 +08:00
|
|
|
if( !ValidateObject( npc ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2020-11-14 02:46:08 +08:00
|
|
|
if( !ExistAndVerify( seOnPathfindEnd, "onPathfindEnd" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2020-11-14 02:46:08 +08:00
|
|
|
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, npc, runTime );
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
2020-11-15 02:59:45 +08:00
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
2020-11-14 02:46:08 +08:00
|
|
|
params[1] = INT_TO_JSVAL( pathfindResult );
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onPathfindEnd", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2020-11-14 02:46:08 +08:00
|
|
|
SetEventExists( seOnPathfindEnd, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2020-11-14 02:46:08 +08:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
2020-11-15 02:59:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
//| Function - SI08 OnEnterEvadeState( CChar *npc )
|
2020-11-15 02:59:45 +08:00
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
|
|
|
//| Purpose - Triggers for NPCs when they enter the evade state after failing to pathfind to
|
|
|
|
|
//| a target in combat
|
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
SI08 cScript::OnEnterEvadeState( CChar *npc, CChar *enemy )
|
2020-11-15 02:59:45 +08:00
|
|
|
{
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
const SI08 RV_NOFUNC = -1;
|
2020-11-15 02:59:45 +08:00
|
|
|
if( !ValidateObject( npc ) || !ValidateObject( enemy ))
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2020-11-15 02:59:45 +08:00
|
|
|
if( !ExistAndVerify( seOnEnterEvadeState, "onEnterEvadeState" ) )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
2020-11-15 02:59:45 +08:00
|
|
|
|
|
|
|
|
JSObject *charObj = JSEngine->AcquireObject( IUE_CHAR, npc, runTime );
|
|
|
|
|
JSObject *enemyObj = JSEngine->AcquireObject( IUE_CHAR, enemy, runTime );
|
|
|
|
|
|
|
|
|
|
jsval params[2], rval;
|
|
|
|
|
params[0] = OBJECT_TO_JSVAL( charObj );
|
|
|
|
|
params[1] = OBJECT_TO_JSVAL( enemyObj );
|
|
|
|
|
|
|
|
|
|
JSBool retVal = JS_CallFunctionName( targContext, targObject, "onEnterEvadeState", 2, params, &rval );
|
|
|
|
|
if( retVal == JS_FALSE )
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
{
|
2020-11-15 02:59:45 +08:00
|
|
|
SetEventExists( seOnEnterEvadeState, false );
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return RV_NOFUNC;
|
|
|
|
|
}
|
2020-11-15 02:59:45 +08:00
|
|
|
|
Minor JS revamp - multiple scripts per object!
Added TryParseJSVal() helper function in cScript.cpp, used to parse jsval values returned from script events. Provides results matching 0 (0, false), 1 (1, true) or any specific int value returned from script.
JS events updated to use new TryParseJSVal helper function (no change in behaviour):
onDecay, onResurrect, onCommand, onBuyFromVendor, onSellToVendor, onPickup, onCharDoubleClick, onSkillGump, onUseBandageMacro, onCombatStart, onCombatEnd, onDeathBlow, onBuy, onSell
JS events with slight change of behaviour after update to use TryParseJSVal:
onDrop, onDropItemOnItem, onDropItemOnNpc - previously, a blank or non-existent return value would be treated the same as a return true. This will now be treated as a return false. Update scripts accordingly!
JS events updated to support return values from scripts:
onCollide, onTalk, onSnooped, OnHungerChange
Return false or nothing to prevent hard code from running
Return true to allow hard code to run like normal
onStolenFrom, onAISliver, onLightChange, onVirtueGumpPress, onQuestGump, onSpecialMove, onSwing, onClick, onHouseCommand, onSellToVendor, onSkillCheck, onSpellGain, onSpellLoss
Return false to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and other scripts with event from running
onSteal
Return false or nothing to allow hard code and other scripts with event to run like normal
Return true to prevent hard code and onStolenFrom event from running (theft failed?)
Return 2 to prevent hard code, but allow onStolenFrom event to run (theft succeeded, but handled in script?)
onLeaving, onEntrance, onEquip, onUnequip, onEnterEvadeState, onSoldToVendor, onBoughtFromVendor, onSpellSuccess, onSpellTarget, onFlagChange, onDeath
Return false or nothing to allow other scripts with event to run like normal
Return true to prevent other scripts with event from running
Added new JS events that run prior to items being equipped/unequipped, with support for return values:
onEquipAttempt( pEquipper, iEquipping )
onUnequipAttempt( pEquipper, iUnequipping )
Return false or nothing to reject attempt to equip/unequip item, and prevent hard-code or other scripts with event from running
Return true to allow hard code to run like normal
Added new JS event that runs prior to onSnooped event, for character doing the snooping:
onSnoopAttempt( snooped, snooper )
Return false or nothing to prevent hard code and other snooping-related events from running
Return true to allow hard code and other snooping-related events to run like normal
Updated onSnooped JS event to accept return values:
Return true when success state is true to prevent other scripts with event from running
Return true when success state is false to prevent hard code and other scripts with event from running
Updated onClick JS event to also run for characters with event attached (return 1 to prevent showing hard-coded name for whatever object is clicked)
Updated onSteal JS event to include a third parameter, an object reference for the target of the theft
Added support for assigning multiple JS scripts per object (item, multi, char, region).
Any time a scriptID is added to an object, the list of such IDs for that object will be sorted from lowest to highest scriptID, which also determines the execution order for the scripts. Note that if the same JS event is present in several scripts assigned to an object, each of those events will trigger, unless the rules about return values for said event prevent this
DFNs for Items, Multis, Characters and Regions can now contain multiple SCRIPT=scriptID tags per definition. Each such SCRIPT tag will be applied to the object in question, then sorted from lowest to highest scriptID by server.
Added new JS property for Items, Multis, Characters and Regions:
.scriptTriggers // If used to get property, will return array object with all script IDs assigned to object. If used to set property, will add script ID to existing list of script IDs for object.
Modified JS property for Items, Multis, Characters and Regions, which for backwards compatibility functions similar to in older versions:
.scripttrigger // If used to get property, will return last script ID in list of script IDs assigned to object. If used to set property, will clear list of script IDs and assign only the new ID
Added new JS Methods for Items, Multis, Characters and Regions:
.AddScriptTrigger( scriptID ) // Adds a new scriptID to list of scripts assigned to object
.RemoveScriptTrigger( scriptID ) // Remove a specific scriptID from object (0 = remove all)
Moved SETSCPTRIG command from code to JS (js/commands/targeting/scptrig.js), and supplemented it with some additional commands:
GETSCPTRIG // List out all scriptIDs assigned to object
SETSCPTRIG scriptID // Clears list of scriptIDs for object, then assigns the specified scriptID
ADDSCPTRIG scriptID // Adds specified scriptID to list of scriptsIDs assigned to object
REMOVESCPTRIG scriptID // Removes specified scriptID from list of scriptIDs assigned to object (0 = remove all)
2021-05-25 19:37:52 +08:00
|
|
|
return TryParseJSVal( rval );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool cScript::EventExists( ScriptEvent eventNum ) const
|
|
|
|
|
{
|
|
|
|
|
UI32 index = eventNum / 32;
|
|
|
|
|
if( index > 2 )
|
|
|
|
|
return false;
|
|
|
|
|
return eventPresence[index].test( (eventNum % 32) );
|
|
|
|
|
}
|
|
|
|
|
void cScript::SetEventExists( ScriptEvent eventNum, bool status )
|
|
|
|
|
{
|
|
|
|
|
UI32 index = eventNum / 32;
|
|
|
|
|
if( index > 2 )
|
|
|
|
|
return;
|
|
|
|
|
eventPresence[index].set( (eventNum % 32), status );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool cScript::NeedsChecking( ScriptEvent eventNum ) const
|
|
|
|
|
{
|
|
|
|
|
UI32 index = eventNum / 32;
|
|
|
|
|
if( index > 2 )
|
|
|
|
|
return false;
|
|
|
|
|
return needsChecking[index].test( (eventNum % 32) );
|
|
|
|
|
}
|
|
|
|
|
void cScript::SetNeedsChecking( ScriptEvent eventNum, bool status )
|
|
|
|
|
{
|
|
|
|
|
UI32 index = eventNum / 32;
|
|
|
|
|
if( index > 2 )
|
|
|
|
|
return;
|
|
|
|
|
needsChecking[index].set( (eventNum % 32), status );
|
2021-04-25 05:01:06 +08:00
|
|
|
}
|