WML RESOURCES by enclave
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.
Re: WML RESOURCES by enclave
I want to point that giving leadership this way can be problematic after unit advances. In WC II I have a way to give leadership to any unit and manage it after unit advances (using into [object])enclave wrote:Adding some ability to some unit at coordinates x,y=5,3
Here we will try to add LEADERSHIP LVL2
Code: Select all
#define WCT_LEADERSHIP_X LEVEL
[effect]
[filter]
level={LEVEL}
[/filter]
apply_to=new_ability
[abilities]
{ABILITY_LEADERSHIP_LEVEL_{LEVEL}}
[/abilities]
[/effect]
#enddef
#define WCT_LEADERSHIP
{WCT_LEADERSHIP_X 1}
{WCT_LEADERSHIP_X 2}
{WCT_LEADERSHIP_X 3}
{WCT_LEADERSHIP_X 4}
#enddef
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: WML RESOURCES by enclave
Thanks tekelili, an interesting and useful example
It would be a lot more efford and pain to do it my way in your case:
And it would also require these defines.. plus define for each level
Thanks zookeeper! It would be great to have a part of wiki with many examples of codes like we do here.. very useful!
Sometimes there is big lack of examples when I'm trying something new.. like [filter_vision] and such.. rare things.
It would be a lot more efford and pain to do it my way in your case:
Code: Select all
#define WCT_LEADERSHIP_X LEVEL
[store_unit]
[filter]
level={LEVEL}
[/filter]
variable=temp_unit_level{LEVEL}
[/store_unit]
{FOREACH temp_unit_level{LEVEL} counter_i}
{INSERT_LEADERSHIP_LVL{LEVEL}_ABILITY_INTO_UNIT_ARRAY temp_unit_level{LEVEL}[$counter_i]}
{NEXT counter_i}
#enddef
#define WCT_LEADERSHIP
{WCT_LEADERSHIP_X 1}
{WCT_LEADERSHIP_X 2}
{WCT_LEADERSHIP_X 3}
{WCT_LEADERSHIP_X 4}
#enddef
Spoiler:
Sometimes there is big lack of examples when I'm trying something new.. like [filter_vision] and such.. rare things.
unexpectedly rebuilt? do you know any example situation? I would really like to know in which cases it might happen.. would be very useful. And also you think, or it really happens? Thanks very much in advance!You can remove abilities via direct variable manipulation like you did, but I think then they might suddenly re-appear when the unit gets unexpectedly rebuilt in some situation. You should generally do things like that with an [object] unless there's a specific reason not to.
Re: WML RESOURCES by enclave
Eh, I'm not sure about situations other than advancement.enclave wrote:unexpectedly rebuilt? do you know any example situation? I would really like to know in which cases it might happen.. would be very useful. And also you think, or it really happens? Thanks very much in advance!
Re: WML RESOURCES by enclave
Ok, nice to know anyway Thanks!zookeeper wrote:Eh, I'm not sure about situations other than advancement.enclave wrote:unexpectedly rebuilt? do you know any example situation? I would really like to know in which cases it might happen.. would be very useful. And also you think, or it really happens? Thanks very much in advance!
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML RESOURCES by enclave
Advancing to a different unit type is the main situation where a unit might get rebuilt. I'm not sure if loading a game or recalling a unit rebuilds it (possibly not, though I recall having some issues related to that). It's also rebuilt if you change its variation (usually with anenclave wrote: unexpectedly rebuilt? do you know any example situation? I would really like to know in which cases it might happen.. would be very useful. And also you think, or it really happens? Thanks very much in advance!
[object]
, I think) or use [transform_unit]
. It's not rebuilt if it gets an AMLA.Re: WML RESOURCES by enclave
its also rebuild if an object is removed because the duration= expires.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML RESOURCES by enclave
Which includes use of
[remove_object]
in 1.13.Re: WML RESOURCES by enclave
Thanks very much guys
Back to business...
If anyone needs to filter mounted unit types then here we go:
Just easier when you don't need to find and write all these unit types yourself.. they already there for your convenience.. copy paste.. what can be easier? I found a nice source here: https://units.wesnoth.org/1.12/mainline ... nline.html
PS. the codes in the spoiler may not work properly.. I have not tested them but I assume they work, let me know if not if you trying to use them.
Back to business...
If anyone needs to filter mounted unit types then here we go:
Spoiler:
PS. the codes in the spoiler may not work properly.. I have not tested them but I assume they work, let me know if not if you trying to use them.
Last edited by enclave on October 7th, 2016, 7:02 pm, edited 1 time in total.
Re: WML RESOURCES by enclave
Hardcoding unit types... meaning it will only ever apply to one version of one era. Not good for a resource.
Resource is not indented. Unstore unstores one. Not all units are recruited see https://wiki.wesnoth.org/EventWML#unit_ ... er_only.29. Not all mounted units are recruited as mounted units. Not all mounted units remain as mounted units. Not all variations of single unit type have same state of mountedness.
Resource is not indented. Unstore unstores one. Not all units are recruited see https://wiki.wesnoth.org/EventWML#unit_ ... er_only.29. Not all mounted units are recruited as mounted units. Not all mounted units remain as mounted units. Not all variations of single unit type have same state of mountedness.
Re: WML RESOURCES by enclave
well I guess my example really bad, all I wanted is to give people a list of mounted unit types that they can just copy paste into their filter to, for example, give double damage vs mounted units.. to their spearman. Before I found the link I provided I was just going into wesnoth core and was opening every single cfg for every single unit to get their "type".. which was a long and annoying work.Ravana wrote:Hardcoding unit types... meaning it will only ever apply to one version of one era. Not good for a resource.
Resource is not indented. Unstore unstores one. Not all units are recruited see https://wiki.wesnoth.org/EventWML#unit_ ... er_only.29. Not all mounted units are recruited as mounted units. Not all mounted units remain as mounted units. Not all variations of single unit type have same state of mountedness.
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: WML RESOURCES by enclave
Zombies mean you can't match mounted units with a simple list of types. If you want a filter that will match all core mounted units, you need something like this:
By the way, wolves are not mounted creatures, so including them in your filter is quite silly. I omitted them from mine. You also forgot the gryphons.
It can also be simplified in 1.13 using the new
Code: Select all
[filter]
type=Cavalryman,Dragoon,Cavalier,Horseman,Knight,Lancer,Grand Knight,Paladin,Elvish Scout,Elvish Rider,Elvish Outrider,Khaiyal,Faris,Qanas,Mufariq,Hadaf,Rami,Saree,Jawal,Chocobone,Wolf Rider,Goblin Knight,Goblin Pillager,Direwolf Rider,Gryphon Rider,Gryphon Master
[or]
type=Walking Corpse,Soulless
variation=mounted
[/or]
[/filter]
It can also be simplified in 1.13 using the new
type_tree
attribute:
Code: Select all
[filter]
type_tree=Elvish Scout,Cavalryman,Horseman,Khaiyal,Rami,Chocobone,Wolf Rider,Gryphon Rider
[or]
type_tree=Walking Corpse
variation=mounted
[/or]
[/filter]
Re: WML RESOURCES by enclave
Thanks very much Celtic_Minstrel, thats really useful!
Back to topic..
Working with arrays
a) Rename arrays
b) Copy arrays
c) inserting arrays etc..
have fun..
a) Renaming arrays
b) Copying arrays
c) Inserting arrays etc
Then just use them like any macro like so: {RENAME_ARRAY old_name new_name}
There is more options in wiki: https://wiki.wesnoth.org/InternalAction ... riables.5D
you can insert into specified index.. and I think if you don't specify mode, it defaults to replace.
Maybe you could do similar with "to_variable", but it's possible that I have already tried and failed, I can't remember.
Back to topic..
Working with arrays
a) Rename arrays
b) Copy arrays
c) inserting arrays etc..
have fun..
a) Renaming arrays
Code: Select all
#define RENAME_ARRAY ARRAY_OLD_NAME ARRAY_NEW_NAME
[set_variables]
name={ARRAY_NEW_NAME}
mode=replace
[insert_tag]
name=value
variable={ARRAY_OLD_NAME}
[/insert_tag]
[/set_variables]
{CLEAR_VARIABLE {ARRAY_OLD_NAME}}
#enddef
Code: Select all
#define COPY_WHOLE_ARRAY ARRAY_OLD_NAME ARRAY_NEW_NAME
[set_variables]
name={ARRAY_NEW_NAME}
mode=replace
[insert_tag]
name=value
variable={ARRAY_OLD_NAME}
[/insert_tag]
[/set_variables]
#enddef
Code: Select all
#define INSERT_ARRAY_TO_ARRAY ARRAY_1 TO_ARRAY_2
[set_variables]
name={TO_ARRAY_2}
mode=insert
[insert_tag]
name=value
variable={ARRAY_1}
[/insert_tag]
[/set_variables]
#enddef
#define MERGE_ARRAY_TO_ARRAY ARRAY_1 TO_ARRAY_2
[set_variables]
name={TO_ARRAY_2}
mode=merge
[insert_tag]
name=value
variable={ARRAY_1}
[/insert_tag]
[/set_variables]
#enddef
#define APPEND_ARRAY_TO_ARRAY ARRAY_1 TO_ARRAY_2
[set_variables]
name={TO_ARRAY_2}
mode=append
[insert_tag]
name=value
variable={ARRAY_1}
[/insert_tag]
[/set_variables]
#enddef
There is more options in wiki: https://wiki.wesnoth.org/InternalAction ... riables.5D
you can insert into specified index.. and I think if you don't specify mode, it defaults to replace.
Maybe you could do similar with "to_variable", but it's possible that I have already tried and failed, I can't remember.