Is possible to attack an ally unit?

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
Posts: 38
Joined: January 22nd, 2018, 12:23 am

Is possible to attack an ally unit?

Post by Enderlook » January 22nd, 2018, 12:56 am

If you let me, I want to know how can I make a unit able to attack its allies (or own units) if it's possible. I don't have any idea of how to do that :(.
Also, if that is possible: is possible to make an attack with negative damage (to heal allies ;) )? I'm trying to make a kind of medic.
And yes, I am aware that if a "medic" try to attack (heal) an ally/own unit, that unit will counter attack... that is a problem that I think I'll be able to fix...
Last edited by Enderlook on January 22nd, 2018, 10:23 pm, edited 1 time in total.

User avatar
Forum Regular
Posts: 408
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Is possible to attack an ally unit?

Post by WhiteWolf » January 22nd, 2018, 7:41 am

If the allies attacking each other are not the player's side, then you could do that, by having both AI sides allied with the player, but not with each other. That way, the player as a viewer will see two allied side also fighting each other.
I think this is the closest you could get with "regular" ways.

If you only want to have specific units attack each others at specific times, then you could animate those attacks by hand. It's inconvenient, and [harm_unit] and [animate_unit] are currently not "clever enough" to simulate an attack without compromises, see this thread: viewtopic.php?f=21&t=47711

If you want to have the player be able to attack allied units (and the allies don't attack back in their turn), just modify alliance settings each side's turn.

These are the possibilities I could think of.

To attack own units, you have to modify the side of the unit, as own units can't be attacked. But you could change the specific units-to-be-attacked side to an enemy side, then change it back at the end of the side's turn.
It won't work for your medic though, I guess you want it to be able to attack any own unit at any time. Negative damage is also not allowed as far as I know you'd need to do it by manually adding the damage worth to the units HP. All in all, not really possible with this attack-method, I think :(
Have you considered working the medic through set_menu_item?
Author of the Underness Series, consisting of V parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Standalone works: The Ravagers - now for 1.14, with new bugs!

User avatar
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am

Re: Is possible to attack an ally unit?

Post by Sapient » January 22nd, 2018, 2:59 pm

It's possible I think, but it would be really clunky to implement. During the select event, you would have to put him on an extra hidden side with it's own team ("selected medic" team). Then you would need some kind of a custom skirmisher ability that lets him skirmish past his allies since they will be treated as enemies while he is on the "selected medic" team. Finally, reversing damage into healing would be the easy part, using an attacker hits event. Because it requires an extra hidden side, you would only be able to use it with custom scenarios.

I would recommend looking into [set_menu_item], as White Wolf suggested. "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."

Posts: 38
Joined: January 22nd, 2018, 12:23 am

Re: Is possible to attack an ally unit?

Post by Enderlook » January 22nd, 2018, 5:09 pm

Ok, I will see that. Thanks both of you.

Post Reply