From 23f9123871c2723d05cc84b3f20e2036b3f0f3d7 Mon Sep 17 00:00:00 2001 From: Kaan Soral Date: Tue, 9 Jun 2020 15:27:27 +0300 Subject: [PATCH] Update runner_compat.js --- runner_compat.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/runner_compat.js b/runner_compat.js index dacad2d..54827a7 100644 --- a/runner_compat.js +++ b/runner_compat.js @@ -18,13 +18,60 @@ function handle_death() // NOTE: Add `if(character.rip) {respawn(); return;}` to your main loop/interval too, just in case } +function can_use(name) +{ + if(G.skills[name] && G.skills[name].class && !in_arr(character.ctype,G.skills[name].class)) return false; // checks the class + return parent.can_use(name); // checks the cooldown +} + +function use(name,target) // a multi-purpose use function, works for skills too +{ + if(isNaN(name)) // if name is not an integer, use the skill + { + if(!target) target=get_target(); + parent.use_skill(name,target); + } + else + { + // for example, if there is a potion at the first inventory slot, use(0) would use it + equip(name); + } +} + function on_cm(name,data) { game_log("Received a code message from: "+name); } +function 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 +{ + // move(character.real_x+5,character.real_y); +} + +function on_game_event(event) +{ + if(event.name=="pinkgoo") + { + // start searching for the "Love Goo" of the Valentine's Day event + } + if(event.name=="goblin") + { + // start searching for the "Sneaky Goblin" + } +} + +function in_attack_range(target) // also works for priests/heal +{ + if(!target) return false; + if(parent.distance(character,target)<=character.range) return true; + return false; +} + +function destroy_item(i){destroy(i)} + +character.on("stacked",function(){ on_combined_damage(); }); character.on("death",function(){ handle_death(); }); -character.on("cm",function(data){ on_cm(data.name,data.message) }); +character.one("cm",function(data){ on_cm(data.name,data.message) }); // [06/03/19]: doneify aimed to add a completion callback to every function // such as buy("shoes").done(function(success_flag,data){})