Graziani 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.
Post Reply
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2337
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: Graziani WML Questions

Post by Lord-Knightmare »

Just one more question (basic one, but I couldn't figure how this work), how can I store units without id ? (The recruited ones by the player ?)
Store by type, side, etc.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Graziani WML Questions

Post by beetlenaut »

Graziani wrote: July 31st, 2021, 11:46 am how can I store units without id ?
Here is the list of everything you can put inside a [filter] tag like the one in store_unit. You can reference a unit by any of these.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Graziani WML Questions

Post by vghetto »

Here you go:

Code: Select all

[teleport]
        [filter]
                id=Alban
        [/filter]
        x=15    
        y=33    
[/teleport]

[store_unit]
        variable=teleport_store
        mode=always_clear
        kill=no
        [filter]
                side=1
                type=Spearman,Bowman,Swordsman,Pikeman,Javelineer,Royal Guard,Halberdier,Javelineer,Longbowman,Master Bowman
                [not]
                        id=Alban
                [/not]
        [/filter]
[/store_unit]

[foreach]
        array=teleport_store
        [do]
                [teleport]
                        [filter]
                                id=$this_item.id
                        [/filter]
                        x=20
                        y=34
                [/teleport]
        [/do]
[/foreach]

{CLEAR_VARIABLE teleport_store}
User avatar
Ravana
Forum Moderator
Posts: 2934
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Graziani WML Questions

Post by Ravana »

Then you can filter by side/location/type/something else.
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

Ok thanks for clarifying. I was wondering why [filter] tag would affect only one unit (like in [teleport] tag, so my type= won't affect all units I want to) and why in [store_unit] the contrary is happening.

But I think I understand better now how this is working. Even if I made a lot of WML since I discovered wesnoth, there are still basic stuff that I have difficulties to understand.



vghetto wrote: July 31st, 2021, 2:01 pm Here you go:

Code: Select all

[foreach]
        array=teleport_store
        [do]
                [teleport]
                        [filter]
                                id=$this_item.id
                        [/filter]
                        x=20
                        y=34
                [/teleport]
        [/do]
[/foreach]

{CLEAR_VARIABLE teleport_store}

Thanks a lot for the code, it's working perfectly ^^
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Graziani WML Questions

Post by beetlenaut »

Two tags in different contexts that have the same name don't always work the same way. Tags are very specific. On the wiki, it says that teleport works on the first unit that matches the [filter], and store_unit works all the units that match the [filter]. The wiki is your friend!
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

Hello !

I have a question concerning objects.

One object in my campaign is a flaming hammer. One character have the opportunity to have new flaming attack thanks to this object. Everything is working perfectly (the character continue to carry it through the campaign and the effects are working). But I have no sound effect during attack.
Here is the code.

Code: Select all

                    [object]
                        name= _ "Flaming Hammer"
                        name=Flaming Hammer
                        image=items/flame_hammer.png
                        duration=forever
                        description= _ "This hammer will give you a new melee attack inflicting fire damage."

                        [effect]
apply_to=new_attack             
name="Flaming Hammer"
description= _ "Flaming Hammer"
icon=attacks/hammer-flaming.png
type=fire
range=melee
                            [specials]
                                {WEAPON_SPECIAL_MAGICAL}
                            [/specials]
damage=14
number=2

   [attack_anim]
            [filter_attack]
                name=Flaming Hammer
            [/filter_attack]
            [frame]
                    begin=-200
                    end=0
               [/frame]
           {SOUND:HIT_AND_MISS mace.ogg mace-miss.ogg -100}
[/attack_anim]

                        [/effect]
                    [/object]

I tried to place the macro at different places, I tried different macros (including for example : sound=mace-miss.ogg), but it doesn't work at all. There is no sound. If anyone have an idea..
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2337
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: Graziani WML Questions

Post by Lord-Knightmare »

You did not add the [effect]apply_to=new_animation to actually include that animation into the unit
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

Indeed I had to create a second [effect] tag that applies to animation only. I couldn't mixed the two. It's perfect ! Thanks a lot !

Code: Select all


          [object]
                        name= _ "Flaming Hammer"
                        name=Flaming Hammer
                        image=items/flame_hammer.png
                        duration=forever
                        description= _ "This hammer will give you a new melee attack inflicting fire damage."
                        
                        [effect]
apply_to=new_attack         
name="Flaming Hammer"
description= _ "Flaming Hammer"
icon=attacks/hammer-flaming.png
type=fire
range=melee
                            [specials]
                                {WEAPON_SPECIAL_MAGICAL}
                            [/specials]
damage=14
number=2

                        [/effect]
                        
[effect]
apply_to=new_animation    
   [attack_anim]
            [filter_attack]
                name=Flaming Hammer
            [/filter_attack]
          [frame]
                    begin=-200
                    end=0
               [/frame]
           {SOUND:HIT_AND_MISS mace.ogg mace-miss.ogg -100}
[/attack_anim]
                        [/effect]
                        
                    [/object]
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

Hi guys, I have 2 questions concerning unit description (including one bug)

1 : Double PNG (see attachment file, I made a screenshot)

The naga spearman I made appears twice in the description box. I have the same problem with few other custom units.

Here is it's code :

Code: Select all

#textdomain wesnoth-frab
[unit_type]
    id=Naga Spearman
    name= _ "Naga Spearman"
    race=naga
    gender=male,female
    image="units/nagas/spearman.png"
    ellipse="misc/ellipse"
    profile=portraits/nagas/fighter.png
    hitpoints=33
    movement_type=naga
    movement=7
    experience=32
    level=1
    alignment=neutral
    advances_to=Naga Pikeman
    cost=14
    usage=fighter
    description= _ "The serpentine naga are one of the few races capable of any meaningful mobility in water, giving them mastery of a whole world effectively forbidden to land dwellers. Still, they are not true creatures of the sea, and their inability to breathe water leaves them in trepidation of the abyss. They are small, and somewhat frail in form, but often much more nimble than their opponents."
    die_sound=naga-die.ogg
    {DEFENSE_ANIM "units/nagas/spearman.png" "units/nagas/spearman.png" {SOUND_LIST:NAGA_HIT} }
    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/nagas/transparent/fighter.png"
    [/portrait]
    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/nagas/transparent/fighter.png"
    [/portrait]
     [attack]
        name=spear
        description=_"spear"
        type=pierce
        range=melee
        damage=7
        number=3
        icon=attacks/spear.png
        [specials]
            {WEAPON_SPECIAL_FIRSTSTRIKE}
        [/specials]
    [/attack]
    [attack]
        name=javelin
        description=_"javelin"
        icon=attacks/javelin-human.png
        type=pierce
        range=ranged
        damage=6
        number=1
    [/attack]
    [attack_anim]
        [filter_attack]
            name=javelin
        [/filter_attack]
        [missile_frame]
            begin=-150
            end=0
            image="projectiles/spear-n.png"
            image_diagonal="projectiles/spear-ne.png"
        [/missile_frame]
        [frame]
            begin=-250
            end=-150
            image="units/nagas/spearman.png"
            sound={SOUND_LIST:THROW}
        [/frame]
        [frame]
            begin=-150
            end=-100
            image="units/nagas/spearman.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-100
                end=-50
                image="units/nagas/spearman.png"
                sound=spear.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-100
                end=-50
                image="units/nagas/spearman.png"
            [/frame]
        [/else]
        [frame]
            begin=-50
            end=50
            image="units/nagas/spearman.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=spear
        [/filter_attack]
        start_time=-200
        direction=s
        offset="0~0.5,0.5~0"
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                duration=25
                image="units/nagas/spearman.png"
                sound=spear.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                duration=25
                image="units/nagas/spearman.png"
                sound=spear-miss.ogg
            [/frame]
        [/else]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=25
            image="units/nagas/spearman.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=spear
        [/filter_attack]
        direction=n
        [frame]
            begin=-200
            end=-100
            image="units/nagas/spearman.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-100
                end=100
                image="units/nagas/spearman.png"
                sound=spear.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-100
                end=100
                image="units/nagas/spearman.png"
                sound=spear-miss.ogg
            [/frame]
        [/else]
        [frame]
            begin=100
            end=150
            image="units/nagas/spearman.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=spear
        [/filter_attack]
        direction=ne,nw
        [frame]
            begin=-200
            end=-100
            image="units/nagas/spearman.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-100
                end=100
                image="units/nagas/spearman.png"
                sound=spear.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-100
                end=100
                image="units/nagas/spearman.png"
                sound=spear-miss.ogg
            [/frame]
        [/else]
        [frame]
            begin=100
            end=150
            image="units/nagas/spearman.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=spear
        [/filter_attack]
        start_time=-224
        direction=se,sw
        offset="0~0.4,0.4~0"
        [frame]
            duration=32
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=32
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=32
            image="units/nagas/spearman.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                duration=32
                image="units/nagas/spearman.png"
                sound=spear.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                duration=32
                image="units/nagas/spearman.png"
                sound=spear-miss.ogg
            [/frame]
        [/else]
        [frame]
            duration=32
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=32
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=32
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=32
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=32
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=32
            image="units/nagas/spearman.png"
        [/frame]
        [frame]
            duration=32
            image="units/nagas/spearman.png"
        [/frame]
    [/attack_anim]

    [female]
        name= _ "Nagini Spearman"
        gender=female
    [/female]
[/unit_type]

2 : A bug :

When I click on unit description ingame for this unit, game crashes and return to windows 10.
Four of my custom units are concerned.

Here is the code of one of them :

Code: Select all

#textdomain wesnoth-frab

[unit_type]

    id=FRAB Bladesman
    name= _ "Goblin Bladesman"
    race=goblin
    image="units/goblins/bladesman.png"
    profile="portraits/goblins/spearman.png"
    ellipse="misc/ellipse"
       hitpoints=22
    movement_type=orcishfoot
    movement=5
    experience=18
    level=0
    alignment=chaotic
    advances_to=FRAB Swordsman
    cost=9
    usage=fighter
    description= _ "In any litter of orcs, several are born much smaller and weaker than the rest. These runts are called ‘Goblins’ and are looked down on by the rest of their kin. In battle, these are given the most meager of equipment, and are used as a soak-off force to give the Warlords time to prepare the real assault. The comparatively small and weak goblin is ill-suited to use as a soldier, unless you have a need of many cheap, expendable troops. Some goblin tribes make better use of their goblin brethren by equipping them with swords and shields instead of spears or bows, and using them in the same role as the slightly larger and stronger orcish soldier."

    die_sound={SOUND_LIST:GOBLIN_DIE}

    [resistance]
        blade=95
        impact=95
    [/resistance]
    {DEFENSE_ANIM "units/goblins/bladesman-defend.png" "units/goblins/bladesman.png" {SOUND_LIST:GOBLIN_HIT} }

    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/goblins/transparent/spearman.png"
    [/portrait]

    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/goblins/transparent/spearman.png"
    [/portrait]

    [attack]
        name=sword
        description=_"sword"
        icon=attacks/sword-orcish.png
        type=blade
        range=melee
        damage=5
        number=3
    [/attack]

    [idle_anim]
        {STANDARD_IDLE_FILTER}
        start_time=0
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-1.png"
        [/frame]
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-2.png"
        [/frame]
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-3.png"
        [/frame]
        [frame]
            duration=300
            image="units/goblins/bladesman-idle-4.png"
        [/frame]
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-5.png"
        [/frame]
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-6.png"
        [/frame]
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-7.png"
        [/frame]
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-8.png"
        [/frame]
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-9.png"
        [/frame]
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-10.png"
        [/frame]
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-11.png"
        [/frame]
        [frame]
            duration=150
            image="units/goblins/bladesman-idle-12.png"
        [/frame]
    [/idle_anim]
      
    [attack_anim]
        [filter_attack]
            name=sword
            range=melee
        [/filter_attack]
        direction=ne,nw
        [frame]
            begin=-200
            end=-100
            image=units/goblins/bladesman-attack-ne1.png
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-100
                end=100
                image=units/goblins/bladesman-attack-ne2.png
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-100
                end=100
                image=units/goblins/bladesman-attack-ne2.png
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            begin=100
            end=200
            image=units/goblins/bladesman-attack-ne1.png
        [/frame]
    [/attack_anim]

    [attack_anim]
        [filter_attack]
            name=sword
            range=melee
        [/filter_attack]
        direction=s
        [frame]
            begin=-200
            end=-100
            image=units/goblins/bladesman.png
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-100
                end=100
                image=units/goblins/bladesman-attack-s.png
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-100
                end=100
                image=units/goblins/bladesman-attack-s.png
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            begin=100
            end=200
            image=units/goblins/bladesman.png
        [/frame]
    [/attack_anim]

    [attack_anim]
        [filter_attack]
            name=sword
            range=melee
        [/filter_attack]
        direction=n
        [frame]
            begin=-200
            end=-100
            image=units/goblins/bladesman-attack-n1.png
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-100
                end=100
                image=units/goblins/bladesman-attack-n2.png
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-100
                end=100
                image=units/goblins/bladesman-attack-n2.png
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            begin=100
            end=200
            image=units/goblins/bladesman-attack-n1.png
        [/frame]
    [/attack_anim]

 [attack_anim]
        [filter_attack]
            name=sword
            range=melee
        [/filter_attack]

        [frame]
            begin=-200
            end=-100
            image=units/goblins/bladesman.png
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-100
                end=100
                image=units/goblins/bladesman-attack.png
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-100
                end=100
                image=units/goblins/bladesman-attack.png
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            begin=100
            end=200
            image=units/goblins/bladesman.png
        [/frame]
    [/attack_anim]

[/unit_type]

Any idea where this crash can come from ? I'm using 1.16 wesnoth.



Interesting thing : when I created most of my custom units for A Goblin Adventure and From Rocks and Blood campaigns, unit description wasn't reachable ingame (meaning that nothing happened, the box won't open). It was happening in wesnoth 1.14 and previous versions.
Since 1.15, unit description works properly without any work from my part.

Thanks in advance for your help !
Attachments
1.png
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Graziani WML Questions

Post by beetlenaut »

Graziani wrote: February 18th, 2022, 12:10 pm The naga spearman I made appears twice in the description box.
This is a feature. It is showing both genders. Other units like the thief or elvish archer do the same thing.
Graziani wrote: February 18th, 2022, 12:10 pm Any idea where this crash can come from ?
Maybe it's [portrait]. I'm not sure that's a thing. If that's not it, this is the method for finding it: Save a copy of the unit somewhere, then delete large chunks of code and try loading it again. Keep doing that, and eventually you will delete the offending line and it won't crash. Whatever you deleted last must have been where the problem was, so check that part.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

Hi, I have a funny graphical issue.

In one of my scenarios, the leader is stored and a secondary character is going to be in charge of recruitment. Funny thing, as soon as the original leader "left" game, the new leader have an image not found yellow case behind him. And as soon as the original leader came back, this problem disapear.
Is someone have an idea about how to fix this ? Tried several stuff without success. I upload two screenshots to let you see this.

Thanks !
Attachments
2.png
1.png
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
User avatar
Ravana
Forum Moderator
Posts: 2934
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Graziani WML Questions

Post by Ravana »

Look logs and copy over the missing images.
User avatar
Graziani
Posts: 179
Joined: December 20th, 2010, 1:04 am
Location: France

Re: Graziani WML Questions

Post by Graziani »

found it
20240202 21:34:29 error display: could not open image 'misc/ellipse-hero-leader-selected-top.png'
20240202 21:34:29 error display: could not open image 'misc/ellipse-hero-leader-selected-bottom.png'
so it is really connected to the leader role
Creator and maintainer of "A goblin adventure" (available) and "From Rocks and Blood"(available) --- Working on a new campaign "Facing Death"
User avatar
Ravana
Forum Moderator
Posts: 2934
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Graziani WML Questions

Post by Ravana »

Game cant decide which ellipse to show, so you need to decide which files to copy there.
Post Reply