summoning skill

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.
herolulu
Posts: 32
Joined: February 29th, 2020, 4:46 pm

summoning skill

Post by herolulu »

Hi everyone, my English is not very good.
I want to make a summoning skill by modifying the text.
Summoned ID: tsm faeries
I can enter the game normally after modification.
The game version is the latest beta version.
Now that I have a problem, I added a summoning ability to the character. But the call menu is not displayed.(According to the instructions, there should be a summon option by clicking the square next to the character)
Below is the script. Can anyone help me see where the problem is? If possible, can you help me modify the script so that it can run normally? thanks.

Code: Select all

abilities_recruit_base.cfg

#textdomain wesnoth
# Ability macros to be included in the SingleWML description of a unit.

#define RECRUIT_MENU_ITEM ID DESCRIPTION COST ABILITY UNIT GENDER
    [event]
        name=select
        first_time_only=no
        [filter]
            ability=recruittsmfaeries
            side=$side_number
        [/filter]
        [store_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            variable=last_selected_unit
        [/store_unit]
    [/event]
    [set_menu_item]
        id=recruit_{ID}
        description={DESCRIPTION}
        [show_if]
        [/show_if]
        [filter_location]
            [filter_adjacent_location]
                [filter]
                    ability={ABILITY}
                    side=$side_number
                    [filter_wml]
                        moves=$this_unit.max_moves
                    [/filter_wml]
                [/filter]
            [/filter_adjacent_location]
            [not]
                [filter]
                [/filter]
                [or]
                    terrain=_off^_usr,Q*,*^X,X*,*^V*
                [/or]
            [/not]
        [/filter_location]
        [command]
            [store_gold]
                variable=actualgold
                side=$side_number
            [/store_gold]
            [if]
                [variable]
                    name=actualgold
                    greater_than_equal_to={COST}
                [/variable]
                [then]
                    [gold]
                        amount=-{COST}
                        side=$side_number
                    [/gold]
                    [unit]
                        type={UNIT}
                        gender={GENDER}
                        #random_gender=yes
                        side=$side_number
                        x,y=$x1,$y1
                        moves=0
                        animate=yes
                    [/unit]
                    [store_unit]
                        variable=newunit
                        [filter]
                            x,y=$x1,$y1
                        [/filter]
                    [/store_unit]
                    [set_variable]
                        name=newunit.attacks_left
                        value=0
                    [/set_variable]
                    [unstore_unit]
                        variable=newunit
                        find_vacant=no
                    [/unstore_unit]
                    [set_variable]
                        name=newunit.moves
                        value=0
                    [/set_variable]
                    [store_unit]
                        [filter]
                            ability={ABILITY}
                            side=$side_number
                            [filter_wml]
                                moves=$this_unit.max_moves
                            [/filter_wml]
                            [filter_adjacent]
                                x,y=$x1,$y1
                            [/filter_adjacent]
                        [/filter]
                        variable=able_to_build
                    [/store_unit]
                    [if]
                        [variable]
                            name=able_to_build.length
                            greater_than=1
                        [/variable]
                        [then]
                            {FOREACH able_to_build a}
                                [if]
                                    [variable]
                                        name=able_to_build[$a].id
                                        equals=$last_selectet_unit.id
                                    [/variable]
                                    [then]
                                        [set_variable]
                                            name=able_to_build[$a].attacks_left
                                            value=0
                                        [/set_variable]
                                        [set_variable]
                                            name=able_to_build[$a].moves
                                            value=0
                                        [/set_variable]
                                        {VARIABLE_OP able_to_build[$a].experience add 3}
                                        [unstore_unit]
                                            variable=able_to_build[$a]
                                            find_vacant=no
                                            text= _ "+$this_unit.level exp"
                                            red,green,blue=50,50,200
                                        [/unstore_unit]
                                        {CLEAR_VARIABLE newunit}
                                        {CLEAR_VARIABLE able_to_build}
                                    [/then]
                                [/if]
                            {NEXT a}
                        [/then]
                        [else]
                            [store_unit]
                                variable=able_to_build
                                [filter]
                                    ability={ABILITY}
                                    side=$side_number
                                    [filter_wml]
                                        moves=$this_unit.max_moves
                                    [/filter_wml]
                                    [filter_adjacent]
                                        x,y=$x1,$y1
                                    [/filter_adjacent]
                                [/filter]
                            [/store_unit]
                            [set_variable]
                                name=able_to_build[$a].attacks_left
                                value=0
                            [/set_variable]
                            [set_variable]
                                name=able_to_build[$a].moves
                                value=0
                            [/set_variable]
                            {VARIABLE_OP able_to_build[$a].experience add 3}
                            [unstore_unit]
                                variable=able_to_build[$a]
                                find_vacant=no
                                text= _ "+$this_unit.level exp"
                                red,green,blue=50,50,200
                            [/unstore_unit]
                            {CLEAR_VARIABLE newunit}
                            {CLEAR_VARIABLE able_to_build}
                        [/else]
                    [/if]
                [/then]
                [else]
                    [message]
                        speaker=narrator
                        side_for=$side_number
                        caption=_ "Error"
                        message=_ "not enough gold"
                        image=wesnoth-icon.png
                    [/message]
                [/else]
            [/if]
            {CLEAR_VARIABLE actualgold}
        [/command]
    [/set_menu_item]
#enddef


abilities_recruit_examples.cfg

#textdomain wesnoth
# Ability macros to be included in the SingleWML description of a unit.

#define SPECIAL_NOTES_RECRUIT
    _ "This units can recruit some soldiers, even while not on the keep. The soldiers can not be recruited in villages."
#enddef

#define ABILITY_RECRUIT_TSM_FAERIES
    [dummy]
        id=recruittsmfaeries
        name="Summon tsm faeries"
        description= _ "This units can summon burning Liches next to it (right click on a tile next to this unit"
        special_note=_"This units can summon burning Liches next to it (right click on a tile next to this unit。"
    [/dummy] # wmlxgettext: [abilities]
[/abilities]
[event]
    name=start
    [if]
        [have_unit]
            ability=recruittsmfaeries
        [/have_unit]
        [then]
            {RECRUIT_TSM_FAERIES}
        [/then]
    [/if]
[/event]
[event]
    name=side turn
    [if]
        [have_unit]
            ability=recruittsmfaeries
        [/have_unit]
        [then]
            {RECRUIT_TSM_FAERIES}
        [/then]
    [/if]
[/event]
[event]
    name=recruit
    [filter]
        ability=recruittsmfaeries
    [/filter]
    {RECRUIT_TSM_FAERIES}
[/event]
[event]
    name=post_advance
    [filter]
        ability=recruittsmfaeries
    [/filter]
    {RECRUIT_TSM_FAERIES}
[/event]
[+abilities] # wmlxgettext: [/abilities]
#enddef
#define RECRUIT_TSM_FAERIES
    {RECRUIT_MENU_ITEM tsm faeries ( _ "tsm faeries (1个金币)") 1 recruittsmfaeries (tsm faeries) female }
#enddef
Last edited by WhiteWolf on July 25th, 2021, 11:41 am, edited 1 time in total.
Reason: [code]
User avatar
Yomar
Posts: 392
Joined: October 27th, 2011, 5:14 am
Contact:

Re: summoning skill

Post by Yomar »

I Think there are already a couple of eras where you can summon units, maybe giving a look to it can help you.
But I dont remember the exact name right now.
One maybe was era of magic, but there was also one that was based all on summoming and magic, where you choose a wizard and use spells and summonings to evoche warriors to fight your opponent.
Beholded Wesnoth's Origins.
Max G on WIF
Rank 🌟🌟🌟🌟🌟
herolulu
Posts: 32
Joined: February 29th, 2020, 4:46 pm

Re: summoning skill

Post by herolulu »

Yomar wrote: July 25th, 2021, 11:28 am I Think there are already a couple of eras where you can summon units, maybe giving a look to it can help you.
But I dont remember the exact name right now.
One maybe was era of magic, but there was also one that was based all on summoming and magic, where you choose a wizard and use spells and summonings to evoche warriors to fight your opponent.
I originally considered learning the summon ability from "Era_of_Magic_Resources", but I spent a lot of time and couldn't find the summon ability script inside. XD
I only found documents for characters with summoning capabilities. But no script to trigger the ability was found.
herolulu
Posts: 32
Joined: February 29th, 2020, 4:46 pm

Re: summoning skill

Post by herolulu »

Ravana wrote: July 25th, 2021, 12:22 pm Code is in main repository https://github.com/inferno8/wesnoth-Era ... summon.cfg
thank you very much.
I saw that this is the main code of the summon, and there is also the animation of the summon in the same folder.
I checked the main code, and it seems that the ID of the callee is not written in it. Are there other associated scripts?
Which script is the script that calls the summon ID?
herolulu
Posts: 32
Joined: February 29th, 2020, 4:46 pm

Re: summoning skill

Post by herolulu »

Ravana wrote: July 25th, 2021, 12:22 pm Code is in main repository https://github.com/inferno8/wesnoth-Era ... summon.cfg
Just tested the summon file. The new version of the game reports an error. There are, and = after the prompt variable.
It seems that I can only give up the research of summoning skills temporarily
XD
User avatar
beetlenaut
Developer
Posts: 2812
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: summoning skill

Post by beetlenaut »

herolulu wrote: July 25th, 2021, 1:58 pm It seems that I can only give up the research of summoning skills temporarily
You should give up the research into other peoples' code. I don't think you have the skills yet to use it properly. However you probably have the skills to make a summoning ability yourself! It doesn't need to be very complicated, and it's not as hard as you think. You just need to write one piece at a time.

For example: Write code that creates a right-click menu item (that does nothing yet), and make sure it appears. Next write code that adds a "summon" ability to a unit (that does nothing yet), and make sure it appears. When that works, modify the menu item to only open next to the unit. Continue like that, and you will soon have the code you want. Ask for help with the one piece you are working on if you need it.

(One problem with the code at the top of this page is that you didn't put the macros in the right places. I know that because it should have caused an error that prevented your scenario from loading. It has other problems too.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
herolulu
Posts: 32
Joined: February 29th, 2020, 4:46 pm

Re: summoning skill

Post by herolulu »

beetlenaut wrote: July 26th, 2021, 12:07 am
herolulu wrote: July 25th, 2021, 1:58 pm It seems that I can only give up the research of summoning skills temporarily
You should give up the research into other peoples' code. I don't think you have the skills yet to use it properly. However you probably have the skills to make a summoning ability yourself! It doesn't need to be very complicated, and it's not as hard as you think. You just need to write one piece at a time.

For example: Write code that creates a right-click menu item (that does nothing yet), and make sure it appears. Next write code that adds a "summon" ability to a unit (that does nothing yet), and make sure it appears. When that works, modify the menu item to only open next to the unit. Continue like that, and you will soon have the code you want. Ask for help with the one piece you are working on if you need it.

(One problem with the code at the top of this page is that you didn't put the macros in the right places. I know that because it should have caused an error that prevented your scenario from loading. It has other problems too.)
Glad you responded to me.
English is not my native language, so it is very difficult for me to read the tutorials.
I currently just try to copy and piece together some skills to make custom characters and add them to the Campaigns.
Did you say that you asked me to make my own summon skills by using the map editing function in the game? :shock:
Last edited by herolulu on July 27th, 2021, 1:55 pm, edited 1 time in total.
herolulu
Posts: 32
Joined: February 29th, 2020, 4:46 pm

Re: summoning skill

Post by herolulu »

beetlenaut wrote: July 26th, 2021, 12:07 am
herolulu wrote: July 25th, 2021, 1:58 pm It seems that I can only give up the research of summoning skills temporarily
You should give up the research into other peoples' code. I don't think you have the skills yet to use it properly. However you probably have the skills to make a summoning ability yourself! It doesn't need to be very complicated, and it's not as hard as you think. You just need to write one piece at a time.

For example: Write code that creates a right-click menu item (that does nothing yet), and make sure it appears. Next write code that adds a "summon" ability to a unit (that does nothing yet), and make sure it appears. When that works, modify the menu item to only open next to the unit. Continue like that, and you will soon have the code you want. Ask for help with the one piece you are working on if you need it.

(One problem with the code at the top of this page is that you didn't put the macros in the right places. I know that because it should have caused an error that prevented your scenario from loading. It has other problems too.)
When I was inquiring about skills, I found that there is a bug in the default skill of the game. Where should I report this bug? This skill description is to reduce the damage received. The actual effect is that the player will suffer more than ten times the damage from the enemy.

#define WEAPON_SPECIAL_ABSORB AMT
# Canned definition of the Absorb ability to be included in a
# [specials] clause.
[damage]
id=absorb
name= _ "absorb"
description= _ "This attack puts the unit in good defensive position, and it absorbs some of the damage dealt by an enemy strike."
special_note= _ "This unit can block enemy strikes, so that it takes reduced damage when hit."
multiply={AMT}
apply_to=opponent
[/damage]
#enddef

:P
User avatar
beetlenaut
Developer
Posts: 2812
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: summoning skill

Post by beetlenaut »

herolulu wrote: July 27th, 2021, 1:35 pm English is not my native language, so it is very difficult for me to read the tutorials.
I see. You could try the campaign WML_Guide. It is very simple, and you can test your units with it.
herolulu wrote: July 27th, 2021, 1:35 pm Did you say that you asked me to make my own summon skills by using the map editing function in the game?
The map editor can only create a few kinds of code. You can't write abilities with it. Most of us only use map editor to make the visual maps. We don't use it to help write the code because it is so limited.
herolulu wrote: July 27th, 2021, 1:41 pm I found that there is a bug in the default skill of the game.
This is working correctly, but you need to use a percentage. If you want the unit to absorb 60%, use 0.6 for {AMT}.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
herolulu
Posts: 32
Joined: February 29th, 2020, 4:46 pm

Re: summoning skill

Post by herolulu »

beetlenaut wrote: July 27th, 2021, 4:20 pm
herolulu wrote: July 27th, 2021, 1:35 pm English is not my native language, so it is very difficult for me to read the tutorials.
I see. You could try the campaign WML_Guide. It is very simple, and you can test your units with it.
herolulu wrote: July 27th, 2021, 1:35 pm Did you say that you asked me to make my own summon skills by using the map editing function in the game?
The map editor can only create a few kinds of code. You can't write abilities with it. Most of us only use map editor to make the visual maps. We don't use it to help write the code because it is so limited.
herolulu wrote: July 27th, 2021, 1:41 pm I found that there is a bug in the default skill of the game.
This is working correctly, but you need to use a percentage. If you want the unit to absorb 60%, use 0.6 for {AMT}.
Okay thank you.
herolulu
Posts: 32
Joined: February 29th, 2020, 4:46 pm

Re: summoning skill

Post by herolulu »

beetlenaut wrote: July 27th, 2021, 4:20 pm
herolulu wrote: July 27th, 2021, 1:35 pm English is not my native language, so it is very difficult for me to read the tutorials.
I see. You could try the campaign WML_Guide. It is very simple, and you can test your units with it.
herolulu wrote: July 27th, 2021, 1:35 pm Did you say that you asked me to make my own summon skills by using the map editing function in the game?
The map editor can only create a few kinds of code. You can't write abilities with it. Most of us only use map editor to make the visual maps. We don't use it to help write the code because it is so limited.
herolulu wrote: July 27th, 2021, 1:41 pm I found that there is a bug in the default skill of the game.
This is working correctly, but you need to use a percentage. If you want the unit to absorb 60%, use 0.6 for {AMT}.
Thank you so much for teaching me. I tried to read WML_Guide. Although it still seems difficult to me. XD I can customize the character, but writing skill scripts seems to take a long time.

I don't want to bother you with simple questions all the time. I know from your last answer that when I encounter capital English in {}, I can try to replace the data. I tried to change the {FACTOR} of the skill code below → 3. But this skill still does not work properly. (It's a skill in the Campaigns that comes with the game), is there any data that needs to be replaced I haven't noticed? I'm sorry this is the last time I bother you with such a simple question.


Code: Select all

#define ABILITY_IRON_WARDEN
    [dummy]
        id=iron warden
        name= _ "iron warden"
        name_inactive= _ "iron warden"
        description= _ "When nearby allies are attacked by physical attacks, they heal for 30% of the damage dealt and return damage equal to the amount healed."
        description_inactive= _ "When nearby allies are attacked by physical attacks, they heal for 30% of the damage dealt and return damage equal to the amount healed."
    [/dummy]
#enddef

#define IRON_WARDEN FACTOR
    [event]
        name=attacker_hits
        first_time_only=no

        [filter_attack]
            type=blade,impact,pierce
        [/filter_attack]

        [filter_second]
            [filter_adjacent]
                ability=iron warden
                is_enemy=no
            [/filter_adjacent]
        [/filter_second]

        [store_unit]
            [filter]
                x,y=$x2,$y2
                [filter_adjacent]
                    ability=iron warden
                    is_enemy=no
                [/filter_adjacent]
            [/filter]
            variable=shielded
        [/store_unit]
        [store_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            variable=opp
        [/store_unit]

        {VARIABLE heal_health $damage_inflicted}
        {VARIABLE_OP heal_health divide {FACTOR}}
        [if]
            [variable]
                name=second_unit.hitpoints
                greater_than=0
            [/variable]
            [then]
                {FOREACH shielded i}
                    [heal_unit]
                        [filter]
                            x,y=$shielded[$i].x,$shielded[$i].y
                        [/filter]
                        amount=$heal_health
                        animate=yes
                        restore_statuses=no
                    [/heal_unit]
                {NEXT i}

                [harm_unit]
                    [filter]
                        x,y=$x1,$y1
                    [/filter]
                    amount=$heal_health
                    animate=yes
                    fire_event=yes
                [/harm_unit]
            [/then]
        [/if]

        [if]
            [have_unit]
                x,y=$x1,$y1
            [/have_unit]
            [else]
                {VARIABLE exp $opp.level}
                {VARIABLE_OP exp multiply 8}
                {VARIABLE_OP second_unit.experience add $exp}
                {CLEAR_VARIABLE exp}
                [unstore_unit]
                    variable=second_unit
                    find_vacant=no
                [/unstore_unit]
            [/else]
        [/if]

        {CLEAR_VARIABLE opp}
        {CLEAR_VARIABLE heal_health}
        {CLEAR_VARIABLE shielded}
    [/event]
#enddef
User avatar
beetlenaut
Developer
Posts: 2812
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: summoning skill

Post by beetlenaut »

herolulu wrote: July 29th, 2021, 11:35 am writing skill scripts seems to take a long time.
Writing a summoning ability or something like iron warden would probably take you several days now, but with some practice it will get much faster. If you get good at WML, you could write either one in an hour or two. (And most of that time would be testing.)
herolulu wrote: July 29th, 2021, 11:35 am I tried to change the {FACTOR} of the skill code below → 3. But this skill still does not work properly.
You are showing us the code that comes from the game--the code that we know works correctly. You didn't show us your code, which is the code that doesn't work, so I can only guess about the problem.

My guess is that you didn't put your code in the right place. You should have {ABILITY_IRON_WARDEN} inside the [abilities] tag under your [unit_type], and {IRON_WARDEN 3} directly inside the [unit_type] tag. If that doesn't help, you should post all the files you are using.
herolulu wrote: July 29th, 2021, 11:35 am I'm sorry this is the last time I bother you with such a simple question.
Don't worry about that! We all asked simple questions at one time. Besides, if I don't have time, someone else will answer.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
herolulu
Posts: 32
Joined: February 29th, 2020, 4:46 pm

Re: summoning skill

Post by herolulu »

beetlenaut wrote: July 29th, 2021, 6:20 pm
herolulu wrote: July 29th, 2021, 11:35 am writing skill scripts seems to take a long time.
Writing a summoning ability or something like iron warden would probably take you several days now, but with some practice it will get much faster. If you get good at WML, you could write either one in an hour or two. (And most of that time would be testing.)
herolulu wrote: July 29th, 2021, 11:35 am I tried to change the {FACTOR} of the skill code below → 3. But this skill still does not work properly.
You are showing us the code that comes from the game--the code that we know works correctly. You didn't show us your code, which is the code that doesn't work, so I can only guess about the problem.

My guess is that you didn't put your code in the right place. You should have {ABILITY_IRON_WARDEN} inside the [abilities] tag under your [unit_type], and {IRON_WARDEN 3} directly inside the [unit_type] tag. If that doesn't help, you should post all the files you are using.
herolulu wrote: July 29th, 2021, 11:35 am I'm sorry this is the last time I bother you with such a simple question.
Don't worry about that! We all asked simple questions at one time. Besides, if I don't have time, someone else will answer.
awesome! According to your statement, I found the corresponding role document. There really is {IRON_WARDEN 3}. Add this code to my custom role document, and the skill can run normally. Thank you so much! Following this idea, I will continue to explore other skills.
herolulu
Posts: 32
Joined: February 29th, 2020, 4:46 pm

Re: summoning skill

Post by herolulu »

beetlenaut wrote: July 29th, 2021, 6:20 pm
herolulu wrote: July 29th, 2021, 11:35 am writing skill scripts seems to take a long time.
Writing a summoning ability or something like iron warden would probably take you several days now, but with some practice it will get much faster. If you get good at WML, you could write either one in an hour or two. (And most of that time would be testing.)
herolulu wrote: July 29th, 2021, 11:35 am I tried to change the {FACTOR} of the skill code below → 3. But this skill still does not work properly.
You are showing us the code that comes from the game--the code that we know works correctly. You didn't show us your code, which is the code that doesn't work, so I can only guess about the problem.

My guess is that you didn't put your code in the right place. You should have {ABILITY_IRON_WARDEN} inside the [abilities] tag under your [unit_type], and {IRON_WARDEN 3} directly inside the [unit_type] tag. If that doesn't help, you should post all the files you are using.
herolulu wrote: July 29th, 2021, 11:35 am I'm sorry this is the last time I bother you with such a simple question.
Don't worry about that! We all asked simple questions at one time. Besides, if I don't have time, someone else will answer.
I follow the method you said. Start paying attention to the [unit_type] of the corresponding character. I found that the [unit_type] of the character corresponding to this skill has {BRIAR_ROSE}. I added this code, and now this ability can be used, each round can poison the surrounding enemies. But when I attacked the enemy, I was counterattacked by the enemy in close combat. This enemy is not poisoned. XD
The incident in which the attacker was poisoned by the attack in the second half of the code did not trigger. :shock:

Code: Select all

#define ABILITY_BRIAR_ROSE
    [dummy]
        id=briar rose
        name= _ "briar rose"
        description= _ "This unit poisons all nearby enemy units on the start of every new turn. Additionally, enemies that strike this unit with melee attacks are poisoned."
    [/dummy]
#enddef

#define BRIAR_ROSE
    [event]
        name=new turn
        first_time_only=no

        [store_unit]
            [filter]
                [filter_adjacent]
                    ability=briar rose
                    is_enemy=yes
                [/filter_adjacent]
            [/filter]
            variable=opp
        [/store_unit]

        [foreach]
            array=opp
            [do]
                [harm_unit]
                    [filter]
                        x,y=$opp[$i].x,$opp[$i].y
                    [/filter]
                    fire_event=yes
                    animate=yes
                    amount=0
                    poisoned=yes
                    delay=25
                [/harm_unit]
            [/do]
        [/foreach]
        {CLEAR_VARIABLE opp}
    [/event]
    [event]
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            range=melee
        [/filter_attack]
        [filter_second]
            ability=briar rose
        [/filter_second]
        [harm_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]
            fire_event=yes
            animate=yes
            amount=0
            poisoned=yes
            delay=25
        [/harm_unit]
    [/event]
#enddef
Post Reply