Clean "Hit and Run" weapons special
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.
Clean "Hit and Run" weapons special
Is there a way to make a weapon special that adds back to the attacking unit some movement points at the end of the attack? I've found some some solutions but they were hackish and weren't weapon specials, they were abilities.
Re: Clean "Hit and Run" weapons special
Only difference between ability and weapon special is the filter. So if you call those hacky there is no better way.
Re: Clean "Hit and Run" weapons special
Thanks, I dit it, based on Era of Magic Goblin Assassin "Hit and Run" ability:
Weapon special to be placed on the unit .cfg:
Event to be placed on scenario .cfg:
Any idea on how to make AI recognise the extra move point and use it as usual? So far the AI just ignores the ability.
Weapon special to be placed on the unit .cfg:
Code: Select all
#define WEAPON_SPECIAL_RETREAT
[dummy]
id=retreat
name= _ "retreat"
description=_"The attacker gains one move point after attacking"
[/dummy]
#enddef
Code: Select all
###WEAPON_SPECIAL_RETREAT
[event]
name=attack_end
id=retreat_event
first_time_only=no
[filter_attack]
#name=$weapon
special=retreat
[/filter_attack]
{VARIABLE_OP unit.moves add 1}
[unstore_unit]
variable=unit
{COLOR_WHITE}
text="1"
find_vacant=no
[/unstore_unit]
[/event]
Re: Clean "Hit and Run" weapons special
Look at the mods Antar and Assassins in the Forest. I think they have something similar to what you want.
- lhybrideur
- Posts: 369
- Joined: July 9th, 2019, 1:46 pm
Re: Clean "Hit and Run" weapons special
There is also Hit and run in Loti
Here is the code
Here is the code
Code: Select all
#define WEAPON_SPECIAL_HIT_AND_RUN
[dummy]
id=hit and run
name= _ "hit and run"
description= _ "When this attack is used, the unit regains half of its max MP."
[/dummy]
#enddef
Code: Select all
[event]
name=attack end
first_time_only=no
[filter_attack]
special=hit and run
[/filter_attack]
{VARIABLE_OP unit.moves add "$($unit.max_moves/2)"}
[unstore_unit]
variable=unit
find_vacant=no
advance=no
[/unstore_unit]
[/event]
Re: Clean "Hit and Run" weapons special
It can be done way easier. As long as you define "Hit and Run" as an ability or weapon special, that allows you to move after attacking.
You can use "movement_used=0". "This determines how many movement points using this attack expends.
By default all movement is used up, set this to 0 to make attacking with this attack expend no movement."
You can also add a dummy special to the attack, that explains how it works.
You can use "movement_used=0". "This determines how many movement points using this attack expends.
By default all movement is used up, set this to 0 to make attacking with this attack expend no movement."
Code: Select all
[attack]
name=Hitandrun
description=_"Hit and Run"
icon=attacks/dagger-curved.png
type=blade
range=melee
damage=3
number=5
movement_used=0
[/attack]
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
- lhybrideur
- Posts: 369
- Joined: July 9th, 2019, 1:46 pm
Re: Clean "Hit and Run" weapons special
This is something different. The first solution, proposed Gibimbius and I consume all the movement then add back some. Your solution consider the unit can use what's left of its movement after the attack.
-
- Posts: 5
- Joined: May 23rd, 2018, 8:10 pm
Re: Clean "Hit and Run" weapons special
AFAIK movement_used solution only makes sense if the unit has skirmisher (or the enemy has no ZOC), as otherwise it will lose all moves after moving next to the enemy even if it doesn't attack. Event solution can work even without skirmisher.
Re: Clean "Hit and Run" weapons special
I see, just wanted to mention it, as it is an easier solution for a hit and run special and Gibimbius wanted such an easy solution. I use it for my hit and run specials and it works fine, considering some drawbacks such as ZOC.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer