Elmor's wml questions
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.
- artisticdude
- Moderator Emeritus
- Posts: 2424
- Joined: December 15th, 2009, 12:37 pm
- Location: Somewhere in the middle of everything
Re: Elmor's wml questions
Oh, you want to change terrain defenses? My apologies, I missed your earlier post.
In that case, no, I don't think you can manipulate variables to change that (although I might be wrong about that). You can use [object] and [effect] to manipulate terrain defense, like so:
Note that you are actually adding defense by using negative numbers. Positive numbers will decrease defense.
In that case, no, I don't think you can manipulate variables to change that (although I might be wrong about that). You can use [object] and [effect] to manipulate terrain defense, like so:
Code: Select all
[object]
silent=yes
[effect]
apply_to=defense
replace=no
[defense]
deep_water=-5%
shallow_water=-5%
swamp_water=-5%
reef=-5%
flat=-5%
sand=-5%
forest=-5%
hills=-5%
mountains=-5%
village=-5%
castle=-5%
cave=-5%
frozen=-5%
unwalkable=-5%
impassable=-5%
fungus=-5%
[/defense]
[/effect]
[/object]
"I'm never wrong. One time I thought I was wrong, but I was mistaken."
Re: Elmor's wml questions
sorry, that code doesn`t work
look, I also want to kill unit if it`s no more another units, but it doesn`t work:
look, I also want to kill unit if it`s no more another units, but it doesn`t work:
Code: Select all
[event]
name=new turn
first_time_only=no
[if]
[not]
[have_unit]
side=$side_turn
[not]
id=Leader$side_turn
[/not]
[/have_unit]
[/not]
[then]
[kill]
[filter]
side=$side_turn
id=Leader$side_turn
[/filter]
[/kill]
[/then]
[/if]
[/event]
Re: Elmor's wml questions
1. Using a
->
->
2.I'm not sure whether variable substitution can do that, but you could simply filter for "canrecruit=yes" instead.
3. The auto-stored variable containing the currently active side's number is named "side_number", not "side_turn".
4. Don't use [filter] in [kill].
side turn
event here would be much more senseful:->
side turn
event: triggers when it's another side's turn->
new turn
event: triggers when a completely new turn begins, i.e. turn number / ToD change2.
Code: Select all
id=Leader$side_turn
3. The auto-stored variable containing the currently active side's number is named "side_number", not "side_turn".
4. Don't use [filter] in [kill].
Co-Creator of The Fellowship of the Clay (BfW 1.10) ~~ Maintainer of the German Code of Conduct
How to isolate problematic WML code ~~ WML error messages and their reasons
How to isolate problematic WML code ~~ WML error messages and their reasons
Re: Elmor's wml questions
thanks, it works
now, please, help me, the biggest question
I want to make all units die after number of turns, but it must be different number for different units
I mean, for example, all units must die after 10 turns, but counting from turn, each of them was placed in game separately
I was thinking about something like that:
may be there is a way to dedicate variable value to unit?
now, please, help me, the biggest question
I want to make all units die after number of turns, but it must be different number for different units
I mean, for example, all units must die after 10 turns, but counting from turn, each of them was placed in game separately
I was thinking about something like that:
Code: Select all
{VARIABLE "unitnumber" 0} #here unit takes number
[unit]
{VARIABLE "unit_turns_max$unit_number" 10}
{VARIABLE "unit_turns$unit_number" 0}
{VARIABLE_OP "unit_number" add 1} #here counting starts for other units numbers
[/unit]
[event]
name=new turn
[if]
[variable]
name=unit_turns$unit_number
greater_than=$unit_turns_max$unit_number
[/variable]
[/if]
[then]
??? # I don`t know how to filter unit with needed variable value
[/then]
[/event]
-
- Posts: 876
- Joined: November 28th, 2008, 6:18 pm
Re: Elmor's wml questions
Yes, any unit can store variables. See http://wiki.wesnoth.org/SingleUnitWMLElmor wrote:may be there is a way to dedicate variable value to unit?
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
Re: Elmor's wml questions
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Elmor's wml questions
sorry, still can`t understand how to save variable inside unit
can you, please, help me understand?
must it be something like storing units? or it must be inside unit tag?
somebody?
can you, please, help me understand?
must it be something like storing units? or it must be inside unit tag?
somebody?
- Elvish_Hunter
- Posts: 1576
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Elmor's wml questions
First you need to store the unit somewhere, with the usual [store_unit] tag.
Then, you need to use [set_variable]. Let's say, for example, that you have your unit stored into the my_unit variable. You'll useThen, you'll have to unstore the unit, with [unstore_unit]. Of course, if there is more than one unit stored inside your variable, you'll have to use {FOREACH} and {NEXT} as appropriate.
It is possible also to place the [variables] tag inside a [unit] tag:
Then, you need to use [set_variable]. Let's say, for example, that you have your unit stored into the my_unit variable. You'll use
Code: Select all
[set_variable]
name=my_unit.variables.my_var
value=5
[/set_variable]
It is possible also to place the [variables] tag inside a [unit] tag:
Code: Select all
[unit]
id=my_unit
type=Yeti
x,y=1,1
[variables]
my_var=5
[/variables]
[/unit]
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Re: Elmor's wml questions
yes, I see, but I need to transform value, that contains variable, to numerical value. But for each unit it must be different value
I mean something like that
or this variable, since it was set, doesn`t change it`s value, despite of value`s variable value?
I mean something like that
Code: Select all
[set_variable]
name=my_unit.variables.my_var
value=$turn_number
[/set_variable]
Re: Elmor's wml questions
Store all units every turn, and then use FOREACH to iterate through all of them, modifying each one's variables.
Anyway, it would be better to not set it to the turn number, but to sub 1 every turn. Set my_unit.variables.my_var to the number of turns they should survive, using a recruit/recall/whatever event, sub 1 each turn and check whether any unit's count is 0, then kill these.
At least that's how I understood what you want to do.
Anyway, it would be better to not set it to the turn number, but to sub 1 every turn. Set my_unit.variables.my_var to the number of turns they should survive, using a recruit/recall/whatever event, sub 1 each turn and check whether any unit's count is 0, then kill these.
At least that's how I understood what you want to do.
Co-Creator of The Fellowship of the Clay (BfW 1.10) ~~ Maintainer of the German Code of Conduct
How to isolate problematic WML code ~~ WML error messages and their reasons
How to isolate problematic WML code ~~ WML error messages and their reasons
-
- Posts: 462
- Joined: June 8th, 2006, 3:25 am
Re: Elmor's wml questions
Actually, I think it would be better to set it to the turn you want them to die. Consider:
Saves a lot of storing/unstoring and variable modification.
Code: Select all
[set_variable]
name=my_unit.variables.die_on
value="$($turn_number+5)"
[/set_variable]
Code: Select all
[event]
name=new turn
first_time_only=no
[kill]
[filter_wml]
[variables]
die_on=$turn_number
[/variables]
[/filter_wml]
[/kill]
[event]
Re: Elmor's wml questions
sorry, still don`t understand
I got unit1, that advances to unit2. I need to kill all unit2 after they spend their lifespan.
I used this one inside [unit_type]:
and this one inside [multiplayer]:
How must it be for real?
I got unit1, that advances to unit2. I need to kill all unit2 after they spend their lifespan.
I used this one inside [unit_type]:
Code: Select all
[set_variable]
name=my_unit.variables.die_on
value=5
[/set_variable]
Code: Select all
[event]
name=new turn
first_time_only=no
{VARIABLE_OP die_on add -1}
[store_unit]
[filter]
[filter_wml]
[variables]
die_on=0
[/variables]
[/filter_wml]
[/filter]
kill=yes
[/store_unit]
[/event]
Re: Elmor's wml questions
1.
Try: (untested)
2.
(again untested)
3. You decrement only the global variable
[set_variables]
is not allowed inside [unit_type]. You'll need to put that in a recruit
event and filter if the primary unit is of the correct unit type.Try: (untested)
Code: Select all
[event]
name=recruit
first_time_only=no
[filter]
type=your_unit_type
[/filter]
[set_variable]
name=unit.variables.die_on
value=5
[/set_variable]
[/event]
[wiki=InternalActionsWML#.5Bstore_unit.5D][store_unit][/wiki]
takes a variable=
key where it saves the units to. If you don't want to keep them, you can just use [wiki=DirectActionsWML#.5Bkill.5D][kill][/wiki]
(be sure not to use a [filter]
tag inside kill).(again untested)
Code: Select all
[kill]
[filter_wml]
[variables]
die_on=0
[/variables]
[/filter_wml]
[/kill]
die_on
, but you have to do this for every unit of your unit type. This would be easier if you followed Exasperation's suggestion.UMC Story Images — Story images for your campaign!
Re: Elmor's wml questions
I support Exasperation's method:
Crend: you forgot unstoring
Code: Select all
[event]
name=post advance
furst_time=only=no
[filter]
type=(unit type after advancing)
[/filter]
[set_variable]
name=unit.variables.die_on
value="$($turn_number+5)"
[/set_variable]
[unstore_unit]
variable=unit
find_vacant=no
[/unstore_unit]
[/event]
[event]
name=new turn
first_time_only=no
[kill]
[filter_wml]
[variables]
die_on=$turn_number
[/variables]
[/filter_wml]
[/kill]
[event]
unit
after variable modification Co-Creator of The Fellowship of the Clay (BfW 1.10) ~~ Maintainer of the German Code of Conduct
How to isolate problematic WML code ~~ WML error messages and their reasons
How to isolate problematic WML code ~~ WML error messages and their reasons
Re: Elmor's wml questions
and if I`m not using recruit and advance, I`m using [unit] and [transform_unit]?
can I use it inside [unit]? and what to do with transforming? variable will be saved?
can I use it inside [unit]? and what to do with transforming? variable will be saved?