• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Melee / Ranged Attack Swap + Animations

Status
Not open for further replies.

sentrywiz

S

sentrywiz

Ok, i have two questions:

1. How can i use a unit's two attacks, one melee the other ranged and somehow enable one and disable the other and vice versa when an item is being clicked?

2. How can i use the unit's specific ranged / melee animations to correlate with the attacks? I tried a trigger with "unit is attacked" and then ordering the attacking unit to cast a specific animation, but it didn't work.

any help is welcomed!
 
Last edited by a moderator:

sentrywiz

S

sentrywiz

1. use war club (as PublishedShadow suggested)
2. dont use abilities, you can instead directly let a unit play an animation instead.
this will, unlike an ability, not interrupt the attack itself.

1. Ok use warclub. can i tie that into an item or something, so that a unit's attack (1 or 2) changes when i click an item? Or?

2. yes but, i want the unit to animate a specific animation. otherwise it will attack with ranged using its randomized order of attack animations.
like for example, lets say the animation i want it to use is "gather lumber". how would i make the unit use that animation? note i also want the unit to only use that animation when attacking with ranged attacks.

any way of making this happen is okay, abilities, triggers, jass.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
1. Check if user of item has ability "Custom War club".
If not, add it, if he has, remove it.
When the item is removed from his inventory, you also remove the ability.
If Warclub is shown in the buttons, then add it to a spellbook and disable the spellbook for all players. Be sure to add/remove/check the spellbook in that case.

2. new trigger
Event: A unit is attacked.
Condition: Attacking unit has "Custom War Club" equal to true.
Action: Animation - Play <Attacking unit>'s "AttackRangeAnimation" animation.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
There's an orb that enables units to target air. It's a passive item ability. It's orb of fire. As for targeting ground, Gyrocopter Bombs (Passive) will probably work. It's another passive.

Units will only attack other units within a certain radius of a property that can be modified. Both the attack range and this radius must be satisfied. I don't remember what this property was. I just remember it can be changed in JASS.

A unit's attack can be completely disabled via Silence. However, you can also set a unit to not be able to target anything and then add the two abilities above and I think that might work ; ).

Unit attack speed can only be modified down a certain %. If you have a 5 second cooldown, you can never reach a .1 second cooldown. The alternative route is to disable a unit's attack during a custom cooldown and given unit's a .1 second cooldown. When the custom cooldown has expired, enable the unit's attack again. This will mess up AI though, meaning that they'll run away rather than chase. To account for this, you'll have to overwrite the standard unit AI and work with the targeting. Let Warcraft 3 target units as that would be very expensive in JASS. However, you can have a unit follow units to within a certain range (min range/max range) : ).

Orb of Fire
Adds 5 bonus fire damage to the attack of a Hero when carried. Deals spell damage. The Hero's attacks also become ranged when attacking air and do splash damage (14 radius) to nearby enemy units.
 
The easiest way to switch between animations is to use animation tags. If you add an animation tag, then the engine will check for that tag in a particular animation (attack, walk, stand) etc. with priority. For example, Grom Hellscream has an "alternate" animation tag that is used after he has drunk the blood of Mannoroth. If you add the "alternate" animation tag, the game will automatically use the "attack alternate", "stand alternate", etc. animations instead of the regular attack/stand as necessary.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Orbs do not make the unit ranged for ground units as the unit can still target those units with his regular attack.
However, there is no reason why he would want that in the first place.
But that is Blizzard, I guess.

Another method is make a secondary unit from that one and make that second unit have all the ranged attacks.
With a Bear Form ability with the stats in reverse (alternative unit is unit1, normal unit is unit2) and you add that ability and remove it again, the unit has been properly replaced.

About War Club on a tree... I dont really know how to do that then.
If casting point would be 0, it would be able to be done flawlessly, but that is not going to happen.
 

sentrywiz

S

sentrywiz

All of the suggestions posted sound viable. but the biggest issue are the animations.

@PurgeandFire how to add animation tags? where do i put them?
 
Level 8
Joined
Dec 10, 2006
Messages
67
A good example of a unit that does something similar to this is the Siege Engine with the Barrage upgrade. It has an attack for ground-based structures as well as an attack for aerial units with corresponding appropriate animations that use the tags "Attack One" and "Attack Two."
 

sentrywiz

S

sentrywiz

OK I LEARNT HOW TO USE ANIMATION TAGS (woot, enlightenment)

one with ranged, other with melee. i can now make as many as i want, each with separate animations and swap them out when items are clicked.

thank you all for your comments, +rep to each of you (special thanks to Purgeandfire for recommending animation tags)

Xonok, i took a peak at your link, and its good. i would use it, but since this is more of a "combat" transform and i want to keep the relative health and mana of the units, i might just go with the standard replace unit.
 
The the passive morph thing from Xonox. It's the cleanest solution. Only downside is that your unit will have a different type rawcode afterwards and that you need a duplicate of your unit in object editor for each attack type.

If you want to use Warclub, then just have it triggered by a dummy ability. Instantly create a valid target (like a tree destructable with no model or pathing) and set the number of attacks to 0. This will make the warclub permanent. You can freely remove the warclub ability then. The changed attack index will persist.
To change it back, simply have a second warclub ability that sets the attack index back to 1.


Note that this will hide the attack UI icon on heroes (on normal units, it works just fine). I've found no way around this unfortunately. If you don't want this, better morph the unit.
 

sentrywiz

S

sentrywiz

The the passive morph thing from Xonox. It's the cleanest solution. Only downside is that your unit will have a different type rawcode afterwards and that you need a duplicate of your unit in object editor for each attack type.

If you want to use Warclub, then just have it triggered by a dummy ability. Instantly create a valid target (like a tree destructable with no model or pathing) and set the number of attacks to 0. This will make the warclub permanent. You can freely remove the warclub ability then. The changed attack index will persist.
To change it back, simply have a second warclub ability that sets the attack index back to 1.


Note that this will hide the attack UI icon on heroes (on normal units, it works just fine). I've found no way around this unfortunately. If you don't want this, better morph the unit.

oh ok. so Xonox's solution is the best since it doesn't mess with stats and it keeps control groups. sounds pretty good.

what you suggest is also good. idk which to use now.

one question though: since i plan to have 3 attack types: ranged, melee and magic which will be swapped via the use of items, then i would need to create 3 morph transformations? it wouldn't mess with the unit somehow if it were to be transformed from one unit to another constantly?
 
Level 12
Joined
May 20, 2009
Messages
822
Orbs do not make the unit ranged for ground units as the unit can still target those units with his regular attack.
However, there is no reason why he would want that in the first place.
But that is Blizzard, I guess.

Another method is make a secondary unit from that one and make that second unit have all the ranged attacks.
With a Bear Form ability with the stats in reverse (alternative unit is unit1, normal unit is unit2) and you add that ability and remove it again, the unit has been properly replaced.

About War Club on a tree... I dont really know how to do that then.
If casting point would be 0, it would be able to be done flawlessly, but that is not going to happen.

This is not true. Orbs specifically enable a certain attack index. The reason why Orbs still let melee units use their melee attack is because Orbs enable both attack indexes, so the melee attack is still enabled and the attack used against air is also enabled so this the melee attack will have priority over ground targets and the air attack will allow for attacking air units.

I'd say Chaos ability, but I don't really know how it effects heroes.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Why has no one mentioned hero passive transformation? (aka "automorph")

Another method is make a secondary unit from that one and make that second unit have all the ranged attacks.
With a Bear Form ability with the stats in reverse (alternative unit is unit1, normal unit is unit2) and you add that ability and remove it again, the unit has been properly replaced.

this?
 
Status
Not open for further replies.
Top