Die event modification
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.
- Spannerbag
- Posts: 572
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Die event modification
I'm trying to do something that may be impossible
I'm posting this here first (rather than lua labs) in case it can be done in WML
I want to resurrect a unit immediately after it dies.
I'm testing the logic using a leader (as its death=defeat).
I have got the logic working except for the removal of the unit when the die event finishes.
I've tried using
in
Which makes sense as
So when I put the killed unit back,
The logic needs to:
- work on both player and ai turn
- work without player interaction/intervention (because of previous point)
- work for more than one unit (including leaders) on the same turn
- maintain unit ids (at least for leaders and some loyals)
- cater for the fact that the resurrected unit could immediately die again, possibly on same ai turn (unit avoids dying only once)
- ideally, the animation/dialogue should be:
-- unit issues alternate
-- unit heals
-- unit (at least apparently) remains on map all the time
-- gameplay continues as normal (no modified unit ids etc.)
I can think of various possibilities but they all seem complex, awkward and the combinations are too many for my little brain to accommodate
I don't see how any "post die" event could be crafted.
To me, the ideal solution would be in effect to allow
Would it be possible to hack
For lua labs if I end up posting this there
Any thoughts/comments greatly appreciated!
Cheers,
--Spannerbag
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
I'm posting this here first (rather than lua labs) in case it can be done in WML
![Smile :)](./images/smilies/icon_smile.gif)
I want to resurrect a unit immediately after it dies.
I'm testing the logic using a leader (as its death=defeat).
I have got the logic working except for the removal of the unit when the die event finishes.
I've tried using
Code: Select all
[kill] # Stop die event (and defeat if leader)
x,y=$x1,$y1
fire_event=no
animate=no
[/kill]
last breath
and die
but when I reinstate the (healed) unit the die event fires and the unit vanishes.Which makes sense as
kill
removes the unit so die
has nothing to do (no unit with specified id).So when I put the killed unit back,
die
kicks in again.The logic needs to:
- work on both player and ai turn
- work without player interaction/intervention (because of previous point)
- work for more than one unit (including leaders) on the same turn
- maintain unit ids (at least for leaders and some loyals)
- cater for the fact that the resurrected unit could immediately die again, possibly on same ai turn (unit avoids dying only once)
- ideally, the animation/dialogue should be:
-- unit issues alternate
last breath
-- unit heals
-- unit (at least apparently) remains on map all the time
-- gameplay continues as normal (no modified unit ids etc.)
I can think of various possibilities but they all seem complex, awkward and the combinations are too many for my little brain to accommodate
![Confused :?](./images/smilies/icon_confused.gif)
I don't see how any "post die" event could be crafted.
To me, the ideal solution would be in effect to allow
die
to fire but not remove the unit.Would it be possible to hack
die
in some way to suppress unit removal or reinstate same?For lua labs if I end up posting this there
What I'm thinking is this: could a chunk of lua code be crafted to allow the insertion of a
If absent/unassigned it defaults to
Not sure if this would interfere with other campaigns? I don't see that it would, but I wouldn't want to break anything...
remove=
boolean
tag into die?If absent/unassigned it defaults to
true
(normal behaviour) but if set to no
/false
unit removal does not occur (but the die
event still fires of course).Not sure if this would interfere with other campaigns? I don't see that it would, but I wouldn't want to break anything...
Any thoughts/comments greatly appreciated!
Cheers,
--Spannerbag
- Lord-Knightmare
- Discord Moderator
- Posts: 2379
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Die event modification
I think DM's S19 had a similar codeI want to resurrect a unit immediately after it dies.
I'm testing the logic using a leader (as its death=defeat).
Code: Select all
[event]
name=last breath
first_time_only=no
[filter]
id=Iliah-Malal
[/filter]
[message]
speaker="Iliah-Malal"
message=_ "The power of death is mine! When you strike me down I arise stronger than before!"
[/message]
{ADVANCE_UNIT (id="Iliah-Malal") ()}
[/event]
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Die event modification
Have you tried just healing the unit, and not
IIRC, defeat isn't triggered by the leader dying, it's triggered by having no units with
[kill]
ing it in the die
event?IIRC, defeat isn't triggered by the leader dying, it's triggered by having no units with
canrecruit=yes
when the game isn't processing an [event]
. Removing and replacing the only canrecruit=yes
unit during an event is fine.- Spannerbag
- Posts: 572
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Die event modification
Thanks for your reply, much appreciated.
Or some other combination of same...
Thanks for the suggestion, will try it out!
Cheers!
--Spannerbag
Hmm... I could try storing the unit, advancing it to itself (same type) then clobbering it with the stored version then finally healing it.Lord-Knightmare wrote: ↑March 15th, 2022, 12:26 pm I think DM's S19 had a similar codeCode: Select all
[event] name=last breath first_time_only=no [filter] id=Iliah-Malal [/filter] [message] speaker="Iliah-Malal" message=_ "The power of death is mine! When you strike me down I arise stronger than before!" [/message] {ADVANCE_UNIT (id="Iliah-Malal") ()} [/event]
Or some other combination of same...
Thanks for the suggestion, will try it out!
Cheers!
--Spannerbag
- pyrophorus
- Posts: 533
- Joined: December 1st, 2010, 12:54 pm
Re: Die event modification
Hi,
If I understand correctly what you want, this should work (in a die event) (at least it works for me).
HTH...
If I understand correctly what you want, this should work (in a die event) (at least it works for me).
Code: Select all
# the kill action is necessary to free the unit position before creating a new one.
# else, the new unit would be created on an adjacent hex.
[store_unit]
[filter]
id=$unit.id
[/filter]
variable=tmp
kill=yes
animate=no
[/store_unit]
{VARIABLE tmp.moves 0}
{VARIABLE tmp.attacks_left 0}
{VARIABLE tmp.hitpoints $tmp.max_hitpoints} # you must restore some hitpoints to avoid unit dying again
{VARIABLE tmp.status.poisoned no}
{VARIABLE tmp.experience "$($tmp.experience / 2)"}
[unstore_unit]
variable=tmp
x,y=$tmp.x,$tmp.y
find_vacant=yes
[/unstore_unit]
HowTos: WML filtering, WML variables
- Spannerbag
- Posts: 572
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Die event modification
Thanks for taking the trouble to reply.
FWIW I'm using
The defeat issue is solved, thanks, the issue is that the healed unit disappears when the various death related events complete.
Cheers!
--Spannerbag
Just tried that, unit still disappears.octalot wrote: ↑March 15th, 2022, 2:46 pm Have you tried just healing the unit, and not[kill]
ing it in thedie
event?
IIRC, defeat isn't triggered by the leader dying, it's triggered by having no units withcanrecruit=yes
when the game isn't processing an[event]
. Removing and replacing the onlycanrecruit=yes
unit during an event is fine.
FWIW I'm using
:debug
's kill (shift-K
) to test.The defeat issue is solved, thanks, the issue is that the healed unit disappears when the various death related events complete.
Cheers!
--Spannerbag
- Spannerbag
- Posts: 572
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Die event modification
Hi pyrophorus,
thanks for the reply.
The issue is (I think) that although the unit is healed it retains the same id, type etc. so
I'm happy to post the relevant code chunks if that helps?
I think I'm going to have to setup a test sling...
Cheers!
--Spannerbag
thanks for the reply.
Tried something similar. Sadly didn't work.pyrophorus wrote: ↑March 15th, 2022, 9:46 pm Hi,
If I understand correctly what you want, this should work (in a die event) (at least it works for me).HTH...Code: Select all
# the kill action is necessary to free the unit position before creating a new one. # else, the new unit would be created on an adjacent hex. [store_unit] [filter] id=$unit.id [/filter] variable=tmp kill=yes animate=no [/store_unit] {VARIABLE tmp.moves 0} {VARIABLE tmp.attacks_left 0} {VARIABLE tmp.hitpoints $tmp.max_hitpoints} # you must restore some hitpoints to avoid unit dying again {VARIABLE tmp.status.poisoned no} {VARIABLE tmp.experience "$($tmp.experience / 2)"} [unstore_unit] variable=tmp x,y=$tmp.x,$tmp.y find_vacant=yes [/unstore_unit]
The issue is (I think) that although the unit is healed it retains the same id, type etc. so
die
finds a matching id and removes it.I'm happy to post the relevant code chunks if that helps?
I think I'm going to have to setup a test sling...
Cheers!
--Spannerbag
- Spannerbag
- Posts: 572
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Die event modification: solved (at least in test sling)
Hi all,
many thanks to everyone who replied, it really is appreciated.
As octalot suggested simply healing the unit does work.
The issue was that I'd hacked about the original code so much I'd forgotten that I wasn't using
Using the former seems to work fine in my test environment so I'll try it in the scenario I'm testing.
Wish I'd spotted that 2 days ago...
Very annoyed with myself
Cheers!
--Spannerbag
many thanks to everyone who replied, it really is appreciated.
As octalot suggested simply healing the unit does work.
The issue was that I'd hacked about the original code so much I'd forgotten that I wasn't using
[filter]
but [filter_condition]
.Using the former seems to work fine in my test environment so I'll try it in the scenario I'm testing.
Wish I'd spotted that 2 days ago...
![Augh :augh:](./images/smilies/icon_augh.gif)
![Augh :augh:](./images/smilies/icon_augh.gif)
![Augh :augh:](./images/smilies/icon_augh.gif)
Very annoyed with myself
![Annoyed :annoyed:](./images/smilies/icon_annoyed.gif)
Cheers!
--Spannerbag
- Spannerbag
- Posts: 572
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Die event modification - ps
Heh, tried the very same code from my test sling in my real scenario: didn't work, same as before.
So, noting that in my test sling I had an enemy kill my leader I spawned a berserker and had that kill my test unit in the real scenario... and it worked
This means that when I was testing using debug and killing the unit "manually" (rather than getting an enemy to do so) my test would never work.
Oh well, I've learned something (if I remember it).
Again, thanks to all for your help and patience, this was driving me crazy and after several days, I can resume testing.
Cheers!
--Spannerbag
So, noting that in my test sling I had an enemy kill my leader I spawned a berserker and had that kill my test unit in the real scenario... and it worked
![Shocked :shock:](./images/smilies/icon_eek.gif)
This means that when I was testing using debug and killing the unit "manually" (rather than getting an enemy to do so) my test would never work.
Oh well, I've learned something (if I remember it).
Again, thanks to all for your help and patience, this was driving me crazy and after several days, I can resume testing.
Cheers!
--Spannerbag
Re: Die event modification
I thought it would be expected that if you use debug you can get any kind of results which have nothing to do with what would actually happen in game.
So instead of debug kill, create new unit, set old unit to 1hp.
So instead of debug kill, create new unit, set old unit to 1hp.
- Spannerbag
- Posts: 572
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Die event modification
Hi Ravana, thanks for your post.
I'd just assumed that
As I say, I've learned something and won't use![Smile :)](./images/smilies/icon_smile.gif)
Cheers!
--Spannerbag
Yep, I did something similar, created an enemy Dwarvish Berserker (didn't bother setting hitpoints to zero on the old unit, though usually I do where appropriate).
I'd just assumed that
:debug
kill would fire the same death events etc. and behave the same as if an enemy had done so.As I say, I've learned something and won't use
:debug
kill except for clearing away unwanted units during testing ![Smile :)](./images/smilies/icon_smile.gif)
Cheers!
--Spannerbag