This code gets called whenever attack starts (to turn on) and ends (to turn off):
The problem: During the attck, unit will still use their normal accuracy, meaning they miss attacks, AND after the attack it says on their weapon "-100%", so they can not hit anything.
The intention is that the code guarantees hits by turning it up by 100, then back to normal after the attack.
It would seem like this line is never run..But when I print the variable after this is run, accuracy is 100.
So what is going on? It seems like the variable is not saved onto the unit if it runs from the attack event.
Code:
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 endend
The intention is that the code guarantees hits by turning it up by 100, then back to normal after the attack.
It would seem like this line is never run..
Code:
unit.attacks[w].accuracy = unit.attacks[w].accuracy + 100
So what is going on? It seems like the variable is not saved onto the unit if it runs from the attack event.
Statistics: Posted by B099 — Yesterday, 6:47 pm