Custom Unit

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
tribes45
Posts: 123
Joined: June 24th, 2010, 12:40 am

Custom Unit

Post by tribes45 »

Is there an abillity, or trait or something I can give a unit to make them "Anti-Drain" meaning they can't be drained?

Oh and, is there error in this? It won't work for some damned reason.

Code: Select all


[event]
name=turn 8
[filter]
side=3
[/filter]
gold=500
[/event]
Thx. :eng:
"In peace, sons bury their fathers. In war, fathers bury their sons." -Herodotus
"Two things are infinite, the universe and Human stupidity. Although, I'm not sure about the universe. -Albert Einstein
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Custom Unit

Post by 8680 »

If you want to give 500 gold to side 3 on turn 8, use:

Code: Select all

[event]
    name=turn 8
    [gold]
        side=3
        amount=500
    [/gold]
[/event]
tribes45
Posts: 123
Joined: June 24th, 2010, 12:40 am

Re: Custom Unit

Post by tribes45 »

8680 wrote:If you want to give 500 gold to side 3 on turn 8, use:

Code: Select all

[event]
    name=turn 8
    [gold]
        side=3
        amount=500
    [/gold]
[/event]
Why thank you :)

1/2 problems solved thanks to the good people of the forum.
"In peace, sons bury their fathers. In war, fathers bury their sons." -Herodotus
"Two things are infinite, the universe and Human stupidity. Although, I'm not sure about the universe. -Albert Einstein
User avatar
The_Other
Posts: 189
Joined: February 3rd, 2012, 10:05 pm
Location: UK

Re: Custom Unit

Post by The_Other »

I'm still learning with WML, but I think this should work.
When a unit with {ABILITY_UNDRAINABLE} fights a unit with a drain attack, the undrainable unit temporarily gains not_living=yes, then loses it after the fight. In effect, it becomes undead for the duration of the fight.
Note that it will also be temporarily immune to plague and poison, though these will not trigger the effect unless they are combined with drain.

Put {ABILITY_UNDRAINABLE} in the unit file like any other ability, along with the word {UNDRAINABLE} (this must be inside [unit_type], but outside all other tags.
Put the event code into a scenario, utils or abilities file.

Code: Select all

#define ABILITY_UNDRAINABLE
	[dummy]
	    id=undrainable
	    name= _ "undrainable"
	    description= _ "this unit is cannot be drained.
It will still be damaged by draining attacks, but the enemy will not gain any HP."
	[/dummy]
#enddef

#define UNDRAINABLE
	[event]
	    name=attack
	    first_time_only=no
		[filter_attack]
		    special=drain
		[/filter_attack]
		[filter_second]
		    ability=undrainable
		[/filter_second]
		    [modify_unit]
			[filter]
			    x,y=$x2,$y2
			[/filter]
			    [status]
				not_living=yes
			    [/status]
		    [/modify_unit]
	[/event]

	[event]
	    name=attack_end
	    first_time_only=no
		[filter_attack]
		    special=drain
		[/filter_attack]
		[filter_second]
		    ability=undrainable
		[/filter_second]
		    [modify_unit]
			[filter]
			    x,y=$x2,$y2
			[/filter]
			    [status]
				not_living=no
			    [/status]
		    [/modify_unit]
	[/event]

	[event]
	    name=attack
	    first_time_only=no
		[filter_second_attack]
		    special=drain
		[/filter_second_attack]
		[filter]
		    ability=undrainable
		[/filter]
		    [modify_unit]
			[filter]
			    x,y=$x1,$y1
			[/filter]
			    [status]
				not_living=yes
			    [/status]
		    [/modify_unit]
	[/event]

	[event]
	    name=attack_end
	    first_time_only=no
		[filter_second_attack]
		    special=drain
		[/filter_second_attack]
		[filter]
		    ability=undrainable
		[/filter]
		    [modify_unit]
			[filter]
			    x,y=$x1,$y1
			[/filter]
			    [status]
				not_living=no
			    [/status]
		    [/modify_unit]
	[/event]
#enddef
Nothing is true; everything is permissible.
tribes45
Posts: 123
Joined: June 24th, 2010, 12:40 am

Re: Custom Unit

Post by tribes45 »

The_Other wrote:I'm still learning with WML, but I think this should work.
When a unit with {ABILITY_UNDRAINABLE} fights a unit with a drain attack, the undrainable unit temporarily gains not_living=yes, then loses it after the fight. In effect, it becomes undead for the duration of the fight.
Note that it will also be temporarily immune to plague and poison, though these will not trigger the effect unless they are combined with drain.

Put {ABILITY_UNDRAINABLE} in the unit file like any other ability, along with the word {UNDRAINABLE} (this must be inside [unit_type], but outside all other tags.
Put the event code into a scenario, utils or abilities file.

Code: Select all

#define ABILITY_UNDRAINABLE
	[dummy]
	    id=undrainable
	    name= _ "undrainable"
	    description= _ "this unit is cannot be drained.
It will still be damaged by draining attacks, but the enemy will not gain any HP."
	[/dummy]
#enddef

#define UNDRAINABLE
	[event]
	    name=attack
	    first_time_only=no
		[filter_attack]
		    special=drain
		[/filter_attack]
		[filter_second]
		    ability=undrainable
		[/filter_second]
		    [modify_unit]
			[filter]
			    x,y=$x2,$y2
			[/filter]
			    [status]
				not_living=yes
			    [/status]
		    [/modify_unit]
	[/event]

	[event]
	    name=attack_end
	    first_time_only=no
		[filter_attack]
		    special=drain
		[/filter_attack]
		[filter_second]
		    ability=undrainable
		[/filter_second]
		    [modify_unit]
			[filter]
			    x,y=$x2,$y2
			[/filter]
			    [status]
				not_living=no
			    [/status]
		    [/modify_unit]
	[/event]

	[event]
	    name=attack
	    first_time_only=no
		[filter_second_attack]
		    special=drain
		[/filter_second_attack]
		[filter]
		    ability=undrainable
		[/filter]
		    [modify_unit]
			[filter]
			    x,y=$x1,$y1
			[/filter]
			    [status]
				not_living=yes
			    [/status]
		    [/modify_unit]
	[/event]

	[event]
	    name=attack_end
	    first_time_only=no
		[filter_second_attack]
		    special=drain
		[/filter_second_attack]
		[filter]
		    ability=undrainable
		[/filter]
		    [modify_unit]
			[filter]
			    x,y=$x1,$y1
			[/filter]
			    [status]
				not_living=no
			    [/status]
		    [/modify_unit]
	[/event]
#enddef
Appercaite it.
"In peace, sons bury their fathers. In war, fathers bury their sons." -Herodotus
"Two things are infinite, the universe and Human stupidity. Although, I'm not sure about the universe. -Albert Einstein
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Custom Unit

Post by Dugi »

Added it into Useful WML Fragments (as it was originally my work).
Post Reply