Unit unable to flag a village

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

Unit unable to flag a village

Post by Helmet »

My enemy unit Vinkus can't flag a village for some reason.

In my campaign's first scenario, Vinkus is the enemy leader of side 2. Vinkus almost certainly survives the skirmish. His data is stored via store_unit, so he can reappear in the middle of Scenario 2.

Scenario 2 begins with Human/side 1 fighting saurians side 2. Vinkus will be the only member of side 3 (until he recruits something). I didn't want side 3 to appear in the Status Table until Vinkus arrives on the scene. I used hidden=yes to do this. After Vinkus is un-stored, I used hidden=no to add his side to the Status Table.

Also, in the previous scenario, Vinkus was side 2, so after Vinkus was un-stored, I changed him to side 3 via modify_unit. So far, so good (presumably).

So Vinkus arrives on the map in the middle of Scenario 2, but he can't flag a village. I've read the wiki and tried everything I can think of to fix the problem, including some wild guesses, but nothing worked. Any help would be appreciated.

Note: I have side 3 set to no_leader=yes. But even when I add an unwanted leader, Vinkus can't flag a village.

Here are the two sections of relevant code.

Code: Select all

    [side] #						Side 3
        side=3
        color=teal
        team_name=3 #						<<< not an ally of the saurians (side 2)
        user_team_name= "Team Vinkus"
        gold=20 # default is 100
        hidden=yes
        controller=ai
        no_leader=yes
 #      id=UnwantedLeader
 #     name= "UnwantedLeader"
 #     unrenamable=yes
 #	type=Skeleton
 #	canrecruit=yes
 #	recruit="Giant Rat"
 #      x,y=13,10 #  middle-bottom of map
 #      max_moves=1
    [/side]

	[event]
		name=turn $vinkus_returns
    		[if]
    			[variable]
				name=vinkus_alive
				equals=yes
			[/variable]
			[then]
			
				# Unstore a unit inside the event that creates it
			    	[unstore_unit]
			        	variable=variable_that_stores_vinkus
			        	x,y= 25,10 # 	<<< where unstored unit appears
			    	[/unstore_unit]
			    	{CLEAR_VARIABLE variable_that_stores_vinkus}

				[modify_unit] #		<<< changes Vinkus to side 3
					[filter]
						id=Vinkus
					[/filter]
					side=3
					extra_recruit=Thief
				[/modify_unit]			
				[modify_side] #		<<< un-hides side 3 from the status menu
					[filter]
						side=3
					[/filter]
					hidden=no
				[/modify_side]			
    				[move_unit]
        				id=Vinkus
        				to_x=23
        				to_y=8
        			[/move_unit]
    				[message]
					speaker=Vinkus
     					message= _ "Truce over!"
				[/message]
			[/then]
		[/if]
	[/event]
Last edited by Helmet on September 30th, 2020, 7:18 pm, edited 1 time 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
Straff
Posts: 87
Joined: September 27th, 2020, 2:53 pm

Re: Unit unable to flag a village

Post by Straff »

I think the „no leader=yes“ causes your trouble.
Remove that line, and it should work.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Unit unable to flag a village

Post by Helmet »

I removed no_leader=yes, but it didn't work. Vinkus still can't flag a village. Thanks for the suggestion, though.
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
Pentarctagon
Project Manager
Posts: 5579
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Unit unable to flag a village

Post by Pentarctagon »

How is the unit getting to a village?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Unit unable to flag a village

Post by vghetto »

I might be wrong about this, but I think a side can flag villages if they have a unit with canrecruit=yes. Make sure Vinkus can recruit.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Unit unable to flag a village

Post by Helmet »

Vinkus appears on a random turn (turn 5, 6 or 7). He appears after using unstore_unit. He appears on hex 25, 10 within forest terrain. And then he immediately moves via move_unit to a village on hex 23, 8.

I want him to steal a village from the player, assuming the player had left it unguarded. As it is, if the player had flagged the village and left, Vinkus can't flag it. It will remain flagged by the player.
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
Pentarctagon
Project Manager
Posts: 5579
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Unit unable to flag a village

Post by Pentarctagon »

If you take control of side 3 and manually move him off the village and back onto it, does the village get captured then?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Unit unable to flag a village

Post by Helmet »

Okay, something weird is going on for sure.

I doubt Vinkus could recruit, so that was a problem. Evidently his recruit list from Scenario 1 didn't carry over to Scenario 2. So I gave him a recruit list that only had "Thief" in it, and then I allowed him to run into the player's keep and recruit. Vinkus recruited some thieves.

Here is the weird part. When the thieves were badly damaged and ran away from the battle, they didn't notice villages. One thief ran 'through' a village and kept going. Hmmm. I don't know what this means, but it looks like a clue.
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: Unit unable to flag a village

Post by Helmet »

Pentarctagon wrote: September 30th, 2020, 6:44 pm If you take control of side 3 and manually move him off the village and back onto it, does the village get captured then?
Results! Weird results, but results.

I made side 3 controller=human like you suggested. Vinkus ran to a village after he appeared on the map, as expected. Vinkus did not flag the village, as usual. But then, when it was my turn to move Vinkus, I moved him off the village and back on, and he flagged it!

What does this mean?
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.
Pilauli
Posts: 115
Joined: August 18th, 2020, 12:56 pm

Re: Unit unable to flag a village

Post by Pilauli »

If the unit has the leader crown icon over their health bar, they have canrecruit=yes set. The contents of the recruit= list should be irrelevant.

Maybe move_unit doesn't trigger village-flagging the way it would if the unit moved itself?

You could try manually flagging the village like this:

Code: Select all

    [capture_village]
        side=3
        x,y=26,5
    [/capture_village]
Of course, (26,5) is the location of the village I tested it with. :D
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Unit unable to flag a village

Post by Helmet »

I just tested move_unit also. You are right: move_unit doesn't allow a unit to flag a village at the destination. I had no idea. Thanks! Problem solved! Also, thanks for pointing me toward capture_village. It was a relief to finally see that teal flag appear in the village after Vinkus runs there.

By the way, I did some more testing and this time the thieves ran to villages to heal, like they should. Whew.

Thanks everybody 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.
Post Reply