Checking weapon specials ids when there is more than one [Resolved]
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.
- ChaosRider
- Posts: 1435
- Joined: April 15th, 2012, 1:15 pm
Checking weapon specials ids when there is more than one [Resolved]
This topic is about that I have a code to check unit each weapon weapon special and when weapon has only one weapon special then it works well but when weapon has more than one weapon special than it catch only first weapon special. Could you explain me why my code doesnt work well for more than 1 weapon special on the same weapon?
Answer or the good working code will be added to the my addons Count Units Cost ( viewtopic.php?t=60193 ) and Stealing Weapons Mode ( viewtopic.php?p=700789&hilit=stealing+weapons#p700789 ).
I've game in Polish language so on the screenshots "Cios w plecy" mean "Backstab" and "Szarża" mean "Charge".
First code try:
Second code try:
Part of the code for setting gold cost per weapon special:
"Unit weapons specials cost: 2" should be 4.5 (backstab (+2) and charge (+2.5), total 4.5)
Answer or the good working code will be added to the my addons Count Units Cost ( viewtopic.php?t=60193 ) and Stealing Weapons Mode ( viewtopic.php?p=700789&hilit=stealing+weapons#p700789 ).
I've game in Polish language so on the screenshots "Cios w plecy" mean "Backstab" and "Szarża" mean "Charge".
First code try:
Spoiler:
Spoiler:
Code: Select all
{UNITS_COST_WEAPONS_SPECIALS damage "charge" "2.5"}
{UNITS_COST_WEAPONS_SPECIALS berserk "berserk" "5"}
{UNITS_COST_WEAPONS_SPECIALS damage "backstab" "2"}
Last edited by ChaosRider on October 4th, 2025, 2:58 pm, edited 1 time in total.
Creator of WOTG (+6500 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
- ChaosRider
- Posts: 1435
- Joined: April 15th, 2012, 1:15 pm
Re: Checking weapon specials ids when there is more than one
Resolved.
Below working code:
Below working code:
Code: Select all
#define UNITS_COST_WEAPONS_SPECIALS TAGS NAME VALUE
{FOREACH check_unit_cost.attack[$i].specials.{TAGS} j}
[if]
[variable]
name=check_unit_cost.attack[$i].specials.{TAGS}[$j].id
equals={NAME}
[/variable]
[then]
{VARIABLE_OP weapons_specials_unit_cost add {VALUE}}
[/then]
[/if]
{NEXT j}
#enddef
Creator of WOTG (+6500 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.