Hover
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.
Hover
Like suggested here
Use it like
in your unit .cfg
It's a pretty unintuitive solution but I think it works.
Use it like
Code: Select all
[abilities]
{ABILITY_HOVER your_unit}
[/abilities]
Code: Select all
#define ABILITY_HOVER TYPE
[heals]
name= _ "hover"
description= _ "..."
[/heals]
[/abilities]
[event]
name=attack
first_time_only=no
[filter_second]
type={TYPE}
[/filter_second]
[special_filter]
range=melee
[/special_filter]
[store_unit]
variable=pre_attack_unit
[filter]
x,y=$x2,$y2
[/filter]
[/store_unit]
[/event]
[event]
name=attacker_hits
first_time_only=no
[/filter_second]
type={TYPE}
[/filter_second]
[special_filter]
range=melee
[/special_filter]
[unstore_unit]
variable=pre_attack_unit
find_vacant=no
[/unstore_unit]
[/then]
[/if]
[/event]
[event]
name=attack_end
first_time_only=no
[filter_second]
type={TYPE}
[/filter_second]
[special_filter]
range=melee
[/special_filter]
{CLEAR_VARIABLE pre_attack_unit}
[/event]
#enddef
I was working on the proof of one of my poems all the morning, and took out a comma. In the afternoon I put it back again. -- Oscar Wilde
=) Thank you for your 5 minutes' work; I'm a programming dunce and it would've taken me half a day to figure even this out.
However, somebody raised a good point about bats (or any other unit with hover) not being able to attack bats-with-hover, and that seems to me to be pretty silly now. Still, I was just throwing up an idea; thanks for giving it a chance.
However, somebody raised a good point about bats (or any other unit with hover) not being able to attack bats-with-hover, and that seems to me to be pretty silly now. Still, I was just throwing up an idea; thanks for giving it a chance.
-
- Posts: 381
- Joined: December 2nd, 2006, 4:10 am
- Location: Thar an scáthán
That looks much more complicated than it needs to be, and I don't think you can put it in [abilities] tags if you do it that way.
Try this:
This goes in abilities.cfg and works exactly like a standard ability - it's an adaptation of Magical, set to lower the opponent's chance to hit to 0% at a specified range (generally Melee or Ranged, but could be something else in EoM or Talamh)
I haven't tested it, but it looks like it should work. The usage is a little strange - I think you use it as a weapon special for a weapon at the same range as the attacks that the unit is immune to (in the case of a hovering bat, it's attached to the Bite attack - if the unit was immune to ranged attacks, it would have to have one itself, with this special.
Try this:
Code: Select all
#define WEAPON_SPECIAL_IMMUNITY RANGE
[chance_to_hit]
id=immunity
name= _ "immunity"
description= _ "Immunity:
This unit cannot be hit by attacks at a specified range."
value=0
cumulative=no
apply_to=opponent
active_on=defense
range={RANGE}
[/chance_to_hit]
#enddef
I haven't tested it, but it looks like it should work. The usage is a little strange - I think you use it as a weapon special for a weapon at the same range as the attacks that the unit is immune to (in the case of a hovering bat, it's attached to the Bite attack - if the unit was immune to ranged attacks, it would have to have one itself, with this special.
Jetryl wrote:Normal people are like candy ravers. You look away for a moment and next thing you know they're spreading vaseline on your nipples and cooing like a pigeon.
*admires Fiach Dubh's cleverness*
Very cool solution! And it does even do it in the way this ability/weapon special logically does it: The unit does not take no damage because it is set back to its state in the beginning of the attack after every hit but because it's simply not hit.
You don't have to use "range=" by the way since it is a weapon special now, not an ability in so it does already only apply to one single range (the range of the weapon that has this special). At least it worked for me without it.
Very cool solution! And it does even do it in the way this ability/weapon special logically does it: The unit does not take no damage because it is set back to its state in the beginning of the attack after every hit but because it's simply not hit.
You don't have to use "range=" by the way since it is a weapon special now, not an ability in so it does already only apply to one single range (the range of the weapon that has this special). At least it worked for me without it.
I was working on the proof of one of my poems all the morning, and took out a comma. In the afternoon I put it back again. -- Oscar Wilde
Right, thanks. I really should not post things I did not actually tryNoyga wrote:I think you forgot aCode: Select all
[+abilities]
At the end of your macro (ABILITY_HOVER)

I was working on the proof of one of my poems all the morning, and took out a comma. In the afternoon I put it back again. -- Oscar Wilde
-
- Posts: 381
- Joined: December 2nd, 2006, 4:10 am
- Location: Thar an scáthán
*Bows*
Thank you, thank you
I hate to see such a huge amount of code, for such a simple task - not only are there more potential errors, but it's also harder to find them. There's no point using dynamite, when a pickaxe will do!
Thank you, thank you

I hate to see such a huge amount of code, for such a simple task - not only are there more potential errors, but it's also harder to find them. There's no point using dynamite, when a pickaxe will do!
Jetryl wrote:Normal people are like candy ravers. You look away for a moment and next thing you know they're spreading vaseline on your nipples and cooing like a pigeon.
- Casual User
- Posts: 475
- Joined: March 11th, 2005, 5:05 pm
Just a nitpick, but that should be apply_to=both.Fiach Dubh wrote:Code: Select all
apply_to=opponent
Otherwise, if a melee unit attacks your bat in-flight, it would be unable to hit whereas the bat would hit normally, which would seem weird.
And, while a human player would never be dumb enough to attack a 'hovering' unit in melee, the AI can be very, very dumb (especially when the number '0' is involved, the AI dislikes it

-
- Posts: 381
- Joined: December 2nd, 2006, 4:10 am
- Location: Thar an scáthán
It can be justified either way, I actually meant for the bat to be able to hit.
I know all about the AI's 'zero problem', it's a major issue in development of my Talamh era/world (currently, the AI is completely unable to use one faction). I haven't tested this specific application, so I don't know how it would react to this ability.
I'm also not sure what happens if a hovering bat is attacked by a unit with a magical melee attack.
I know all about the AI's 'zero problem', it's a major issue in development of my Talamh era/world (currently, the AI is completely unable to use one faction). I haven't tested this specific application, so I don't know how it would react to this ability.
I'm also not sure what happens if a hovering bat is attacked by a unit with a magical melee attack.
Jetryl wrote:Normal people are like candy ravers. You look away for a moment and next thing you know they're spreading vaseline on your nipples and cooing like a pigeon.