Global

Methods

accept_party_invite(name)

Accept party invite from player
Parameters:
Name Type Description
name string
Source:

accept_party_request(name)

Accept party request from player.
Parameters:
Name Type Description
name string
Source:

activate(num)

Activates an item, likely a booster, in the num-th inventory slot
Parameters:
Name Type Description
num number number of Inventory slot
Source:

attack(target)

Tries to attack the target
Parameters:
Name Type Description
target Player | Monster Target to attack
Source:

bfs()

Internal smart_move function
Source:

buy(name, quantity)

Buys items from NPC. The NPC has to be near enough to be able to buy from him.
Parameters:
Name Type Description
name String Name of the Item
quantity number Quantity
Source:

can_attack(target) → {boolean}

Checks if the character is able to attack the target
Parameters:
Name Type Description
target Monster | Player the Entity for which to check
Source:
Returns:
Type
boolean

can_heal(target) → {boolean}

Checks if the character is able to heal the target Same as can_attack but with a more intuitive name
Parameters:
Name Type Description
target Monster | Player the Entity for which to check
Source:
Returns:
Type
boolean

can_move_to(x, yopt) → {boolean}

Checks if there is a clear path to the coordinates or the entity. For an entity you don't have to supply the second argument
Parameters:
Name Type Attributes Description
x Monster | Player | number
y number <optional>
Source:
Returns:
Type
boolean

can_use(name) → {boolean}

(WIP) Check if the cooldown of a class skill has passed
Parameters:
Name Type Description
name string name of skill
Source:
Returns:
- true of cooldown has passed
Type
boolean

change_target(target, sendopt)

Change the targeted entity
Parameters:
Name Type Attributes Default Description
target Monster
send boolean <optional>
false send change target to server
Source:

clear_drawings()

Clears drawings on the screen.
Source:

compound(item0, item1, item2, scroll_num, offering_numopt)

Uses the upgrade npc to combine jewelery Combining works by taking 3 jewelery items of the same type and a scroll for example -> compound(0,1,2,6) -> 3 items in the first 3 slots, scroll at the 6th spot
Parameters:
Name Type Attributes Description
item0 number Item one
item1 number Item two
item2 number Item three
scroll_num number
offering_num number <optional>
Source:

continue_pathfinding()

Internal smart_move function
Source:

destroy_item(num)

Destorys an item in the num-th Inventory slot
Parameters:
Name Type Description
num number
Source:

draw_circle(x, y, radius, size, color) → {PIXI.Graphics}

Documentation: https://pixijs.github.io/docs/PIXI.Graphics.html Example: draw_circle(character.real_x,character.real_y,character.range) :) [22/10/16]
Parameters:
Name Type Description
x
y
radius
size
color
Source:
Returns:
Type
PIXI.Graphics

draw_line(x, y, x2, y2, size, color) → {PIXI.Graphics}

Documentation: https://pixijs.github.io/docs/PIXI.Graphics.html keep in mind that drawings could significantly slow redraws, especially if you don't .destroy() them
Parameters:
Name Type Description
x
y
x2
y2
size
color
Source:
Returns:
Type
PIXI.Graphics

equip(num)

Equips the Item in the num-th inventory Slot starting from 0.
Parameters:
Name Type Description
num number
Source:

game_log(message, coloropt)

Uses the game log to print out a message
Parameters:
Name Type Attributes Default Description
message string the message to print
color string <optional>
#51D2E1 the color in which to display the message
Source:

get_map() → {Map}

Returns current map the player is on
Source:
Returns:
current map the player is on
Type
Map

get_nearest_hostile(args) → {Player}

Parameters:
Name Type Description
args Object
Properties
Name Type Attributes Default Description
exclude Array.<string> <optional>
A list of Player names which will not be considered hostile
friendship boolean <optional>
true Should friends be considered not hostile
Source:
Returns:
Type
Player

get_nearest_monster(args) → {Monster}

Parameters:
Name Type Description
args Object
Properties
Name Type Description
type string the monster type of Monster
min_xp number Minimum xp that the Monster should give
max_att number The Maximum attack value a Monster should have
no_target boolean Attack only targets that have no target
path_check boolean Check If you can walk straight to the target
Source:
Returns:
Type
Monster

get_player(name) → {Player}

Parameters:
Name Type Description
name String The name of the character
Source:
Returns:
- The Player Object
Type
Player

get_socket() → {socket}

Return Socket.IO socket, this is the Object which the game uses to communicate with the server
Source:
Returns:
Type
socket

get_target() → {Monster|Player|null}

Returns the current target Entity of the character without checks
Source:
Returns:
- Returns the current target Entity of the character
Type
Monster | Player | null

get_target_of(entity) → {Monster|null}

Returns Entity which the Entity is targeting
Parameters:
Name Type Description
entity Monster
Source:
Returns:
Type
Monster | null

get_targeted_monster() → {Monster|null}

Returns the current target Entity of the character but with additional checks. This prevents the targeting of already dead targets or players
Source:
Returns:
- Returns the current target Entity of the character
Type
Monster | null

handle_command(command, args) → {number}

Parameters:
Name Type Description
command
args
Source:
Returns:
Type
number

handle_death()

When a character dies, character.rip is true, you can override handle_death and manually respawn IDEA: A Resident PVP-Dweller, with an evasive Code + irregular respawning respawn current has a 12 second cooldown, best wait 15 seconds before respawning [24/11/16] setTimeout(respawn,15000); return true; NOTE: Add `if(character.rip) {respawn(); return;}` to your main loop/interval too, just in case
Source:

heal(target)

Tries to heal the targeted Character
Parameters:
Name Type Description
target Player
Source:

in_attack_range(target) → {boolean}

Checks if the Entity is in attack range
Parameters:
Name Type Description
target Player | Monster
Source:
Returns:
Type
boolean

is_moving(entity) → {boolean}

Parameters:
Name Type Description
entity Player | Character | Monster
Source:
Returns:
Type
boolean

is_transporting(entity) → {boolean}

Is the entity using the town teleportation skill
Parameters:
Name Type Description
entity
Source:
Returns:
Type
boolean

item_grade(item) → {number}

Returns the item Grade in Number format. -1: Invalid Input 0 : Normal 1 : High 2 : Rare
Parameters:
Name Type Description
item Object
Properties
Name Type Description
name string
Source:
Returns:
- {-1:Something went wrong, 0:Normal, 1:High, 2:Rare}
Type
number

item_properties(item) → {ItemStats|null}

Returns an object containing all the stat properties of an item
Parameters:
Name Type Description
item Gear The Item in question
Source:
Returns:
- An Object containing all stats and there number or null on error
Type
ItemStats | null

item_value(item) → {number}

Returns how much the item is worth in gold
Parameters:
Name Type Description
item Gear | Consumables
Source:
Returns:
- How the item is worth in gold when sold to an npc
Type
number

load_code(name, onerror)

Parameters:
Name Type Description
name string
onerror function A function that gets executed when the code errors
Source:

loot()

Looks for chests and tries to open them
Source:

move(x, y)

sets the character moving to specific coordinates
Parameters:
Name Type Description
x number
y number
Source:

mssince(a, b) → {number}

Returns
Parameters:
Name Type Description
a Date start
b Date stop
Source:
Returns:
Type
number

on_cm(name, data)

Parameters:
Name Type Description
name string Sender of Code Message
data Object An Object containing the information send
Source:

on_combined_damage()

When multiple characters stay in the same spot, they receive combined damage, this function gets called whenever a monster deals combined damage. Override this function in CODE to react to it
Source:

on_destroy()

Called just before the CODE is destroyed
Source:

on_disappear(entity, data)

This function gets called whenever an entity disappears
Parameters:
Name Type Description
entity Player | Monster
data
Source:

on_draw()

The game calls this function at the best place in each game draw frame, so if you are playing the game at 60fps, this function gets called 60 times per second
Source:

on_party_invite(name)

Someone is inviting you to a party
Parameters:
Name Type Description
name string The name of the inviting player
Source:

on_party_request(name)

Someone requesting to join your existing party
Parameters:
Name Type Description
name string The name of the player
Source:

respawn()

Lets the player respawn
Source:

say(message)

Acts as if the player had typed the message into the chat and then send it. This also allows for the use of commands.
Parameters:
Name Type Description
message string The message
Source:

sell(num, quantity)

Sell the Item in the num-th inventory slot starting from 0.
Parameters:
Name Type Description
num number Inventory slot
quantity number Quantity
Source:

send_cm(to, data)

Send CODE messages to the characters, of course it only works if both characters have CODE active.
Parameters:
Name Type Description
to Array | string Either an Array of names or just a name
data Object The data to be sent in object form
Source:

send_gold(receiver, gold)

Send gold to another player
Parameters:
Name Type Description
receiver Player | string Either a character name or a OtherCharacter Object
gold number
Source:

send_item(receiver, num, quantityopt)

Send item to another player
Parameters:
Name Type Attributes Default Description
receiver Player | string Either a character name or a OtherCharacter Object
num number Inventory slot starting from 0
quantity number <optional>
1 Quantity
Source:

send_party_invite(name, is_request)

Sens a party Invite to another character
Parameters:
Name Type Description
name Player | string name ca be a player object, a player name, or an id
is_request boolean Is requesting to be invited
Source:

send_party_request(name)

Request to be invited into a party
Parameters:
Name Type Description
name Player | string name ca be a player object, a player name, or an id
Source:

set_message(text, coloropt)

When CODE is active uses a window in the bottom right hand corner to display a status messages The window is pretty small so keep it short.
Parameters:
Name Type Attributes Description
text string the text that should be displayed
color string <optional>
the color in which the text should be displayed
Source:

shift(num, name)

Shifts an item, likely a booster, in the num-th inventory slot to s pecific mode shift(0,'goldbooster'); would set the booster int the first inventory slot to gold mode Other modes are "xpbooster" and "luckbooster"
Parameters:
Name Type Description
num number Position of Inventory Slot starting from 0
name string name of the Item
Source:

show_json(e)

A debug Command which opens a Window and shows the json representation of the Object.
Parameters:
Name Type Description
e Object The Object you like to inspect
Source:

smart_move(destination, on_done)

smart_move uses a Breadth-first search path finding algorithm to find the shortest path despite the name, smart_move isn't very smart or efficient, it's up to the players to implement a better movement method.
Parameters:
Name Type Description
destination Object
Properties
Name Type Description
to string Can be of multiple values. If destination.to is a monster name we will find where they spawn and set the target destination. Monsters like the phoenix or mvampire have random spawn locations we want to check for the accordingly Every time we search for the phoenix we will try a different location so if nobody kill it we will eventually find it If destination to is one of "upgrade", "exchange", "potions", "scrolls" we will find the path to the closest shop that sells the items.
map string Destination map
x number Destination coordinates
y number Destination coordinates
on_done
Source:

smart_move_logic()

Internal smart_move function
Source:

smooth_path()

Internal smart_move function
Source:

start_pathfinding()

Internal smart_move function
Source:

stop()

Stop path finding and moving
Source:

trade_buy(target, trade_slot)

Parameters:
Name Type Description
target Player
trade_slot number
Source:

upgrade(item_num, scroll_num, offering_numopt)

Parameters:
Name Type Attributes Description
item_num number
scroll_num number
offering_num number <optional>
Source:

use(name, targetopt)

if name parameter is a number, the character will try to equip the Item in the specified slot. Otherwise it will try to cast the skill with that name and Target
Parameters:
Name Type Attributes Description
name number | string skill name or item slot
target Monster <optional>
target Entity when using skill
Source:

use_hp_or_mp()

Uses a simple algorithm to decide weather to use a mana or health potion. Tries to max out the health and mana. This function should not be called in fast running loops or otherwise it will use a high amount of potions.
Source:

use_skill(name, targetopt)

Will use a skill on the specified target If no target is specified the current character target will be used
Parameters:
Name Type Attributes Description
name string name of skill
target Monster <optional>
target Entity
Source:

Type Definitions

ChannelingConditions

Type:
  • Object
Properties:
Name Type Description
town boolean Using the town teleportation skill
Source:

CharacterSlots

Type:
  • Object
Properties:
Name Type Description
ring1 Gear
ring2 Gear
earring1 Gear
earring2 Gear
belt Gear
offhand Gear
chest Gear
pants Gear
shoes Gear
gloves Gear
amulet Gear
orb Gear
elixir Gear
cape Gear
mainhand Gear
helmet Gear
Source:

CharacterStats

//TODO: describe how character stats effect affect the character
Type:
  • Object
Properties:
Name Type Description
dex number
int number
vit number
str number
Source:

Consumables

Type:
  • Object
Properties:
Name Type Description
name string Item name
q number quantity
Source:

Gear

Type:
  • Object
Properties:
Name Type Attributes Description
name string Item name
level number level of item
stat_type string <optional>
stat type
Source:

ItemStats

Type:
  • Object
Properties:
Name Type Description
apiercing number
armor number
attack number
attr0 number
attr1 number
crit number
dex number
dreturn number
evasion number
gold number
hp number
int number
level number
lifesteal number
mp number
range number
reflection number
resistance number
rpiercing number
speed number
stat number
str number
vit number
Source:

Map

Type:
  • Object
Properties:
Name Type Description
name string A Human readable name
on_death number
monsters Array.<Object>
compound Object
data Object
doors Array.<Array>
drop_norm number
exchange Object
items Object
key string
merchants Array.<Object>
monsters Array.<Object>
npcs Array.<Object>
quirks Array.<Array>
ref Object
u_mid Array.<number>
c_mid Array.<number>
spawns Array.<Array>
transporter Object
upgrade Object
Source:

on_game_event

Source:

StatusConditions

//TODO: describe how status effect affect the character
Type:
  • Object
Properties:
Name Type Description
stunned boolean -
cursed boolean -
poisoned boolean -
poisonous boolean -
charging boolean -
invis boolean -
invincible boolean -
mute boolean -
Source: