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

How do I add a ranged attack to a melee unit when it equips an item

Status
Not open for further replies.
Level 2
Joined
Feb 17, 2009
Messages
8
i'm trying to make a unit when it acquires a bow to gain a ranged attack to replace it's basic melee attack. i tried replacing the unit with a ranged version but it crashed my game, haha. i also tried to make an autocast spell based off searing / cold arrows, they work, but i have to click to use it every single time which is really lame. can anyone help me out?
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
That's to enable ranged attacks, but you also need to play a ranged attack animation instead of the melee attack animation. I'm not known with making animations, but my first thought of this would be: Since there are 'stand' and 'stand alternate' animations with models like moveable Night Elf buildings, would it be possible to change the attack animation in the same way by making 'attack' and 'attack alternate' animations?
Just sharing thoughts, but I don't know if this is possible. Any verification on this would be nice :thumbs_up:
 
Level 2
Joined
Feb 17, 2009
Messages
8
i know i can use a ranged attack, i got that to work; but i want to replace the melee attack with a ranged attack. i'll try and paint a picture.
so i have a villager model whom i'm using as a hero. when he equips the Beginner's Bow it grants him +4 damage and a ranged attack (with a range of 350) but i want it to replace his melee attack. i don't want two attacks. i want a single attack. the ranged attack to replace the melee attack while the bow is equipped.

You ever mess with a units 2 different attacks?

Might be good.

awesome sarcasm, stupid idea. why would i want to clutter a hero's status window with even MORE garbage. not to mention that two attacks wont solve my problem at all since i want to REPLACE a single attack.
 
Last edited by a moderator:
Level 5
Joined
Jan 25, 2006
Messages
103
There is no way to do that, as far as i know. Even if there is, it would require massive amounts of triggers and the hero would still not have attack animation, projectile speed may be wrong, etc...
What you could do is create a second villager, same model, name, armor, stats, etc, except his attack. Make his attack ranged obviously.

Now with triggers you do this:
Untitled Trigger 001
Events
Unit - A unit Sells an item (from shop)
Conditions
(Sold Item) Equal to (Item carried by (Matching unit) of type Tome of Experience)
Actions
Set temp = (Buying unit)
Unit - Create 1 Child (2) for Player 1 (Red) at (Position of (Sold Item)) facing Default building facing degrees
Hero - Add (Hero level of (Triggering unit)) experience to (Last created unit), Hide level-up graphics
Unit - Remove temp from the game

Temp is a unit variable, use this to restore your old unit, if for example the player removes that item, so its melee again!
 
Level 15
Joined
Dec 18, 2007
Messages
1,098
You could replace the unit with another, use something like Bearform. But that is a rather stupid Idea :p
I'm not sure about this but I doubt you can have more than 2 kinds of attack for 1 unit so I would suggest using different units if you want them to be able to use many kinds of weapons.
 
Level 2
Joined
Feb 17, 2009
Messages
8
Incinerate ability FTW.

this is the same kind of spell as searing arrows and cold arrows, it wont work properly or atleast the way i'd like it to.

maybe there's a way i can force the unit to use spells instead of his attack. is there a way to disable my regular attack without replacing the unit and his attack? whatever works. i just need to make it so when the item is equipped he attacks at range. someone linked a map with triggers that enable an item to increase their range, but there's TONS of variables and the triggers look so messy i don't feel like implementing it, and i am not sure if it enables my melee attack to work at distance.

i just tried again replacing the unit with a ranged version and the game crashes every time, for no apparent reason. it doesn't even give me an error message; it just, wont let me replace the villager with a ranged version of himself.

so i need to force auto cast a spell and prevent my auto/regular attack.
 
Last edited by a moderator:
Level 5
Joined
Jan 25, 2006
Messages
103
My bad, gave you error trigger.
There is no matching unit.

It should be unit acquires and item.
item of type bow
and do the same actions.
Will also test it myself and reply later, i don't have time now!
 
Level 2
Joined
Feb 17, 2009
Messages
8
My bad, gave you error trigger.
There is no matching unit.

It should be unit acquires and item.
item of type bow
and do the same actions.
Will also test it myself and reply later, i don't have time now!

don't worry about trying this, i already did this earlier, i got it to give them an ability to cast searing arrows, of course the searing arrow spell is just a dummy spell for enabling a ranged attack.

Incinerate isn't an autocast ability. It's passive!

just tested this out, it doesn't work.
 
Last edited by a moderator:
Level 2
Joined
Feb 17, 2009
Messages
8
Well then, all of the mods have less than half a brain. You're supposed to edit posts, not make more. Anyway, I have helped, I offered another suggestion, orb abilities.

just make the skill and screenshot it for me or anything, i obviously cant figure it out on my own if i still need to keep checking this thread.
 
Level 3
Joined
Feb 24, 2009
Messages
42
awesome sarcasm, stupid idea. why would i want to clutter a hero's status window with even MORE garbage. not to mention that two attacks wont solve my problem at all since i want to REPLACE a single attack.

why don't you offer some help then? don't just say incinerate, why don't you tell me how to make it work instead? because i just used both the basic incinerate and arrow form.
and noone with half a brain would give someone bad rep just because they posted twice inside their thread. it's not like i'm making multiple threads, i'm just adding side notes.


Edit: Hey look I can edit and not multi-post!



Holy crap anger problems.

I may be wrong, but I took his comment to be of use.

Could it be possible to set up two attacks, lock the second one, and trigger the item picked up to lock the first and unlock the second?

Once again, you have anger problems.
 
Last edited:
Level 5
Joined
Jan 25, 2006
Messages
103
Okay tell me/us what you've tested and how, maybe show us some triggers or just give us general idea how you done it, so we can be of more help.

Also I just tested out my idea with the changes and it works for me, it creates a unit with ranged attack on the position of purchased item, adds the experience to the new unit and removes the old unit.

Will post the triggers in a while, I'm still kind of busy right now!

EDIT: here is the trigger:
Untitled Trigger 001
Events
Unit - A unit Sells an item (from shop)
Conditions
(Item-type of (Sold Item)) Equal to Orb of Fire
Actions
Unit - Create 1 Archmage for Player 1 (Red) at (Position of (Sold Item)) facing Default building facing degrees

Works like charm.

Or you could also enable the second attack as people have suggested and then just control when to enable it or disable it, either way is fine!

Also if you use my triggers, add the other actions I posted previously, adding unit variable to store your hero, add the experience and then remove the initial hero.
 
Last edited:
Level 12
Joined
Mar 16, 2006
Messages
992
Just because a unit has 1 melee attack, and 1 ranged attack, doesn't mean it will show in the UI. Think of how the Ancient Protector functions. It's exactly like that. From melee to range. You can enable attack A, attack B, both, or none.

Editing a unit's attack A and attack B, and then using an ability to control which attack is enabled is a surefire method to get the result you want. Try not to let all that angst get in the way of the eventual realization that people are giving you advice that you should take.
 
Level 2
Joined
Feb 17, 2009
Messages
8
harharhar, i figured out that by replacing the unit it made my game crash, but if i remove it and create the ranged version of the hero it doesn't crash. but now, i need to figure out how to move the items to the new hero, and then back again when they drop the bow, so the player doesn't lose their items.

and also, thanks slickr for providing help when noone else could no.
impatience =/= anger issues.
you guys just give less-than-acceptable answers and don't believe in showing how to go about things to someone who doesn't understand it.
 
Last edited:
We, who apparently "aren't giving adequate advice", are trying to help you learn. If we offer a whole trigger, how are you going to learn from it? We are giving you suggestions for abilities to play around with that may solve your problem if you go about them in the right way. If you want a whole trigger, request a system. If you want "adequate advice" - and our advice is more than adequate, it would help you very much if you listened to us other than saying "You're not giving me adequate advice!!! Fuck you!!!" as soon as you see we aren't posting you whole triggers - post here.

And yeah. Sort out your anger problem. Normal people don't get impatient with people who give them good advice. People with anger problems, however...
 
Level 2
Joined
Feb 17, 2009
Messages
8
We, who apparently "aren't giving adequate advice", are trying to help you learn. If we offer a whole trigger, how are you going to learn from it? We are giving you suggestions for abilities to play around with that may solve your problem if you go about them in the right way. If you want a whole trigger, request a system. If you want "adequate advice" - and our advice is more than adequate, it would help you very much if you listened to us other than saying "You're not giving me adequate advice!!! Fuck you!!!" as soon as you see we aren't posting you whole triggers - post here.

And yeah. Sort out your anger problem. Normal people don't get impatient with people who give them good advice. People with anger problems, however...

no, it's impatience, sorry you have a hard time distinguishing the difference between two different words.

and a trigger would have helped me a lot, sorry the answer "ORB 3FF3CTZ LOLZ, NUB" wasn't good enough.

and finally i am having trouble getting my hero's experience to carry over to the created unit, i have it set up to where it would logically work, but it's not working.

unit - created hero (ranged) at position of triggering unit
hero - set last created unit's experience at level of triggering unit
unit - remove triggering unit from the game
hero - create beginner's bow (obviously not the dummy-to-trigger weapon) and give to last created unit.

why doesn't that work?
 
Level 5
Joined
Jan 25, 2006
Messages
103
Hey guys stop the fight alright. In a sense you both are right, but if you can't or are unwilling to help this guy out some more element of water better stop writing and telling him to do it himself, since it only creates a mess and you are not helping.

Okay now for the trigger:
Actions -
Hero - Add (Hero level of (buying unit)) experience to (Last created unit), Hide level-up graphics

As far as items goes it will be a bigger effort, I haven't thought it out yet, but I'm sure it can't be that hard.

Will test some triggers later and post an update, in the meantime you should try do the other elements of your map.
 
Level 11
Joined
Feb 16, 2009
Messages
760
Ill say it. use the Chaos ability to instantly create an alternate unit. You only need the trigger

Event
Unit buys an item

Condition
Item equal to (YOUR ITEM)

Action
Add (your chaos version) To triggering unit.

Edit chaos data field New unit type to get teh desired unit.


TADAAAAAAA
 
Level 7
Joined
Jul 20, 2008
Messages
377
Soo, why again is he replacing the hero when orbs do exactly what he wants?

This. Freakin' this.

Edit your unit's second attack in the object editor then disable the second attack. Giving the unit an orb ability (such as orb of fire) that enables the second attack will... well, enable its second attack.
 
Ill say it. use the Chaos ability to instantly create an alternate unit. You only need the trigger

Event
Unit buys an item

Condition
Item equal to (YOUR ITEM)

Action
Add (your chaos version) To triggering unit.

Edit chaos data field New unit type to get teh desired unit.


TADAAAAAAA
Replacing units is not really the best option is it? Hero name changing etc...
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
...

Object editor -> Units -> Combat
There are two attacks per hero. Make attack one melee and attack two ranged. Than give your item an ability based of an orb ability(orb of lightning, poison and etc). Edit that ability to enable attack two and disable attack one. So when you get that item, the unit will become ranged.
 
Level 15
Joined
Aug 14, 2007
Messages
936
My idea here is more complicated but It will not crash game plus it is efficient


When a unit aquires the item, condition will check for unit type

You store the int, str and agility in variable of int, level, facing
store the items in array of item
then you drop and hide the item
after that, create the replacement and set the level and exp set the attributes
right... now give the new one the items, set the facing as well
Right now he should be in reset animation mode
Thats all simple and easy to code, yet efficient

Remember to remove memory leaks!
 
Status
Not open for further replies.
Top