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 »

Ceres wrote:No.
You want an attacker hits event.
So like this:

Code: Select all

[event]
       name=attacker hits
        first_time_only=no
        [filter]
            id=Sir_Miles
        [/filter]
        [set_variable]
            name=Mlance
            add=-2
        [/set_variable]
    [/event]
Ceres wrote:You have to modify the unit itself every time it hits, not only the variable.
Err... where would you put the

Code: Select all

 increase_damage=$Mlance
then :?:
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

Move the whole [object] to the event (without the [modifications]).
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]
        [set_variable]
            name=Mlance
            add=-2
        [/set_variable]
                [object]
                    [effect]
                        apply_to=attack
                        type=pierce
                        increase_damage=$Mlance
                    [/effect]
                [/object]
    [/event]
Like this?
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

Basically you don't need a variable at all (unless you want to change the amount the attack value decreases).

Code: Select all

    [event]
           name=attacker hits
            first_time_only=no
            [filter]
                id=Sir_Miles
            [/filter]
                    [object]
                        [effect]
                            apply_to=attack
                            type=pierce
                            increase_damage=-2
                        [/effect]
                    [/object]
        [/event]
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

O.K. but I was thinking that the player could like go back to his tent and get another lance ie. that the attack damage goes back to its original level when you go back to your starting position.
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

Then remove this attack and give him a new one (see EffectWML).
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

Some thing like this?

Code: Select all

[event]
       name=attacker hits
        first_time_only=no
        [filter]
            id=Sir_Miles
        [/filter]
 [object]
                    
                                [effect]
                                    apply_to=new_attack
                                    name=lance
                                    description=_"lance"
                                    type=pierce
                                    [specials]
                                        {WEAPON_SPECIAL_CHARGE}
                                    [/specials]
                                    range=melee
                                    damage=$Mlance
                                    number=2
                                [/effect]
                [/object]
        [set_variable]
            name=Mlance
            add=-2
        [/set_variable]
    [/event]
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

You mixed up both events.
This
Ceres wrote:

Code: Select all

    [event]
           name=attacker hits
            first_time_only=no
            [filter]
                id=Sir_Miles
            [/filter]
                    [object]
                        [effect]
                            apply_to=attack
                            type=pierce
                            increase_damage=-2
                        [/effect]
                    [/object]
        [/event]
for the attack decreasing.

For the restoring,
this.

Code: Select all

[event]
   name=start
   ...
   [store_unit]
      [filter]
         id=Sir_Miles
      [/filter]
      variable=stored_sir_miles
      kill=no
      mode=replace
   [/store_unit]
[/event]
[event]
   name=moveto
   first_time_only=no
   [filter]
      id=Sir_Miles
      x,y= (coordinates of your keep)
   [/filter]
   [object]
      [effect]
         apply_to=remove_attacks
         type=pierce
      [/effect]
      [effect]
         apply_to=new_attack
         [attack]
            ...
            damage=$stored_sir_miles.attack[1].damage
         [/attack]
      [/effect]
   [/object]
   [store_unit]
      [filter]
         id=Sir_Miles
      [/filter]
      variable=stored_sir_miles
      kill=no
      mode=replace
   [/store_unit]
[/event]
(caution: untested)
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

Umm, right I tested it and two things came up.

1) When you have a successful attack, a blank text box appears See picture, highlighted in red
Screenshot-7.jpg
2) When you go back to starting position, the lance attack goes loopy See picture, again highlighted in red
Screenshotb-8.jpg
Last edited by matsjoyce on July 15th, 2011, 2:23 pm, edited 1 time in total.
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

For the first one, add silent=yes to all [object]s.
The second... well, that doesn't look nice. No idea about what caused this.

Delete+Repost:
Ok, then try a workaround:
In the start event, put this after the [store_unit]:

Code: Select all

[set_variable]
	name=initial_damage
	value=$stored_sir_miles.attack[1].damage
[/set_variable]
And then replace the whole code in the moveto event (except the filter) with this:

Code: Select all

[store_unit]
	[filter]
		id=Sir_Miles
	[/filter]
	variable=stored_sir_miles
	mode=replace
[/store_unit]
[set_variable]
	name=stored_sir_miles.attack[1].damage
	value=$initial_damage
[/set_variable]
[unstore_unit]
	variable=stored_sir_miles
	find_vacant=no
[/unstore_unit]
(If there's the possibility that Sir Miles may level up, create a post advance event with exactly the same code as in the start event)
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

Right, I was mucking around a bit and I came up with some code I think I'll stick with. ^_^ I made some code in which the players lance will randomly snap when they are attacking and then I made an object that will replace the lance. I had one problem though. The lance attack attacks two times, so when the lance snaps on the first charge it attacks again and then seemingly snaps again. Is there any code that will stop the attack the first time it snaps and not let you attack again? :hmm:
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

Make an attacker hits event with the right conditions, and then store and unstore Sir Miles. That will stop the attack.
(fyi, [store_unit] , [unstore_unit])
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

Thanks, that works fine now. When the lance is snapped on the first attack, the second time he attacks with the sword :D .
User avatar
matsjoyce
Posts: 233
Joined: May 8th, 2011, 2:10 pm
Location: UK

Re: Campaign won't start

Post by matsjoyce »

Oh, and another question, would the AI know how to use this?
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: Campaign won't start

Post by Ceres »

Depends on what you mean by "know how to use". The ai doesn't know that there's the possibility the lance may break when attacking. It will use the lance as always. And if it breaks, ai will have to fight with the sword.
Post Reply