"Alert" unit immune to backstab
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.
"Alert" unit immune to backstab
I need a Saurian Ambusher named Smekk to be immune to backstab. I thought I should make a trait called "alert" to bestow an immunity to backstab...but is such a thing even possible? Or do I need an event? An ability?
How would you code it? By the way, it's just one scenario and one unit, so the solution needn't be versatile.
The trait:
The event:
How would you code it? By the way, it's just one scenario and one unit, so the solution needn't be versatile.
The trait:
Code: Select all
#define TRAIT_ALERT
[trait]
id=alert
male_name= _ "alert"
female_name= _ "female^alert"
description="Immune to backstab"
[effect]
apply_to=status
add=unbackstabbable # I know there's no such thing
[/effect]
[/trait]
#enddef
Code: Select all
[event]
name=attack
first_time_only=no
[filter_attack]
special=backstab
[/filter_attack]
[filter_second]
ability=alert
[/filter_second]
[modify_unit]
[filter]
id=Smekk
[/filter]
???
[/modify_unit]
[/event]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: "Alert" unit immune to backstab
I think this is a case where you have to give an object to all the OTHER units in the scenario that modifies their ability when your alert unit is involved. (Use a "unit placed" event.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: "Alert" unit immune to backstab
All the units with backstab must be recruited or recalled to appear on the map, sobeetlenaut wrote: ↑December 14th, 2020, 10:16 pm I think this is a case where you have to give an object to all the OTHER units in the scenario that modifies their ability when your alert unit is involved. (Use a "unit placed" event.)
unit_placed
seems promising.I'm not sure how to modify backstab to exclude Smekk, though.
So...there's no way to filter attacks against Smekk? Something like...
Code: Select all
name=attack
[filter]
id=Smekk
[/filter]
[if]
?
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: "Alert" unit immune to backstab
The way to do this is to create your own backstab ability that excludes Smekk, and then replace every backstab ability in the game with that one.
Insert the not-Smekk condition to backstab:
And to make the switch for this everywhere:
EDIT:
And if you want to make it general with the 'Alert' ability, then make a
Insert the not-Smekk condition to backstab:
Code: Select all
#define WEAPON_SPECIAL_BACKSTAB_CUSTOM
# Canned definition of the Backstab ability to be included in a
# [specials] clause.
[damage]
id=backstab
name= _ "backstab"
description= _ "When used offensively, this attack deals double damage if there is an enemy of the target on the opposite side of the target, and that unit is not incapacitated (turned to stone or otherwise paralyzed)."
multiply=2
active_on=offense
[filter_opponent]
formula="
enemy_of(self, flanker) and not flanker.petrified
where
flanker = unit_at(direction_from(loc, other.facing))
"
# ADDED LINES:
[not]
id=Smekk
[/not]
# ADDED end
[/filter_opponent]
[/damage]
#enddef
Code: Select all
# event in some toplevel place so it gets included to every scenario
[event]
name=unit placed
id=backstab_switcher
first_time_only=no
[filter]
[has_attack]
special=backstab
# if you're on 1.15.x (idk which), it's 'special_id' and not 'special'
[/has_attack]
[/filter]
[object]
id=backstab_customizer
[filter]
id=$unit.id
[/filter]
[effect]
apply_to=attack
special(_id)=backstab
remove_specials=backstab
[set_specials]
mode=append
{WEAPON_SPECIAL_BACKSTAB_CUSTOM}
[/set_specials]
[/effect]
[/object]
[/event]
And if you want to make it general with the 'Alert' ability, then make a
[dummy]
Alert ability, and in your modified backstab ability, use ability=alert_dummy
instead of id=Smekk
.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: "Alert" unit immune to backstab
Thanks, WhiteWolf! I tested the code with recruited units and it works some of the time, but most of the time the units can still backstab. I'm not 100% sure what the pattern is. Preliminary tests indicate that a unit may not backstab when it counter-attacks, and may not backstab when it's already in position for a backstab and doesn't need to move. But if a unit moves into position for a backstab, the backstab usually works.
At least the code works some of the time, which is great. That means the solution works; it just needs a little refining.
I'm on 1.15.7, so I used
The units with backstab are custom units, but I don't think that would cause a problem. They're nothing unusual, apart from backstab.
As Smekk only appears in scenario 3, I only put the event in scenario 3, just after start.
At least the code works some of the time, which is great. That means the solution works; it just needs a little refining.
I'm on 1.15.7, so I used
special_id=backstab
.The units with backstab are custom units, but I don't think that would cause a problem. They're nothing unusual, apart from backstab.
As Smekk only appears in scenario 3, I only put the event in scenario 3, just after start.
Code: Select all
[scenario]
[prestart]
[/prestart]
[start]
[/start]
>>> YOUR CODE HERE
[/scenario]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: "Alert" unit immune to backstab
Backstab only works on offense, so counter-attacking units don't get backstab even from the vanilla special. So it sounds like it doesn't work at all.
I'm not sure if it's the source of all the problems, but I did make a mistake, the id of the modified backstab special should be unique.
Could try fixing this first.
You could also open the inspection window for a recruited unit and check that the object has been correctly applied (or not...?). I'm just guessing now, but maybe I can test the thing tomorrow.
I'm not sure if it's the source of all the problems, but I did make a mistake, the id of the modified backstab special should be unique.
Code: Select all
#define WEAPON_SPECIAL_BACKSTAB_CUSTOM
# Canned definition of the Backstab ability to be included in a
# [specials] clause.
[damage]
id=backstab # problem here -> rename to backstab_custom or sth like that
...
You could also open the inspection window for a recruited unit and check that the object has been correctly applied (or not...?). I'm just guessing now, but maybe I can test the thing tomorrow.
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: "Alert" unit immune to backstab
That didn't work completely...but progress was made. Now (it seems) the first unit recruited gets the object, and the rest don't. So it seems to work for one unit. Hmm.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: "Alert" unit immune to backstab
wiki wrote:By default, an object with a defined ID can only be picked up once per scenario, even if it is removed later or first_time_only=no is set for the event. You can remove this restriction by setting take_only_once=no.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: "Alert" unit immune to backstab
That did it! Thanks!
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- Celtic_Minstrel
- Developer
- Posts: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: "Alert" unit immune to backstab
Personally I prefer to use my own tag for custom abilities, rather than
[dummy]
. You can use any tag as an ability, and if it's not an ability recognized by the engine, it will just have no effect other than showing in the sidebar.Re: "Alert" unit immune to backstab
Hmm, I'm aware of that, but is there any advantage to actually doing that? My reason for not doing so is that theCeltic_Minstrel wrote: ↑December 20th, 2020, 8:48 pm You can use any tag as an ability, and if it's not an ability recognized by the engine, it will just have no effect other than showing in the sidebar.
id
identifies everything anyway, and by using [dummy] for everything, when I just open up old code, and see [dummy], I immediately know - yes, this is an event-implemented ability. If I called it its name, I'd have to think for an extra second if it's an engine-supported tag or a custom name. 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: "Alert" unit immune to backstab
There can be advantages. When filtering, you can reference an ability either by tag or by ID. For example, if you had a group of related abilities, you could give them the same tag but a different ID.
I guess that probably doesn't apply to this specific case, but it's something to be aware of, at least.
I guess that probably doesn't apply to this specific case, but it's something to be aware of, at least.
-
- Code Contributor
- Posts: 172
- Joined: October 6th, 2017, 12:57 pm
Re: "Alert" unit immune to backstab
if you use 1.15.7 then you could make an alert abilities without customi backstab
the divide by 2 applied to opponent cancel the multiply=2 of backstab without use a customised backstab or [event]
Code: Select all
#define ABILITY_SPECIAL_ALERT
# to be included in a [abilities] clause.
[damage]
id=alert
name= _ "alert"
female_name= _ "female^alert"
description= _ "Immune to backstab"
divide=2
cumulative=no
active_on=defense
apply_to=opponent
affect_self=yes
[filter_opponent]
[filter_weapon]
special_id_active=backstab
[/filter_weapon]
[/filter_opponent]
[/damage]
#enddef
Re: "Alert" unit immune to backstab
A brand new feature? Cool! I'm using 1.15.8 because I like brand new features. Thank you.newfrenchy83 wrote: ↑December 21st, 2020, 2:44 pm if you use 1.15.7 then you could make an alert abilities without customi backstab...
Early on, I had tried to think of a way to counteract the doubling of damage through division, but my limited knowledge of WML didn't allow me progress the idea beyond the conceptual stage.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: "Alert" unit immune to backstab
The code works great...except for one tiny little thing.newfrenchy83 wrote: ↑December 21st, 2020, 2:44 pm if you use 1.15.7 then you could make an alert abilities without customi backstab...
the divide by 2 applied to opponent cancel the multiply=2 of backstab without use a customised backstab or [event]
In the Attack Enemy window, the word "backstab" is not grayed-out when a unit that can backstab tries to backstab an Alert unit. Yes, the damage displayed remains the normal damage, and the Alert unit only takes normal damage, but since "backstab" is not grayed-out, a player might assume damage will be doubled anyway.
Is there a way to gray-out the word backstab in the Attack Enemy window?
I'm thinking...no. The way the Alert ability works is to permit the damage to be doubled, then divide it in half. So...in a sense, a unit is still being backstabbed, but for half damage. Nonetheless, I thought I should ask.
Thanks.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.