Global

Members

u_item

Created by nexus on 12/06/17.
Source:

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 added with draw_circle and draw_line functions from 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 On the normal Server you have to be close to the npc for it to work.
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)

Destroys an item in the num-th Inventory slot
Parameters:
Name Type Description
num number The Inventory slot of the Item [0,41].
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 number
y number
radius number
size number
color 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 number
y number
x2 number
y2 number
size number
color 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 The slot the items is currently in
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 friendly
Source:
Returns:
Type
Player

get_nearest_monster(args) → {Monster}

Get nearest Monster out of the entities array that meets certain criteria and returns it.
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:
- 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}

You can implement your own chat commands with this function.
Parameters:
Name Type Description
command string
args string
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}

return true if the entity is moving
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 Player | Character | Monster
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()

Find the first 2 chests and opens them
Source:

move(x, y)

sets the character moving to specific coordinates
Parameters:
Name Type Description
x number X coordinate
y number Y coordinate
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. Can be used to remove event listeners or revert states.
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 character 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 The amount of gold to send
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 function Function that gets executed once the path finding finishes.
Source:

smart_move_logic()

Internal smart_move function
Source:

smooth_path()

Internal smart_move function Assume the path ahead is [i] [i+1] [i+2] - This routine checks whether [i+1] could be skipped The resulting path is smooth rather than rectangular and bumpy Try adding "function smooth_path(){}" or "smart.prune.smooth=false;" to your Code
Source:

start_pathfinding()

Internal smart_move function
Source:

stop()

Stop path finding and moving
Source:

trade(num, trade_slot, price)

Puts an item up for sale
Parameters:
Name Type Description
num number The slot the item is in
trade_slot number The slot in the trade window where is shoudl appear
price number The price of the item
Source:

trade_buy(target, trade_slot)

Parameters:
Name Type Description
target Player The player entity you want to buy from.
trade_slot number The trade slot in which the item is you want to buy.
Source:

upgrade(item_num, scroll_num, offering_numopt)

Uses the upgrade npc to upgrade items.
Parameters:
Name Type Attributes Description
item_num number Slot number of the item you want to upgrade.
scroll_num number Slot number of the scroll you want to upgrade
offering_num number <optional>
Slot number of the offering you want to use
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

The name of the character slots, they may or may not contain Gear
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

Type:
  • Object
Properties:
Name Type Description
dex number Dexterity: Increases the attack speed.
int number Intelligence: Increases maximum mana, also increases resistance by a factor of 1.5 for every int point.
vit number Vitality: Increases Health points proportional to level.
str number Strength: Increases Health points and Armor.
Source:

Consumables

Type:
  • Object
Properties:
Name Type Description
name string Item name
q number quantity: how many items are on this stack.
Source:

Gear

Type:
  • Object
Properties:
Name Type Attributes Description
name string Item name
level number level of item
CharacterStats string <optional>
either dexterity, intelligence, vitality, strength.
Source:

ItemStats

Every item may or may not contain any number or combination of these attributes. It is probably a good idea to check if they exist first.
Type:
  • Object
Properties:
Name Type Description
apiercing number
armor number Reduces the incoming physical damage by 1% for every 10 armor points.
attack number
attr0 number
attr1 number
crit number Chance to crit and do double damage
dreturn number
evasion number Chance to evade the attack and negate all damage
gold number
hp number
level number The item level
lifesteal number
mp number
range number
reflection number
resistance number Reduces the incoming magical damage by 1% for every 10 resistance points.
rpiercing number
speed number Adds the the character speed, 1 point equals one additional pixel walked per second.
stat number Can be converted to dex, int, str or vit with the corresponding scrolls
dex number Dexterity: Increases the attack speed.
int number Intelligence: Increases maximum mana, also increases resistance by a factor of 1.5 for every int point.
vit number Vitality: Increases Health points proportional to level.
str number Strength: Increases Health points and Armor.
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

Override this function to listen for game events
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 The character is invisible
invincible boolean -
mute boolean -
Source: