Forbid unstored unit to move and attack

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
Samaximus
Posts: 9
Joined: September 8th, 2023, 1:53 pm

Forbid unstored unit to move and attack

Post by Samaximus »

Hello! I'm trying to make a realistic zombie campaign. When a living unit gets hit from a walking corpse it turns into a walking corpse. This mechanic works, however the new walking corpse can move and attack immediately and that is not desired. I read the wiki abot unit attributes, so I tried to set moves to 0 and attacks_left to 0 without success. Here is my code:

Code: Select all

	# when Zombie attacks
	[event]
		name=attacker hits
		first_time_only=no
	
		[filter]
			type=Walking Corpse, Soulless
		[/filter]
	
		[filter_second]
			[not]
				trait=undead,elemental
			[/not]
		[/filter_second]

		[store_unit]
			[filter]
				id=$second_unit.id
			[/filter]
			kill=yes
			variable=infected
		[/store_unit]
	
		{VARIABLE infected.side $unit.side}
		{VARIABLE infected.type "Walking Corpse"}
		{VARIABLE infected.hitpoints $unit.max_hitpoints}
		{VARIABLE infected.max_hitpoints $unit.max_hitpoints}
		{VARIABLE infected.canrecruit no}
		{VARIABLE infected.movementpoints 0}
		{VARIABLE infected.attacks 0}
	
		[unstore_unit]
			variable=infected
		[/unstore_unit]
	
		[redraw]
			side=1
		[/redraw]
	
	[/event]
	
	# When Zombie makes hit during defense
	[event]
		name=defender hits
		first_time_only=no
	
		[filter]
			[not]
				trait=undead,elemental
			[/not]
		[/filter]

		[filter_second]
			type=Walking Corpse, Soulless
		[/filter_second]
	
		[store_unit]
			[filter]
				id=$unit.id
			[/filter]
			kill=yes
			variable=infected
		[/store_unit]
	
		{VARIABLE infected.side $second_unit.side}
		{VARIABLE infected.type "Walking Corpse"}
		{VARIABLE infected.hitpoints $second_unit.max_hitpoints}
		{VARIABLE infected.max_hitpoints $second_unit.max_hitpoints}
		{VARIABLE infected.canrecruit no}
		{VARIABLE infected.moves 0}
		{VARIABLE infected.experience 0}
		{VARIABLE infected.attacks_left 0}
	
		[unstore_unit]
			variable=infected
		[/unstore_unit]
	
		[redraw]
			side=1
		[/redraw]
	[/event]
User avatar
ForestDragon
Posts: 1857
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: Forbid unstored unit to move and attack

Post by ForestDragon »

Instead of this



{VARIABLE infected.movementpoints 0}
{VARIABLE infected.attacks 0}


You need this:



{VARIABLE infected.moves 0}
{VARIABLE infected.attacks_left 0}
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
Samaximus
Posts: 9
Joined: September 8th, 2023, 1:53 pm

Re: Forbid unstored unit to move and attack

Post by Samaximus »

Indeed! Thank you!
white_haired_uncle
Posts: 1456
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Forbid unstored unit to move and attack

Post by white_haired_uncle »

Interesting. I didn't know you could just change a unit's type like that without using [transform_unit]. Have you tested to make sure that the unit is unpoisoned when it becomes a WC?

Also, have you tested what happens if infected is the only unit on the side and/or the leader?

P.S. viewforum.php?f=21
Speak softly, and carry Doombringer.
Post Reply