No custom unit image

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
Perprec
Posts: 2
Joined: August 19th, 2021, 3:27 pm

No custom unit image

Post by Perprec »

Hi i'm new to wml and i tried to make new custom unit. I wrote a script and made a image for it but when i loaded my campaign scenario, my custom unit was recrutable but without image and couldn't move even when i gave it 5 movement. The image was ok i checked it by switching it with wesnoth core unit image and it was visible in game. I really don't know what is wrong. I tried a lot of things but maybe someone more expirienced will be able to help me.

Here is my custom unit.cfg

Code: Select all

#textdomain wesnoth-reborn_evil

[unit_type]
    id=Templar
    name= _ "Templar"
    image="images/units/templar.png"
    movement=5
    hitpoints=65
    alignment=lawful
    description= _ "A few white mages that decided to join their brothers in first front, put on armour and trained themselfs in arts of combat so they can join their allies in frontal assault. Such mages call themself templars and are know for their courage and devotion, becouse of their fighting style they discarded their staffs and armed themselfs with iconic big warhammers which allowed them to fight hand to hand and cast magic so they can support their allies in battle. Templars are formidable foes for anyone that stands in their way and can decide the outcome of the battle just by their presence on battlefield."
    advances_to=null
    attacks=1
    cost=46
    do_not_list=no
    experience=99
    gender=male
    level=3
    race=human
    usage=fighter

    [advancefrom]
        unit=White Mage
    [/advancefrom]

    [ability]
        [leadership]
            value=3
        [/leadership]
        [heals]
            value=6
        [/heals]
        [heals]
            value=-6
            id=retribution aura
            affect_enemies=yes
            name= _ "retribution aura"
            description=  _ "Retibution aura: Forces enemy units to condemn for their sins dealing damage to all foes around Templar every turn"

            {COLOR_HARM}
            affect_self=no
            affect_allies=no
                [affect_adjacent]
                    adjacent=n,ne,se,s,sw,nw
                [/affect_adjacent]
         [/heals]
    [/ability]

    [attack]
        [special]
            [firststrike]
            [/firststrike]
        [/special]
            name=hammer	
            type=arcane
            range=melee
            damage=12
            number=4
            icon=attacks/hammer.png
    [/attack]

[/unit_type]
That's my scenario cfg.

Code: Select all

#textdomain wesnoth-reborn_evil

[scenario]
    id=orcish_invasion
    next_scenario=null
    name=_"Orcish Invasion."
    map_data="{~add-ons/reborn_evil/maps/survive_the_orcs.map}"
    turns=40
    [side]
        side=1
        color=blue
        controller=human
        team_name="good"
        user_team_name= _ "Alliance"
        id=MyLeader
        name= _ "Edgar Brightheart"
        type="Lieutenant"
        unrenameable=yes
        canrecruit=yes
        recruit="Spearman, Peasant, Bowman, Cavalryman, Horseman, Templar"
        gold=75
    [/side]
    [side]
        side=2
        color=orange
        controller=ai
        team_name="bad"
        user_team_name= _ "Invaders"
        id="EnemyLeader"
        name= _ "Borkosh the Vile"
        type= "Orcish Warlord"
        unrenameable=yes
        canrecruit=yes
        recruit="Orcish Grunt, Orcish Archer, Wolf Rider"
        income=2
        gold=175
    [/side]
    [side]
         side=3
         color=white
         controller=ai
         team_name="good"
         user_team_name= _ "Alliance"
         no_leader=yes
    [/side]

[story]
    [part]
         music=intro_music.ogg
         background=landscape-bridge_sun.jpg
         story= _ "The south border of human kingdom was at peace for ceuntries, until day when orcs attacked."
    [/part]
    [part]
      background=some_castle_by_draken4o_dc2n2wt-fullview.jpg
      story= _ "It was sudden and local garrison was not ready for such an event. Most of the garrison troops were sent to reinforce northen borders in fighting off Drgonkin agression."
    [/part]
    [part]
      background=mateusz-michalski-orc-camp2.jpg
      story= _ "Orc horde after setting up the camp on the other side of Nilea river, pillaged near villages and started to prepare attack on border outpost."
    [/part]
    [part]
      background=landscape-coast.jpg
      story= _ "Outpost commander lieutenant Edgar Brightheart after seeing Orc doing sent messengers to capital and neighboring Dwarven keep asking for help and mobilized all remaining men he had to fight off Orcish threat."
    [/part]
[/story]

{SCENARIO_MUSIC scenario_music.ogg}
 
[event]
        name=prestart
        [unit]
        side=1
        type=Spearman	
        x=30
        y=14
    [/unit]
    [unit]
        side=1
        type=Spearman	
        x=32
        y=11
    [/unit]
    [unit]
        side=1
        type=Peasant	
        x=30
        y=12
    [/unit]
[/event]

    [event]
        name=start
        [message]
            speaker=MyLeader
            message= _ "I see the Orcs. They are preparing for the attack. Men on your stations! We must fight until reinforcements from capital arrive!"
        [/message]
        [message]
            speaker=EnemyLeader
            message= _ "WAGHH! Prepare to die meatbags! FOR THE BLACK FOOTS!"
        [/message]
        [objectives]
            [objective]
                description= _ "Survive 40 turns or kill enemy warlord"
                condition="win"
            [/objective]
            [objective]
                description= _ "Death of your leader"
                condition="lose"
            [/objective]
        [/objectives]
    [/event]

    [event]
        name="last breath"
        first_time_only=yes
        [filter]
            side=2
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [message]
            speaker=second_unit
            message= _ "Die Orc scum!"
        [/message]
        [message]
            speaker=unit
            message= _ "CHAOS WILL CONSUME YOU! ARGHHH!"
        [/message]
    [/event]

    [event]
        name=turn 15
            [unit]
                side=1
                type=Dwarvish Stalwart
                x=2
                y=20
            [/unit]
            [unit]
                side=1
                type=Dwarvish Stalwart
                x=2
                y=21
            [/unit]
            [unit]
                side=1
                type=Dwarvish Thunderer
                x=1
                y=20
            [/unit]
            [unit]
                side=1
                type=Dwarvish Thunderer
                x=1
                y=22
            [/unit]
            [unit]
                side=1
                type=Dwarvish Lord
                id=lord
                name=Aldin the Mountain King
                x=1
                y=21
            [/unit]
    [/event]

[event]
    name=turn 15
        [message]
            speaker=lord
            message= _ "Fear not human friends. We've come to help ya with this orc scum. Ready your weapons lads!"
        [/message]
[/event]

[event]
    name=side 2 turn 40
        [unit]
            side=3
            type=General
            name=Derion Dragonbane
            x=1
            y=6
        [/unit]
        [unit]
            side=3
            type=Longbowman
            x=2
            y=5
        [/unit]
        [unit]
            side=3
            type=Longbowman
            x=2
            y=6
        [/unit]
        [unit]
            side=3
            type=White Mage
            gender=female
            x=1
            y=5
        [/unit]
        [unit]
            side=3
            type=Swordsman
            x=1
            y=7
        [/unit]
        [unit]
            side=3
            type=Swordsman
            x=2
            y=4
        [/unit] 
        [unit]
            side=3
            type=Swordsman
            x=2
            y=7
        [/unit]
        [unit]
            side=3
            type=Knight
            x=3
            y=5
        [/unit]
        [unit]
            side=3
            type=Knight
            x=3
            y=7
        [/unit]
[/event]
      
    [event]
        name=time over
            [message]
                speaker=MyLeader
                message= _ "We did it the reinforcments are here!"
            [/message]

        [endlevel]
            result=victory
        [/endlevel]
    [/event]
[/scenario]
Thanks in advance!
User avatar
Atreides
Posts: 1074
Joined: March 30th, 2019, 10:38 pm
Location: On the 2nd story of the centre village of Merwuerdigliebe turning the lights on and off

Re: No custom unit image

Post by Atreides »

image="units/templar.png" should work if the pic is in the images/units subdirectory. Images is auto-added.

p.s. for the moves you need a movement_type also so it knows how many points any terrain might cost to enter.
Perprec
Posts: 2
Joined: August 19th, 2021, 3:27 pm

Re: No custom unit image

Post by Perprec »

Thank you it worked :).
I had no idea that adding to much directories can make script unable to find the image.
Now i'm off to try making it move. :D
Post Reply