Campaign won't start

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.
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

would it go back to the starting position?
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

No, not really. But you can set an ai goal manually, so that the leader will try to move there: just look through all possible tags of AiWML.
(customizing ai was changed from 1.8 on, in this case see here, but for me the old syntax always worked as well, no idea about that)
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

Code: Select all

[event]
name=attacker hits
first_time_only=no
[filter]
id=Sir_Miles
[/filter]
[filter_attack]
name=lance
[/filter_attack]
[set_variable]
name=lance
rand="0..2"
[/set_variable]
[if]
[variable]
name=lance
greater_than=0
[/variable]
[then]
[object]
silent=yes
[effect]
apply_to=remove_attacks
type=pierce
[/effect]
[/object]
[message]
id=Sir_Miles
message=_"Aw, my lance has snapped."
[/message]
[store_unit] #to stop the unit attack
[filter]
id=Sir_Miles
[/filter]
variable=stored_sir_miles
kill=yes
[/store_unit]
[unstore_unit]
variable=stored_sir_miles
[/unstore_unit]
[fire_event]
name=lance_snapped
[/fire_event]
[/then]
[else]
[/else]
[/if]
[/event]
[event]
name=lance_snapped
[filter]
side=2
[/filter]
[ai]
[leader_goal]
x,y=2,18
[/leader_goal]
[/ai]
[/event]
[event]
name=moveto
first_time_only=no
[filter]
id=Sir_Miles
x,y=2,18
[/filter]
[ai]
grouping=offensive
attack_depth=5
[target]
id=Sir_Miles
value=10.0
[/target]
[/ai]
[/event]
???
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

To change [ai] you have to use [modify_side].
And I forgot, you need a [filter] in effect :doh:
Why are you trying to give a leader_goal when Sir_Miles' lance snaps?
(The following is based on my understanding of your intention, namely that you want your and your enemy's lance to randomly snap. If one unit's lance broke, it has to move to its keep to get a new one.)
Just make two different attacker_hits events (no custom ones), one for Sir Miles, one for side 2 leader, with accordingly slightly different filters (also remember the filters for message and effect). And then put the leader_goal modifying in the event for side 2.
Then make two moveto events, one for each side. In the side 2 one, remove the leader_goal (by setting it to nothing, x,y="").
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

Code: Select all

#textdomain wesnoth-j

#define INITIALIZE_SCENARIO_VARIABLES
 	{VARIABLE lancem 0}
 	{VARIABLE lanceb 0}
#enddef
#define CLEAR_SCENARIO_VARIABLES
	{CLEAR_VARIABLE lancem}
	{CLEAR_VARIABLE lanceb}
#enddef
[scenario]
     name= "Sir Boris"
    id="1_Sir_Boris"
    map_data="{~add-ons/jousting/Maps/jousting.map}"
    turns=10
    next_scenario=null
    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC "battle.ogg" "the_city_falls.ogg"}
    {EXTRA_SCENARIO_MUSIC "loyalists.ogg"}
    {EXTRA_SCENARIO_MUSIC "legends_of_the_north.ogg"}
{PLACE_IMAGE scenery/tent-fancy-red.png 3 1}
{PLACE_IMAGE scenery/tent-fancy-blue.png 2 18}
{J_BRAZIER 7 7}
{J_BRAZIER 7 12}
{OBJ_NEW_LANCE 3 1 Sir_Miles}
{OBJ_NEW_LANCE 2 18 Sir_Boris ([modify_side]
			  side=2
        [ai]
            grouping=offensive
            attack_depth=5
          [target]
                id=Sir_Miles
                value=10.0
          [/target]
        [/ai]
		      [/modify_side])}
    [story]
        [part]
            background=story/jousting1.jpg
            story=_"You are a knight going by the name of Sir Miles."
        [/part]
        [part]
            background=story/jousting1.jpg
            story=_"The king is watching you joust which is a great privilage."
        [/part]
    [/story]
    [side]
        type="Knight"
        id="Sir_Miles"
        canrecruit=yes
        name=_"Sir Miles"
        unrenamable=yes
        side=1
        controller=human
        {GOLD 0 0 0}
        income=0
        team_name="Sir_Miles"
        user_team_name=_"Sir_Miles"
        fog=no
        shroud=no
        recruit=""
		[modifications]
			{TRAIT_STRONG}
			{TRAIT_INTELLIGENT}
		      [object]
		      silent=yes
			[effect]
			  apply_to=attack
			  type=pierce
			  increase_damage=-50%
			[/effect]
		      [/object]
		      [object]
		      silent=yes
			[effect]
			  apply_to=attack
			  type=blade
			  increase_damage=-50%
			[/effect]
		      [/object]
		[/modifications]
    [/side]
    [side]
        type="Knight"
        id="Sir_Boris"
        name=_"Sir Boris"
        canrecruit=no
        unrenamable=yes
        side=2
        {GOLD 0 0 0}
        team_name="Sir_Boris"
        user_team_name=_"Sir_Boris"
        controller=ai
        fog=no
        shroud=no
        income=0
        recruit=""
		[modifications]
		      [object]
		      silent=yes
			[effect]
			  apply_to=attack
			  type=pierce
			  increase_damage=-50%
			[/effect]
		      [/object]
		      [object]
		      silent=yes
			[effect]
			  apply_to=attack
			  type=blade
			  increase_damage=-50%
			[/effect]
		      [/object]
		[/modifications]
        [ai]
            grouping=offensive
            attack_depth=5
          [target]
                id=Sir_Miles
                value=10.0
          [/target]
        [/ai]
   [/side]
   [side]
        type="Grand Marshal"
        id="King"
        name=_"The King"
        canrecruit=yes
        unrenamable=yes
        side=3
        {GOLD 0 0 0}
        team_name="Spectators"
        user_team_name=_"Spectators"
        controller=ai
        fog=no
        shroud=no
        income=0
        recruit=""
	[ai]
	    grouping=offensive
            attack_depth=5
        [/ai]
    [/side]
    [event]
        name=prestart
{INITIALIZE_SCENARIO_VARIABLES}
        [objectives]
            [objective]
                description=_"Make Sir Boris surrender by reducing his hitpoints to 0 or less"
                condition=win
            [/objective]
            [objective]
                description=_"Sir Miles is made to surender by reducing his hitpoints to 0 or less"
                condition=lose
            [/objective]
            [objective]
                description=_"Time runs out"
                condition=lose
            [/objective]
        [/objectives]
    [/event]
    [event]
        name=start
		[unit]
			type=Elvish Lady
			side=3
			id="Queen"
			name=_"The Queen"
			unrenamable=yes
			x=7
			y=9
		[/unit]
		[unit]
			type=Elvish Lady
			side=3
			id="Matilda"
			name=_"Princess Matilda"
			unrenamable=yes
			x=7
			y=10
		[/unit]
		[unit]
			type=Horseman
			side=3
			id="Chevalier"
			name=_"Chevalier d'honneur"
			unrenamable=yes
			x=5
			y=10
		[/unit]
		[unit]
			type=Royal Guard
			side=3
			id="Guard1"
			name=_"Royal Guard"
			unrenamable=yes
			x=7
			y=8
		[/unit]
		[unit]
			type=Royal Guard
			side=3
			id="Guard2"
			name=_"Royal Guard"
			unrenamable=yes
			x=7
			y=11
		[/unit]
        [message]
            id=King
            message=_"So, Sir Miles, you will joust for the hand of my daughter?"
        [/message]
        [message]
            id=Sir_Miles
            message=_"I will, sire"
        [/message]
        [message]
            id=King
            message=_"Well, here is the first challenger. This is Sir Boris."
        [/message]
        [message]
            id=Sir_Boris
            message=_"I am here at your command."
        [/message]
        [message]
            id=King
            message=_"Joust well, brave knights!"
        [/message]
        [message]
            id=Queen
            message=_"Good luck, Sir Miles"
        [/message]
        [message]
            id=Chevalier
            message=_"Ready, steady, joust!"
        [/message]
    [/event]
    [event]
        name=time over
        [message]
            id=Chevalier
            message=_"Halt!"
        [/message]
        [message]
            id=King
            message=_"Sorry Sirs, but you have run out of time."
        [/message]
    [/event]
 [event]
           name=attacker hits
            first_time_only=no
            [filter]
                id=Sir_Miles
            [/filter]
	    [filter_attack]
	      name=lancem
	    [/filter_attack]
		[set_variable]
		    name=lancem
		    rand="0..2"
		[/set_variable]
		[if]
		    [variable]
			name=lancem
			greater_than=0
		    [/variable]
		    [then]
		      [object]
		      silent=yes
			[effect]
			  apply_to=remove_attacks
			  type=pierce
			[/effect]
		      [/object]
		      [message]
			id=Sir_Miles
			message=_"Aw, my lance has snapped."
		      [/message]
   [store_unit] #to stop the unit attack
      [filter]
         id=Sir_Miles
      [/filter]
      variable=stored_sir_miles
      kill=yes
   [/store_unit]
[unstore_unit]
      variable=stored_sir_miles
[/unstore_unit]
		      [fire_event]
			name=lance_snapped
		      [/fire_event]
		    [/then]
		    [else]
		    [/else]
		[/if]
        [/event]
        [event]
	  name=lance_snapped # a separate event is needed so that you only get the below 
			     # message the first time so it doesn't get on your nerves
		[message]
			speaker=narrator
			image=wesnoth-icon.png
			message=_"To get another lance, you will have to go to your starting position"
		[/message]
        [/event]
 [event]
           name=attacker hits
            first_time_only=no
            [filter]
                id=Sir_Boris
            [/filter]
	    [filter_attack]
	      name=lanceb
	    [/filter_attack]
		[set_variable]
		    name=lanceb
		    rand="0..2"
		[/set_variable]
		[if]
		    [variable]
			name=lanceb
			greater_than=0
		    [/variable]
		    [then]
		      [object]
		      silent=yes
			[effect]
			  apply_to=remove_attacks
			  type=pierce
			[/effect]
		      [/object]
		      [message]
			id=Sir_Boris
			message=_"Aw, my lance has snapped."
		      [/message]
		      [store_unit] #to stop the unit attack
			  [filter]
			    id=Sir_Boris
			  [/filter]
			  variable=stored_sir_boris
			  kill=yes
		      [/store_unit]
		      [unstore_unit]
			  variable=stored_sir_boris
		      [/unstore_unit]
		      [modify_side]
			  side=2
			  [ai]
			      passive_leader=yes
			      [leader_goal]
				  x,y=2,18
			      [leader_goal]
			  [/ai]
		      [/modify_side]
		    [/then]
		    [else]
		    [/else]
		[/if]
        [/event]
    [event]
        name=last breath
        [filter]
            id=Sir_Miles
        [/filter]

        [message]
            id=Sir_Miles
            message=_"Ugh..."
        [/message]
        [message]
            id=Sir_Boris
            message=_"Do you yield!"
        [/message]
        [message]
            id=Sir_Miles
            message=_"I ... yield"
        [/message]
    [/event]
    [event]
        name=last breath
        [filter]
            id=Sir_Boris
        [/filter]
        [message]
            speaker=Sir_Miles
            message=_"Do you yield!"
        [/message]
        [message]
            id=Sir_Boris
            message=_"I yield!"
        [/message]
    [/event]
    [event]
        name=die
        [filter]
            id=Sir_Boris
        [/filter]
        [message]
            id=Sir_Miles
            message=_"I have beaten him!"
        [/message]
        [message]
            id=Queen
            message=_"Well done, Sir Miles"
        [/message]
        [message]
            id=King
            message=_"Now you may go on to the next challenger"
        [/message]
{CLEAR_SCENARIO_VARIABLES}
        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 100}
        [/endlevel]
    [/event]
[/scenario]
#undef INITIALIZE_SCENARIO_VARIABLES
#undef CLEAR_SCENARIO_VARIABLES
O.K. this is the scenario, but when I run it, it says "Missing closing tag for tag scenario" :?
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Campaign won't start

Post by zookeeper »

matsjoyce wrote:O.K. this is the scenario, but when I run it, it says "Missing closing tag for tag scenario" :?
That means you've made a syntax error somewhere. It's probably a missing closing or opening tag somewhere, the wrong number of arguments given to a macro or a missing opening or closing quote. You need to find those and fix them.
User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: Campaign won't start

Post by SkyOne »

Just a guess (sorry if it's wrong):

Code: Select all

{OBJ_NEW_LANCE 3 1 Sir_Miles}
{OBJ_NEW_LANCE 2 18 Sir_Boris ([modify_side]
           side=2
        [ai]
            grouping=offensive
            attack_depth=5
          [target]
                id=Sir_Miles
                value=10.0
          [/target]
        [/ai]
            [/modify_side])}
These two macros seem the same, but the number of arguments is different.
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

Yes, its got that to work for the ai as well as the human player. If you want to see it, here is the macro:

Code: Select all

#define OBJ_NEW_LANCE X Y ID AI_MOD
       [item]
        x={X}
        y={Y}
        image=scenery/lance2.png
	[/item]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x={X}
            y={Y}
            id={ID}
        [/filter]
        [object]
	silent=yes
            [filter]
                x={X}
                y={Y}
            [/filter]
      [effect]
	  apply_to=new_attack
	  name=lance
	  description=_"lance"
	  type=pierce
	  [specials]
            {WEAPON_SPECIAL_CHARGE}
	  [/specials]
	  range=melee
	  damage=7
	  number=2
      [/effect]
      [/object]
      {AI_MOD}
      [message]
	id={ID}
	message=_"I have a new lance, now lets knock this man off his horse"
      [/message]
    [/event]
#enddef
User avatar
Crendgrim
Moderator Emeritus
Posts: 1328
Joined: October 15th, 2010, 10:39 am
Location: Germany

Re: Campaign won't start

Post by Crendgrim »

If you have a macro with a certain amount of parameters, you always have to include exactly this amount of parameters in the macro call. You may just set AI_MOD to something irrelevant, but you must give a value for that parameter.


Crend
UMC Story Images — Story images for your campaign!
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

Just put () as AI_MOD. That counts as argument value, but does nothing.
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

O.K. done that. It starts but the lance doesn't snap. I attacked for nine turns with most of them hits and the lance didn't snap.
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

Code: Select all

[filter_attack]
         name=lancem
[/filter_attack]
He has no 'lancem' attack.
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

Opps, I must have done that when I was turning the lance var to lancem...
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

Right, both lances snap now, but the ai doesn't go back for a new one.
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

passive_leader=yes is not good when you want the enemy leader to move.
Post Reply