How to make one unit stop striking during an attack
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.
- Celtic_Minstrel
- Developer
- Posts: 2209
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: How to make one unit stop striking during an attack
Based on the wiki, you could likely copy the implementation of
[store_unit_defense]
into your addon and use it even on 1.12. I can't guarantee 100% that it will work, but I think there's a very good chance.Re: How to make one unit stop striking during an attack
I'll try that, thanks
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: How to make one unit stop striking during an attack
Yeah, that's still not a total solution though, because it ignores things like leadership and weapon specials.
I think there really needs to be an easier way to do this: either harm_unit needs enhancements so that it can completely emulate a normal strike, or there should be a new tag to do it.
Probably a new tag would be best... one can check defense, fires hit/miss/death events, apply damage, grant exp, and trigger all the relevant animations with ease.
I think there really needs to be an easier way to do this: either harm_unit needs enhancements so that it can completely emulate a normal strike, or there should be a new tag to do it.
Probably a new tag would be best... one can check defense, fires hit/miss/death events, apply damage, grant exp, and trigger all the relevant animations with ease.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
- skeptical_troll
- Posts: 500
- Joined: August 31st, 2015, 11:06 pm
Re: How to make one unit stop striking during an attack
hmm, I was curious about this and did some experiment myself. If instead of using the [modify_unit] tag I do manually the store-unstore business in an 'attack' event and set it does what you want. Am I missing something? Of course, you need to take care of choosing the right attack to disable and to restore the right number at the end of the event, but I'm confident that should be pretty doable.
I tried this because I already noticed in the past that [modify_unit] doesn't work exactly as doing things manually, or using the {MODIFY_UNIT} macro.
EDIT: I see now that you want 'attacker_hits' and indeed it doesn't work. I'll leave this here anyway, it's weird that the behaviour is different for the two events.
Code: Select all
stored_unit_variable.attack[0].number=0
I tried this because I already noticed in the past that [modify_unit] doesn't work exactly as doing things manually, or using the {MODIFY_UNIT} macro.
EDIT: I see now that you want 'attacker_hits' and indeed it doesn't work. I'll leave this here anyway, it's weird that the behaviour is different for the two events.
Re: How to make one unit stop striking during an attack
If you accepted the unit striking, but doing no damage, it could work like the EoMa Cyclops' growing fury special. In that special, each successful hit means that the following strikes do more damage, with adjustments for resistance and slows.
https://github.com/ProditorMagnus/Agele ... g-fury.cfg
But, I'm trying it today with a local game (1.12 in multiplayer mode), and the special works. I was hosting a game last night where another player had a cyclops, we didn't have any OOS reports, the other player reported it working and watching the replay I see the special working; however during the game itself the damage displayed to me when he hit enemies didn't change. So possibly the correct damage is only shown to the active player. The pre-fight damage calculations show it wrongly.
http://replays.wesnoth.org/1.12/2018011 ... 92991).bz2
And, seeing as it might do what you want, you are now debugging it not me, kthxbye
https://github.com/ProditorMagnus/Agele ... g-fury.cfg
But, I'm trying it today with a local game (1.12 in multiplayer mode), and the special works. I was hosting a game last night where another player had a cyclops, we didn't have any OOS reports, the other player reported it working and watching the replay I see the special working; however during the game itself the damage displayed to me when he hit enemies didn't change. So possibly the correct damage is only shown to the active player. The pre-fight damage calculations show it wrongly.
http://replays.wesnoth.org/1.12/2018011 ... 92991).bz2
And, seeing as it might do what you want, you are now debugging it not me, kthxbye
Re: How to make one unit stop striking during an attack
Sapient wrote: Probably a new tag would be best... one can check defense, fires hit/miss/death events, apply damage, grant exp, and trigger all the relevant animations with ease.
Code: Select all
[simulate_attack]
[filter]
# attacker
[/filter]
[filter_second]
# defender
[/filter_second]
[filter_weapon]
# primary attack, if omitted, decided by attack_weight
[/filter_weapon]
[filter_second_weapon]
# defense weapon, if omitted, decided by defense_weight
[/filter_second_weapon]
reduce_attacks = # if specified, subtracted from the attack numbers, defaults to 0
# couple of booleans, like in [harm_unit]:
kill, experience, fire_event, etc. = yes=/no
[/simulate_attack]
Yeah A couple of posts back, I was guessing for an interpretation, attack event works because it's before the "fight is loaded", in attacker hits, modification can only take place after the fight.skeptical_troll wrote: I see now that you want 'attacker_hits' and indeed it doesn't work.
I think that's far from what is intended here It's not the damage that needs to be altered or anything.octalot wrote:If you accepted the unit striking, but doing no damage, it could work like the EoMa Cyclops' growing fury special. In that special, each successful hit means that the following strikes do more damage, with adjustments for resistance and slows.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: How to make one unit stop striking during an attack
Although the animation would look different, I don't understand how "stops doing damage" is functionally different from "stops striking". Please would you explain, as it might help someone think of a way to do what you want.WhiteWolf wrote:I think that's far from what is intended here It's not the damage that needs to be altered or anything.octalot wrote:If you accepted the unit striking, but doing no damage, it could work like the EoMa Cyclops' growing fury special. In that special, each successful hit means that the following strikes do more damage, with adjustments for resistance and slows.
My idea would be to modify the growing fury code to fit a description like this:
Trainer's Sabre: A duellist may wish to avoid the killing blow, allowing the opponent to fight a little longer. On the practise ground, where training should not be fatal, on the parade ground, where a fatal blow would be undiplomatic, or on the battlefield, to give a trainee the experience of the kill. Special notes: this attack hits normally when the opponent has enough hp to survive the blow, but does no damage if it would be the killing blow.
Re: How to make one unit stop striking during an attack
Sorry, I was a little ignorant here. Yes, it would make the desired result, but I discarded this solution at the very beginning, because of the animation issue. In my opinion, for the case where I'd like this effect, the unit that's supposed to stop the fight, would look weird and out of context, keeping hitting, just doing 0 damage.
I'm thinking now about ways to somehow hide the attack animations that happen there. Not sure if this is possible, somehow with [hide_unit] or, by removing temporarily the attack animations, I'll try and experiment with this
I'm thinking now about ways to somehow hide the attack animations that happen there. Not sure if this is possible, somehow with [hide_unit] or, by removing temporarily the attack animations, I'll try and experiment with this
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
- Celtic_Minstrel
- Developer
- Posts: 2209
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: How to make one unit stop striking during an attack
Simulate attack is something that already exists (though only in Lua). So that tag you suggested might be able to be implemented even in 1.12.
Re: How to make one unit stop striking during an attack
well, that’s pretty close. but it doesn’t take care of animating, damaging, granting kill exp. I still think it needs an official WML tag.Celtic_Minstrel wrote:Simulate attack is something that already exists (though only in Lua). So that tag you suggested might be able to be implemented even in 1.12.
ideally when these C++ hooks are being added to Lua there should be a WML-only way of getting similar information committed at around the same time, for the benefit of those who don’t grok Lua.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: How to make one unit stop striking during an attack
I had the thing on rest for a while, but I finished experimenting, and the best result i'd say is... set the damage to zero.
Not sure if it's intentional or not, but when damage=0, always the miss animation is played, even when the unit should hit a do 0 damage. Kinda cool for the feature I want out of this, so "stop striking" is degraded to "stop delivering hits", but all effects are the same without compromises.
Here's the full code (now with the combating events passing over weapon info
The fun thing is, if instead of iterating over the attack array, and finding the weapon with $weapon.name, I wanted to directly modify the unit, it doesn't work.
What this does, is that it ALWAYS does the effect on the first attack (usually the melee for most units). So if the unit attacks with its attack[0] == sword, it works fine, but if it attacks with f.e. its bow, even though $weapon.name == bow will be correct, this modify_unit will still find and modify attack[0], the sword.
Not sure if this is a WML bug or not, but luckily it can be worked around.
Not sure if it's intentional or not, but when damage=0, always the miss animation is played, even when the unit should hit a do 0 damage. Kinda cool for the feature I want out of this, so "stop striking" is degraded to "stop delivering hits", but all effects are the same without compromises.
Here's the full code (now with the combating events passing over weapon info
Spoiler:
Code: Select all
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
[attack]
name=$weapon.name
damage=0
[/attack]
[/modify_unit]
Not sure if this is a WML bug or not, but luckily it can be worked around.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: How to make one unit stop striking during an attack
That's not a bug. You are in fact modifying both the name and the damage for the first attack. If you want to use modify_unit and avoid writing your own loop, you could do it like this:WhiteWolf wrote: The fun thing is, if instead of iterating over the attack array, and finding the weapon with $weapon.name, I wanted to directly modify the unit, it doesn't work... What this does, is that it ALWAYS does the effect on the first attack (usually the melee for most units)... Not sure if this is a WML bug or not, but luckily it can be worked around.
Code: Select all
{LOOKUP_INDEX unit.attack name $weapon.name weapon_index}
{SET_VARIABLE modify_attack[$weapon_index].damage 0}
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
[insert_tag]
name=attack
variable=modify_attack
[/insert_tag]
[/modify_unit]
{CLEAR_VARIABLE modify_attack}
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: How to make one unit stop striking during an attack
So I see. Another insert_tag example Thanks
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
- Celtic_Minstrel
- Developer
- Posts: 2209
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: How to make one unit stop striking during an attack
If I recall correctly, in order to modify an attack other than the first with
Sapient's example works because it takes the attacks as an array, changes the damage on the desired attack, then writes the array into the
[modify_unit]
, you actually need to have empty [attack]
tags. For modifying the second attack, you'd need one empty tag; for the third attack, two empty tags, and so on.Sapient's example works because it takes the attacks as an array, changes the damage on the desired attack, then writes the array into the
[modify_unit]
tag - effectively overwriting all attacks at the same time.