How do i spawn units around certain terrain every turn

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
User avatar
Misaghhhh
Posts: 6
Joined: April 14th, 2023, 4:50 pm

How do i spawn units around certain terrain every turn

Post by Misaghhhh »

Hi everyone, this is my first post in the forum and english is not my native language so i'm sorry if i'm asking my question in the wrong place or making any grammar mistake.

How do i spawn a certain unit around certain terrain every turn for certain side (myself,my ally or enemy).

I'm playing 4p_A_New_Land scenario and i'm maked my own little change so when enemies capture my human-city(^Vhc) terrain will change to human-city-ruin(^Vhcr).

I want few Walking Corpse spawn around human-city-ruin(^Vhcr) wich is now under enemys control every turn.

Human citys spawn zombies......its a zombie apocalypse scenario. :mrgreen:

I will be very grateful if someone send me the code or point me to the helpful topic.

Thanks. :)
User avatar
Misaghhhh
Posts: 6
Joined: April 14th, 2023, 4:50 pm

Re: How do i spawn units around certain terrain every turn

Post by Misaghhhh »

Ravana wrote: April 14th, 2023, 9:11 pm Start by creating one zombie every turn in specific location. Once that is working adjust it to affect all Vhcr.

https://wiki.wesnoth.org/EventWML#new_turn
https://wiki.wesnoth.org/SingleUnitWML

https://wiki.wesnoth.org/InternalAction ... cations.5D
https://wiki.wesnoth.org/ConditionalAct ... foreach.5D
Thanks Ravana for the guidance and links, right now i can create one zombie in specific location every turn by using this code:

Code: Select all

[set_variable]
	  name=Corpse
	  rand=defpl_Corpse_Walking
      [/set_variable]
      [unit]
	  x,y={X},{Y}
	  generate_name=yes
	  random_traits=yes
	  type=$Corpse
	  side=5
      [/unit]
      [if]
	  [variable]
	      name=Corpse
	      equals=defpl_Corpse_Walking
	  [/variable]
	  [then]
	      [unit]
		  terrain={X},{Y}
		  type=defpl_Corpse_Walking
		  side=8
	      [/unit]
      [/then]
      [/if]
      [clear_variable]
	  name=typeofenemy
      [/clear_variable]
      #enddef

      [event]
	  name=new turn
      first_time_only=no
	  {CORPSE 32 27}
      [/event]
My next step will be adjust it to affect all ^Vhcr terrain, which i must confess its a little hard for me with my current skill and understanding of WML, :hmm: but i will try my best. :)
Last edited by Ravana on April 15th, 2023, 8:41 am, edited 1 time in total.
Reason: [code][/code]
User avatar
Ravana
Forum Moderator
Posts: 3017
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How do i spawn units around certain terrain every turn

Post by Ravana »

https://wiki.wesnoth.org/StandardLocati ... g_Terrains example 2 shows how to filter for terrain by overlay.
Post Reply