From f8e816d9185c09d1c17d921b775e483d132982e5 Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Tue, 3 Apr 2012 13:29:05 +0200 Subject: Enhanced special support - Made the current charge being saved. - Added script binds: - chr_set_special_recharge_speed - chr_get_special_recharge_speed - chr_set_special_mana - chr_get_special_mana - get_special_info - Added special info lua class. Functions: - name - needed_mana - rechargeable - on_use - on_recharged - category Further the engine no longer sets charge to 0 after using of specials this allows more flexbilillity (like failing specials). Changes on the xml database: - recharge renamed to rechargeable (needed by client and server) - needed - the needed mana to trigger a special (server only) - rechargespeed - the defailt recharge speed in mana per tick (server only) - target - the type of target (either being or point) (server and client) I also made the lua engine pushing nil instead of a 0 light userdata when the pointer was 0. Database update needed. Change is tested. Mana-Mantis: #167, #156 Reviewed-by: bjorn. --- example/permissions.xml | 4 ++++ example/scripts/special_actions.lua | 33 ++++++++++----------------------- example/specials.xml | 27 +++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 27 deletions(-) (limited to 'example') diff --git a/example/permissions.xml b/example/permissions.xml index e6615864..4c46af1a 100644 --- a/example/permissions.xml +++ b/example/permissions.xml @@ -25,6 +25,10 @@ @killmonsters @getpos @effect + @givespecial + @takespecial + @rechargespecial + @listspecials gm diff --git a/example/scripts/special_actions.lua b/example/scripts/special_actions.lua index 25619f41..6070ecd3 100644 --- a/example/scripts/special_actions.lua +++ b/example/scripts/special_actions.lua @@ -8,28 +8,15 @@ --]] -local specialCost = {} -specialCost[1] = 50 -specialCost[2] = 250 -specialCost[3] = 1000 +local spell1 = get_special_info("Magic_Test Spell 1") +spell1:on_use(function(user, target, specialid) + target = target or user + being_say(target, "Kaaame...Haaame... HAAAAAA!") + chr_set_special_mana(user, specialid, 0) +end) +spell1:on_recharged(function(ch) being_say(ch, "Hoooooooo...") end) -local function use_special(ch, id) - -- perform whatever the special with the ID does - if id == 1 then - being_say(ch, "Kaaame...Haaame... HAAAAAA!") - end - if id == 2 then - being_say(ch, "HAA-DOKEN!") - end - if id == 3 then - being_say(ch, "Sonic BOOM") - end -end +local spell2 = get_special_info(2) +spell2:on_use(function(user) being_say(user, "HAA-DOKEN!") end) -local function get_special_recharge_cost(id) - -- return the recharge cost for the special with the ID - return specialCost[id] -end - -on_use_special(use_special) -on_get_special_recharge_cost(get_special_recharge_cost) +get_special_info(3):on_use(function(user) being_say(user, "Sonic BOOM") end) diff --git a/example/specials.xml b/example/specials.xml index c234f667..2c1d61a6 100644 --- a/example/specials.xml +++ b/example/specials.xml @@ -1,9 +1,28 @@ - - - - + + + -- cgit v1.2.3-60-g2f50