Event parameters

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
hypercross
Posts: 6
Joined: June 18th, 2013, 10:37 am

Event parameters

Post by hypercross »

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 ?
Luther
Posts: 115
Joined: July 28th, 2007, 5:19 pm
Location: USA

Re: Event parameters

Post by Luther »

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
hypercross
Posts: 6
Joined: June 18th, 2013, 10:37 am

Re: Event parameters

Post by hypercross »

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
Thanks.
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Event parameters

Post by 8680 »

The second argument to helper.get_child should be a string, "weapon".
Luther
Posts: 115
Joined: July 28th, 2007, 5:19 pm
Location: USA

Re: Event parameters

Post by Luther »

Yes, that's noted in the comment.
Post Reply