Event parameters
Moderator: Forum Moderators
-
- Posts: 6
- Joined: June 18th, 2013, 10:37 am
Event parameters
So I am trying to make a mod that reduces random damage deviation in Wesnoth. The idea is, before every attack I calculate a sequence of chances that will override literal chances of hit for every hit, so that the randomness distribution can be limited.
For example for a 4-4 50% attack I will generate a permutation of {hit, hit ,miss, miss} and override the chance of hit for every hit in the sequence with 100% or 0% accordingly.
The problem is I am using WML events to hook into combat calculation. I need to override chances every hit, that's not a problem because there is attacker hit and attacker miss. But there's no information about which attack the combatants are using in the events, so I don't know the length of my sequence.
Is that information actually in there, or is there a way around this ?
For example for a 4-4 50% attack I will generate a permutation of {hit, hit ,miss, miss} and override the chance of hit for every hit in the sequence with 100% or 0% accordingly.
The problem is I am using WML events to hook into combat calculation. I need to override chances every hit, that's not a problem because there is attacker hit and attacker miss. But there's no information about which attack the combatants are using in the events, so I don't know the length of my sequence.
Is that information actually in there, or is there a way around this ?
Re: Event parameters
Code: Select all
H = wesnoth.require 'lua/helper.lua'
-- weapon may be either 'weapon' or 'second_weapon'
local length = H.get_child(wesnoth.current.event_context, weapon).number
-
- Posts: 6
- Joined: June 18th, 2013, 10:37 am
Re: Event parameters
Thanks.Luther wrote:Code: Select all
H = wesnoth.require 'lua/helper.lua' -- weapon may be either 'weapon' or 'second_weapon' local length = H.get_child(wesnoth.current.event_context, weapon).number
Re: Event parameters
The second argument to
helper.get_child
should be a string, "weapon"
.Re: Event parameters
Yes, that's noted in the comment.