• 🏆 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!

Range Units switching to melee

Status
Not open for further replies.
Level 2
Joined
Aug 4, 2008
Messages
12
My mod is very simular to the warhammer series, where there is mainly range units but when a melee unit gets in range of the range unit, the range unit than turn into melee and is forced to use melee while attacking that unit.

I wondering if there is an easy way to do that or do i have to make a whole system on this?

Thanks for all the help
 
You can use Bear Form ability, where the Normal Unit Form will be your unit with Range stats and your Alternate Unit Form a unit with Melee stats (Just change the "Combat - Attack 1 - Range" field in each unit; don't forget to add "Weapon Type" to "Missile" for the range unit).
You can also use Orb of Fire Melee Bonus (which enabled the second attack index of the hero); make sure that Targets allowed in Combat - Attack 2 - Targets Allowed do not contain only "Air" units, but Copy and Paste the Combat - Attack 1 - Targets allowed to this field.
 
Level 2
Joined
Jun 6, 2008
Messages
7
Use the "Chaos" abilities found in the Orc tree, and make a ranged version and a melee version of your desired unit. When the Chaos ability is added to your target (through triggers), it changes (like if you click the Bear Form ability), and thus you can do this with triggers in any situation you desire. Unit ability cooldowns and unit buffs are maintained.

I'll throw in an example later tonight.
 
Level 2
Joined
Jun 6, 2008
Messages
7
I attached a small map illustrating how the "Chaos" ability works.

Pros:
  • Stats tied to a hero's level (attribute points, damage, armor, etc.) are maintained when swapping unit.
  • Ability cooldowns are maintained (the unit isn't replaced per se).
  • Buffs stay on the unit.

Cons:
  • You need two units for each unit type you want to be able to swap between melee attack mode and ranged attack mode. The units should look the same and have all the same abilities, except for the ranged unit having the "Swap to melee" ability, and the melee unit having the "Swap to ranged" ability.
  • The unit's animation resets when swapping units.

I'm sure some of the JASS crazies can make something much more potent, but from my perspective this is a lot better than the Bear Form solution.


Force unit to go melee
You can add a trigger like this to force a unit to go melee when in close range to the target it attacks:

  • Events
    • Unit - A unit Is attacked
  • Conditions
    • (Unit-type of (Attacking unit)) Equal to Swapper (Ranged)
    • (Distance between (Position of (Attacking unit)) and (Poisition of (Attacked unit)) Less than or equal to 250.00
  • Actions
    • If ((Level of Swap Ranged for (Attacking unit)) Great than 0) then do (Unit- Remove Swap Ranged from (Attacking unit)) else do (Do nothing)
    • Unit - Add Swap Melee to (Attacking unit)
 

Attachments

  • MeleeRangedSwapper.w3x
    19.7 KB · Views: 71
Last edited:
Level 2
Joined
Jun 6, 2008
Messages
7
@ Destiny.Knight

That will involve a lot more triggers for handling damage, and the attack animation of the unit(s) won't change.
 
Level 2
Joined
Jun 6, 2008
Messages
7
@ DarkAngelAzazel

You can, easily. But how will you mana the swapping between Attack Index 1 and Attack Index 2? I have experimented with Orbs (Orb of Fire, Orb of Frost, etc.) which enables Attack Index 2, however, I haven't been able to make it work properly, and I haven't been able to conceive another bullet proof method for managing Attack Indexes.

And just a note: Upgrades can't be undone or "degraded", so using this is not an option.

I'm all ears if you know of a clever method. :)

And then again there is of course the problem with the unit's attack animation. One animation should show a melee swing, the other one a bow or gun firing animation.
 
Status
Not open for further replies.
Top