Parameter Notation
Parameter prefixes indicate their data type:dw- DWORD (unsigned 32-bit integer)n- Integer (signed)b- Booleanby- BYTE (unsigned 8-bit integer)sz- String (null-terminated character array)f- Floatdl- Double or longw- WORD (unsigned 16-bit integer)
Event Handlers
Event handlers are automatically called by the game engine when specific events occur.Called when the mob is attacked by a character.Parameters:
dwTime(integer) - Current game time in ticksdwCharId(integer) - Character ID of the attacker
Called when the mob becomes attackable.Parameters:
dwTime(integer) - Current game time in ticksdwCharId(integer) - Character ID
Called when the mob’s AI resets to normal state.Parameters:
dwTime(integer) - Current game time in ticks
Called when the mob dies.Parameters:
dwTime(integer) - Current game time in ticksdwAttackedCount(integer) - Number of times the mob was attacked
Called when the mob returns to its spawn point (leash).Parameters:
dwTime(integer) - Current game time in ticksdwAttackedCount(integer) - Number of times the mob was attacked
Called when the mob finishes moving.Parameters:
dwTime(integer) - Current game time in ticks
Functions
These functions are called by the game engine at specific times.Called once when the mob is initialized. Use this to set up initial state variables.
Called repeatedly while the mob is in combat. Use this for combat behavior logic.Parameters:
dwTime(integer) - Current game time in ticksdwHPPercent(integer) - Current HP percentage (0-100)dwAttackedCount(integer) - Number of times attacked
Mob Methods
These methods are called on theMob object to control mob behavior.
Gets aggro information for a specific target.Parameters:
dwNumber(integer) - Target index
Gets the target with minimum aggro.
Orders surrounding mobs to attack a target.Parameters:
dwCharId(integer) - Target character IDdlPosX(double) - X coordinatedlPosZ(double) - Z coordinate
Makes the mob say a message within a specified distance.Parameters:
szMessage(string) - Message to displayfDist(float) - Maximum distance players can see the message
Makes the mob say a message using a system message index.Parameters:
wIndex(word) - System message indexfDist(float) - Maximum distance
Plays a voice file for the mob.Parameters:
szFileName(string) - Voice file namefDist(float) - Maximum distance
Gets the name of a character.Parameters:
dwCharId(integer) - Character ID
Spawns new mobs at a location.Parameters:
dwMobId(integer) - Mob type ID to spawnnCount(integer) - Number of mobs to spawndlPosX(double) - X coordinatedlPosZ(double) - Z coordinate
Makes the mob use a skill on a target.Parameters:
dwSkillId(integer) - Skill ID to usedwCharId(integer) - Target character ID
Sets the mob’s current target.Parameters:
dwCharId(integer) - Target character ID
Resets the targeting term/cooldown.Parameters:
dwTerm(integer) - Term duration in ticks
Sets whether the mob can only use Lua-scripted attacks.Parameters:
bLuaAttack(boolean) - True to only use Lua attacks
Sets whether the mob holds its position.Parameters:
bHoldPosion(boolean) - True to hold position
Counts mobs of a specific type in an area.Parameters:
dwType(integer) - Mob type IDdlPosX(double) - Center X coordinatedlPosZ(double) - Center Z coordinatenAddDist(integer) - Additional search distance
Sets whether the mob is invulnerable.Parameters:
bUnBeatable(boolean) - True to make invulnerable
Resets all aggro on the mob.
Removes mobs of a specific type from an area.Parameters:
dwMobId(integer) - Mob type ID to removebyCount(byte) - Number of mobs to removedlPosX(double) - Center X coordinatedlPosZ(double) - Center Z coordinate
Makes the mob move to a fixed location.Parameters:
nMoveMode(integer) - Movement modedlPosX(double) - Target X coordinatedlPosZ(double) - Target Z coordinate
Teleports players of a specific job within range to a location.Parameters:
byJob(byte) - Job class filter (0-5, or use random)fDist(float) - Maximum distance to affect playerswMap(word) - Target map IDdlPosX(double) - Target X coordinatedlPosY(double) - Target Y coordinatedlPosZ(double) - Target Z coordinate
Recovers HP, SP, or MP for the mob.Parameters:
byType(byte) - Recovery type (1=HP, 2=SP, 3=MP)dlValue(double) - Amount to recover (can be percentage if < 1.0)
Gets the position of a specific mob.Parameters:
dwId(integer) - Mob IDfPosX(float) - Output X coordinatefPosZ(float) - Output Z coordinate
Gets the HP of a specific mob.Parameters:
dwId(integer) - Mob ID
Updates portal state in the zone.Parameters:
nPortalId(integer) - Portal IDnCountry(integer) - Country/faction
Complete Example
Here’s a complete boss mob script demonstrating various API features:Best Practices
Initialize Variables
Always initialize state variables in the
Init() function or at the top of your script.Reset State
Reset all state variables in
OnReturnHome() to ensure proper behavior when the mob leashes.Random Seed
Use
math.randomseed(os.time()) at the start of your script for proper randomization.HP Checks
Use
dwHPPercent in WhileCombat() to trigger phase-based behavior.