Bitrons WML Questions

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
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

I have another question for another weapon_special.

Is this valid code ? : multiply=$((($second_unit.max_hitpoints - $second_unit.hitpoints)/$second_unit.max_hitpoints)*2)

it should say 2*((MaxHP-HP)/MaxHP)

what it should do:

Example: Attack: 10-2
Opponent with 50% hitpoints: Damage 10-2 (50*2 = 100%)
Opponent with 80% hitpoints: Damage 4-2 (20*2 = 40%)
Opponent with 20% hitpoints: Damage 16-2 (80*2 = 160%)
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: [Ability] - Inspiration

Post by beetlenaut »

You need to put everything to the right of the equals sign in quotes for this type of expression. Usually, that's optional, but not in this case. Also, multiply isn't correct. That's to multiply the previously-named variable by this amount, which is not what you are doing. You probably want value or damage depending on exactly where this is.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

here's the whole thing:

Code: Select all

#define WEAPON_SPECIAL_EXECUTE
    [damage]
        id=execute
        name= _ "Execute"
        name_inactive=_ "Execute"
        description= _ "the lower the acutal HP of the enemy is, the higher is the damage of this attack (only offensive)"
        multiply="$((($second_unit.max_hitpoints - $second_unit.hitpoints)/$second_unit.max_hitpoints)*2)"
        apply_to=defender
        active_on=offense
    [/damage]
#enddef
why are the quotes neccessary in this case ?
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

I don't think that any formulas are accepted inside weapon specials.
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

formulas ? ..
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: [Ability] - Inspiration

Post by Dugi »

The $(blablabla) part is called formula.
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

oh okay. then I'll try rewrite it as an event.
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

Good Morning guys.

I hava another little problem. I'm working on the first campaign, and i wrote an event, in wich the attacked unit flees and hides in a forest, using [hide_unit]. The problem is, if this event triggers, instead of the one unit i want to hide, all other units get hide and the unit i want to hide is still visible. I tried several filter-variations .. nothing worked like i want it to.

here es is the event:

Code: Select all

[event]
        name=attack end
        [filter]
            side=1
        [/filter]
        [filter_second]
            id=Karga
        [/filter_second]
        [message]
            speaker=Karga
            message= _ "Arrgh, ihr Maden! (flüsternd) Ich versteck mich vielleicht doch lieber."
        [/message]
        
       # moving Karga
        {MOVE_UNIT id=Karga 17 3}
        [hide_unit]
            [filter]
               id=Karga
            [/filter]
        [/hide_unit]
        [modify_unit]
            [filter]
                id=Karga
            [/filter]
            max_moves=0
        [/modify_unit]
    [/event]
Yes, messages are in german .. ill change it as soon as i have the english translations.
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [Ability] - Inspiration

Post by Ravana »

Try without [filter].
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

Ravana wrote:Try without [filter].
like this ?

Code: Select all

[...]
# moving Karga
        {MOVE_UNIT id=Karga 17 3}
        [hide_unit]
        [/hide_unit]
[...]
that doesnt work. still the same all get hide except the unit i want to hide
User avatar
James_The_Invisible
Posts: 534
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: [Ability] - Inspiration

Post by James_The_Invisible »

No, this way:

Code: Select all

[hide_unit]
    id=Karga
[/hide_unit]
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

oh right, that worked, thanks a lot !
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

And once again I'm here with a Problem.

I'm trying to programm a moveto event with position specific messages using [have_location]. But somehow it always uses the last possible [if] Variation, in this case "des Eremiten"
My guess is the [have_location] condition, but i have no clue where the mistake is.

here's the code:

Code: Select all

    [event]
        name=moveto
        first_time_only=yes
        [filter]
            id=Ysedda
            [filter_location]
                terrain=*^V*
                # Houses within the Town
                [not]
                    x=22
                    y=15
                [/not]
                [not]
                    x=18
                    y=15
                [/not]
            [/filter_location]
        [/filter]
        
        # wich neighbour should it be
        [if]
            [have_location]
                x,y=15,25
            [/have_location]
            [then]
                {VARIABLE neighbour_is (_ "des Bäckers")}
            [/then]
        [/if]
        [if]
            [have_location]
                x,y=7,28
            [/have_location]
            [then]
                {VARIABLE neighbour_is (_ "der alten Hexe")}
            [/then]
        [/if]
        [if]
            [have_location]
                x,y=4,36
            [/have_location]
            [then]
                {VARIABLE neighbour_is (_ "des Eremiten")}
            [/then]
        [/if]        
        [unit]
            {CHARACTER_VEN}
            side=1
            x,y=$x1,$y1            
        [/unit]
        [message]
            speaker=Ysedda
            message= _ "Was machst du denn hier? Das ist das Haus $neighbour_is!"
        [/message]
        [message]
            speaker=Ven
            message= _ "Der wohnt ein Haus weiter. Das hier gehört ei-.. mir."
        [/message]            
        [message]
            speaker=Ysedda
            message= _ "Du plünderst schon wieder, statt zu kämpfen?"
        [/message]
        [message]
            speaker=Ven
            message= _ "Und wenn? Am Ende wird eh kein Kerker mehr übrig sein, in dem ich geworfen werden könnte!"
        [/message]
        [message]
            speaker=Ysedda
            message= _ "Stimmt. Um genau zu sein, können wir nicht nur keinen Kerker mitnehmen, sondern auch keine Diebe, die nur Ballast sind!"
        [/message]
        [message]
            speaker=Ven
            message= _ "Ich sehe schon, wo das hinführt. Nun gut, weil Ihr so nett darum bittet: Ich verteidige erneut mit Euch die Bewohner"
        [/message]
        
        {CLEAR_VARIABLE neighbour_is}        
    [/event]
    
    #
    # Brealla appears: Denvan version
    #
    [event]
        name=moveto
        [filter]
            id=Denvan
            x,y=7,16
        [/filter]
        [unit]
            {CHARACTER_BREALLA}
            x,y=8,16
        [/unit]
        [message]
            speaker=Brealla
            message= _ "(gespielt bestürzt) Denvan! Du kannst doch nicht einfach so in das Haus einer allein lebenden Dame stürmen! Was sollen die Leute von dir denken?"
        [/message]
        [message]
            speaker=Denvan
            message= _ "Die denken, dass ich Verstärkung hole. Wir evakuieren das Dorf, du wirst gebraucht!"
        [/message]
        [message]
            speaker=Brealla
            message= _ "((etwas) ernster) Warum sagst du das nicht gleich? Ich bin unterwegs!"
        [/message]  
    [/event]
Hope, someone can help me (:

All the best,

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

Re: [Ability] - Inspiration

Post by Ravana »

[have_location] only checks if such location exists on map. Effectively you check if map is large enough. You do not compare it with current event location.
User avatar
Bitron
Developer
Posts: 453
Joined: October 19th, 2015, 9:23 am
Location: Germany

Re: [Ability] - Inspiration

Post by Bitron »

okay.
uhm...

Code: Select all

[have_unit]
    id=Ysedda
    [filter_location]
        y,x=X,Y
    [filter_location]
[/have_unit]
would this work ?

oh, or

Code: Select all

[have_location]
    x,y=X,Y
    [filter]
        id=Ysedda
    [/filter]
[/have_location]
EDIT: the second worked for me!

Thanks anyway (:
Post Reply