Teleport after battle on specific field

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.
Wussel
Posts: 624
Joined: July 28th, 2012, 5:58 am

Teleport after battle on specific field

Post by Wussel »

Hi I want to teleport the winner of 2 units fighting on a specific field to an other field. That can happen repeated times. Maybe the die=event does not support location filter? Please check my not working code. Right now one unit gets teleported, when ever a unit loses a fight anywhere on the map. Y is always 9 and X is starting at 1 but later goes up3,4,5 and so on. The go to location is matched the first time an than the new arrivals scatter around.

Code: Select all

[event]
    name=die
    first_time_only=no
	[filter]
           x=1
           y=8,9
	[/filter]
     {TELEPORT_TILE 1 (8,9) 1 6}
[/event]
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Teleport after battle on specific field

Post by Ravana »

Code: Select all

[event]
    name=die
    first_time_only=no
	[filter]
           x=1
           y=8-9
	[/filter]
     {TELEPORT_TILE 1 (8-9) 1 6}
[/event]
Try that way.
Wussel
Posts: 624
Joined: July 28th, 2012, 5:58 am

Re: Teleport after battle on specific field

Post by Wussel »

That helped a lot. However the $x2 trick was needed to teleport the winning unit.

Code: Select all

   [event]
        name=die
        first_time_only=no
       [filter]
               x=3
               y=8-9
       [/filter]
         {TELEPORT_TILE $x2 $y2 3 6}
    [/event]

One more thing: the teleported unit does not get XP regardless of winning the fight. How to fix this?
I would like to add some HP to the teleported unit too. I want to change the side of the teleported unit. All my filtering attempts inside the die event are not working right now.

Code: Select all

	[set_variable]	
		second_unit.side=1
		second_unit.hitpoints=+4
		second_unit.experience=+4
	[/set_variable]
 
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Teleport after battle on specific field

Post by Ravana »

Code: Select all

{VARIABLE second_unit.side 1}
{VARIABLE_OP second_unit.hitpoints add 4}
{VARIABLE_OP second_unit.experience add 4}
[unstore_unit]
variable=second_unit
x,y=3,6
[/unstore_unit]
That goes instead of {TELEPORT_TILE} , you can add heal and status refresh if you want, currently it just increases max hp and leaves current hitpoints as they were before.
You also need to kill that second unit before this code happens, else there will be 2 of them with same id.

Changed from max_hitpoints to hitpoints
Last edited by Ravana on July 19th, 2013, 5:58 pm, edited 1 time in total.
Wussel
Posts: 624
Joined: July 28th, 2012, 5:58 am

Re: Teleport after battle on specific field

Post by Wussel »

I tried like this (see below). store unstore kill is confusing for me. I want to heal for 4 Hitpoints. I do not want to increase max_Hitpoints. I actually want to give right amount of experience for primary_unit. (4,8,16,24,32). None of the 3 things is happening.

Code: Select all

    [event]
        name=die
        first_time_only=no
       [filter]
               x=1
               y=8-9
       [/filter]
			{VARIABLE second_unit.side 1}
			{VARIABLE_OP second_unit.hitpoints add 4}
			{VARIABLE_OP second_unit.experience add 4}
         {TELEPORT_TILE $x2 $y2 1 6}
    [/event]
I tried inbetween a moveto event on the target field (see below). It did not work either.

Code: Select all

[event]	
	name=moveto
	 first_time_only=no
	[filter]
		x=1
		y=6 
	[/filter]
	[modify_unit]
		side=1
	[/modify_unit]	
[/event]	

User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Teleport after battle on specific field

Post by Ravana »

Without [unstore_unit] every {VARIABLE} and {VARIABLE_OP} in code i posted is worthless, it changes unit variables but [unstore_unit] is what makes these changes in game as well. [modifiy_unit] seems to have wrong syntax, it needs both filter and what to change, but not sure, i avoid that tag. Have you read http://wiki.wesnoth.org/ReferenceWML ?
As kill i meant [kill]x,y=1,8-9[/kill]
For correct amount of xp you can use [switch] with variable=unit.level
Wussel
Posts: 624
Joined: July 28th, 2012, 5:58 am

Re: Teleport after battle on specific field

Post by Wussel »

It works like a charm. I am getting this unstore thingy slowly. Still not use to kill. So everything is working fine.
I never used switch successfully. Is this really needed? Why doesn't the second unit get XP as usual?

I read reference-wml manytimes, but hard to understand without proper examples.

Code: Select all

 [event]
        name=die
        first_time_only=no
       [filter]
               x=1
               y=8-9
       [/filter]
			{VARIABLE second_unit.side 2}
			{VARIABLE_OP second_unit.hitpoints add 4}
			{VARIABLE_OP second_unit.experience add 4}
			[unstore_unit]
				variable=second_unit
			[/unstore_unit]
         {TELEPORT_TILE $x2 $y2 1 6}
    [/event]

User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Teleport after battle on specific field

Post by Ravana »

When you have [unstore_unit] with x and y then unit is created there, so no need for extra teleport.

Code: Select all

[unstore_unit]
variable=second_unit
x,y=1,6
[/unstore_unit]
You can do without [switch] but then you would need to use more [if] to get correct amount. That is IF unit doesnt get xp normally, as i assumed here.

I understand that lack of examples, when i started with wml i had same problem.

Just put that [kill] from my last post somewhere before [unstore_unit] , exact place isnt very important here.
Wussel
Posts: 624
Joined: July 28th, 2012, 5:58 am

Re: Teleport after battle on specific field

Post by Wussel »

The die event is really working very well the way I posted it last. What is wrong with using the teleport?

The issue about the granted XP is postphoned.

I went all crazy and did a last breath event. The event was working perfectly. Than I wanted to make a macro out of it and I screwed up badly. Basically now the original event says missing closing tack, but I cannot find.

The last breath events gives 3 options what will happen to the loser by players choice. 2 different looser teleport option and one proceed to the known die event.

Code: Select all

[event]
        name=last_breath
        first_time_only=no
       [filter]
               x=1
               y=8-9
       [/filter]
	   
	   [message]
			speaker=Julius
			message= _ "What shall I do?"
        [option]
            message= _ "Feed the lions!"
            [command]
                [message]
                    speaker=Julius
                    message= _ "bla."
                [/message]
                [message]
                    speaker=unit
                    message= _ "bla."
                [/message]
					{VARIABLE unit.side 3}
					{VARIABLE unit.hitpoints 1}
				[unstore_unit]
					variable=unit
				[/unstore_unit]
				{TELEPORT_TILE $x1 $y1 5 2}
					{VARIABLE second_unit.side 2}
					{VARIABLE_OP second_unit.hitpoints add 0}
					{VARIABLE_OP second_unit.experience add 0}
				[unstore_unit]
					variable=second_unit
				[/unstore_unit]
				{TELEPORT_TILE $x2 $y2 1 6}
			[/command]
        [/option]
		[option]
            message= _ "Thumb up"
            [command]
				[message]
                    speaker=Julius
                    message= _ "bla."
                [/message]
				[message]
                    speaker=unit
                    message= _ "bla."
                [/message]
					{VARIABLE unit.side 1}
					{VARIABLE unit.hitpoints add 8}
				[unstore_unit]
					variable=unit
				[/unstore_unit]
				{TELEPORT_TILE $x1 $y1 5 2}
					{VARIABLE second_unit.side 2}
					{VARIABLE_OP second_unit.hitpoints add 4}
					{VARIABLE_OP second_unit.experience add 0}
				[unstore_unit]
					variable=second_unit
				[/unstore_unit]
				{TELEPORT_TILE $x2 $y2 1 6}
			[/command]
        [/option]
        [option]
            message= _ "Thumb down!"
            [command]
                [message]
                    speaker=Julius
                    message= _ "bla."
                [/message]
                [message]
                    speaker=second_unit
                    message= _ "bla."
                [/message]
           [/command]
        [/option]
    [/message]
  [/event]
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Teleport after battle on specific field

Post by Ravana »

You used {VARIABLE} when you should have used {VARIABLE_OP}
1. sets value, 2. changes value.
Mistake is in line 50.

Code: Select all

[event]
    name=last_breath
    first_time_only=no
    [filter]
        x=1
        y=8-9
    [/filter]

    [message]
        speaker=Julius
        message= _ "What shall I do?"
        [option]
            message= _ "Feed the lions!"
            [command]
                [message]
                    speaker=Julius
                    message= _ "bla."
                [/message]
                [message]
                    speaker=unit
                    message= _ "bla."
                [/message]
                {VARIABLE unit.side 3}
                {VARIABLE unit.hitpoints 1}
                [unstore_unit]
                    variable=unit
                [/unstore_unit]
                {TELEPORT_TILE $x1 $y1 5 2}
                {VARIABLE second_unit.side 2}
                {VARIABLE_OP second_unit.hitpoints add 0}
                {VARIABLE_OP second_unit.experience add 0}
                [unstore_unit]
                    variable=second_unit
                [/unstore_unit]
                {TELEPORT_TILE $x2 $y2 1 6}
            [/command]
        [/option]
        [option]
            message= _ "Thumb up"
            [command]
                [message]
                    speaker=Julius
                    message= _ "bla."
                [/message]
                [message]
                    speaker=unit
                    message= _ "bla."
                [/message]
                {VARIABLE unit.side 1}
                {VARIABLE_OP unit.hitpoints add 8}
                [unstore_unit]
                    variable=unit
                [/unstore_unit]
                {TELEPORT_TILE $x1 $y1 5 2}
                {VARIABLE second_unit.side 2}
                {VARIABLE_OP second_unit.hitpoints add 4}
                {VARIABLE_OP second_unit.experience add 0}
                [unstore_unit]
                    variable=second_unit
                [/unstore_unit]
                {TELEPORT_TILE $x2 $y2 1 6}
            [/command]
        [/option]
        [option]
            message= _ "Thumb down!"
            [command]
                [message]
                    speaker=Julius
                    message= _ "bla."
                [/message]
                [message]
                    speaker=second_unit
                    message= _ "bla."
                [/message]
            [/command]
        [/option]
    [/message]
[/event]
Fixed and used wmlindent on it as well.
Wussel
Posts: 624
Joined: July 28th, 2012, 5:58 am

Re: Teleport after battle on specific field

Post by Wussel »

Thank you so much! That is exactly what I did! Changed to setting a fixed value and than changed back while screwing up.

I like this wmlindent. My indenting by hand is somewhat tedious. Is there an easy way to use this program? I once tried to figure it out but never managed.
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Teleport after battle on specific field

Post by Max »

you could try the UMC Editor, it supports running those tools. last time i checked they worked (on windows):
http://forums.wesnoth.org/viewtopic.php?f=21&t=30880
http://eclipse.wesnoth.org/

if it didn't work for you've probably forgot to quote paths that contain spaces.
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Teleport after battle on specific field

Post by Ravana »

I use windows, not sure how you use these with other systems.
I use wmlindent (and wmllint as well) with .bat files consisting of

Code: Select all

"C:\python27\python.exe" "C:\Documents and Settings\kasutaja\Desktop\synced\Dropbox\wesnoth1.10.3\data\tools\wmlindent" "C:\Documents and Settings\kasutaja\Desktop\wml"
pause
1. Full path to python
2. Full path to tool
3. Full path to file/folder you want tool to change. I created folder for that.
Pause can be replaced with output file instead but usually there is no need for that IMO.
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Teleport after battle on specific field

Post by Elvish_Hunter »

Wussel wrote:I like this wmlindent. My indenting by hand is somewhat tedious. Is there an easy way to use this program? I once tried to figure it out but never managed.
Ravana already did a good job of explaining it :) . I just want to add a detail: be careful to use Python 2.7.X, because our Python maintenance tools don't work with Python3.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
User avatar
A Guy
Posts: 793
Joined: May 24th, 2008, 1:55 am

Re: Teleport after battle on specific field

Post by A Guy »

Ravana wrote:I use windows, not sure how you use these with other systems.
I use wmlindent (and wmllint as well) with .bat files consisting of

Code: Select all

"C:\python27\python.exe" "C:\Documents and Settings\kasutaja\Desktop\synced\Dropbox\wesnoth1.10.3\data\tools\wmlindent" "C:\Documents and Settings\kasutaja\Desktop\wml"
pause
1. Full path to python
2. Full path to tool
3. Full path to file/folder you want tool to change. I created folder for that.
Pause can be replaced with output file instead but usually there is no need for that IMO.
My god, this just made my day. Thank you so much for this, I owe you.
I'm just... a guy...
I'm back for now, I might get started on some work again.
Post Reply