This page covers four small tables: Monster (monsters), Skill (skill watching), Party (party) and Map (maps). A player's summoned monster is in Player.SummonMonster (page Player: send information and actions); the functions for iterating monsters are on the page Iterate and count objects.

The functions that create / delete monsters (Monster.Create, CreateInArea, CreateEx, Delete) are blocked when the script is in restricted mode (see the page General rules for functions).

Monster

Monster.Create

Creates a temporary monster at a cell. A temporary monster does not respawn after it dies.

Monster.Create(class, map, x, y [, dir, moveRange, despawnSeconds, instance]) -> integer
ParameterTypeDescription
classintegerMonster / NPC code (must exist in the monster data)
mapintegerMap number (must exist on this GameServer)
x, yintegerCoordinates (clamped from 0 to 255)
dirintegerDirection 0 to 7; -1 (default) = random
moveRangeintegerMovement range; -1 (default) = according to the monster data
despawnSecondsintegerDisappears by itself after this many seconds (maximum 30 days); 0 (default) = does not disappear by itself
instanceintegerInstance number; -1 (default) = no instance

Returns: the index of the monster just created; -1 on failure (wrong parameters, the monster code / map does not exist, no free slots for creating objects, restricted mode). Short name: MonsterCreate(class, map, x, y, dir).

local npc = Monster.Create(240, MAP_LORENCIA, 130, 130, 3)
if npc == -1 then Log.AddC(1, "Unable to create the NPC") end

Monster.CreateInArea

Creates several temporary monsters of the same type inside a rectangular area.

Monster.CreateInArea(class, map, x1, y1, x2, y2 [, count, despawnSeconds]) -> integer
ParameterTypeDescription
classintegerMonster code
mapintegerMap number
x1, y1, x2, y2integerThe two corners of the area (clamped from 0 to 255); either corner may come first
countintegerNumber of monsters to create, from 1 to 200 (default 1)
despawnSecondsintegerDisappears by itself after this many seconds (maximum 30 days); 0 (default) = does not disappear by itself

Returns: the number of monsters actually created (may be less than count); 0 if the parameters are wrong.

local n = Monster.CreateInArea(14, MAP_DUNGEON, 20, 20, 60, 60, 30, 600)

Monster.CreateEx

Creates a temporary monster with custom stats. Each stat is only applied when its value is greater than 0; otherwise the monster data is kept.

Monster.CreateEx(class, map, x, y, dir, moveRange, life, damageMin, damageMax, defense, attackRate, defenseRate) -> integer
ParameterTypeDescription
class, map, x, yintegerSame as Monster.Create
dirintegerDirection 0 to 7; -1 = random
moveRangeintegerMovement range; -1 = according to the monster data
lifeintegerMaximum HP (and current HP)
damageMin, damageMaxintegerMinimum / maximum physical damage
defenseintegerDefense
attackRateintegerAttack success rate
defenseRateintegerDefense success rate

Returns: the index of the monster just created; -1 on failure. A monster created with this function does not disappear by itself. Short name: MonsterCreateEx(class, map, x, y, dir, moveRange, life, damage, defense, attackRate, defenseRate) (a single damage value is used for both the minimum and the maximum).

local boss = Monster.CreateEx(78, MAP_ICARUS, 100, 100, -1, -1, 5000000, 8000, 12000, 3000, 2000, 1500)

Monster.Delete

Deletes a temporary monster (created by a script or a GM command). A fixed monster of the map cannot be deleted.

Monster.Delete(aIndex) -> boolean
ParameterTypeDescription
aIndexintegerMonster index

Returns: true if it was deleted; false if it is not a temporary monster, is invalid or the script is in restricted mode. Short name: MonsterDelete.

Monster.Delete(npc)

Monster.GetTopDamageDealer

Returns the player with the highest hatred (aggro) toward the monster, according to the monster's threat table (the result of GetMaxAggro in GameServer). This is the player the monster is targeting the most, usually the one dealing the most damage, but it is not an accumulated damage statistics table.

Monster.GetTopDamageDealer(aIndex) -> integer
ParameterTypeDescription
aIndexintegerMonster index

Returns: the index of the player with the highest aggro; -1 if aIndex is not a valid monster, nobody is in the monster's threat table yet, or that player is no longer in game.

local top = Monster.GetTopDamageDealer(bossIndex)
if top ~= -1 then Message.SendAll(0, Player.GetName(top) .. " dealt the most damage to the Boss") end

Monster.GetAttr

Reads the base data of a monster type (from the server's monster data file).

Monster.GetAttr(class) -> table | nil
ParameterTypeDescription
classintegerMonster code

Returns: a table, or nil if the monster code does not exist. The fields:

FieldTypeMeaning
ClassintegerMonster code
NamestringName
LevelintegerLevel
Life, ManaintegerHP, MP
DamageMin, DamageMaxintegerMinimum / maximum damage
DefenseintegerDefense
AttackRate, DefenseRateintegerAttack / defense success rate
MoveRange, AttackRange, ViewRangeintegerMovement / attack / view range
AttackSpeedintegerAttack speed
RespawnTimeMin, RespawnTimeMaxintegerMinimum / maximum respawn time
ItemRate, ZenRateintegerItem / zen drop rate
ElementalAttributeintegerElemental attribute
ScriptNamestringName of the monster's AI script
local a = Monster.GetAttr(44)
if a then Log.Add(a.Name .. " HP=" .. a.Life) end

Monster.WatchRespawn

Turns on / off GameServer calling the onMonsterRespawn callback for a monster type. By default GameServer does not report this event, to save resources.

Monster.WatchRespawn(class [, watch])
ParameterTypeDescription
classintegerMonster code (0 to 65535)
watchbooleantrue = on (default), false = off
Monster.WatchRespawn(44, true)

Skill

Skill.Watch

Turns on / off GameServer calling the onUseSkill callback when a player uses a skill.

Skill.Watch(skill [, watch])
ParameterTypeDescription
skillintegerSkill number (0 to 65535)
watchbooleantrue = on (default), false = off
Skill.Watch(17, true)   -- watch skill 17

Party

Party.GetCount

Returns the number of members in the party.

Party.GetCount(partyNumber) -> integer
ParameterTypeDescription
partyNumberintegerParty number, obtained from Player.GetPartyNumber

Returns: the number of members; 0 if the party does not exist. Short name: PartyGetMemberCount.

local n = Party.GetCount(Player.GetPartyNumber(aIndex))

Party.GetMember

Returns the index of the n-th member of the party.

Party.GetMember(partyNumber, n) -> integer
ParameterTypeDescription
partyNumberintegerParty number
nintegerPosition in the party, from 1 (party leader) to 5

Returns: the character index; -1 if there is no member at that position or that member is not online on this GameServer. Short name: PartyGetMemberIndex(party, slot) with slot counted from 0.

local leader = Party.GetMember(Player.GetPartyNumber(aIndex), 1)

Map

The Map functions take a map number map (a MAP_* constant). If the map does not exist on this GameServer, the function returns the default value (an empty string, 0, false).

Map.GetName

Returns the map name.

Map.GetName(map) -> string
ParameterTypeDescription
mapintegerMap number

Returns: the map name; an empty string if it does not exist. Short name: GetMapName.

Message.SendAll(1, "Event at " .. Map.GetName(MAP_ARENA))

Map.Exists

Checks whether the map is running on this GameServer.

Map.Exists(map) -> boolean
ParameterTypeDescription
mapintegerMap number
if Map.Exists(MAP_CRYWOLF) then ... end

Map.GetAttr

Reads the attributes of a map cell.

Map.GetAttr(map, x, y) -> integer
ParameterTypeDescription
mapintegerMap number
x, yintegerCell coordinates (clamped from 0 to 255)

Returns: the cell attribute bit mask: bit 1 safe zone (SAFE), bit 2 standing cell (STAND), bits 4, 8, 16 are lock cells 1, 2, 3 (LOCK_1, LOCK_2, LOCK_3). Lock cells are used by event maps to block / open areas (for example Chaos Castle uses lock cell 2, Imperial Guardian uses lock cell 3 for areas that are not yet open); the exact meaning depends on the map. Returns 0 if the map does not exist or the parameters are wrong.

local attr = Map.GetAttr(MAP_LORENCIA, 130, 130)

Map.CheckAttr

Checks whether a cell carries the specified attribute bit(s).

Map.CheckAttr(map, x, y, attr) -> boolean
ParameterTypeDescription
mapintegerMap number
x, yintegerCell coordinates (clamped from 0 to 255)
attrintegerBit mask to check (see Map.GetAttr)

Returns: true if the cell has at least one bit of attr; false if not or the parameters are wrong. Short name: MapCheckAttr (returns 1 / 0).

if Map.CheckAttr(Object.GetMap(aIndex), Object.GetX(aIndex), Object.GetY(aIndex), 1) then
    Message.Send(aIndex, 1, "You are in a safe zone")
end

Map.Fireworks

Launches fireworks at a cell for the players nearby.

Map.Fireworks(map, x, y [, instance])
ParameterTypeDescription
mapintegerMap number (must exist on this GameServer)
x, yintegerCoordinates (clamped from 0 to 255)
instanceinteger4th parameter: the map's instance number; default -1 (a normal map, not a copy). Only players belonging to exactly this instance and no more than 20 cells away from cell (x, y) see the fireworks

Short name: FireworksSend(aIndex, x, y) launches on the map of aIndex; if x, y are omitted, the position of aIndex is used.

Map.Fireworks(MAP_LORENCIA, 130, 130)