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.
How to make one unit stop striking during an attack
Hi,
Is there any way to tell, which attack is used in an event? For example, in an "attacker hits" event, is there a variable that stores the name of the attack used?
I though of running a loop, which compares all attack damages with $damage_inflicted, but that would be ambiguous - what if there's a unit with two attacks of the same damage?
Also, is there a way to somehow make a unit stop striking during the attack, (but let the opponent continue hitting back), if a certain criteria is met in the attacker hits event? But the unit should fight normally, if he's attacked again.
1.13.x solutions (add an object, then remove it) are not available, I use 1.12
Best regards,
WhiteWolf
Is there any way to tell, which attack is used in an event? For example, in an "attacker hits" event, is there a variable that stores the name of the attack used?
I though of running a loop, which compares all attack damages with $damage_inflicted, but that would be ambiguous - what if there's a unit with two attacks of the same damage?
Also, is there a way to somehow make a unit stop striking during the attack, (but let the opponent continue hitting back), if a certain criteria is met in the attacker hits event? But the unit should fight normally, if he's attacked again.
1.13.x solutions (add an object, then remove it) are not available, I use 1.12
Best regards,
WhiteWolf
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 tell which attack is used in an event?
Thanks
Is it somehow possible to make a unit stop fighting, but let the opponent keep fighting?
For example, this is a feature that gives some bonus somewhere, but the cost is, that when a unit attacks, if a certain criteria is met, it will stop trying to hit, but the opponent will finish his attacks as normal.
I tried to zero the attack's number through [modify_unit], or through an object, but the attack went on as normal, the effects only kicked in after the attack. How can it be done, to apply the effects immediately, during the attack?
I suspect I need to use Lua - but I really don't know lua
Is it somehow possible to make a unit stop fighting, but let the opponent keep fighting?
For example, this is a feature that gives some bonus somewhere, but the cost is, that when a unit attacks, if a certain criteria is met, it will stop trying to hit, but the opponent will finish his attacks as normal.
I tried to zero the attack's number through [modify_unit], or through an object, but the attack went on as normal, the effects only kicked in after the attack. How can it be done, to apply the effects immediately, during the attack?
I suspect I need to use Lua - but I really don't know lua
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
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: How to tell which attack is used in an event?
Check Critical Strikes mod. Use there weapon special that set strikes to 0 or chance to hit to 0.WhiteWolf wrote:Thanks
Is it somehow possible to make a unit stop fighting, but let the opponent keep fighting?
For example, this is a feature that gives some bonus somewhere, but the cost is, that when a unit attacks, if a certain criteria is met, it will stop trying to hit, but the opponent will finish his attacks as normal.
I tried to zero the attack's number through [modify_unit], or through an object, but the attack went on as normal, the effects only kicked in after the attack. How can it be done, to apply the effects immediately, during the attack?
I suspect I need to use Lua - but I really don't know lua
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
Re: How to tell which attack is used in an event?
Critical Strikes mod adds the objects in an event=attack. Before the attack, so I guess it works.
I need the unit to be "reloaded" with the mod in an event=attacker/defender hits.
I tried it, it doesn't work. The attack numbers are only set to 0 after the fight took place, not during, right when the event kicks in. I do not really understand this behaviour of objects, why doesn't it kick in right when applied? I guess it's because unit attack values are "loaded" into the fight at the start, and they can't be overriden during the attack?
I need the unit to be "reloaded" with the mod in an event=attacker/defender hits.
I tried it, it doesn't work. The attack numbers are only set to 0 after the fight took place, not during, right when the event kicks in. I do not really understand this behaviour of objects, why doesn't it kick in right when applied? I guess it's because unit attack values are "loaded" into the fight at the start, and they can't be overriden during the attack?
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 tell which attack is used in an event?
I believe that that interpretation is pretty much correct. What you can do to interrupt the fight is to save and kill the unit, and then reload it in an attack_end event. As an example, something along those lines is done here. That doesn't do what you want, but maybe you can use it as a model to get the desired behavior?WhiteWolf wrote:I guess it's because unit attack values are "loaded" into the fight at the start, and they can't be overriden during the attack?
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: How to tell which attack is used in an event?
I'm looking or interesting skills (weapon specials, abilities) and I've found this (might be helpful for you):
Code: Select all
#define WEAPON_SPECIAL_IE_INTERRUPT
[knockback]
id=ie_interrupt
name= _ "interrupt-day only"
description=_ "When a unit is hit with an interrupting attack, combat is immediately stopped. Works only during dawn and dusk and during the day, when the sun is in the sky."
[/knockback]
[/specials]
[/attack]
[event]
name=defender hits
first_time_only=no
[filter_second_attack]
special=interrupt
[/filter_second_attack]
[filter]
[filter_location]
time_of_day_id=dawn,morning,afternoon,dusk
[/filter_location]
[/filter]
[if]
[then]
[store_unit]
[filter]
find_in=second_unit
[/filter]
variable=target
kill=yes
[/store_unit]
[/then]
[/if]
[/event]
[event]
name=attack end
first_time_only=no
[unstore_unit]
variable=target
text="interrupt"
{COLOR_HEAL}
[/unstore_unit]
{CLEAR_VARIABLE target}
[/event]
[+attack]
[+specials]
#enddef
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
Re: How to tell which attack is used in an event?
I've kept experimenting with adding an object at the beginning of the attack, that kicks in with a formula for filter_opponent, but I gave up.
However, I found a workaround with interrupting the battle Namely, I start counting the strikes that the opponent has left at the beginning. If the criteria is met, fight is interrupted in way similar to the ones you described, and then the remaining strikes from the opponent are done manually with animate_unit and harm_unit.
Probably not elegant, but it works more or less as I intended
The only compromises are that chance-to-hit is completely lost, I hardwired it for 30%. I can reason for this when introducing the mechanics in the game, so for this context, it's not such a big problem. There is also loss of information on the actual damage to be done, luckily harm_unit can take resistance and time of day into accout (it's not in the code yet, my bad), but extra-extra-custom modifiers are lost.
Here's the about final code if anyone's interested:
Thanks
However, I found a workaround with interrupting the battle Namely, I start counting the strikes that the opponent has left at the beginning. If the criteria is met, fight is interrupted in way similar to the ones you described, and then the remaining strikes from the opponent are done manually with animate_unit and harm_unit.
Probably not elegant, but it works more or less as I intended
The only compromises are that chance-to-hit is completely lost, I hardwired it for 30%. I can reason for this when introducing the mechanics in the game, so for this context, it's not such a big problem. There is also loss of information on the actual damage to be done, luckily harm_unit can take resistance and time of day into accout (it's not in the code yet, my bad), but extra-extra-custom modifiers are lost.
Here's the about final code if anyone's interested:
Spoiler:
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
You seem to be missing some code, for example, the fire_event. It is possible to pass along weapon data with fire_event, by the way.
I have a suggestion... I am not 100% sure this will work, but have you tried removing all the unit's attacks when the special hits? Worth a try anyway.
I have a suggestion... I am not 100% sure this will work, but have you tried removing all the unit's attacks when the special hits? Worth a try anyway.
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
The fire events are in another file. I made a post about the combat events a while ago: viewtopic.php?f=12&t=44574&p=601967&hil ... at#p601967 They come in handy, when it doesn't matter who's the attacker and who's the defender.
OK, here's the full code
The code still loses the information on weapon specials. I'll hardwire 'magic' and 'marksman', because they are rather frequent, but other chance-to-hit-modifiers will be lost, and the hardwired 30% chance-to-hit for the leftover attacks will be applied.
I tried removing all attacks, but the attack continues as normal, the object that removes the attacks only kicks in after the attack.
Yes, I see now, that primary/secondary attack can be passed along, but how exactly? (no example on the wikipage) Would it be
Or do I need to declare every attribute I want to pass, like damage=$weapon.damage, type=$weapon.tpye, etc?
OK, here's the full code
Spoiler:
I tried removing all attacks, but the attack continues as normal, the object that removes the attacks only kicks in after the attack.
Yes, I see now, that primary/secondary attack can be passed along, but how exactly? (no example on the wikipage) Would it be
Code: Select all
[fire_event]
[primary_attack]
weapon=$weapon....? sounds dull
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
The
In
[petrifies]
special is handled by the by the engine, and immediately stops the combat. It's also built in to the combat UI, in the pre-combat stats the hp bar will be shown as grey if a unit will get petrified. It seems that nothing in the mainline units or mainline campaigns uses this weapon special.In
Ageless_Era/data/EoMa_data/sculpt.cfg
there's events that trigger after the combat, used by the level 3 Medusa Witch. For her, the petrify ability has been reduced to "sculpts", with the victim automatically unpetrified in a later turn by these events.Currently updating the SurvivalXtreme Collection, and the SXC Pressure scenario. That's about a mermish necromancer, who's just found out that her Tentacles Of The Deep have been nerfed.
Re: How to make one unit stop striking during an attack
Oh, that's too bad. I have a couple of other ideas. I may experiment with it a bit on my own.WhiteWolf wrote:I tried removing all attacks, but the attack continues as normal, the object that removes the attacks only kicks in after the attack.
This is where [insert_tag] comes in handy:WhiteWolf wrote: Yes, I see now, that primary/secondary attack can be passed along, but how exactly? (no example on the wikipage) ... do I need to declare every attribute I want to pass, like damage=$weapon.damage, type=$weapon.tpye, etc?
Code: Select all
[fire_event]
[insert_tag]
name=primary_attack
variable=weapon
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
OK, petrifying and unpetrifying would have a similar effect, stopping the attack, but the other unit would not continue striking. Petrified units can't be striked at as far as I know So as I understand, it's the same as storing the unit, then unstoring it in an attack end.octalot wrote:The [petrifies] special"
Let me know if you find anythingSapient wrote:I may experiment with it a bit on my own.
That's cool, thanks
This is where [insert_tag] comes in handy:
Oh, and thanks for renaming the topic - I quite forgot about that
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: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: How to make one unit stop striking during an attack
You should be able to get the proper base chance to hit by using
[store_unit_defense]
, I think?Re: How to make one unit stop striking during an attack
Sounds cool, but I use 1.12 for the campaign where I'd like the effect 1.14 should solve it then
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