unit ends a move on a specific terrain type?
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.
unit ends a move on a specific terrain type?
Basically, I'm creating a new unit (not important at this time), and I want something to happen if this unit is left on a specific terrain type.
Specifically: it is allowed to move across Deep Water (Wo), but if it ends it's move there, it drowns .. (ie kill it). (for now, we'll just use a Gryphon, as it can move across Deep Water ..)
I used this code to find the condition:
[filter]
type=Gryphon
[filter_location]
terrain=Wo
[/filter_location]
[/filter]
I know about the [kill] tag, but not sure how to use it, or if it uses filters "properly" ..
I tried the [select] event, but it seemed to only detect the unit if it started on Deep Water .. it didn't fire when it ended it's move on Deep Water ..
So, I tried event "side turn" .. figured at the start of anyone's turn .. I'll just look for ANY gryphon on Deep water .. and kill it ..
Wow .. bad idea .. it nuked ALL creatures, (gryphon or not .. Deep water or not), and threw the game into a loop .. screen flashing, round counter climbed to about 200 before I managed to kill the process.
yikes.
Anyway, I know of the tag: "fire_event=no" in the [kill] tag .. but that didn't seem to stop the getaway loop ..
any ideas?
Specifically: it is allowed to move across Deep Water (Wo), but if it ends it's move there, it drowns .. (ie kill it). (for now, we'll just use a Gryphon, as it can move across Deep Water ..)
I used this code to find the condition:
[filter]
type=Gryphon
[filter_location]
terrain=Wo
[/filter_location]
[/filter]
I know about the [kill] tag, but not sure how to use it, or if it uses filters "properly" ..
I tried the [select] event, but it seemed to only detect the unit if it started on Deep Water .. it didn't fire when it ended it's move on Deep Water ..
So, I tried event "side turn" .. figured at the start of anyone's turn .. I'll just look for ANY gryphon on Deep water .. and kill it ..
Wow .. bad idea .. it nuked ALL creatures, (gryphon or not .. Deep water or not), and threw the game into a loop .. screen flashing, round counter climbed to about 200 before I managed to kill the process.
yikes.
Anyway, I know of the tag: "fire_event=no" in the [kill] tag .. but that didn't seem to stop the getaway loop ..
any ideas?
Re: unit ends a move on a specific terrain type?
try something like this:
this should work. only thing is... the way i wrote it, it will kill all the gryphons.
so you'll need to modify it a little
Code: Select all
[event]
name=moveto
first_time_only=no
[filter]
type=Gryphon
[filter_location]
terrain=Wo
[/filter_location]
[/filter]
[kill]
type=gryphon
animate=no
[/kill]
[/event]
so you'll need to modify it a little
coded Rebellion During the Dark Age
Currently working on:
Era of the Future
Currently working on:
Era of the Future
Re: unit ends a move on a specific terrain type?
It would kill them all wouldn't it. That could be useful. It would need a few if-then's to not do that.
The best example I found was UTBS 02_Across_the_Harsh_Sands.cfg
There's a macro called {FILTER}. Find #define APPLY_DEHYDRATION_EFFECT FILTER on line 364. It uses the [have_unit] tag to cause damage to a unit on sand during the daytime.
The best example I found was UTBS 02_Across_the_Harsh_Sands.cfg
There's a macro called {FILTER}. Find #define APPLY_DEHYDRATION_EFFECT FILTER on line 364. It uses the [have_unit] tag to cause damage to a unit on sand during the daytime.
Re: unit ends a move on a specific terrain type?
The Dehydration effect is much more complicated. This is very simple.
Here's how to kill the Gryphon that just moved onto deep water:
Here's how to kill all of a player's units in deep water at the beginning of their turn:
Here's how to kill the Gryphon that just moved onto deep water:
Spoiler:
Spoiler:
Re: unit ends a move on a specific terrain type?
Got it!!
This seems to work well enough ..
Thanks!
Code: Select all
[multiplayer]
id=test_water
name= _"test_water"
description= _"test_water"
victory_when_enemies_defeated=no
map_data="{/multiplayer/maps/tester.map}"
{DEFAULT_SCHEDULE}
[side]
side=1
id=Spider
name=Spider
type=Giant Spider
canrecruit=yes
fog=no
shroud=no
[unit]
type=Gryphon
id=Gryp1
name=Gryp2
x,y=5,5
[/unit]
[/side]
[side]
side=2
type=Giant Scorpion
id=Scorpion
name=Scorpion
canrecruit=yes
fog=no
shroud=no
[unit]
type=Gryphon
id=Gryp2
name=Gryp2
x,y=5,15
[/unit]
[/side]
[event]
name=side turn
first_time_only=no
[store_unit]
[filter]
type=Gryphon
[filter_location]
terrain=Wo
[/filter_location]
[/filter]
variable=MODIFY_UNIT_store
kill=yes
[/store_unit]
{FOREACH MODIFY_UNIT_store MODIFY_UNIT_i}
{DEBUG_MSG "$MODIFY_UNIT_store[$MODIFY_UNIT_i].name has drowned!"}
{NEXT MODIFY_UNIT_i}
{CLEAR_VARIABLE MODIFY_UNIT_store}
[/event]
[/multiplayer]
Thanks!
Last edited by Ditto on July 2nd, 2009, 12:27 am, edited 1 time in total.
Re: unit ends a move on a specific terrain type?
Hmm... that is a nice solution. Incidentally, putting code in a .
Code: Select all
[code] tag makes it much easier to read
Re: unit ends a move on a specific terrain type?
Right .. forgot ... fixed!melinath wrote:Hmm... that is a nice solution. Incidentally, putting code in a.Code: Select all
[code] tag makes it much easier to read
Ok, now the next question to this is .. how do I "imbed" this into a new unit_type?
ie I create a new unit type, create the file and drop it in ./units.
Can I imbed this event somehow so that it gets included anywhere a unit of that type gets used?
Or do I have to use macros and rely on the tag being added "manually" with the scenario?
Re: unit ends a move on a specific terrain type?
UnitTypeWML - look under "other tags"
Re: unit ends a move on a specific terrain type?
Of course!!melinath wrote:UnitTypeWML - look under "other tags"
Thanks!!
I'll try that when I get a chance ..
Re: unit ends a move on a specific terrain type?
Alternatively, you could've done the following:
Note: fire_event=yes is important in a [kill] tag if you want any events that would happen upon the death of the units to occur. Otherwise, if a player should lose if a mission-critical gryphon dies, the player doesn't lose if it gets killed by the [kill] tag.
Code: Select all
[kill]
type=Gryphon
side=$side_number
fire_event=yes
[filter_location]
terrain=Wo
[/filter_location]
[/kill][event]
name=new turn
first_time_only=no
[if]
[have_unit]
type=Gryphon
side=$side_number
[filter_location]
terrain=Wo
[/filter_location]
[/have_unit]
[then]
[message]
speaker=narrator
side_for=$side_number
message= _ "Gryphons that you had over deep water have drowned!"
[/message]
[/then]
[/if]
[/event]
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
Re: unit ends a move on a specific terrain type?
I did try this, couldn't get it to work .. so I'll stick with the other logic .. Thanks anywhom.A Guy wrote:Alternatively, you could've done the following:
Note: fire_event=yes is important in a [kill] tag if you want any events that would happen upon the death of the units to occur. Otherwise, if a player should lose if a mission-critical gryphon dies, the player doesn't lose if it gets killed by the [kill] tag.Code: Select all
[kill] type=Gryphon side=$side_number fire_event=yes [filter_location] terrain=Wo [/filter_location] [/kill][event] name=new turn first_time_only=no [if] [have_unit] type=Gryphon side=$side_number [filter_location] terrain=Wo [/filter_location] [/have_unit] [then] [message] speaker=narrator side_for=$side_number message= _ "Gryphons that you had over deep water have drowned!" [/message] [/then] [/if] [/event]
Re: unit ends a move on a specific terrain type?
Oh, I forgot the closing tag for the previous event you put the [kill] tag in. It works for me, anyways.
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.