Is there a way to change an attack's range?

The place to post your WML questions and answers.

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.
Post Reply
weewah
Posts: 101
Joined: October 31st, 2019, 7:11 pm

Is there a way to change an attack's range?

Post by weewah »

As in, change an existing ranged attack into a melee attack? Or even a user-defined range?
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: Is there a way to change an attack's range?

Post by Helmet »

This is how I did it. Within [unit_type], I gave my custom unit two identical attacks, except one was range=melee and one was range=ranged. That way, no matter how the unit was attacked, it would counter-attack with the same weapon.

I don't know how to literally change "an existing ranged attack into a melee attack," though.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Is there a way to change an attack's range?

Post by beetlenaut »

The mechanism for doing this sort of thing is [object]. You give a unit a virtual object that can have a huge range of possible effects which are defined in the object's [effect] section. I would probably do this by defining two attack objects using a macro and adding or removing them as needed.

Working with objects this way can be a little complicated, so do it in small steps. The objects, effects, filters, attacks and so on can mostly be written and tested independently, and not combined until you have verified that each one works on its own.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Celtic_Minstrel
Developer
Posts: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Is there a way to change an attack's range?

Post by Celtic_Minstrel »

It looks like it was never documented until today, but the following works in an [object]:

Code: Select all

[effect]
	apply_to=attack
	# filter the attack to modify here
	set_range=melee
[/effect]
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply