Various questions and answers thread

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
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Various questions and answers thread

Post by beetlenaut »

Ravana wrote:I believe it causes recheck of victory condition therefore ending game, and possibly firing victory event again.
That sounds like a reasonable guess. I think it shouldn't do that because the MOVE_UNIT macro includes fire_event=no, so maybe would be considered a bug. It doesn't seem right to me. To get around it, you could use victory_when_enemies_defeated=no, and fire the victory event manually from within the enemy leader's last_breath or die event. That way, the game would never check the victory conditions.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Various questions and answers thread

Post by TrashMan »

Code: Select all

 [+units]
 
	[race]
        id=human	
{TRAIT_BRAWLER}
    [/race]			

	
	[race]
        id=elf		
        {TRAIT_EAGLEEYE}
		{TRAIT_AGILE}
    [/race]
   
[/units]
Why does this not work?

The traits appear only if I remove the [race]tag and apply them on everyone
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Various questions and answers thread

Post by TrashMan »

beetlenaut wrote:
Ravana wrote:I believe it causes recheck of victory condition therefore ending game, and possibly firing victory event again.
That sounds like a reasonable guess. I think it shouldn't do that because the MOVE_UNIT macro includes fire_event=no, so maybe would be considered a bug. It doesn't seem right to me. To get around it, you could use victory_when_enemies_defeated=no, and fire the victory event manually from within the enemy leader's last_breath or die event. That way, the game would never check the victory conditions.

Actually....I already did that.
Victory event is fired only if both objectives are met.
Here's the full code:

Code: Select all

 # All hydras are dead
[event]
    name=die
    first_time_only=no
    [filter]
      side=4
    [/filter]
        [if]
      	[have_unit]
        		side=4
      	[/have_unit]
      	[then]
      	[/then]
      	[else]
        		[message]
           		 	speaker=Allistair
            		message=_"Excellent! All hydras are dead. They will trouble us no more!"
       		 [/message]

 			[if]
      			[have_unit]
        				id=Zhyllis
      			[/have_unit]
      			[then]
      			[/then]
      			[else]
      [endlevel]
         result=victory
         linger_mode=no
         save=yes
         {NEW_GOLD_CARRYOVER 100}
         carryover_report=no
         bonus=no
      [/endlevel]

      			[/else]
       		[/if]

      	[/else]
       [/if]
  [/event]



#Saurian leader killed
  [event]
      name=die
 	[filter]
   		id=Zhyllis
 	[/filter]
  	[message]
  		speaker=Zhyllis
  		message=_"..Hsssshhhfffsss haaaaassss!"
  	[/message]
  	[message]
  		speaker=Allistair
  		message=_"..And that does it for the saurian force. They are routing."
  	[/message]

 	[if]
      [have_unit]
        side=4
      [/have_unit]
      [then]
      [/then]
      [else]
      [endlevel]
         result=victory
         linger_mode=no
         save=yes
         {NEW_GOLD_CARRYOVER 100}
         carryover_report=no
         bonus=no
      [/endlevel]
      [/else]
    [/if]

  [/event]




     [event]
		name=victory
  	[message]
  		speaker=Allistair
  		message=_"Both the saurians and the hydras have been taken care of. Now we can rest easy for a while."
  	[/message]
  	[message]
  		speaker=Ellderon
  		message=_"So you will help us now?"
  	[/message]
  	[message]
  		speaker=Allistair
  		message=_"I gave my word, have I not? Of course we will. Come, let's head back to the city. Let's see if your mage has some news."
  	[/message]
	
	{MOVE_UNIT id=Allistair 45 41}	


  	[message]
  		speaker=Ellderon
  		message=_"Well, I guess you are done spying?"
  	[/message]
  	[message]
  		speaker=Aquae
  		message=_"I've been observing their healers and their warriors. The magic they use is different from other magics I've seen."
  	[/message]
  	[message]
  		speaker=Ellderon
  		message=_"How exactly?"
  	[/message]
  	[message]
  		speaker=Aquae
  		message=_"... Well, human mages use magic staffs as a focusing point for magical energy, while elves use their own bodies. Their magic is also more verbal compared to fairy magic. The vaynar healers seem to use something in between."
  	[/message]
  	[message]
  		speaker=Aquae
  		message=_"It's not just that....I find it difficult to explain it to you...it...it feels similar to fairy magic, but still different. I can even feel it on their warriors."
  	[/message]
  	[message]
  		speaker=Ellderon
  		message=_"Come again?"
  	[/message]
  	[message]
  		speaker=Aquae
  		message=_"Allistair and Elhan. It is faint and disperesed around them. A magical aura. I have no better words for discribing it I'm afraid."
  	[/message]
  	[message]
  		speaker=Ellderon
  		message=_"Amazing... Have you talked to Valinor about it?"
  	[/message]
  	[message]
  		speaker=Aquae
  		message=_"Not yet. He is busy looking for a way home and I don't want to bother him. I really should be helping him any way I can instead of wasting my time spying on people."
  	[/message]
  	[message]
  		speaker=Ellderon
  		message=_"So you are curious. Nothing wrong with that. If you want to help Valinor go ahead and do that. I'm sure he'll appreciate help from someone as gifted as you."
  	[/message]
  	[message]
  		speaker=Aquae
  		message=_"...   Thank you. I will do that. We better go, Allistair is way ahead of us by now."
  	[/message]
	
     [/event]
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Various questions and answers thread

Post by TrashMan »

GgggAAAAh..... :annoyed:
Friggin scenario 26

I have tried several variations of the code, but the switch simply refuses to work
And before you ask VARIABLE and VARIABLE_OP macros work flawlessly in other scenarios

Code: Select all

#set in pre-start:
	{VARIABLE dam_destroyed 0}	  



#powder found
	[event]
		name=moveto

		[filter]
			side=1
			x=7
			y=10
		[/filter]


			[message]
  				speaker=unit
  				message="I think this is it... Yes, I got the powder."
  			[/message]
			
			[modify_unit]
				[filter]
					x,y=7,10
				[/filter]

				role=sapper
				overlays=misc/bomb-icon.png
			[/modify_unit]

	{MODIFY_UNIT (x,y=7,10) (overlays) (misc/bomb-icon.png)}			
	[/event]


#unit reached the damm
	[event]
		name=moveto

		[filter]
			side=1
			x=13,14
			y=5,4
            role=sapper			
		[/filter]


			[message]
  				speaker=unit
  				message="We reached the damm. Setting the powder now."
  			[/message]
			
					{VARIABLE_OP dam_destroyed add 1}			
	
	[/event]




	
#Event that starts the flood. Flood entire valley in 3-4 turns.
[event]
	name=side 1 turn
	fist_time_only=no

	 [switch]
    		variable=dam_destroyed

    		[case]
       		value=1
    			[message]
        			speaker=Ithilien
        			message= _ "Move away! Get to high ground!"
    			[/message]

			[sound]
				name=explosion.ogg
			[/sound]				
                	[terrain]
                    		x=15,14,15,16,14,15,16,17,16,15,17,18,18,16,17
                    		y=5,5,6,5,6,7,6,6,7,8,7,6,7,4,5
                    		terrain=Wo
                	[/terrain]
					[redraw]
					[/redraw]						
					{VARIABLE_OP dam_destroyed add 1}
			
				{KILL_DEEP_WATER}
				[message]
					speaker=MalRhazGul
					message="What is happening?"
				[/message]						
				
    		[/case]

    		[case]
       		value=2

                	[terrain]
                    		x=17-32
                    		y=4-9
                    		terrain=Wo
                	[/terrain]
                	[terrain]
                    		x=23-32
                    		y=0-4
                    		terrain=Wo
                	[/terrain]
                	[terrain]
                    		x=22,21,20,19,18,20,22,22
                    		y=1,2,2,3,3,3,3,2
                    		terrain=Wo
                	[/terrain]
					[redraw]
					[/redraw]						
					{VARIABLE_OP dam_destroyed add 1}
							{KILL_DEEP_WATER}
				[message]
					speaker=MalRhazGul
					message="The dam!? Oh... sneaky lillte insects aren't you?"
				[/message]									
							
    		[/case]
			
    		[case]
				value=3

                	[terrain]
                    		x=9,10,11,12,9,10,11,12,13,14,11,12,13,14
                    		y=1,1,2,2,0,0,1,1,2,2,0,0,1,1
                    		terrain=Wo
                	[/terrain]
					[redraw]
					[/redraw]					
					
    			[message]
        			speaker=Ithilien
        			message= _ "It's working! Prepare to pull out!"
    			[/message]
				[message]
					speaker=MalRhazGul
					message="This won't stop me! You are merely delaying the inevitable..."
				[/message]						
				
			{PLACE_IMAGE items/gohere.png 1 23}
    		[scroll_to]
				x,y=1,23
    		[/scroll_to]	  
	  
					{VARIABLE_OP dam_destroyed add 1}
							{KILL_DEEP_WATER}
    		[/case]
		
		[else]
    			[message]
        			speaker=Ithilien
        			message= _ "TEST MESSAGE"
    			[/message]		
    	[/else]
 	[/switch]
[/event]
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Various questions and answers thread

Post by beetlenaut »

I don't see the problem off hand, but it's not always that easy. So, are you using the game state inspector? You can check the running game to make sure the variables do actually equal what you think they should, and that the role is getting set properly. If you are using the inspector, tell us what it says. If you aren't using it, do it.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Various questions and answers thread

Post by TrashMan »

The overlay is not applied, but the "reach the dam" event does trigger.
Since one of the conditions is the role, I can only assume it is assigned correctly.
I say assume because I didn't use the Inspector. Will try with it.
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Various questions and answers thread

Post by TrashMan »

Stupid question - how do I use the inspector?

I used the command line to check the variable and it seems stuck at 1.
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
Ravana
Forum Moderator
Posts: 3004
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Various questions and answers thread

Post by Ravana »

I use :alias i=inspectalias d=debug once to access them faster later.

This would suggest you have problem with variable not inspector.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Various questions and answers thread

Post by beetlenaut »

If you are using :debug :show_var, that's what I was talking about anyway. The inspector does the same thing. It's :debug :inspect. The only difference is that it lets you see all variables and units.

So, now you know something. Are you saying that the unit reaches the dam, gives his message, and at that point the dam_destroyed variable changes to 1, and then nothing else happens? You don't get any message from the [switch] statement, including the test message from the [else] part, and the variable never goes up?

Edit: I had some time, so I made a scenario with this code, and found out that the switch does fire once, giving the test message! You said it refused to fire, which is a very different thing! It fires one time, but then not again. That indicated a problem with first_time_only=no, so I looked at that carefully. It's spelled wrong. That's your problem. If you had been more clear, I could have told you a long time ago.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Various questions and answers thread

Post by TrashMan »

Wut the... how come there was no debug message about an unknown/illegal command/argument? :hmm:

Bloody typos.
Progress is being made.
Now I can (hopefully) finally fix that mission.
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Various questions and answers thread

Post by TrashMan »

Works now! YES:

Finally fixed the scenario!


Also, this still bugs me:

Code: Select all

 [+units]
 
   [race]
        id=human   
{TRAIT_BRAWLER}
    [/race]         

   
   [race]
        id=elf      
        {TRAIT_EAGLEEYE}
      {TRAIT_AGILE}
    [/race]
   
[/units]
doesn't work if there is a race condition.
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
Ravana
Forum Moderator
Posts: 3004
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Various questions and answers thread

Post by Ravana »

I believe you can not append to subtag there. You might need to replace entire block, but doing that means its better to just define your own race.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Various questions and answers thread

Post by TrashMan »

But it's supposed to work on stock units too.
Making a copy of every core unit is not a solution.
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
Ravana
Forum Moderator
Posts: 3004
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Various questions and answers thread

Post by Ravana »

Naive solution would be scenario-based way, recalculating all traits on unit creation.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Various questions and answers thread

Post by TrashMan »

OK...new scenario, new problems.

And this one is .. scenario 27..wow.. epic.

Sides are switched. Enemy gets to recruit and recall MY units. Side ID is OK.

To top it off, the Instructor Training code does not seem to work either. It's maddening....
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
Post Reply