Attack changing targeted tile to snowy terrain
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.
Attack changing targeted tile to snowy terrain
Hi,
I would like to create unit with a Freeze attack that in addition to damaging the enemy also changes the terrain he is standing on to its winter version - like makes ice from water, snowy hills from other hills etc.
My understanding of WML is too weak however and I don't even know where to start.
Event should probably filter targeted tile through all possible terrain and change it to Arctic version.
For the start I can live with the version that only changes water tiles to Ice as is was the first idea and probably will end up as the final one.
Please help
I would like to create unit with a Freeze attack that in addition to damaging the enemy also changes the terrain he is standing on to its winter version - like makes ice from water, snowy hills from other hills etc.
My understanding of WML is too weak however and I don't even know where to start.
Event should probably filter targeted tile through all possible terrain and change it to Arctic version.
For the start I can live with the version that only changes water tiles to Ice as is was the first idea and probably will end up as the final one.
Please help
Re: Attack changing targeted tile to snowy terrain
There might be more than one way of doing this.
An easy way would be by changing the [terrain] inside an 'attack_end' event.
An easy way would be by changing the [terrain] inside an 'attack_end' event.
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Attack changing targeted tile to snowy terrain
I think a single-hex [terrain_mask] is probably the best way to handle this, something like the following:
Code: Select all
[terrain_mask]
x,y=$x1,$y1
# Whatever terrain code you set here will be used for locations that don't match any of the rules
mask=Ai
# I'm not sure whether these two keys are necessary for a single-hex mask
border=no
alignment=raw
# Turn water tiles into ice
[rule]
old=W*
terrain=Ai
[/rule]
# Turn grass tiles into snow
[rule]
old=G*
terrain=Aa
[/rule]
# Add more rules as needed
[/terrain_mask]
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Attack changing targeted tile to snowy terrain
That was an interesting challenge. I had an idea of how to do it without copying and pasting a lot of rules. I didn't think I could explain it very well though, and I wasn't sure it would work anyway, so I just wrote it. Celtic_Minstrel's terrain masks are probably more elegant, but you can choose or use a combination.
It's currently hooked to a menu item so you can test it more easily, so put this in a prestart event. You will probably want it in an attack_end event eventually, like vghetto said. I entered a bunch of terrain codes to see how it looked. You can enter any other codes you need.
It's currently hooked to a menu item so you can test it more easily, so put this in a prestart event. You will probably want it in an attack_end event eventually, like vghetto said. I entered a bunch of terrain codes to see how it looked. You can enter any other codes you need.
Code: Select all
# Set up an array of container variables holding the terrain codes for normal terrains
# and their frozen versions.
# First, make an array of all the terrains that can be frozen.
[set_variables]
name=terrains
# Don't use carats or wildcards here. They will be added automatically later.
# (Apparently, spaces are ignored, so you can use them for clarity.)
[split]
list="W*, S*, H*, G*, R*, D*, I*, Ur*, M*, Fp*, Fd*, Fm*, Vl*, Vc*, Vh, Vhc*, Vhh*, Vo, Vu, Ve"
key=normal
separator=","
[/split]
[/set_variables]
# Next, make an array of what the above terrains turn into.
[set_variables]
name=temp_frozen
[split]
# Do put a carat on overlay terrains here.
list="Ai, Ai, Ha, Aa, Aa, Aa, Aa, Aa, Ms, ^Fpa, ^Fda, ^Fma, ^Vla, ^Vca, ^Vha, ^Vhca, ^Vhha, ^Voa, ^Vaa, ^Vea"
key=frozen
separator=","
[/split]
[/set_variables]
# Last, combine the two arrays above into one, and discard the second one.
[foreach]
array=terrains
[do]
[set_variable]
name=this_item.frozen
value=$temp_frozen[$i].frozen
[/set_variable]
[/do]
[/foreach]
[clear_variable]
name=temp_frozen
[/clear_variable]
# You can use ":inspect" to see what the final array looks like now.
# Create a menu item for testing the effect.
[set_menu_item]
id=freeze_tile
description="Freeze Tile"
[command]
# Move everything from in here into an [event] when you finish testing it
# and entering all the terrain codes you want.
[foreach]
array=terrains
[do]
# This [if] statement adds carats and wildcards to the terrain
# codes in the appropriate place so you don't have to add them
# to every single item in the "terrains" list. It also sets
# the layer appropriately.
[if]
# Check to see if the terrain is an overlay.
[variable]
name=this_item.frozen
contains="^"
[/variable]
[then]
[set_variable]
name=layer
value="overlay"
[/set_variable]
[set_variable]
name=normal
value="*^$this_item.normal"
[/set_variable]
[/then]
[else]
[set_variable]
name=layer
value="base"
[/set_variable]
[set_variable]
name=normal
value="$this_item.normal^*"
[/set_variable]
[/else]
[/if]
# Change the terrain.
[terrain]
# x1 and y1 are stored by the menu item. You might want
# to use x2 and y2.
x,y=$x1,$y1
# You use an [and] to filter a terrain inside a [terrain] tag.
[and]
terrain=$normal
[/and]
terrain=$this_item.frozen
layer=$layer
[/terrain]
[/do]
[/foreach]
[clear_variable]
name=normal, layer
[/clear_variable]
[/command]
[/set_menu_item]
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: Attack changing targeted tile to snowy terrain
Thank you all!
Before your answers I received great working code as a private message so the case is closed.
However I am really gratefull for your response and all the descriptions in your codes, because of that I will be able to understand WML a bit more
Before your answers I received great working code as a private message so the case is closed.
However I am really gratefull for your response and all the descriptions in your codes, because of that I will be able to understand WML a bit more