I have tried wesnoth.units.to_map. guarantee(u, true) does get run, I can see the variable get printed correctly too.
But suddenly... when guarantee(u, false) is run, it goes from 100 to -100.. which should not be possible.
Here is my code (in order of execution):
But suddenly... when guarantee(u, false) is run, it goes from 100 to -100.. which should not be possible.
Here is my code (in order of execution):
Code:
1. on_event("attack", attack_start_event) 2. local function attack_start_event(ctx) local unit1 = wesnoth.get_unit(ctx.x1, ctx.y1) local unit2 = wesnoth.get_unit(ctx.x2, ctx.y2) [...] guarantee_hit(unit1, true) guarantee_hit(unit2, true)end 3. local function guarantee_hit(unit, guarantee) for w =1, #unit.attacks do if guarantee == true then unit.attacks[w].accuracy = unit.attacks[w].accuracy + 100 wesnoth.interface.add_chat_message("attack accuracy start" .. unit.attacks[w].accuracy) else unit.attacks[w].accuracy = unit.attacks[w].accuracy - 100 wesnoth.interface.add_chat_message("attack accuracy end " .. unit.attacks[w].accuracy) end endend4. on_event("attack end", remove_tmp_hits)5. local function remove_tmp_hits(ctx) local unit1 = wesnoth.get_unit(ctx.x1, ctx.y1) local unit2 = wesnoth.get_unit(ctx.x2, ctx.y2) [...] guarantee_hit(unit1, false) guarantee_hit(unit2, false)end6 (see 3)WHY DOESNT DOES THIS WORK?!! IS WML EVIL?!!
Statistics: Posted by B099 — Today, 6:51 am