filtering by status

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
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

filtering by status

Post by Helmet »

My campaign has a custom status called "corrupted."

A corrupted unit turns slightly purple, changes their alignment to chaotic, and gains 3 temporary hitpoints. The problem is, units are getting corrupted multiple times, getting more and more hitpoints every turn. I want a unit to get corrupted once. I wanted to filter based on the status.

I originally tried to make it so that any side 2 unit that is neutral would be corrupted during the corruption event, but I couldn't get it to work. So I invented the corrupted status. But it also doesn't work.

How do you filter based on status?

Code: Select all

[event]
	name=side 2 turn #		before turn refresh (i.e., before healing, calculating income, etc.)
	first_time_only=no
	[filter]
		side=2
	[/filter]
	[unit_filter]
		[wml_filter]
			[status]
				corrupted=no
			[/status]
		[/wml_filter]
	[/unit_filter]	
	[modify_unit]
		[filter]
			type=Shroomling,Shroomid,War Spore
		[/filter]		
		{CORRUPTED_SHROOMKIN}  #		corrupt all uncorrupted shroomkin on the map, status=corrupted
	[/modify_unit]
[/event]
For the curious, here is the code for making a unique status. Of course, it doesn't really do anything.

Code: Select all

	[status]
		corrupted=yes #	unique status to ensure that a unit is not corrupted multiple times
	[/status]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: filtering by status

Post by beetlenaut »

[unit_filter] is not a real tag, and neither is [wml_filter], so that part is being ignored, and a "side 2" event doesn't store a unit filter, so that part is being ignored too. You should filter for side and status in the [filter] block under [modify_unit] because that one exists. Are you using the wiki to verify that the tags you use are correct, or trying to do it all from memory?
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: filtering by status

Post by Helmet »

beetlenaut wrote: December 27th, 2020, 1:50 am [unit_filter] is not a real tag, and neither is [wml_filter], so that part is being ignored, and a "side 2" event doesn't store a unit filter, so that part is being ignored too. You should filter for side and status in the [filter] block under [modify_unit] because that one exists. Are you using the wiki to verify that the tags you use are correct, or trying to do it all from memory?
I got the code from an old forum post made by, I think, a developer? Before that, I tried using my memory, then the Wiki, but couldn't get anything to work.

I'm pretty sure your solution was the first thing I tried, and the nonsense I posted above was like my 10th attempt to stumble upon a solution. But I'll try the solution you recommended again.

EDIT: Here's the old, old post I referenced for status.
Alink wrote: November 14th, 2007, 5:48 pm Then you need to know how filter the poisoned state

Code: Select all

[unit_filter]
    [wml_filter]
        [status]
            poisoned="yes"
         [/status]
    [/wml_filter]
[/unit_filter]
Yikes, that post was 13 years old. No wonder the code didn't work.
Last edited by Helmet on December 27th, 2020, 2:18 am, edited 2 times in total.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: filtering by status

Post by Helmet »

I use modify_unit a lot. But I can't get it to work right. The units keep getting corrupted over and over.

Code: Select all

[event]
	name=side 2 turn #					before turn refresh (i.e., before healing, calculating income, etc.)
	first_time_only=no

	[modify_unit]
		[filter]
			side=2
		[/filter]
		[filter]
			[not]
				corrupted=yes
			[/not]
		[/filter]
 		[filter]
			type=Shroomling,Shroomid,War Spore,Spore Lord
		[/filter]		
		{CORRUPTED_SHROOMKIN}  #		corrupt all uncorrupted shroomkin on the map, status=corrupted
	[/modify_unit]
[/event]
I tried filtering for alignment=neutral. All the side 2 uncorrupted units are neutral, so that seemed a good solution. But I couldn't get it to work.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: filtering by status

Post by beetlenaut »

I think you need to use the wiki more. You should have looked under the standard unit filter to see how to filter statuses and what that looked like. I think you just guessed and hoped it would work. Even after writing four campaigns, I have the wiki bookmarked and refer to it all the time. I didn't test this, but I did check, so I think it will work.

Code: Select all

[modify_unit]
	[filter]
		type=Shroomling,Shroomid,War Spore
		side=2
		[not]
			status=corrupted
		[/not]
	[/filter]		
	{CORRUPTED_SHROOMKIN}
[/modify_unit]
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: filtering by status

Post by Helmet »

beetlenaut wrote: December 27th, 2020, 2:25 am I think you need to use the wiki more. You should have looked under the standard unit filter to see how to filter statuses and what that looked like. I think you just guessed and hoped it would work. Even after writing four campaigns, I have the wiki bookmarked and refer to it all the time. I didn't test this, but I did check, so I think it will work.

Code: Select all

[modify_unit]
	[filter]
		type=Shroomling,Shroomid,War Spore
		side=2
		[not]
			status=corrupted
		[/not]
	[/filter]		
	{CORRUPTED_SHROOMKIN}
[/modify_unit]
Thank you, Beetlenaut, your code worked.

I do refer to the Wiki quite a bit, but I also make a lot of mistakes, especially with filters. I did write status=corrupted after reading the Wiki, but it didn't work when I did it. I probably had my [not] in the wrong place, or something else. It's like I have the right puzzle pieces, but I assemble them wrong.

Here's a recent example of me using the Wiki...

I needed to remove an object and I had never done that before, so I checked the Wiki. The Wiki said I needed to use remove_object. So I wrote...

Code: Select all

		[modify_unit]
			[filter]
				id=Domo
			[/filter]
			[remove_object]
				[effect]
					apply_to=image_mod
					add="BLEND(255,0,255,18%)" # (r,g,b,o)
				[/effect]
			[/remove_object]
		[/modify_unit]	
That didn't work, so I read the Wiki again. I needed to add an id to the object before I can remove the object. So I added an id to the object, and then I wrote...

Code: Select all

		[modify_unit]
			[filter]
				id=Domo
			[/filter]
			[remove_object]
				id=blend_color
			[/remove_object]
		[/modify_unit]	
That didn't work, so I read the Wiki again. It's not id, it's object_id. Oops. Then I wrote...

Code: Select all

		[modify_unit]
			[filter]
				id=Domo
			[/filter]
			[remove_object]
				object_id=blend_color
			[/remove_object]
		[/modify_unit]	
That didn't work, so I read the Wiki again. Maybe the filter is to blame? Then I wrote...

Code: Select all

		[modify_unit]
			[remove_object]
				id=Domo
				object_id=blend_color
			[/remove_object]
		[/modify_unit]	
That didn't work. I got an error message about modify_unit needing a filter. Instead of putting the filter back, I guessed that maybe modify_unit can be deleted? Then I wrote...

Code: Select all

			[remove_object]
				id=Domo
				object_id=blend_color
			[/remove_object]
Success!

But you're right. I need to use the Wiki more. All the puzzle pieces are there in the Wiki, I just have to study those pieces and figure out where they go.

Thanks again for your help.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: filtering by status

Post by beetlenaut »

Helmet wrote: December 27th, 2020, 3:35 am Thank you, Beetlenaut, your code worked.
Good! It's always dangerous to offer untested code. Computers are dumb, so you have to be exact.

This is something you have to remember: You can only use tags where the wiki tells you they are supported. The section on the [modify_unit] tag does not list [remove_object] as supported under it, so it isn't. Simple as that. If it seems like the game is ignoring a tag, that's what you should always check first. Make sure it's valid in the context where you are using it.

(Sometimes, like on the page for [event], the wiki just says "actions" are supported, because that's a big list. There is a page on it though.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: filtering by status

Post by Helmet »

beetlenaut wrote: December 27th, 2020, 4:24 am This is something you have to remember: You can only use tags where the wiki tells you they are supported. The section on the [modify_unit] tag does not list [remove_object] as supported under it, so it isn't. Simple as that. If it seems like the game is ignoring a tag, that's what you should always check first. Make sure it's valid in the context where you are using it.
That's good advice, I'll start doing that. I'm beginning to accept the fact that I am a bad guesser with WML.

Here's a guessing-related mistake I made recently. I know that move_unit takes the keys to_x and to_y. So naturally I assumed move_unit_fake takes the same keys. Nope. The keys are x and y. I was about 99% sure I had guessed that one correctly.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Post Reply