An event that can auto modify terrain but end with question

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
ZeoN_PoweR
Posts: 11
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

An event that can auto modify terrain but end with question

Post by ZeoN_PoweR » December 12th, 2017, 1:55 pm

Hi all,

I'm a newbie for WML.
Recently, I'm working on an event that can modify terrain every new turn. That is, I want my unit to plant some tree on the map, but don't want it finished in a turn. I want it to have "growth" procedure.
Therefore I search for likely WML and change its detail. Please see below:

Code: Select all

	[event]
		name=new turn
		first_time_only=no	
		[store_locations]
			[filter]
				[filter_location]
					terrain=*^Zt0 #this is seed terrain I made myself
				[/filter_location]
			[/filter]
			variable=0tree
		[/store_locations]		
		[store_locations]
			[filter]
				[filter_location]
					terrain=*^Zta #this is small tree terrain I made myself
				[/filter_location]
			[/filter]
			variable=atree
		[/store_locations]

		[store_locations]
			[filter]
				[filter_location]
					terrain=*^Ztb #this is medium tree terrain I made myself
				[/filter_location]
			[/filter]
			variable=btree
		[/store_locations]		
		[set_variable]
            name=sound
            value=no
        [/set_variable]
#----------------------------------
		{FOREACH 0tree rh}
            [set_variable]
                name=temp_x
                value=$0tree[$rh].x
            [/set_variable]
            [set_variable]
                name=temp_y
                value=$0tree[$rh].y
            [/set_variable]
            [set_variable]
                name=sound
                value=yes
            [/set_variable]
		{MODIFY_TERRAIN "Gs^Zta" $temp_x $temp_y}			
		{NEXT rh}
        [if]
            [variable]
                name=sound
                equals=yes
            [/variable]
            [then]
                [sound]
                    name=entangle.wav
                [/sound]

                [delay]
                    time=200
                [/delay]
            [/then]
        [/if]       
#------------------------------		
		{FOREACH atree rh}
            [set_variable]
                name=temp_x
                value=$atree[$rh].x
            [/set_variable]
            [set_variable]
                name=temp_y
                value=$atree[$rh].y
            [/set_variable]
            [set_variable]
                name=sound
                value=yes
            [/set_variable]
		{MODIFY_TERRAIN "Gs^Ztb" $temp_x $temp_y}	
		{NEXT rh}
        [if]
            [variable]
                name=sound
                equals=yes
            [/variable]
            [then]
                [sound]
                    name=entangle.wav
                [/sound]

                [delay]
                    time=200
                [/delay]
            [/then]
        [/if]
#-----------------------------------------      		
		{FOREACH btree rh}
            [set_variable]
                name=temp_x
                value=$btree[$rh].x
            [/set_variable]
            [set_variable]
                name=temp_y
                value=$btree[$rh].y
            [/set_variable]
            [set_variable]
                name=sound
                value=yes
            [/set_variable]		
		{MODIFY_TERRAIN "Gs^Fp" $temp_x $temp_y}	
		{NEXT rh}
        [if]
            [variable]
                name=sound
                equals=yes
            [/variable]

            [then]
                [sound]
                    name=entangle.wav
                [/sound]

                [delay]
                    time=200
                [/delay]
            [/then]
        [/if]
        [clear_variable]
            name=sound,0tree,atree,btree
        [/clear_variable]		
		[redraw]
        [/redraw]
    [/event]
Well...event does works, but only when there is unit standing on the terrain(no matter from which side or what unit).
I wish it could growth automatically. I've been trying many other WML(like have _location, set_variable) to fix it but still in vain. Does anyone who can point out where is the problem?
Thanks a lot.

User avatar
Ravana
Moderator
Posts: 1746
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: An event that can auto modify terrain but end with quest

Post by Ravana » December 12th, 2017, 2:01 pm

[filter] filters units. Remove that part from around filtering locations.

ZeoN_PoweR
Posts: 11
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

Re: An event that can auto modify terrain but end with quest

Post by ZeoN_PoweR » December 12th, 2017, 2:27 pm

Hi Ravana,

I've tried this before, but it end up with all map change into tree terrain at the very beginning, even my own castle. :lol: Should I make any modification with this change? Thanks for your advice.

ZeoN_PoweR
Posts: 11
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

Re: An event that can auto modify terrain but end with quest

Post by ZeoN_PoweR » December 12th, 2017, 2:34 pm

Oops, I misunderstanding what you mean. After I remove whole [filter] and [filter_locations], event works fine!!! Thank you so much!!!

Greenwiz34
Posts: 3
Joined: December 17th, 2017, 6:33 am

Re: An event that can auto modify terrain but end with quest

Post by Greenwiz34 » December 17th, 2017, 6:50 am

Hey, after I saw this thread earlier today, I started trying to add a similar effect to explosive (AoE) attacks from Dugi's LotI for my own use. This has given me the best results so far:

Code: Select all

        [if]
            [variable]
                name=damage
                greater_than=108		# If the damage is higher than most common attacks can get, the range is increased even even more.
            [/variable]
            [then]
                [harm_unit_loti]
                    [filter]
                        [filter_location]
                            # Exclude the units that just received the damage.
                            [not]
                                x,y=$x2,$y2
                                radius=3
                            [/not]
                            # Include the remaining units within two hexes.
                            [and]
                                x,y=$x2,$y2
                                radius=5                                
                            [/and]
                        [/filter_location]
                        [filter_side]
                            [enemy_of]
                                side=$unit.side
                            [/enemy_of]
                        [/filter_side]
                    [/filter]
                    [filter_second]
                        x,y=$x1,$y1
                    [/filter_second]
                    amount=$($($damage)/3-16)
                    damage_type=$weapon.type
                    fire_event=yes
                    animate=no
                    poisoned=$has_poison
                [/harm_unit_loti]
#My changes start here
                [store_locations] 
                    [filter_location]
                        x,y=$x2,$y2
                        radius=3
                    [/filter_location]
                    variable=wall
                [/store_locations]      
      
                {FOREACH wall rh}
                    [set_variable]
                        name=temp_x
                        value=$wall[$rh].x
                    [/set_variable]
                    [set_variable]
                        name=temp_y
                        value=$wall[$rh].y
                    [/set_variable]                    
                [terrain]
                    [and]
                        terrain=X*,X*^*,*^X* # here is the filter criterion
                    [/and]
                    terrain=Zvw^Dr # and the new terrain
                [/terrain]         
                {NEXT rh}
                [redraw]
                [/redraw]
            [/then]
        [/if]
        {CLEAR_VARIABLE damage,has_poison}
    [/event]
Problem is, it changes all walls on the entire map, and I can't for the life of me figure out how to reign it in without restricting it to one hex only, which defeats the purpose of this effort. My thought was that an attack this powerful SHOULD have some sort of effect on the terrain as well, like breaking down walls near the impact site.

I'm kind of a noob at coding, so any help/advice is greatly appreciated!


Edit: ...and yes, I'm aware this can make these moves OP, breaks balance/scenario flow/etc.
Like I said, this is only for my own use, and I LIKE having a couple of OP godlings under my control! :whistle: :lol: :twisted: *awkward slide*

User avatar
beetlenaut
Developer
Posts: 2174
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: An event that can auto modify terrain but end with quest

Post by beetlenaut » December 19th, 2017, 1:57 am

Greenwiz34 wrote:Problem is, it changes all walls on the entire map
That's because you didn't put any x and y values in the [terrain] tag. If I understand what you're trying to do, you need to put x=temp_x and y=temp_y in there.
Campaigns: Dead Water
The Founding of Borstep
Secrets of the Ancients

Greenwiz34
Posts: 3
Joined: December 17th, 2017, 6:33 am

Re: An event that can auto modify terrain but end with quest

Post by Greenwiz34 » December 19th, 2017, 3:49 am

So, I tried what you suggested, but it limited the effect to the targeted hex only, no AoE.
I'm thinking my store_location block isn't doing what I want, but I don't know enough about WML to have any clue how to fix it...

User avatar
beetlenaut
Developer
Posts: 2174
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: An event that can auto modify terrain but end with quest

Post by beetlenaut » December 19th, 2017, 7:48 am

Greenwiz34 wrote:I'm thinking my store_location block isn't doing what I want
Oh, right. [filter_location] is part of the standard unit filter, not part of the standard location filter. You need to take it out.

Code: Select all

[store_locations] 
	x,y=$x2,$y2
	radius=3
	variable=wall
[/store_locations]
When the wiki entry on a tag says it takes a "standard [whatever] filter," it will also tell you whether or not that set of filters needs to be inside some sort of tag. Usually it doesn't, like in the case of [store_locations]. (For an example of what the wiki says when it does, look at [modify_unit].)
Campaigns: Dead Water
The Founding of Borstep
Secrets of the Ancients

Greenwiz34
Posts: 3
Joined: December 17th, 2017, 6:33 am

Re: An event that can auto modify terrain but end with quest

Post by Greenwiz34 » December 22nd, 2017, 11:19 pm

Hey, I finally got it working how I wanted!
Here's what I ended up with:

Code: Select all

[store_locations]
     terrain=X*,X*^*,*^X* # here is the filter criterion
     [and]
          x,y=$x2,$y2
          radius=3
     [/and]                    
     variable=wall
[/store_locations]      
      
{FOREACH wall rh}
     [set_variable]
           name=temp_x
           value=$wall[$rh].x
     [/set_variable]
     [set_variable]
           name=temp_y
           value=$wall[$rh].y
     [/set_variable]                    
     {MODIFY_TERRAIN "Zvw^Dr" $temp_x $temp_y}                               
{NEXT rh}
[redraw]
[/redraw]
It knocks down walls within a few hexes of the impact site, but leaves the rest of the map alone, just as I envisioned it.
Thanks for the tips! I don't think I could have managed this without the help.

Post Reply