Lava Spread
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.
-
- Posts: 4
- Joined: June 19th, 2012, 8:13 pm
Lava Spread
I am attempting to set up a scenario where, when the player steps on a certain tile, all the chasms on the map are turned into lava chasms. Two turns later, they turn into lava, which then begins to spread periodically. I cannot seem to get the WML to work. I have tried several existing fragments, for SoF, HttT, UtBS, and TDH, but I've had no luck with any of them.
This is what I have currently in place:
At the moment, it gives me an invalid closing tag error. If I remove the {FOREACH magma I}, it loads, but fails to work. I admit to having no idea what {FOREACH} does, so I do not know if the problem is there.
I have managed to get the lava spread part to work, but, for some reason, it only worked the first turn I had listed. Now it won't do it at all. Before it was:
Finally, I had it set for several Fire Guardians to crop up on the stepping on of a tile. No errors, but nothing happens. The code for this is as follows:
As a side note, how do you get units to spawn randomly from a set tile (like the shaxthals in IftU)? I’m thinking of using this later in the campaign.
Any help would be appreciated. If there's anything I forgot to attach, please let me know.
-Liechtenauer
This is what I have currently in place:
Code: Select all
[event]
name=moveto
first_time_only=yes
[filter]
x=30
y=18
side=1
[/filter]
{QUAKE "rumble.ogg"}
{QUAKE "rumble.ogg"}
{QUAKE "rumble.ogg"}
[set_variable]
name=lava
value=awake
[/set_variable]
[set_variable]
name=overlayturn
value=0
[/set_variable]
[store_locations]
variable=magma
terrain=Qxu
[/store_locations]
{FOREACH magma i}
[terrain]
x=$magma[$i].x
y=$magma[$i].y
terrain=Ql
[/terrain]
[delay]
time=1000
[/delay]
[/event]
Code: Select all
#define SPREAD_LAVA
{QUAKE "rumble.ogg"}
{QUAKE "rumble.ogg"}
[store_locations]
variable=lava
terrain=Uu
[filter_adjacent_location]
count=1-6
terrain=Qlf
[/filter_adjacent_location]
[/store_locations]
{FOREACH lava i}
[terrain]
x=$lava[$i].x
y=$lava[$i].y
terrain=Qlf
[/terrain]
{NEXT i}
[redraw]
[/redraw]
[kill]
[not]
type=Fire Guardian
[/not]
[filter_location]
terrain=Uu
[/filter_location]
animate=yes
fire_event=yes
[/kill]
[redraw]
[/redraw]
{CLEAR_VARIABLE (lava) }
#enddef
Code: Select all
[event]
name=new turn
first_time_only=no
[if]
[variable]
name=lava
equals=awake
[/variable]
[then]
[set_variable]
name=overlayturn
add=1
[/set_variable]
[/then]
[/if]
[if]
[variable]
name=overlayturn
equals=2
[/variable]
[then]
[store_locations]
variable=magma
terrain=Ql
[/store_locations]
{FOREACH magma i}
[terrain]
x=$magma[$i].x
y=$magma[$i].y
terrain=Qlf
[/terrain]
[/then]
[/if]
[if]
[variable]
name=overlayturn
equals=4,6,7,8,9,10,11,12,13,14,15
[/variable]
[then]
{SPREAD_LAVA}
[/then]
[/if]
[/event]
I have managed to get the lava spread part to work, but, for some reason, it only worked the first turn I had listed. Now it won't do it at all. Before it was:
Code: Select all
#define SPREAD_LAVA TURN
[if]
[variable]
name=overlayturn
numerical_equals={TURN}
[/variable]
[then]
{QUAKE "rumble.ogg"}
{QUAKE "rumble.ogg"}
[store_locations]
variable=lava
terrain=Qlf,Ql
[filter_adjacent_location]
count=1-6
terrain=Uu
[/filter_adjacent_location]
[/store_locations]
{FOREACH lava i}
[terrain]
x=$lava[$i].x
y=$lava[$i].y
terrain=Uu
[/terrain]
{NEXT i}
[redraw]
[/redraw]
[kill]
[not]
type=Fire Guardian
[/not]
[filter_location]
terrain=Uu
[/filter_location]
animate=yes
fire_event=yes
[/kill]
{NEXT i}
[redraw]
[/redraw]
{CLEAR_VARIABLE (lava) }
[/then]
[/if]
#enddef
Code: Select all
[event]
name=new turn
first_time_only=no
[if]
[variable]
name=lava
equals=awake
[/variable]
[then]
[set_variable]
name=overlayturn
add=1
[/set_variable]
{SPREAD_LAVA 1}
{SPREAD_LAVA 3}
{SPREAD_LAVA 5}
[/then]
[/if]
[/event]
Finally, I had it set for several Fire Guardians to crop up on the stepping on of a tile. No errors, but nothing happens. The code for this is as follows:
Code: Select all
[event]
name=moveto
first_time_only=yes
[filter]
x=43,44
y=30,29
side=1
[/filter]
[set_variable]
name=guardians
value="awake"
[/set_variable]
#ifdef EASY
{GENERIC_UNIT 2 (Fire Guardian) 44 18}
{GENERIC_UNIT 2 (Fire Guardian) 36 26}
{GENERIC_UNIT 2 (Fire Guardian) 33 7}
#endif
#ifdef MEDIUM
{GENERIC_UNIT 2 (Fire Guardian) 44 18}
{GENERIC_UNIT 2 (Fire Guardian) 36 26}
{GENERIC_UNIT 2 (Fire Guardian) 33 7}
{GENERIC_UNIT 2 (Fire Guardian) 34 29}
#endif
#ifdef HARD
{GENERIC_UNIT 2 (Fire Guardian) 44 18}
{GENERIC_UNIT 2 (Fire Guardian) 36 26}
{GENERIC_UNIT 2 (Fire Guardian) 33 7}
{GENERIC_UNIT 2 (Fire Guardian) 34 29}
{GENERIC_UNIT 2 (Fire Guardian) 49 20}
{GENERIC_UNIT 2 (Fire Guardian) 33 9}
#endif
[/event]
Any help would be appreciated. If there's anything I forgot to attach, please let me know.
-Liechtenauer
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Lava Spread
FOREACH and NEXT should be treated like opening/closing tags respectively. Look in data/core/macros/utils.cfg for the actual code used. If you are using something and have no idea what something does, that is an issue by itself.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
-
- Posts: 4
- Joined: June 19th, 2012, 8:13 pm
Re: Lava Spread
Thank you. The {FOREACH} is working now. Any advice on the lava spread and other issues?
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Lava Spread
When they walk onto the location to start this whole thing:
The event then triggers the first time, over the course of which you have this:
So basically just change the variable name in either place to something other than lava that isn't already being used.
For the guardians not appearing, is anything not from side 1 stepping on those locations? If they are, it might trigger the moveto event, fail the filter and do nothing since they aren't from side 1, but then since you have first_time_only=yes it would never trigger again.
For randomly spawning units, every turn for each location you want a unit to randomly spawn, just randomly generate a number and if it equals the correct number then spawn the unit.
Code: Select all
[set_variable]
name=lava
value=awake
[/set_variable]
Code: Select all
[store_locations]
variable=lava
terrain=Uu
[filter_adjacent_location]
count=1-6
terrain=Qlf
[/filter_adjacent_location]
[/store_locations]
For the guardians not appearing, is anything not from side 1 stepping on those locations? If they are, it might trigger the moveto event, fail the filter and do nothing since they aren't from side 1, but then since you have first_time_only=yes it would never trigger again.
For randomly spawning units, every turn for each location you want a unit to randomly spawn, just randomly generate a number and if it equals the correct number then spawn the unit.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
-
- Posts: 4
- Joined: June 19th, 2012, 8:13 pm
Re: Lava Spread
I switched the macro variables to 'volcano', but still nothing is happening. As to the Fire Guardians, side 1 is the only side with units on the map at that point. Thanks for the help with the random spawn.
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Lava Spread
Do you think you could upload it here? It would be easier if I could actually test stuff out than me guessing what could possibly fix it and then waiting for a response.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code