Weapon Special "maims" and "impales"
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Weapon Special "maims" and "impales"
I'm basically trying to make a weapon special called "Maims" that combines the activates-on-hits and the one-turn-duration nature of Slows with the reduces-strikes-based-on-current-hp nature of Swarms, to create a special that, when successfully landed, inflicts a debuff on the enemy that reduces their strikes on every weapon as if their weapons had the Swarms keyword. Similarly, I'm also trying to make a special called 'Impales' which does the same but reduces the enemy's movement points instead of their weapon strikes.
Unfortunately, I haven't been able to dig up example code from the macros list in core, and being entirely new to this WML business I have literally no idea where I'd start making a custom macro of my own. Help?
Unfortunately, I haven't been able to dig up example code from the macros list in core, and being entirely new to this WML business I have literally no idea where I'd start making a custom macro of my own. Help?
Re: Weapon Special "maims" and "impales"
Easy. There might be petty errors, but should be easy to fix (I haven't tested it).
I have used an unofficial WML-tag I found useful, just have this in main to keep it working:
Code: Select all
#define WEAPON_SPECIAL_MAIMS
[dummy]
id=maims
description= _ "Write your coolly worded description here"
[/dummy]
[/specials]
[/attack]
[event]
name=attacker hits
first_time_only=no
[filter_attack]
special=maims
[/filter_attack]
[event]
name=attack end
{VARIABLE intensity "$(-100+$($(100*$second_unit.hitpoints)/$second_unit.max_hitpoints))"}
{FORECH second_unit.modifications.object i}
[if]
[variable]
name=second_unit.modifications.object[$i].name
equals="maimed"
[/variable]
[then] #Removing all objects like this
{CLEAR_VARIABLE second_unit.modifications.object[$i]}
{VARIABLE_OP i sub 1}
[/then]
[/if]
{NEXT i}
[unstore_unit]
variable=second_unit
[/unstore_unit]
[reload_unit_modifications]
id=$second_unit.id
[/reload_unit_modifications]
[object]
duration=turn
silent=yes
name="maimed"
[filter]
find_in=second_unit
[/filter]
[effect]
apply_to=attack
increase_damage=$intensity|%
[/effect]
[effect]
apply_to=status
add=maimed
[/effect]
[/object]
{CLEAR_VARIABLE intesity}
[/event]
[/event]
[event]
name=defender hits
first_time_only=no
[filter_second_attack]
special=maims
[/filter_second_attack]
[event]
name=attack end
{VARIABLE intensity "$(-100+$($(100*$unit.hitpoints)/$unit.max_hitpoints))"}
{FORECH unit.modifications.object i}
[if]
[variable]
name=unit.modifications.object[$i].name
equals="maimed"
[/variable]
[then] #Removing all objects like this
{CLEAR_VARIABLE unit.modifications.object[$i]}
{VARIABLE_OP i sub 1}
[/then]
[/if]
{NEXT i}
[unstore_unit]
variable=unit
[/unstore_unit]
[reload_unit_modifications]
id=$unit.id
[/reload_unit_modifications]
[object]
duration=turn
silent=yes
name="maimed"
[filter]
find_in=unit
[/filter]
[effect]
apply_to=attack
increase_damage=$intensity|%
[/effect]
[effect]
apply_to=status
add=maimed
[/effect]
[/object]
{CLEAR_VARIABLE intesity}
[/event]
[/event]
[+attack]
[+specials]
#enddef
Code: Select all
#define WEAPON_SPECIAL_IMPALES
[dummy]
id=impales
description= _ "Write your coolly worded description here"
[/dummy]
[/specials]
[/attack]
[event]
name=attacker hits
first_time_only=no
[filter_attack]
special=impales
[/filter_attack]
[event]
name=attack end
{VARIABLE intensity "$(-1*$second_unit.max_moves*$second_unit.hitpoints/$second_unit.max_hitpoints)"}
{FORECH second_unit.modifications.object i}
[if]
[variable]
name=second_unit.modifications.object[$i].name
equals="maimed"
[/variable]
[then] #Removing all objects like this
{CLEAR_VARIABLE second_unit.modifications.object[$i]}
{VARIABLE_OP i sub 1}
[/then]
[/if]
{NEXT i}
[unstore_unit]
variable=second_unit
[/unstore_unit]
[reload_unit_modifications]
id=$second_unit.id
[/reload_unit_modifications]
[object]
duration=turn
silent=yes
name="maimed"
[filter]
find_in=second_unit
[/filter]
[effect]
apply_to=movement
increase=$intensity
[/effect]
[effect]
apply_to=status
add=impaled
[/effect]
[/object]
{CLEAR_VARIABLE intesity}
[/event]
[/event]
[event]
name=defender hits
first_time_only=no
[filter_second_attack]
special=impales
[/filter_second_attack]
[event]
name=attack end
{VARIABLE intensity "$(-1*$unit.max_moves*$unit.hitpoints/$unit.max_hitpoints)"}
{FORECH unit.modifications.object i}
[if]
[variable]
name=unit.modifications.object[$i].name
equals="maimed"
[/variable]
[then] #Removing all objects like this
{CLEAR_VARIABLE unit.modifications.object[$i]}
{VARIABLE_OP i sub 1}
[/then]
[/if]
{NEXT i}
[unstore_unit]
variable=unit
[/unstore_unit]
[reload_unit_modifications]
id=$unit.id
[/reload_unit_modifications]
[object]
duration=turn
silent=yes
name="maimed"
[filter]
find_in=unit
[/filter]
[effect]
apply_to=movement
increase=$intensity
[/effect]
[effect]
apply_to=status
add=impaled
[/effect]
[/object]
{CLEAR_VARIABLE intesity}
[/event]
[/event]
[+attack]
[+specials]
#enddef
Code: Select all
[lua]
code=<<
local helper = wesnoth.require "lua/helper.lua"
function wesnoth.wml_actions.reload_unit_modifications(cfg)
-- This is a simple function helping WML - if we remove an [object] or something, we usually need to update its properies, but using [transform_unit] and restoring all other properties every time
-- is tedious. It is simpler to make a WML tag for it.
for i,ru in ipairs(wesnoth.get_units(cfg)) do
local u = ru.__cfg
local health_percentage = u.hitpoints / u.max_hitpoints
local experience_percentage = u.experience / u.max_experience
local moves_percentage = u.moves / u.max_moves
local status = helper.get_child( u, "status" )
local variables = helper.get_child( u, "variables" )
local modifications = helper.get_child( u, "modifications" )
local raw_unit = wesnoth.create_unit { type=u.type, id=u.id, gender=u.gender, facing=u.facing, x=u.x, y=u.y, canrecruit=u.canrecruit, side=u.side, attacks_left=u.attacks_left, name=u.name, { "variables" , variables }, {"modifications" , modifications }, { "status" , status} }
u = raw_unit.__cfg
u.moves = u.max_moves * moves_percentage
u.hitpoints = u.max_hitpoints * health_percentage
u.experience = u.max_experience * experience_percentage
wesnoth.put_unit(u)
end
end
>>
[/lua]
Last edited by Dugi on September 26th, 2013, 10:50 pm, edited 4 times in total.
Re: Weapon Special "maims" and "impales"
Thanks for the help!
I implemented the special (after editing it to also have a line with name=maims to make the dummy special actually show up), and it works- but for some reason whenever I attack or get attacked, an empty text box shows up in the middle of the screen that I have to manually click out of. It's rather distracting- what's up with that?
I implemented the special (after editing it to also have a line with name=maims to make the dummy special actually show up), and it works- but for some reason whenever I attack or get attacked, an empty text box shows up in the middle of the screen that I have to manually click out of. It's rather distracting- what's up with that?
Re: Weapon Special "maims" and "impales"
Oops. I forgot to silence showing the (blank) description of objects. Just add silent=yes to all [object] tags (2 in first code chunk, 2 in second code chunk). I have changed the post above with this correction, so you can just copy it again.
Re: Weapon Special "maims" and "impales"
Hm- it seems that with the current implementation of 'maims', since it reitirates every time i sink a hit, even if the damage is insignificant the minimum possible strikes-decrease for the enemy is still 1, which results in every hit i land equalling a hit the enemy can't land, which is a bit stronger than I intended. Would it be possible to code 'maims' as something which inflicts a status on the enemy similarly to poison and slows, instead of an event which simply fires when the hit lands? (That way, there could also perhaps be a visual indicator like a semitransparent red overlay to indicate the 'wounded' nature.)
E: Also, the fact that the enemy's maimed-ness wears off as soon as they get to their next turn, and the fact that as it is, maim doesn't fire in the middle of a fight- that is, the fight continues with the stats the unit had at the start of it- maim doesn't get much of an opportunity to do much at all as it wears off before a combat with it active can actually happen. Right now, for it to actually be useful, I have to let the enemy hit one of my guys first, because the effect doesn't wear off on /my/ turn- but that's not how I intended the weapon special to work :V
E: Also, the fact that the enemy's maimed-ness wears off as soon as they get to their next turn, and the fact that as it is, maim doesn't fire in the middle of a fight- that is, the fight continues with the stats the unit had at the start of it- maim doesn't get much of an opportunity to do much at all as it wears off before a combat with it active can actually happen. Right now, for it to actually be useful, I have to let the enemy hit one of my guys first, because the effect doesn't wear off on /my/ turn- but that's not how I intended the weapon special to work :V
Last edited by Zerovirus on September 26th, 2013, 9:51 pm, edited 2 times in total.
Re: Weapon Special "maims" and "impales"
You won't be able to implement the status without using an event-based ability (for example, look at stun in UtBS).Zerovirus wrote:Hm- it seems that with the current implementation of 'maims', since it reitirates every time i sink a hit, even if the damage is insignificant the minimum possible strikes-decrease for the enemy is still 1, which results in every hit i land equalling a hit the enemy can't land, which is a bit stronger than I intended. Would it be possible to code 'maims' as something which inflicts a status on the enemy similarly to poison and slows, instead of an event which simply fires when the hit lands? (That way, there could also perhaps be a visual indicator like a semitransparent red overlay to indicate the 'wounded' nature.)
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.
Re: Weapon Special "maims" and "impales"
Ability, you say?bumbadadabum wrote:You won't be able to implement the status without using an event-based ability (for example, look at stun in UtBS).
I have simply edited my codes above, delaying the effect of the weapon special to the end of attack by moving it into a nested attack end event. I have made it also remove all objects of this kind before applying the new one. Also, it adds a status, that can be assigned an icon using this.
Re: Weapon Special "maims" and "impales"
...By "have it in main", you mean _main.cfg? Because this is what I'm getting right now. (I figure I probably have the lua code in the wrong place or something.)
Re: Weapon Special "maims" and "impales"
Oh, dammit, forgot to tell it to load helper. Fixed it in that post above.
Re: Weapon Special "maims" and "impales"
Welp, copypasted in the new version of the lua addendum to _main. Got rid of the error... but the weapon special /still/ doesn't work? :S Can't tell you what exactly is going wrong, here.Dugi wrote:Oh, dammit, forgot to tell it to load helper. Fixed it in that post above.
Re: Weapon Special "maims" and "impales"
Still doesn't work? Means that it does the same than for the first time when it stacked with itself or doesn't work at all? Please, be more specific when telling that something doesn't work.
Re: Weapon Special "maims" and "impales"
It would be the second, in this case. The weapon special basically doesn't change anything regarding how combat plays out, as far as I've been able to tell.Dugi wrote: Still doesn't work? Means that it does the same than for the first time when it stacked with itself or doesn't work at all? Please, be more specific when telling that something doesn't work.
Re: Weapon Special "maims" and "impales"
I tried my hand at the maims special (this only work on 1.11, as far as I know):
EDIT: And Impales as well
Code: Select all
#define WEAPON_SPECIAL_MAIMS
[dummy]
id=maims
name= _ "maims"
description= _ "xyz"
[/dummy]
# wmlindent: start ignoring
# wmlxgettext: [specials]
[/specials]
# wmlxgettext: [attack]
[/attack]
# wmlindent: stop ignoring
[event]
name=attacker hits
id=maims_attacker_hits
first_time_only=no
[filter_attack]
special=maims
[/filter_attack]
[filter_second]
[not]
[filter_wml]
[status]
maimed=yes
[/status]
[/filter_wml]
[/not]
[/filter_second]
[modify_unit]
[filter]
find_in=second_unit
[/filter]
[status]
maimed=yes
[/status]
[/modify_unit]
[object]
silent=yes
duration=turn
[filter]
find_in=second_unit
[/filter]
[effect]
apply_to=image_mod
replace="CS(50,50,50)" # Change if you want another color shift
[/effect]
[effect]
apply_to=attack
[set_specials]
mode=append
{WEAPON_SPECIAL_SWARM}
[/set_specials]
[/effect]
[/object]
[/event]
[event]
name=defender hits
id=maims_defender_hits
first_time_only=no
[filter_second_attack]
special=maims
[/filter_second_attack]
[filter]
[not]
[filter_wml]
[status]
maimed=yes
[/status]
[/filter_wml]
[/not]
[/filter]
[modify_unit]
[filter]
find_in=unit
[/filter]
[status]
maimed=yes
[/status]
[/modify_unit]
[object]
silent=yes
duration=turn
[filter]
find_in=unit
[/filter]
[effect]
apply_to=image_mod
replace="CS(50,50,50)" # Change if you want another color shift
[/effect]
[effect]
apply_to=attack
[set_specials]
mode=append
{WEAPON_SPECIAL_SWARM}
[/set_specials]
[/effect]
[/object]
[/event]
[event]
name=turn refresh
id=maimed_turn_refresh
first_time_only=no
[store_unit]
[filter]
side=$side_number
[filter_wml]
[status]
maimed=yes
[/status]
[/filter_wml]
[/filter]
variable=maimed
[/store_unit]
{FOREACH maimed i}
{CLEAR_VARIABLE maimed[$i].status.maimed}
[unstore_unit]
variable=maimed[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE maimed}
[/event]
# wmlindent: start ignoring
[+attack]
[+specials]
# wmlxgettext: [/specials]
# wmlxgettext: [/attack]
# wmlindent: stop ignoring
#enddef
Code: Select all
#define WEAPON_SPECIAL_IMPALES
[dummy]
id=impales
name= _ "impales"
description= _ "asdf"
[/dummy]
# wmlindent: start ignoring
# wmlxgettext: [specials]
[/specials]
# wmlxgettext: [attack]
[/attack]
# wmlindent: stop ignoring
[event]
name=attacker hits
id=impales_attacker_hits
first_time_only=no
[filter_attack]
special=impales
[/filter_attack]
[filter_second]
[not]
[filter_wml]
[status]
impaled=yes
[/status]
[/filter_wml]
[/not]
[/filter_second]
{VARIABLE impales_set_moves $second_unit.hitpoints}
{VARIABLE_OP impales_set_moves divide $second_unit.max_hitpoints}
{VARIABLE_OP impales_set_moves multiply $second_unit.max_moves}
{VARIABLE_OP impales_set_moves round ceil}
[modify_unit]
[filter]
find_in=second_unit
[/filter]
max_moves=$impales_set_moves
[status]
impaled=yes
[/status]
[variables]
original_moves=$second_unit.max_moves
[/variables]
[/modify_unit]
{CLEAR_VARIABLE impales_set_moves}
[object]
silent=yes
duration=turn
[filter]
find_in=second_unit
[/filter]
[effect]
apply_to=image_mod
replace="CS(80,20,20)" # Change if you want another color shift
[/effect]
[/object]
[/event]
[event]
name=defender hits
id=impales_defender_hits
first_time_only=no
[filter_second_attack]
special=impales
[/filter_second_attack]
[filter]
[not]
[filter_wml]
[status]
impaled=yes
[/status]
[/filter_wml]
[/not]
[/filter]
{VARIABLE impales_set_moves $unit.hitpoints}
{VARIABLE_OP impales_set_moves divide $unit.max_hitpoints}
{VARIABLE_OP impales_set_moves multiply $unit.max_moves}
{VARIABLE_OP impales_set_moves round ceil}
[modify_unit]
[filter]
find_in=unit
[/filter]
max_moves=$impales_set_moves
[status]
impaled=yes
[/status]
[variables]
original_moves=$unit.max_moves
[/variables]
[/modify_unit]
{CLEAR_VARIABLE impales_set_moves}
[object]
silent=yes
duration=turn
[filter]
find_in=unit
[/filter]
[effect]
apply_to=image_mod
replace="CS(80,20,20)" # Change if you want another color shift
[/effect]
[/object]
[/event]
[event]
name=attacker hits
id=impaled_defender
first_time_only=no
[filter_second]
[filter_wml]
[status]
impaled=yes
[/status]
[/filter_wml]
[/filter_second]
{VARIABLE impales_set_moves $second_unit.hitpoints}
{VARIABLE_OP impales_set_moves divide $second_unit.max_hitpoints}
{VARIABLE_OP impales_set_moves multiply $second_unit.max_moves}
{VARIABLE_OP impales_set_moves round ceil}
[modify_unit]
[filter]
find_in=second_unit
[/filter]
max_moves=$impales_set_moves
[/modify_unit]
{CLEAR_VARIABLE impales_set_moves}
[/event]
[event]
name=defender hits
id=impaled_attacker
first_time_only=no
[filter]
[filter_wml]
[status]
impaled=yes
[/status]
[/filter_wml]
[/filter]
{VARIABLE impales_set_moves $unit.hitpoints}
{VARIABLE_OP impales_set_moves divide $unit.max_hitpoints}
{VARIABLE_OP impales_set_moves multiply $unit.max_moves}
{VARIABLE_OP impales_set_moves round ceil}
[modify_unit]
[filter]
find_in=unit
[/filter]
max_moves=$impales_set_moves
[/modify_unit]
{CLEAR_VARIABLE impales_set_moves}
[/event]
[event]
name=turn refresh
id=maimed_turn_refresh
first_time_only=no
[store_unit]
[filter]
side=$side_number
[filter_wml]
[status]
impaled=yes
[/status]
[/filter_wml]
[/filter]
variable=impaled
[/store_unit]
{FOREACH impaled i}
{CLEAR_VARIABLE impaled[$i].status.impaled}
{VARIABLE impaled[$i].max_moves $impaled[$i].variables.original_moves}
[unstore_unit]
variable=impaled[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE impaled}
[/event]
# wmlindent: start ignoring
[+attack]
[+specials]
# wmlxgettext: [/specials]
# wmlxgettext: [/attack]
# wmlindent: stop ignoring
#enddef
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.
Re: Weapon Special "maims" and "impales"
I've only tried implementing your version of 'maims', but it works very well, except for the issue that the duration is somewhat inconsistent (I suspect because of the timing of the event that checks to deactivate the appended swarms effect)- if I attack the enemy and activate it, the effect wears off as soon as it becomes the enemy's turn, but if the enemy attacks me and activates it, the effect remains active through my turn and only deactivates on the enemy's turn. I'd be okay with either the effect just lasting one turn and ending as soon as my turn ends, or the effect lasting through the next turn, but right now it's a bit inconsistent. (If that's not possible, I'll probably remove the defender_hits version of maims- in fact, I may do that anyways just because a unit which inflicts swarms on retaliation damage is sort of really powerful as far as acting as a deterrent against enemy offensive operations goes.)bumbadadabum wrote:I tried my hand at the maims special (this only work on 1.11, as far as I know):
Still, thanks! This is probably the best version of maims that I've gotten my hands on at this point.
E: Impales suffers from the same problem- and it's worse for impales, because a weapon special designed to make the opponent have trouble running away on their turn isn't very useful if it removes itself as soon as the enemy actually /gets/ to their turn. At least maims can be used to make it easier to zerg-rush an enemy unit on your turn- in the current state, impales is all but useless.
Re: Weapon Special "maims" and "impales"
Fixed that and rewrote some other things (with some help from 8680):Zerovirus wrote:I've only tried implementing your version of 'maims', but it works very well, except for the issue that the duration is somewhat inconsistent (I suspect because of the timing of the event that checks to deactivate the appended swarms effect)- if I attack the enemy and activate it, the effect wears off as soon as it becomes the enemy's turn, but if the enemy attacks me and activates it, the effect remains active through my turn and only deactivates on the enemy's turn. I'd be okay with either the effect just lasting one turn and ending as soon as my turn ends, or the effect lasting through the next turn, but right now it's a bit inconsistent. (If that's not possible, I'll probably remove the defender_hits version of maims- in fact, I may do that anyways just because a unit which inflicts swarms on retaliation damage is sort of really powerful as far as acting as a deterrent against enemy offensive operations goes.)bumbadadabum wrote:I tried my hand at the maims special (this only work on 1.11, as far as I know):
Still, thanks! This is probably the best version of maims that I've gotten my hands on at this point.
E: Impales suffers from the same problem- and it's worse for impales, because a weapon special designed to make the opponent have trouble running away on their turn isn't very useful if it removes itself as soon as the enemy actually /gets/ to their turn. At least maims can be used to make it easier to zerg-rush an enemy unit on your turn- in the current state, impales is all but useless.
Code: Select all
#define WEAPON_SPECIAL_MAIMS
[dummy]
id=maims
name= _ "maims"
description= _ "xyz"
[/dummy]
# wmlindent: start ignoring
# wmlxgettext: [specials]
[/specials]
# wmlxgettext: [attack]
[/attack]
# wmlindent: stop ignoring
[event]
name=attacker hits
id=maims_attacker_hits
first_time_only=no
[filter_attack]
special=maims
[/filter_attack]
[filter_second]
[not]
[filter_wml]
[status]
maimed=yes
[/status]
[/filter_wml]
[/not]
[/filter_second]
[fire_event]
name=maims_event
[primary_unit]
find_in=unit
[/primary_unit]
[secondary_unit]
find_in=second_unit
[/secondary_unit]
[/fire_event]
[/event]
[event]
name=defender hits
id=maims_defender_hits
first_time_only=no
[filter_second_attack]
special=maims
[/filter_second_attack]
[filter]
[not]
[filter_wml]
[status]
maimed=yes
[/status]
[/filter_wml]
[/not]
[/filter]
[fire_event]
name=maims_event
[primary_unit]
find_in=second_unit
[/primary_unit]
[secondary_unit]
find_in=unit
[/secondary_unit]
[/fire_event]
[/event]
[event]
name=maims_event
id=maims_event
first_time_only=no
[modify_unit]
[filter]
find_in=second_unit
[/filter]
[status]
maimed=yes
[/status]
[variables]
maimed_by=$unit.side
[/variables]
[/modify_unit]
[object]
silent=yes
duration=turn
object_type=maimed
[filter]
find_in=second_unit
[/filter]
[effect]
apply_to=image_mod
replace="CS(50,50,50)" # Change if you want another color shift
[/effect]
[effect]
apply_to=attack
[set_specials]
mode=append
{WEAPON_SPECIAL_SWARM}
[/set_specials]
[/effect]
[/object]
[/event]
[event]
name=turn refresh
id=maimed_turn_refresh
first_time_only=no
[store_unit]
[filter]
[filter_wml]
[status]
maimed=yes
[/status]
[variables]
maimed_by=$side_number
[/variables]
[/filter_wml]
[/filter]
variable=maimed
[/store_unit]
{FOREACH maimed i}
{LOOKUP_INDEX maimed[$i].modifications object_type maimed clear_maimed}
{CLEAR_VARIABLE maimed[$i].status.maimed,maimed[$i].variables.maimed_by,maimed[$i].modifications[$clear_maimed],clear_maimed}
[unstore_unit]
variable=maimed[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE maimed}
[/event]
# wmlindent: start ignoring
[+attack]
[+specials]
# wmlxgettext: [/specials]
# wmlxgettext: [/attack]
# wmlindent: stop ignoring
#enddef
#define WEAPON_SPECIAL_IMPALES
[dummy]
id=impales
name= _ "impales"
description= _ "asdf"
[/dummy]
# wmlindent: start ignoring
# wmlxgettext: [specials]
[/specials]
# wmlxgettext: [attack]
[/attack]
# wmlindent: stop ignoring
[event]
name=attacker hits
id=impales_attacker_hits
first_time_only=no
[filter_attack]
special=impales
[/filter_attack]
[filter_second]
[not]
[filter_wml]
[status]
impaled=yes
[/status]
[/filter_wml]
[/not]
[/filter_second]
[fire_event]
name=impales_event
[primary_unit]
find_in=unit
[/primary_unit]
[secondary_unit]
find_in=second_unit
[/secondary_unit]
[/fire_event]
[/event]
[event]
name=defender hits
id=impales_defender_hits
first_time_only=no
[filter_second_attack]
special=impales
[/filter_second_attack]
[filter]
[not]
[filter_wml]
[status]
impaled=yes
[/status]
[/filter_wml]
[/not]
[/filter]
[fire_event]
name=impales_event
[primary_unit]
find_in=second_unit
[/primary_unit]
[secondary_unit]
find_in=unit
[/secondary_unit]
[/fire_event]
[/event]
[event]
name=impales_event
id=impales_event
first_time_only=no
{VARIABLE impales_set_moves $second_unit.hitpoints}
{VARIABLE_OP impales_set_moves divide $second_unit.max_hitpoints}
{VARIABLE_OP impales_set_moves multiply $second_unit.max_moves}
{VARIABLE_OP impales_set_moves round ceil}
[modify_unit]
[filter]
find_in=second_unit
[/filter]
max_moves=$impales_set_moves
[status]
impaled=yes
[/status]
[variables]
original_moves=$second_unit.max_moves
impaled_by=$unit.side
[/variables]
[/modify_unit]
{CLEAR_VARIABLE impales_set_moves}
[object]
silent=yes
duration=turn
object_type=impaled
[filter]
find_in=second_unit
[/filter]
[effect]
apply_to=image_mod
replace="CS(80,20,20)" # Change if you want another color shift
[/effect]
[/object]
[/event]
[event]
name=attacker hits
id=impaled_defender
first_time_only=no
[filter_second]
[filter_wml]
[status]
impaled=yes
[/status]
[/filter_wml]
[/filter_second]
[fire_event]
name=impale_set_moves
[primary_unit]
find_in=unit
[/primary_unit]
[secondary_unit]
find_in=second_unit
[/secondary_unit]
[/fire_event]
[/event]
[event]
name=defender hits
id=impaled_attacker
first_time_only=no
[filter]
[filter_wml]
[status]
impaled=yes
[/status]
[/filter_wml]
[/filter]
[fire_event]
name=impale_set_moves
[primary_unit]
find_in=second_unit
[/primary_unit]
[secondary_unit]
find_in=unit
[/secondary_unit]
[/fire_event]
[/event]
[event]
name=impale_set_moves
id=impale_set_moves
first_time_only=no
{VARIABLE impales_set_moves $second_unit.hitpoints}
{VARIABLE_OP impales_set_moves divide $second_unit.max_hitpoints}
{VARIABLE_OP impales_set_moves multiply $second_unit.max_moves}
{VARIABLE_OP impales_set_moves round ceil}
[modify_unit]
[filter]
find_in=second_unit
[/filter]
max_moves=$impales_set_moves
[/modify_unit]
{CLEAR_VARIABLE impales_set_moves}
[/event]
[event]
name=turn refresh
id=maimed_turn_refresh
first_time_only=no
[store_unit]
[filter]
[filter_wml]
[status]
impaled=yes
[/status]
[variables]
impaled_by=$side_number
[/variables]
[/filter_wml]
[/filter]
variable=impaled
[/store_unit]
{FOREACH impaled i}
{VARIABLE impaled[$i].max_moves $impaled[$i].variables.original_moves}
{LOOKUP_INDEX impaled[$i].modifications object_type impaled clear_impaled}
{CLEAR_VARIABLE impaled[$i].status.impaled,impaled[$i].variables.original_moves,impaled[$i].variables.impaled_by,impaled[$i].modifications[$clear_impaled],clear_impaled}
[unstore_unit]
variable=impaled[$i]
[/unstore_unit]
{NEXT i}
{CLEAR_VARIABLE impaled}
[/event]
# wmlindent: start ignoring
[+attack]
[+specials]
# wmlxgettext: [/specials]
# wmlxgettext: [/attack]
# wmlindent: stop ignoring
#enddef
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.