Hover

The place to post your WML questions and answers.

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.
Post Reply
User avatar
Baufo
Inactive Developer
Posts: 1115
Joined: January 29th, 2006, 4:53 pm
Location: Vienna, Austria

Hover

Post by Baufo »

Like suggested here

Use it like

Code: Select all

	[abilities]
		{ABILITY_HOVER your_unit}
	[/abilities]
in your unit .cfg

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
It's a pretty unintuitive solution but I think it works.
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
wnsk
Posts: 12
Joined: November 21st, 2006, 12:49 pm
Location: SG

Post by wnsk »

=) 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.
Fiach Dubh
Posts: 381
Joined: December 2nd, 2006, 4:10 am
Location: Thar an scáthán

Post by Fiach Dubh »

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:

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
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.
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.
User avatar
Baufo
Inactive Developer
Posts: 1115
Joined: January 29th, 2006, 4:53 pm
Location: Vienna, Austria

Post by Baufo »

*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.
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
User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga »

I think you forgot a

Code: Select all

[+abilities]

At the end of your macro (ABILITY_HOVER) ;)
"Ooh, man, my mage had a 30% chance to miss, but he still managed to hit! Awesome!" ;) -- xtifr
User avatar
Baufo
Inactive Developer
Posts: 1115
Joined: January 29th, 2006, 4:53 pm
Location: Vienna, Austria

Post by Baufo »

Noyga wrote:I think you forgot a

Code: Select all

[+abilities]

At the end of your macro (ABILITY_HOVER) ;)
Right, thanks. I really should not post things I did not actually try :wink:
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
Fiach Dubh
Posts: 381
Joined: December 2nd, 2006, 4:10 am
Location: Thar an scáthán

Post by Fiach Dubh »

*Bows*

Thank you, thank you :wink:
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.
User avatar
Casual User
Posts: 475
Joined: March 11th, 2005, 5:05 pm

Post by Casual User »

Fiach Dubh wrote:

Code: Select all

apply_to=opponent 
Just a nitpick, but that should be apply_to=both.

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 :P ).
Fiach Dubh
Posts: 381
Joined: December 2nd, 2006, 4:10 am
Location: Thar an scáthán

Post by Fiach Dubh »

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.
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.
Post Reply