how to limit movement upgrade?
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.
how to limit movement upgrade?
i want to limit movement upgrade to 14.
thanks in advance, sapientx. hahaha
thanks in advance, sapientx. hahaha
Well, I'm just going to type something off the top of my head here without testing it:
Then whenever you are about to increase movement, first check that current_movement is less than the desired maximum.
Code: Select all
[event]
name=side turn
[store_unit]
[filter]
side=$side_number
canrecruit=1
[/filter]
kill=no
variable=side_leader_store
[/store_unit]
{VARIABLE_OP current_movement format $side_leader_store.moves}
{CLEAR_VARIABLE side_leader_store}
[/event]
Code: Select all
[if]
[variable]
name=current_movement
less_than=14
[/variable]
# your code here
[/if]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
yay sapient it works
you only missed one thing...
at first the codes you provided didn't work and i didn't know that that's what caused the problem. so i tried to use side_leader_store.moves instead of current_movement. i changed your code making it this way ...
and then for the movement upgrade option ...
it works fine, so i let it be that way haha. thanks again
you only missed one thing...
Code: Select all
[object]
silent=yes
[effect]
apply_to=movement
increase=1
[/effect]
[/object]
# this :)
{VARIABLE_OP current_movement add 1}
Code: Select all
[event]
name=side turn
first_time_only=no
{CLEAR_VARIABLE side_leader_store}
[store_unit]
[filter]
side=$side_number
canrecruit=1
[/filter]
kill=no
variable=side_leader_store
[/store_unit]
[/event]
Code: Select all
[if]
[variable]
name=side_leader_store.moves
less_than=14
[/variable]
# my code
[/if]
good point! I forgot to increment the counter.
Since the unit is moving after you stored it into a variable, the stored variable still has the correct # moves. That is an interesting way to do it, too.
Since the unit is moving after you stored it into a variable, the stored variable still has the correct # moves. That is an interesting way to do it, too.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Right. I was afraid that might happen. The problem is that side turn events fire before moves are restored from the last turn. So, to work around this you can store a variable for each side at the beginning of the game, and restore it each turn.
Like so:
However, there is still a special case for the very first turn, which is not considered a side turn:
Then to check and increment:
I tested it, and it works for me.
Like so:
Code: Select all
[event]
name=side turn
first_time_only=no
{VARIABLE_OP movement_var format "stored_movement$side_number"}
[if]
[variable]
name=$movement_var
less_than_equal_to=0
[/variable]
[then]
[store_unit]
[filter]
side=$side_number
canrecruit=1
[/filter]
kill=no
variable=side_leader_store
[/store_unit]
{VARIABLE_OP $movement_var format $side_leader_store.moves}
{CLEAR_VARIABLE side_leader_store}
[/then]
[/if]
[/event]
Code: Select all
[event]
name=start
first_time_only=yes
{VARIABLE_OP movement_var format "stored_movement1"}
[store_unit]
[filter]
side=1
canrecruit=1
[/filter]
kill=no
variable=start_leader_store
[/store_unit]
{VARIABLE_OP $movement_var format $start_leader_store.moves}
{CLEAR_VARIABLE start_leader_store}
[/event]
Code: Select all
[if]
[variable]
name=$movement_var
less_than=14
[/variable]
# additional conditions here
[then]
{VARIABLE_OP $movement_var add 1}
# your code here
[/then]
[/if]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."