Character events are individual to your character.
// Register to a single character event:
character.on("level_up",function(data){
game_log("I am now level "+data.level+"!");
});
// Register to all character events:
character.all(function(name,data){
data.event_name=name;
show_json(data);
});
Data Reference:
"new_map"
{
// Sent after your character enters a new map
name: "main", // G.maps.main
in: "main", // Unique instance ID for instances
}
"incoming"
{
// If an "action" Game Event is targeting you
// It's emitted to your character as an "incoming" event
source: "attack", // Can be positive or negative
actor: "CharacterName", // Monster ID or Character ID
target: "42", // Monster ID or Character ID
damage: 1390,
projectile: "momentum",
eta: 50, // Arrival in milliseconds
pid: "abcd1234", // Projectile ID
}
"hit"
{
// Emitted when you've been hit by a projectile
// Could be damaging, healing, or containing a condition
// The full reference can be found in Game Events
source: "attack",
actor: "AttackerID", // Monster ID or Character ID
target: "YourCharacterName", // Monster ID or Character ID
damage: 1390,
pid: "abcd1234", // Projectile ID
}
"target_hit"
{
// Same format as "hit" event
// Emitted when you've hit someone
}
"loot"
{
// Emitted when you or a party member opens a chest
id: "qwerty12345",
opener: "CharacterName", // Character who opened the chest
goldm: 1.2, // Character who opened the chest had +20% Gold
dry: false, // Set if the opener was far away from the chest
stale: false, // Set if the chest was unopened for more than 30 minutes
// If the dry or stale flags are set, goldm is 1
gold: 87, // You looted 87 gold
party: true, // The chest was looted by a party
items:[
{name:"xsword", "level":0, "looter":"ACharacterName"},
{name:"xstaff", "level":0, "looter":null, "lostandfound":true}, // Lost
{name:"xbow", "level":10, "looter":"AnotherCharacterName", pvp_loot:true},
// pvp_loot flag is set if the chest was a character drop at pvp
],
}
"buy"
{
name: "coat",
num: 0, // Inventory slot 0
q: 1, // Quantity
cost: 6000, // Gold spent
}
"sell"
{
item: {name:"staff",level:9},
gold: 500,
}
"cm"
{
name: "CharacterName", // Name of the character who sent the code message
message: object, // Can be a string, array, any serializable object
}
"clim"
{
// Raw data that's posted to the CLI jsdom window from character.js
// Can also be posted from master.js, which character.js will propagate
}
"death"
{
past: false, // true when your code executes with a dead character
}
"respawn"
{
// Respawned
}
"item_received"
{
name: "SenderName",
item: "staff",
q: 1,
num: 12, // Inventory#
}
"item_sent"
{
name: "ReceiverName",
item: "staff",
q: 1,
num: 12, // Inventory#
}
"mail_sent"
{
to: "ReceiverName",
// There's also a "mail_failed" with a reason
}
"gold_sent"
{
name: "ReceiverName",
gold: 100,
}
"gold_received"
{
name: "SenderName",
gold: 100,
}
"craft"
{
name: "gstaff", // Item ID of the item
num: 12, // Inventory# of the item
}
"dismantle"
{
name: "staff", // Item ID of the item you've dismantled
}
"sale"
{
buyer: "BuyerName",
item: {name:"staff",level:9},
slot: "trade8",
}
"mluck"
{
name: "MerchantName",
item: {name:"staff",level:0},
num: 12,
}
"exchange_buy"
{
// Token Exchange
num: 12, // Inventory# of the item
}
"mobbing"
{
// If you target 4+ monsters, they start dealing increased damage
// This behaviour is called "mobbing"
intensity: 1, // The intensity increases with each hit
}
"stacked"
{
// If you place your characters on top of each other
// Monsters deal stacked/increasing damage to all the stacked characters
// When this event is triggered, scatter your characters
ids: ["CharacterName1","CharacterName2","..."],
}
"level_up"
{
level: 72, // Your new level
}
Work in progress ...