• 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.

Making a unit ranged

Status
Not open for further replies.
Level 11
Joined
Sep 12, 2008
Messages
657
Is it possible that when my unit picks up an item of type X, it becomes ranged?..
I need it for bows.. if he picks up a bow for example, he becomes ranged, when he drops it, he loses his range..
 
Level 11
Joined
Sep 12, 2008
Messages
657
Well.. my problem is that its a hero..
How ever.. if i can make it set the agi\str\int\damage\life it could be nice XD (leakless allso)
Since i got "Add stats"
And it includes damage and life..
 
Level 4
Joined
Oct 11, 2008
Messages
90
Make a new hero exactly like the melee one but give him ranged attack. Then make a trigger when the unit picks the item, replace it with the new ranged unit. All the exp, stats and stuff will be transfered to the new hero, except his hero name (this is a good case if you only have 1 hero name per hero).
P.S. Doing this might cause the game to enter an infinite loop, so be careful about it. To avoid such a think add a trigger condition like "unit type of hero manipulating item equal to "your melee hero".
 
Yes, there is an easier way. When you create a custom hero based off of a melee one, you'll find that it also has an unused ranged attack. Simply give the item in question the ability to enable the second attack (and disable the first attack to make it purely ranged), tinker around with the ranged attack so it hits every target, and it should work. If you're unsure of how to enable/disable attacks using items, check out the Orb of Fire abilities and such.

EDIT: Hmm... disabling the first attack doesn't appear possible, sorry if I mislead you :/
 
Level 11
Joined
Sep 12, 2008
Messages
657
Gah..
This is bad.. if any 1 here plays sotdrp..you can use the " 'ranged' " Command,
adding a unit a spell, if its used, it makes the unit ranged.. but its attack is gone, and it cannot be reputted into melle again.. i supose i can use "ranged" guy, exactly the same way i make mount hero..
just put diff base damage like i think balance would work, set agi\str\int to the caster,
remove caster, make a new unit, make it have the same stats.. count how many times u used the addstats option on damage\health, for integer X give unit the item manual of health... seems possible even if its a bit hard ;o
 
Level 5
Joined
Nov 22, 2009
Messages
181
why not do what wazz said but instead of disabling the attack (which can't be done) just set the melee damage to 0 or something like that. or if you do use the replacing method you should create a variable array and do something like
  • Convert to Ranged
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Triggering unit) has an item of type Bow) Equal to True
      • (Unit-type of (Triggering unit)) Equal to Paladin
    • Actions
      • Set Stats[1] = (Strength of (Hero manipulating item) (Exclude bonuses))
      • Set Stats[2] = (Agility of (Hero manipulating item) (Exclude bonuses))
      • Set Stats[3] = (Intelligence of (Hero manipulating item) (Exclude bonuses))
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Itemsdropped[(Integer A)] = (Item carried by (Hero manipulating item) in slot (Integer A))
          • Hero - Drop the item from slot (Integer A) of (Hero manipulating item)
      • Unit - Replace (Triggering unit) with a Paladin using The old unit's relative life and mana
      • Hero - Modify Strength of (Last replaced unit): Set to Stats[1]
      • Hero - Modify Agility of (Last replaced unit): Set to Stats[2]
      • Hero - Modify Intelligence of (Last replaced unit): Set to Stats[3]
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Give Itemsdropped[(Integer A)] to (Last replaced unit)
      • Set Stats[1] = 0
      • Set Stats[2] = 0
      • Set Stats[3] = 0
and then to revert him back:
  • Convert to Melee
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Last dropped item)) Equal to Bow
      • (Unit-type of (Triggering unit)) Equal to Paladin (ranged)
    • Actions
      • Set Stats[1] = (Strength of (Hero manipulating item) (Exclude bonuses))
      • Set Stats[2] = (Agility of (Hero manipulating item) (Exclude bonuses))
      • Set Stats[3] = (Intelligence of (Hero manipulating item) (Exclude bonuses))
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set Itemsdropped[(Integer A)] = (Item carried by (Hero manipulating item) in slot (Integer A))
          • Hero - Drop the item from slot (Integer A) of (Hero manipulating item)
      • Unit - Replace (Triggering unit) with a Paladin using The old unit's relative life and mana
      • Hero - Modify Strength of (Last replaced unit): Set to Stats[1]
      • Hero - Modify Agility of (Last replaced unit): Set to Stats[2]
      • Hero - Modify Intelligence of (Last replaced unit): Set to Stats[3]
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Give Itemsdropped[(Integer A)] to (Last replaced unit)
          • Set Itemsdropped[(Integer A)] = No item
      • Set Stats[1] = 0
      • Set Stats[2] = 0
      • Set Stats[3] = 0
 
Last edited:
Level 5
Joined
Nov 22, 2009
Messages
181
Perhaps you can also make a string variable, set it to the hero's name and set the replacement's name = the variable. Also you should edit the attack animations so that it actually looks like a ranged attack. Unfortunately I do not know how to do that as I'm still rather new to this stuff. I'm actually working on my first map right now.
 
Last edited:
You can create a dead zone on the map. (Put pathing blockers and everything around it) Simply run a loop, and use this function:
JASS:
native GetHeroProperName takes unit whichHero returns string

Umm.. Basically something like this:
JASS:
    local string s = GetHeroProperName(HeroUnit)
    local string x
    local unit g
    loop
        exitwhen x == s
        set g = CreateUnit(Player(0),herorawcode,x_deadzone,y_deadzone,270)
        set x = GetHeroProperName(g)
        if x != s then
            call RemoveUnit(g)
        endif
    endloop
    set g = null

Bleh, something like that. I did this quickly. ;P But you get the idea... If you need to use GUI, I am not sure if there is a GetHeroProperName() function in it, but you can just use custom script.
 
Level 11
Joined
Sep 12, 2008
Messages
657
Okay.. i dont really know jass... but i can read it a bit..
but wanna hear what i understended up there?

To topic:
Well, i do have only 1 name for the hero..
So i guess itll work.. btw, is there integers in jass? ;p

Edit: Gah, heres the trigger:
for some reason it wont work.. it just drops the bow and does nothing..


  • Wear a bow
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Become Ranged
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Wealding_Bow[(Player number of (Owner of (Casting unit)))] Equal to False
        • Then - Actions
          • Game - Display to (All players) the text: true
          • Set Wealding_Bow[(Player number of (Owner of (Casting unit)))] = True
          • Set Wealding_Bow_Stats[0] = (Strength of (Casting unit) (Exclude bonuses))
          • Set Wealding_Bow_Stats[1] = (Agility of (Casting unit) (Exclude bonuses))
          • Set Wealding_Bow_Stats[2] = (Intelligence of (Casting unit) (Exclude bonuses))
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Set Wealding_Bow_Items[(Integer A)] = (Item carried by (Casting unit) in slot (Integer A))
              • Hero - Drop Wealding_Bow_Items[(Integer A)] from (Casting unit)
          • Unit - Replace (Casting unit) with a Villiager Bow using The old unit's relative life and mana
          • Hero - Modify Strength of (Casting unit): Set to Wealding_Bow_Stats[0]
          • Hero - Modify Agility of (Casting unit): Set to Wealding_Bow_Stats[1]
          • Hero - Modify Intelligence of (Casting unit): Set to Wealding_Bow_Stats[2]
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Hero - Give Wealding_Bow_Items[(Integer A)] to (Last replaced unit)
          • Set Wealding_Bow_Stats[0] = 0
          • Set Wealding_Bow_Stats[1] = 0
          • Set Wealding_Bow_Stats[2] = 0
          • Animation - Add the lumber animation tag to (Last replaced unit)
        • Else - Actions
          • Set Wealding_Bow[(Player number of (Owner of (Casting unit)))] = False
          • Game - Display to (All players) the text: false
 
Last edited:
Level 11
Joined
Feb 23, 2009
Messages
577
Teelo is right. But it requires that your unit does not have an orb effect already.

Change 1st attack of unit to melee
Change 2nd attack of unit to range (do all changes)
ATTACK 1 & 2 are DISABLED!

Orb of Lightning:
Enable attack index 1 = makes hero melee
Enable attack index 2 = makes hero range

Simply give the Item the spell.

(No triggers needed at all!)

Only problem is your unit may not attack unarmed. Unless you add a few triggers.
 
Level 5
Joined
Jul 18, 2010
Messages
159
hey i've readed this topic and i've got problem if i'll pick up my bow i need to learn skills again how i can make the abillities stay at the unit? ThisPOT idea doesn't work couse my blade master allways shoots ;<
 
Last edited:
Level 5
Joined
Nov 22, 2009
Messages
181
can you set the ability level for each spell to a variable array and implement it into each loop when replacing the unit the same way the other stats are?
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
hey, if a unit pick up an item like orb of venom an when it attack the air unit i will be ranged?
why use trigger then?
add the second attack of the unit add the range and the projectiles add the damage and all of the nessesarry needs and when unit pick up an item and the item has ability like orb of venom it will automaticly become ranged attacker
 
Status
Not open for further replies.
Top