• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Multiple Attack Types

Status
Not open for further replies.
Level 7
Joined
May 11, 2010
Messages
278
Is it possible to make a unit with two attacks enabled, where one is melee and the other is ranged?
So, if the unit is within, say, 125 range from target it will attack with Normal attack with melee range, but if it is further away it attacks with it's ranged attack?
 
You are forced to trigger that ;/
Use event unit - a unit is attacked (with some calculations related to range) and mix that with passive tranformation ability. That means, that unit should be transformed into it's "melee" form whenever it attacks unit in close range; and to "range" form whenever the distance between it and it's actual target is high enough.

Hero passive tranformation.
 
Level 9
Joined
Apr 26, 2011
Messages
403
Is it possible to make a unit with two attacks enabled, where one is melee and the other is ranged?
I is possible and I done it :
- inside world editor, there are Attack 1 & attack 2.
- enable attack 2
- set attack 1 to melee, ground only
- set attack 2 to range, air only

so my unit have two attack type base on what enemy they attack.

So, if the unit is within, say, 125 range from target it will attack with Normal attack with melee range, but if it is further away it attacks with it's ranged attack?
Not sure about this, (never try before).

you can try enable both attack, and set both to air & ground. see what happen
 
Level 8
Joined
Sep 23, 2007
Messages
357
I is possible and I done it :
- inside world editor, there are Attack 1 & attack 2.
- enable attack 2
- set attack 1 to melee, ground only
- set attack 2 to range, air only

so my unit have two attack type base on what enemy they attack.


Not sure about this, (never try before).

you can try enable both attack, and set both to air & ground. see what happen

Set Attack 1 to melee and Attack 2 to range, allow both to hit air AND ground units. Im pretty sure this will work.
 
Level 8
Joined
Jan 8, 2010
Messages
493
using Huanak's will cause you to change all ranged units to be Targeted As - Air, while all melee units will be Targeted As - Ground.

using Miles111's will actually cause the unit to only attack in melee. it's quite the same with orb based items. it enables a hero's Attack 2 index, meaning it can now target Air and Ground aside from the Attack 1's Ground only. but whenever the hero attacks a unit, it will check if it can attack first using Attack 1. if it can, it will not attack using Attack 2. so you will see that even if Attack 2 (500 range) with Air and Ground is enabled, a hero with an Orb of Fire will still attack a Footman at melee.
 
Level 8
Joined
Sep 23, 2007
Messages
357
using Huanak's will cause you to change all ranged units to be Targeted As - Air, while all melee units will be Targeted As - Ground.

using Miles111's will actually cause the unit to only attack in melee. it's quite the same with orb based items. it enables a hero's Attack 2 index, meaning it can now target Air and Ground aside from the Attack 1's Ground only. but whenever the hero attacks a unit, it will check if it can attack first using Attack 1. if it can, it will not attack using Attack 2. so you will see that even if Attack 2 (500 range) with Air and Ground is enabled, a hero with an Orb of Fire will still attack a Footman at melee.

So what your saying is, do what I said except set Attack 1 to range and Attack 2 to melee?
 
Level 8
Joined
Jan 8, 2010
Messages
493
it's just the same as setting Attack 1 to melee and Attack 2 to range, except the unit will now always attack at range since Attack 1 is ranged. i used that setting once, and even though i actually caused the unit be unable to move from a certain range, it still does not attack a ground unit at range. so i figured it first checks using Attack 1 before attacking with Attack 2.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Here you go. This system turned out to be pretty nice.


  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Trigger - Add to Change Attack <gen> the event (Unit - Paladin 0002 <gen> Acquires a target)
  • Change Attack
    • Events
      • Unit - A unit Is attacked
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Set u = (Attacking unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • u Equal to No unit
        • Then - Actions
          • Set u = (Triggering unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of u) Equal to Paladin
                  • (Unit-type of u) Equal to Paladin2
            • Then - Actions
              • Custom script: set udg_i = GetHandleId(GetTriggerEventId())
              • Set p1 = (Position of (Targeted unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • i Equal to 40
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Issued order) Equal to (Order(smart))
                          • (Issued order) Equal to (Order(attack))
                    • Then - Actions
                    • Else - Actions
                      • Skip remaining actions
                • Else - Actions
            • Else - Actions
              • Skip remaining actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of u) Equal to Paladin
                  • (Unit-type of u) Equal to Paladin2
            • Then - Actions
              • Set p1 = (Position of (Attacked unit))
            • Else - Actions
              • Skip remaining actions
      • Set p2 = (Position of u)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between p1 and p2) Greater than or equal to 175.00
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AttackMode[(Custom value of u)] Equal to False
            • Then - Actions
              • Unit - Add Transform Ranged to u
              • Unit - Remove Transform Ranged from u
              • Set AttackMode[(Custom value of u)] = True
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AttackMode[(Custom value of u)] Equal to True
            • Then - Actions
              • Unit - Add Transform Melee to u
              • Unit - Remove Transform Melee from u
              • Set AttackMode[(Custom value of u)] = False
            • Else - Actions
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)
      • Set u = No unit


How it works:
When a unit attacks another and it is further away than the specified range, it will switch to range if it is not ranged yet.
When a unit is issue an order to attack a unit, it will switch to ranged if if is far away.
When a unit aquires a target, it will switch to ranged if conditions are met.

How to import:
File -> Preferences, tick Automatically generate unknown...
Copy an paste Init and Change triggers to your map. I'm also using Bribe's unit indexer. Copy that to your map.
Copy the Transform abilities to your map.
Create a melee and ranged version of your units. Set the unit types correctly in the transform abilities.
Set the correct unit types in the conditions in Change Attack trigger.
Then add "Unit acquires a target" event for the units you want this system to work for.

Pastebin Link
 
Level 7
Joined
May 11, 2010
Messages
278
whoa whoa whoa, Maker! my intention was to ask if there is a simple way of doing this xP
as it seems it isn't, i'll stick with the design of my champ as it is :p
but thanks anyways everyone :)

but then, is it possible to trigger that when my unit uses wind walk, his attack gets changed to melee, and when windwalk ends (or is deactivated), his attack becomes "normal" (ranged) again?
do i have to use two units wich i trigger to swap/transform between or can i trigger like "activate My Units attack 2"?
Or do i need to check when he gains/loses the buff?
 
Level 8
Joined
Jan 8, 2010
Messages
493
it's just that there's no easy way to do it, except to create a system. you should try Maker's X]

anyway, you can just base off of your melee-to-range and vice versa spell from Channel. and yes, you need to create 2 units from the same type (one with the melee, and one from range) since you should have read the discussion with Miles111 about using Attack 1 and Attack 2, and use this Hero Passive Transformation. if ever you played DoTA, you should have an idea on changing melee-to-range from Troll Warlord.
 
Status
Not open for further replies.
Top