Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wesnoth.wml_actions.check_unit_in_range(cfg)
- local primary_suf = helper.get_child(cfg, "filter") or
- helper.wml_error "[check_unit_in_range] missing required [filter] tag"
- local second_suf = helper.get_child(cfg, "filter_second") or
- helper.wml_error "[check_unit_in_range] missing required [filter_second] tag"
- local variable = cfg.variable
- if variable == nil then
- variable = "in_range"
- end
- local u1 = wesnoth.get_units(primary_suf) or
- helper.wml_error "[check_unit_in_range] could not match primary unit"
- local u2 = wesnoth.get_units(secondary_suf) or
- helper.wml_error "[check_unit_in_range] could not match secondary unit"
- if helper.distance_between(u1.x, u1.y, u2.x, u2.y) <= u1.max_moves then
- wesnoth.set_variable(variable, true)
- else
- wesnoth.set_variable(variable, false)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment