Victory when killing specific leaders

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
revansurik
Posts: 604
Joined: October 17th, 2012, 11:40 pm
Location: Brazil
Contact:

Victory when killing specific leaders

Post by revansurik »

Hi folks! See if this is possible: in a scenario of my campaign, the player must defeat 2 specific leaders (out of 5) to win the scenario. Problem is, I'm not figuring out a way of making their deaths result in victory; I have used victor_when_enemies_defeated=no and the code below, but none works. Is there a way to make those 2 leaders' deaths the victory condition?

This is the code I tried; sides 3 and 4 are those of the leaders that must be killed; afterwards there is only some dialog and the endlevel=victory tag:

Code: Select all

	
    [event]
	   name=enemies defeated
	   [filter]
	    side=3,4
      [/filter]
Author of the Dragon Trilogy.

If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy
;-)
User avatar
Captain_Wrathbow
Posts: 1664
Joined: June 30th, 2009, 2:03 pm
Location: Guardia

Re: Victory when killing specific leaders

Post by Captain_Wrathbow »

Create two events, one for the death of each leader. In each event, check to see if the other leader is still living; if not, go to the victory event.
User avatar
revansurik
Posts: 604
Joined: October 17th, 2012, 11:40 pm
Location: Brazil
Contact:

Re: Victory when killing specific leaders

Post by revansurik »

I hadn't thought of that... It worked, thanks very much!

Erm, just another little doubt I've just found, how does the store_unit_type tag works? I tried to use it to store all dwarf units on the recall list, but a message popped up saying 'invalid WML found: store_unit_type missing required type = attribute'

the code I used...

Code: Select all

            [store_unit_type]
                [filter]
                    side=1
                    x,y=recall,recall
                    type=Dwarvish Fighter,Dwarvish Steelclad,Dwarvish Lord,Dwarvish Scout,Dwarvish Pathfinder,Dwarvish Explorer
                [/filter]

                kill=yes
                variable=dwarf_workers
            [/store_unit_type]
			
Author of the Dragon Trilogy.

If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy
;-)
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Victory when killing specific leaders

Post by Ceres »

[store_unit_type] only takes type= as an argument, no [filter]. If you want to use a filter like that, just use[store_unit].
User avatar
revansurik
Posts: 604
Joined: October 17th, 2012, 11:40 pm
Location: Brazil
Contact:

Re: Victory when killing specific leaders

Post by revansurik »

Changed the code as below, still not working... I also tried without the 'side' and 'x,y', to no avail...

Code: Select all

           [store_unit_type]
			    side=1
				x,y=recall,recall
                type=Dwarvish Fighter,Dwarvish Steelclad,Dwarvish Lord,Dwarvish Scout,Dwarvish Pathfinder,Dwarvish Explorer
                variable=dwarf_workers
            [/store_unit_type]
Maybe I'll just disallow the recruiting of dwarves, the way I want to make it is getting too complicated... later in the scenario, I'd put (or try to) the stored dwarves back to the recall list, and I don't know whether the code I used will work

This is the code, anyway...

Code: Select all

	   
{PUT_TO_RECALL_LIST (
    variable=dwarf_workers

)}		
Author of the Dragon Trilogy.

If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy
;-)
User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm
Location: The past

Re: Victory when killing specific leaders

Post by 8680 »

Use what you had before, but with [store_unit], not [store_unit_type].
User avatar
revansurik
Posts: 604
Joined: October 17th, 2012, 11:40 pm
Location: Brazil
Contact:

Re: Victory when killing specific leaders

Post by revansurik »

I used [store_unit], and the units disappeared from the recall list; but, when I unstored them (at x,y=recall,recall), only 1 unit was back, and originally there were many.

Did I forget anything in the code, or should I use a different one?

Code: Select all

		[unstore_unit]
           variable=dwarf_workers
           x=recall
           y=recall
        [/unstore_unit]	
Author of the Dragon Trilogy.

If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy
;-)
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Victory when killing specific leaders

Post by Pentarctagon »

If you store multiple units it creates an array of them, so you'll have to loop through and unstore all of them.
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
revansurik
Posts: 604
Joined: October 17th, 2012, 11:40 pm
Location: Brazil
Contact:

Re: Victory when killing specific leaders

Post by revansurik »

and how could I make this loop...? (sorry, my knowledge of coding is still a bit limited :oops: )
Author of the Dragon Trilogy.

If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy
;-)
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Victory when killing specific leaders

Post by Pentarctagon »

With the FOREACH macro:

Code: Select all

{FOREACH dwarf_workers i}
          [unstore_unit]
               variable=dwarf_workers[$i]
               x=recall
               y=recall
          [/unstore_unit]   
{NEXT i}
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
revansurik
Posts: 604
Joined: October 17th, 2012, 11:40 pm
Location: Brazil
Contact:

Re: Victory when killing specific leaders

Post by revansurik »

Yessss, it worked! Thanks a lot! :-D
Author of the Dragon Trilogy.

If you enjoyed A Song of Fire, War of the Jewel, Aria of the Dragon-Slayer and Soldier of Wesnoth, you may like my new project: Star of Chaos, a science-fiction mystery/adventure intended to be a trilogy
;-)
Post Reply