Work in Progress!
I would suggest before proceeding that you read How to Make a Quest for a general breakdown of scripting to familiarize yourself with the basics
This guide is a look into some of the more advanced and uncommon elements of scripting. Here you will find help with how to use all of the currently available functions, as well as how to combine functions for useful (and often interesting!) results.
- 1 Function Breakdown
- 1.1 Getting Entity References
- 1.2 Getting Information About the World
- 1.3 Getting Information About an Entity
- 1.4 Manipulating the World
- 1.5 Manipulating an Entity
- 1.6 Miscellaneous
- 2 Conditionals Breakdown
- 2.1 Conditions Primarily Affecting PCs
- 2.2 Conditions Involving Multiple Entities
- 2.3 Conditions that Apply to PCs or NPCs
- 2.4 Conditions Applying only to Mob Entities
- 2.5 OnZoneInitialize
- 3 Advanced Scripting Techniques
- 4 See Also
A reference of all of the luautils functions available for use in scripting at the time of this writing. Additional "convenience" functions created in global scripts will not be covered here, and should be explored at your leisure. Basic familiarity with LUA syntax is assumed. For further information, you can reference src/map/lua/luautils.cpp and its accompanying header file.
Getting Entity References
Requires you to look up an NPC's ID and returns a reference that can be used to manipulate that NPC. How to use this will be covered more in the next section.
Similar to the above, except it is used for Mobs. Will also be covered more in the next section.
Mainly useful for GM commands, it returns a reference for a player that can be manipulated with additional functions. Names given to it are case-sensitive, so the first letter must be capitalized with the remaining lower-case.
Getting Information About the World
Retrieves a numerical value for the country that owns the region. These numerical values can be referenced with the aliases SANDORIA BASTOK WINDURST BEASTMEN or OTHER defined in scripts/globals/conquest.lua
Returns the Time of the Day as a number. The values to reference are stored in src/map/vana_time.h and should be put into a global script if you plan to use this.
Returns the current hour in the game-world. There are 24 hours in a day.
Returns the current minute in the game-world. There are 60 minutes in an hour.
Returns the current day of the year (similar to a Julian calendar) in the game-world. There are 12 months or 360 days in a Year.
Returns the current day of the month (as on a typical calendar) in the game-world. There are 30 days in a month.
Returns the current day of the week in the game world. There are 8 days in a week. Aliases for the return values can be found in scripts/globals/magic.lua
Retrieve a variable that affects the entire game world, rather than a specific character.
Getting Information About an Entity
Returns the current action of a mob entity as a number. This is usually checked against zero to see if a mob is currently taking no special action (general wandering).
Manipulating the World
Changes the offset from the universal Vana'Diel time. This should ONLY be used for testing, as there is a configuration option for the map server should you wish to offset your server permanently.
Starts a specific elevator in the game world. Unfortunately, there is no reference to assist you with this.
Sets a variable that affects the entire game world, rather than a specific character.
Manipulating an Entity
Used to create an instance of a specific mob in the game world. It cannot be used to spawn an arbitrary monster at a particular location. It can only produce mobs that are defined in the mob_spawn_points table.
Opposite of above. You should not attempt to use this on any sort of timer.
This is basically a method that is only used to propel characters up the cliff in the geyser spots at Dangruf Wadi.
Simply an abstraction of the C method for Bitwise AND
This is a list of conditions in which the core checks scripts. It should make some sense if you are already familiar with the ones used in the quest-writing tutorial.
Conditions Primarily Affecting PCs
Conditions Involving Multiple Entities
Conditions that Apply to PCs or NPCs
Conditions Applying only to Mob Entities
Advanced Scripting Techniques
A compendium of useful combinations of functions and techniques to help with scripting in tricky situations. If you don't understand how to execute something here properly, feel free to ask in Discord.
Other scripting situations not covered here: BCNM Scripting