Global Utility Functions¶
LogAdd(color, message)¶
Writes a message to the GameServer console and log file.
- Parameters:
color(number) — log color constant;message(string) — text to log. - Returns:
nil
GetTickCount()¶
Returns the number of milliseconds since system start. Useful for measuring time intervals.
- Returns:
number
local start = GetTickCount()
-- ... do work ...
LogAdd(LOG_GREEN, "Took " .. (GetTickCount() - start) .. " ms.")
GetLargeRand(value)¶
Generates a high-quality random integer in the range [0, value-1].
- Parameters:
value(number) — exclusive upper bound. - Returns:
number
rand(value)¶
Standard random integer in the range [0, value-1].
- Parameters:
value(number) — exclusive upper bound. - Returns:
number
Object Limit Constants¶
These functions return compile-time constants defining object index ranges.
| Function | Description |
|---|---|
MAX_OBJECT_MONSTER() |
Maximum number of monsters |
MAX_OBJECT_USER() |
Maximum number of players |
MAX_OBJECT_SUMMON() |
Maximum number of summons |
MAX_OBJECT() |
Total object slots |
OBJECT_START_MONSTER() |
First monster index |
OBJECT_START_USER() |
First player index |
Object Range Checks¶
| Function | Returns true if... |
|---|---|
OBJECT_RANGE(index) |
Index is valid for any object |
OBJECT_MONSTER_RANGE(index) |
Index is a monster |
OBJECT_SUMMON_RANGE(index) |
Index is a summon |
OBJECT_USER_RANGE(index) |
Index is a player |
Bit Manipulation¶
Used primarily for network packet construction.
| Function | Description |
|---|---|
SET_NUMBERHB(value) |
High byte of a WORD |
SET_NUMBERLB(value) |
Low byte of a WORD |
SET_NUMBERHW(value) |
High word of a DWORD |
SET_NUMBERLW(value) |
Low word of a DWORD |
SET_NUMBERHDW(value) |
High dword of a QWORD |
SET_NUMBERLDW(value) |
Low dword of a QWORD |
GetLevelExperience(level)¶
Returns the total experience required to reach the given character level.
- Parameters:
level(number) - Returns:
number
GetMasterLevelExp(level)¶
Returns the total experience required to reach the given Master Level.
- Parameters:
level(number) - Returns:
number
GetCrywolfState()¶
Returns the current Crywolf event state (0=Inactive, 1=Notification, 2=Active).
- Returns:
number
Help