Ephraim's WML questions

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
Ephraim
Posts: 47
Joined: July 3rd, 2017, 2:03 pm
Location: The Great Library of WML, Studiying it

Ephraim's WML questions

Post by Ephraim » October 15th, 2017, 9:46 pm

Hello!

I was working on a map with some magic tiles that teleport you to a nother place (just a moveto with teleport unit and a lightning sound). But, I was thinking so hard and I realized that if I add an animation to this magic event, it will be better.

The idea is: when a unit enters in the hex, an animation of a lightbeam and an animation of the light star (the one that appears when you teleport a silver mage) will appear at the same time. When the animation finishes, there will sound a lightning and the unit will be teleported.

How can I code the animations?

Thanks.
The Great Library of WML is huge and extense. I must find the book who will lead me to create a perfect campaign.
Future Project: History of Vindalf

User avatar
Dugi
Posts: 4846
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Ephraim's WML questions

Post by Dugi » October 16th, 2017, 1:26 pm

The teleport animation uses a mask and does not need to depend on the unit's sprite, so it's quite doable.

You can use an object (possibly a temporary one) to add the teleport animation to the unit. Then you active the pre-teleport animation with animate_unit, use the teleport action tag to move it to the other location and then use the post-teleport animation to make it land there. You can add the lightbeam to the teleport animation as well.

User avatar
Ephraim
Posts: 47
Joined: July 3rd, 2017, 2:03 pm
Location: The Great Library of WML, Studiying it

Re: Ephraim's WML questions

Post by Ephraim » October 21st, 2017, 2:10 pm

I have been working on that, and I've got this:

Code: Select all

[event]
name=start
[object]
    [filter]
	    canrecruit=no
	[/filter]
	{TELEPORT_EFFECT_OBJECT}
[/object]
[/event]


[event]


name=moveto
first_time_only=no
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
[sound]
name=lightning.ogg
[/sound]
[animate_unit]
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
flag=pre_teleport
[animate]
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
{MISSILE_FRAME_LIGHT_BEAM}
[/animate]
[/animate_unit]
{TELEPORT_TILE 49 51 38 56}
[scroll_to]
x=38
y=56
[/scroll_to]
[animate_unit]
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
flag=post_teleport
[/animate_unit]
[/event]
But it doesn't work. What can I do?
The Great Library of WML is huge and extense. I must find the book who will lead me to create a perfect campaign.
Future Project: History of Vindalf

User avatar
James_The_Invisible
Posts: 464
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces

Re: Ephraim's WML questions

Post by James_The_Invisible » October 21st, 2017, 3:01 pm

[object] is applied only to first unit that matches the filter, no all those units. If you want to apply it to more units, you should store them to a variable and loop over it ({FOREACH ...} ... {NEXT ...}).

User avatar
Ephraim
Posts: 47
Joined: July 3rd, 2017, 2:03 pm
Location: The Great Library of WML, Studiying it

Re: Ephraim's WML questions

Post by Ephraim » October 21st, 2017, 4:14 pm

James_The_Invisible wrote:[object] is applied only to first unit that matches the filter, no all those units. If you want to apply it to more units, you should store them to a variable and loop over it ({FOREACH ...} ... {NEXT ...}).
I have changed the code for work in just one unit, but it still doesn't work:

Code: Select all

[event]
name=start
[object]
    [filter]
      [filter_location]
             x,y=4, 2
      [/filter_location]
   [/filter]
   {TELEPORT_EFFECT_OBJECT}
[/object]
[/event]


[event]


name=moveto
first_time_only=no
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
[sound]
name=lightning.ogg
[/sound]
[animate_unit]
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
flag=pre_teleport
[animate]
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
{MISSILE_FRAME_LIGHT_BEAM}
[/animate]
[/animate_unit]
{TELEPORT_TILE 49 51 38 56}
[scroll_to]
x=38
y=56
[/scroll_to]
[animate_unit]
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
flag=post_teleport
[/animate_unit]
[/event]
The location is the starting location of the unit, because it is the leader of the side but he can't recruit.
The Great Library of WML is huge and extense. I must find the book who will lead me to create a perfect campaign.
Future Project: History of Vindalf

enclave
Posts: 851
Joined: December 15th, 2007, 8:52 am

Re: Ephraim's WML questions

Post by enclave » October 21st, 2017, 4:23 pm

try
[filter]
x,y=4,2
[/filter]
without location.. and dont make spaces before numbers.. not sure if it matters, but it may..
I'm not expert about objects :) so no idea if it can help.

User avatar
James_The_Invisible
Posts: 464
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces

Re: Ephraim's WML questions

Post by James_The_Invisible » October 21st, 2017, 4:26 pm

Have you actually seen the definition of macro TELEPORT_EFFECT_OBJECT? It is:

Code: Select all

#define TELEPORT_EFFECT_OBJECT
    # Creates and assigns a temporary object which applies the generalized silver mage
    # teleport animations to the primary unit
    #
    # For example, to apply teleport animations to the unit that triggered a 'move_to' event:
    #!{TELEPORT_EFFECT_OBJECT}

    [object]
        silent=yes
        duration=turn

        [effect]
            apply_to=new_animation

            [animation]
                apply_to=pre_teleport
                {TELEPORT_OUT_ANIMATION}
            [/animation]

            [animation]
                apply_to=post_teleport
                {TELEPORT_IN_ANIMATION}
            [/animation]
        [/effect]
    [/object]
#enddef
. That inserts [object] which is added to primary unit in an event. So it might be a good idea to remove the additional [object] tag and use the macro in your moveto event.

User avatar
Ephraim
Posts: 47
Joined: July 3rd, 2017, 2:03 pm
Location: The Great Library of WML, Studiying it

Re: Ephraim's WML questions

Post by Ephraim » October 21st, 2017, 4:48 pm

James_The_Invisible wrote:Have you actually seen the definition of macro TELEPORT_EFFECT_OBJECT? It is:

Code: Select all

#define TELEPORT_EFFECT_OBJECT
    # Creates and assigns a temporary object which applies the generalized silver mage
    # teleport animations to the primary unit
    #
    # For example, to apply teleport animations to the unit that triggered a 'move_to' event:
    #!{TELEPORT_EFFECT_OBJECT}

    [object]
        silent=yes
        duration=turn

        [effect]
            apply_to=new_animation

            [animation]
                apply_to=pre_teleport
                {TELEPORT_OUT_ANIMATION}
            [/animation]

            [animation]
                apply_to=post_teleport
                {TELEPORT_IN_ANIMATION}
            [/animation]
        [/effect]
    [/object]
#enddef
. That inserts [object] which is added to primary unit in an event. So it might be a good idea to remove the additional [object] tag and use the macro in your moveto event.
Ok, it worked! Thank you! And how can I add a lightbeam that falls over the tile that triggers the moveto (at the same time that the pre_teleport frame)? (49,51)

Code: Select all

[event]


name=moveto
first_time_only=no
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
[sound]
name=lightning.ogg
[/sound]
{TELEPORT_EFFECT_OBJECT}
[animate_unit]
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
flag=pre_teleport
[/animate_unit]
{TELEPORT_TILE 49 51 38 56}
[scroll_to]
x=38
y=56
[/scroll_to]
[animate_unit]
[filter]
[filter_location]
x,y=49,51
[/filter_location]
[/filter]
flag=post_teleport
[/animate_unit]
[/event]
The Great Library of WML is huge and extense. I must find the book who will lead me to create a perfect campaign.
Future Project: History of Vindalf

User avatar
Dugi
Posts: 4846
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Ephraim's WML questions

Post by Dugi » October 21st, 2017, 7:19 pm

Add the lightbeam frame sequence to the animation in the object. See how it's done in core/macros, in one of the files about animations.

User avatar
Ephraim
Posts: 47
Joined: July 3rd, 2017, 2:03 pm
Location: The Great Library of WML, Studiying it

Re: Ephraim's WML questions

Post by Ephraim » October 21st, 2017, 9:53 pm

Yes, now it works! Thank you!
The Great Library of WML is huge and extense. I must find the book who will lead me to create a perfect campaign.
Future Project: History of Vindalf

User avatar
Ephraim
Posts: 47
Joined: July 3rd, 2017, 2:03 pm
Location: The Great Library of WML, Studiying it

Re: Ephraim's WML questions

Post by Ephraim » October 22nd, 2017, 1:17 pm

Hello again! I'm going on with the lightbeam and I want to change its color: from white to green, red, blue and brown. How can I code that without using an image editor program?
The Great Library of WML is huge and extense. I must find the book who will lead me to create a perfect campaign.
Future Project: History of Vindalf

User avatar
Pentarctagon
Forum Administrator
Posts: 3547
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Ephraim's WML questions

Post by Pentarctagon » October 22nd, 2017, 3:58 pm

ImagePathFunctionWML - I would guess BLEND().
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
Ephraim
Posts: 47
Joined: July 3rd, 2017, 2:03 pm
Location: The Great Library of WML, Studiying it

Re: Ephraim's WML questions

Post by Ephraim » January 18th, 2018, 10:32 am

Hello!

I wan't to do the following:

The unit enters in a shop. Then, there will be a menu that allows this unit to buy some upgrades, like more damage, more HP, etc. But, each unit can only buy X number of upgrades of each one, for avoid making units invincibles.

So, how can I code that? I'm worried because if I use some variable like "number_hp", this variable will stand there for all the units, but I want that every unit has his own variable, that lasts all the game.

Thanks!
The Great Library of WML is huge and extense. I must find the book who will lead me to create a perfect campaign.
Future Project: History of Vindalf

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

Re: Ephraim's WML questions

Post by Ravana » January 18th, 2018, 10:40 am

Within each unit you can store variables to names such as unit.variables.something. And after changing it unstore unit.

User avatar
Ephraim
Posts: 47
Joined: July 3rd, 2017, 2:03 pm
Location: The Great Library of WML, Studiying it

Re: Ephraim's WML questions

Post by Ephraim » January 18th, 2018, 11:39 am

Ravana wrote:Within each unit you can store variables to names such as unit.variables.something. And after changing it unstore unit.
So, the code shoyld be like:

Code: Select all

[option] 
label= +8hp
[command]
[modify_unit]
[filter] 
x=$x1
y=$y1
[/filter] 
max_hitpoints=+8
[/modify_unit] 
[set_variable] 
name=unit.variables.hp.upgrades
literal=+1
[/set_variable] 
[/command] 
[/option]
Or maybe is different than that?
The Great Library of WML is huge and extense. I must find the book who will lead me to create a perfect campaign.
Future Project: History of Vindalf

Post Reply