how give all unit a abilitie?

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
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

how give all unit a abilitie?

Post by ERROR1025 »

i hope make a add-on,player can choose "give all units abilitie" to start
I want to choose different abilitie for different side in the start settings
Or ask to select the abilitie right after the game starts
If it is selected after the game starts, I hope that all players can know the choices of all players, and can choose multiple or not
Last edited by ERROR1025 on January 28th, 2023, 2:19 am, edited 1 time in total.
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: how give all unit a abilitie?

Post by beetlenaut »

I can't see any way to have a different list of choices for different factions in the start settings, but you can do this right after the game starts. You can use [message] with an [option] for each ability that allows the user to choose what they want. Then, you would use [object] in the option's [command] in order to add the ability to the unit. The [object] will have an [effect] with the key apply_to=new_ability. You can look up those things in the wiki to see how they work.

Your question refers to a project with many different parts. You would get better help if you asked a more specific question, but this information should get you started on one way to do it.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: how give all unit a abilitie?

Post by ERROR1025 »

I don't understand how to add abilitie for "all units", can you provide a sample WML? This will give leadership to "all units" for the side 1
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: how give all unit a abilitie?

Post by Helmet »

ERROR1025 wrote: January 28th, 2023, 2:14 am I don't understand how to add abilitie for "all units", can you provide a sample WML? This will give leadership to "all units" for the side 1
I didn't test it, so you may need to de-bug it...
I suggest you read the WML guide about [event], [object], [effect] and [filter].

Using [filter], you can limit the "effect" to only certain types of units.

Code: Select all


[event]
    name=start, recruit
    first_time_only=no
    [modify_unit]
    [filter]
    	side=1
    [/filter]
	[object]
		[effect]
			apply_to=new_ability
			{ABILITY_LEADERSHIP}
		[/effect]
	[/object]
    [/modify_unit]
[/event]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: how give all unit a abilitie?

Post by beetlenaut »

You can also use [foreach] to loop through all the units one at a time so they can each have a different ability. However, you should make it work for just one faction and just one unit first. Don't try to do everything at the same time.

Code: Select all

[event]
    name=start

    [store_unit]
        [filter]
            side=1
        [/filter]
        variable=all_units
    [/store_unit]

    [foreach]
        array=all_units
        [do]
            [object]
                [filter]
                    # Variable this_item is automatically stored by [foreach].
                    id=$this_item.id
                [/filter]
                [effect]
                    apply_to=new_ability
                    [abilities]
                        {ABILITY_LEADERSHIP}
                    [/abilities]
                [/effect]
            [/object]
            [message]
                speaker=$this_item.id
                message="I just got leadership."
            [/message]
        [/do]
    [/foreach]
[/event]
Helmet's code is close, but the macro needs to be inside an [abilities] tag under [effect].
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: how give all unit a abilitie?

Post by ERROR1025 »

why my wml can not work?
log is:
Mandatory WML child missing yet untested for.Please report
not have more info
Attachments
_main.cfg
(664 Bytes) Downloaded 23 times
User avatar
Ravana
Forum Moderator
Posts: 2934
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: how give all unit a abilitie?

Post by Ravana »

[if] is not allowed as toplevel tag.
[event] is not recognized condition https://wiki.wesnoth.org/ConditionalAct ... ition_Tags.

To start you can move [event] under [modification] and remove [if].
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: how give all unit a abilitie?

Post by ERROR1025 »

but i need the event only work on 1UR=1
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: how give all unit a abilitie?

Post by beetlenaut »

The [if] will work inside the [event].
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: how give all unit a abilitie?

Post by ERROR1025 »

the WML can not work too
i hope it give all side 1 unit LEADERSHIP,if 1UR=yes
Attachments
ProWesnothStart-modf.zip
(656 Bytes) Downloaded 26 times
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: how give all unit a abilitie?

Post by Helmet »

ERROR1025 wrote: February 2nd, 2023, 1:56 am the WML can not work too
i hope it give all side 1 unit LEADERSHIP,if 1UR=yes
I don't know what's wrong, but I noticed you had some code in the beginning, but not in your recent version.
Did you leave it out on purpose?
Good luck.

Code: Select all

#ifdef MULTIPLAYER
[binary_path]
	path=data/add-ons/ProWesnothStart-modf/
[/binary_path]
. . .
#endif
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: how give all unit a abilitie?

Post by ERROR1025 »

Helmet wrote: February 2nd, 2023, 2:07 am
ERROR1025 wrote: February 2nd, 2023, 1:56 am the WML can not work too
i hope it give all side 1 unit LEADERSHIP,if 1UR=yes
I don't know what's wrong, but I noticed you had some code in the beginning, but not in your recent version.
Did you leave it out on purpose?
Good luck.

Code: Select all

#ifdef MULTIPLAYER
[binary_path]
	path=data/add-ons/ProWesnothStart-modf/
[/binary_path]
. . .
#endif
purpose
I referenced the WML for XP Modification and I noticed that these deleted WMLs were not needed
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: how give all unit a abilitie?

Post by beetlenaut »

ERROR1025 wrote: February 2nd, 2023, 1:56 am i hope it give all side 1 unit LEADERSHIP,if 1UR=yes
Your [effect] is missing an [abilities] tag. The rest looks good now though.

Code: Select all

[effect]
    apply_to=new_ability
    [abilities]
        {ABILITY_LEADERSHIP}
    [/abilities]
[/effect]
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ERROR1025
Posts: 46
Joined: February 23rd, 2020, 10:18 am

Re: how give all unit a abilitie?

Post by ERROR1025 »

Code: Select all

[modification]
id=PWSM
name="ProWesnothStart-modf(PWSM)"
#define PWSMR V
[resistance]
max_value=100
add={V}
[/resistance]
#enddef
	    [options]
        [checkbox]
            id=S1R
            default=false
            name=_"SIDE 1 R"
            description=_"side 1"
        [/checkbox]
        [slider]
            id=S1RV
            default=0
            min=-100
            max=100
            step=1
            name=_"1 R"
            description=_"P1 R"
        [/slider]
        [checkbox]
            id=S2R
            default=false
            name=_"SIDE 2 R"
            description=_"side 2"
        [/checkbox]
        [slider]
            id=S2RV
            default=0
            min=-100
            max=100
            step=1
            name=_"2 R"
            description=_"P2 R"
        [/slider]
	[/options]
[event]
    name=start, recruit
    first_time_only=no
[if]
	[variable]
		name=S1R
		equals=yes
	[/variable]
	[then]
    [modify_unit]
    [filter]
    	side=1
    [/filter]
		[effect]
			apply_to=new_ability
	[abilities]
        {PWSMR S1RV}
	
    [/abilities]
		[/effect]
    [/modify_unit]
	[/then]
[/if]
[/event]
[event]
    name=start, recruit
    first_time_only=no
[if]
	[variable]
		name=S2R
		equals=yes
	[/variable]
	[then]
    [modify_unit]
    [filter]
    	side=2
    [/filter]
		[effect]
			apply_to=new_ability
	[abilities]
        {PWSMR S2RV}
    [/abilities]
		[/effect]
    [/modify_unit]
	[/then]
[/if]
[/event]
[/modification]
I'm not sure where the problem is, when S1R=yes,S1RV=10
all side1 unit resistance *2(i need +10)
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: how give all unit a abilitie?

Post by beetlenaut »

If you had used :inspect to look at a side 1 unit, you would have seen this line in the new resistance section: add="S1RV". You need a $ in front of the values you send to the macro. (You also need to indent in a normal way if you are going to share your code. It is very hard to read.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Post Reply