Help: Unit that makes adjacent units move faster
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.
Help: Unit that makes adjacent units move faster
I am looking to code something in the ability of a unit such that at the start of each turn, any units adjacent to it get X movement over their base amount.
Anyone know where to start? Research is turning up nothing.
Anyone know where to start? Research is turning up nothing.
Creator of 120+ units Lord of the Rings era and campaign now outdated & lost.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.
Re: Help: Unit that makes adjacent units move faster
Turn refresh event, store_unit with filter filter_adjacent to find which units to change. Then foreach over those stored and with VARIABLE_OP add those moves, then unstore to save changes.
Re: Help: Unit that makes adjacent units move faster
Ravana wrote:Turn refresh event, store_unit with filter filter_adjacent to find which units to change. Then foreach over those stored and with VARIABLE_OP add those moves, then unstore to save changes.
Will this work in multiplayer? Can I place the event into the unit file? If not where?
This also looks like it will use a loop, which I am not too comfortable in WML despite lots of basic and c++ programming. Wouldnt {MODIFY_UNIT x,y=$x2,$y2 moves 0} work?
Creator of 120+ units Lord of the Rings era and campaign now outdated & lost.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.
Re: Help: Unit that makes adjacent units move faster
Yes
Something like the above should work.
But iterating over stored units is really not that hard...
Code: Select all
[modify_unit]
[filter]
[filter_adjacent]
ability=speedboost2
[/filter_adjacent]
[/filter]
moves="$($this_unit.movement + 2)"
[/modify_unit]
But iterating over stored units is really not that hard...
Code: Select all
[store_unit]
[filter]
[filter_adjacent]
ability=speedboost2
[/filter_adjacent]
[/filter]
variable=stored_units
[/store_unit]
{FOREACH stored_units i}
[set_variable]
name=stored_units[$i].moves
value=$stored_units[$i].movement
[/set_variable]
[set_variable]
name=stored_units[$i].moves
add=2
[/set_variable]
[unstore_unit]
variable=stored_units[$i]
[/unstore_unit]
{NEXT i}
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
- ChaosRider
- Posts: 846
- Joined: April 15th, 2012, 1:15 pm
Re: Help: Unit that makes adjacent units move faster
Amazing, after 240 items they are still some abilities which dont required so long wml code... aura of speed (weaker +1 mp, normal +2 mp, greater +3 mp at turn start for adjected not enemies). Thx for idea !
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
Re: Help: Unit that makes adjacent units move faster
Thank you Sapient! The only issue I found with the code you supplied is that it sets moves to 0 each time instead of +2. I changed the variable from movement to max_moves to resolve.
To share with others, here is the more finished code that is working for me.
The following code can be applied into as many unit files as you want without the effects stacking.
To share with others, here is the more finished code that is working for me.
The following code can be applied into as many unit files as you want without the effects stacking.
Code: Select all
[event]
name=turn refresh
first_time_only=no
[modify_unit]
[filter]
race=Infantry
side="$side_number"
[filter_adjacent]
type=Supply_Truck, Supply_Truck_Vet, Supply_Truck_Elite, Armoured_Supply_Truck, Armoured_Supply_Truck_Vet
is_enemy=no
[/filter_adjacent]
[/filter]
moves="$($this_unit.max_moves + 2)"
[/modify_unit]
[/event]
Creator of 120+ units Lord of the Rings era and campaign now outdated & lost.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.
Re: Help: Unit that makes adjacent units move faster
Using ability filter instead of type filter would make the code easier to maintain.