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

Unit Comes Within Range {kill unit B and give item to unit A}

Status
Not open for further replies.
Level 2
Joined
Apr 5, 2008
Messages
10
I would like to know a trigger to make the following happen: Unit A comes within range of Unit B. Kill Unit B. Add a item to Unit A. The problem I have is that Unit B and the item aren't on the map at the start of the game and there will be multiple Unit B's on the map. I don't want all Unit B's to die when one is approached.

What happens in game: Unit A will be running around the map and every X seconds Unit B will spawn. When Unit Type A comes within 100 range of Unit Type B I would like Unit Type A to be given an item and Unit B to die.

I don't want ALL Unit B's on the map to die.

Every time a Unit B is spawned I DON'T want the previous one to die.
 
Last edited:
Level 36
Joined
Feb 5, 2009
Messages
4,630
You could set the Acquisition range of Unit A to what ever range you want units to die from it (this comes under attack, in case you don't know). Then, set the attack of Unit A to 0 (This is accomplished by setting the attack type to none, that base damage to -1 and the attack dice to 1 with 1 side) and have a trigger that when Unit A attacks a unit, that unit dies instantly. Then you'd have a trigger that creates an item at the location of Unit A (in this case, the variable would be attacking unit. Yes, this is just 1 trigger, it should be enough) and then have a Unit - Issue Order - Give Last Created Item to Attacking Unit. Easy peasy. Let me know if you want anything changed and don't know quite how to do it.

Oh, and you might want to set the cooldown of Unit A's attack to 0.01 (or whatever the smallest cooldown available is) and also set the range to what range you want the Unit B's to die. The Acquisition Range just specifies the range a unit can come with in this unit before this unit decides to attack. It can also limit the attack range (you can't just set a unit's attack range to 2500 if the Acquisition is only 600. The range would just be 600 that way).
 
Level 2
Joined
Apr 5, 2008
Messages
10
You could set the Acquisition range of Unit A to what ever range you want units to die from it (this comes under attack, in case you don't know). Then, set the attack of Unit A to 0 (This is accomplished by setting the attack type to none, that base damage to -1 and the attack dice to 1 with 1 side) and have a trigger that when Unit A attacks a unit, that unit dies instantly. Then you'd have a trigger that creates an item at the location of Unit A (in this case, the variable would be attacking unit. Yes, this is just 1 trigger, it should be enough) and then have a Unit - Issue Order - Give Last Created Item to Attacking Unit. Easy peasy. Let me know if you want anything changed and don't know quite how to do it.

Oh, and you might want to set the cooldown of Unit A's attack to 0.01 (or whatever the smallest cooldown available is) and also set the range to what range you want the Unit B's to die. The Acquisition Range just specifies the range a unit can come with in this unit before this unit decides to attack. It can also limit the attack range (you can't just set a unit's attack range to 2500 if the Acquisition is only 600. The range would just be 600 that way).

Thanks for help.

I have given Unit A a permanent immolation that kills Unit B when they come within 100 range of each other. When Unit B dies a item drops on the ground but I don't know how to get the item on Unit A. Also, Unit A is sliding on ice making it hard for it to pick up the item.

With the Unit - Issue Order - Give Last Created Item to Attacking Unit action, a unit is required to give the item to attacking/killing unit which is impossible because the item is on the ground.

SOLVED
EDIT: I got it working! :D

  • Trigger
  • Unit - A unit Dies
  • (Unit-type of (Dying unit)) Equal to Unit B
  • Unit Group - Remove (Killing unit) from SLIDING GROUP
  • Item - Create ITEM at (Position of (Dying unit))
  • Item - Hide (Last created item)
  • Unit - Order (Killing unit) to Right-Click (Last created item)
  • Wait 0.01 seconds
  • Unit Group - Add (Killing unit) to SLIDING GROUP
 
Last edited:
Level 17
Joined
Aug 20, 2007
Messages
1,122
http://www.hiveworkshop.com/forums/pastebin.php?id=bis5wm

Here ya go.

I think you'll like it because its instant...

Anyway, there are a few settings there...

It features the following (Based on what I think you needed)

1. Kill unit near a preloaded unit
2. Kill unit near a non-preloaded unit
3. Give non-/preloaded unit an item (stacks all together)
4. Respawn kill unit with immunity from the trigger
5. Kill more specific kinds of units
6. Instant kill

If you need any help in twitching any options, ask me.

EDIT:

I forgot all about Unit Groups.

You can use it in the map I gave you.
 
Level 36
Joined
Feb 5, 2009
Messages
4,630
Thanks for help.
SOLVED
EDIT: I got it working! :D

  • Trigger
  • Unit - A unit Dies
  • (Unit-type of (Dying unit)) Equal to Unit B
  • Unit Group - Remove (Killing unit) from SLIDING GROUP
  • Item - Create ITEM at (Position of (Dying unit))
  • Item - Hide (Last created item)
  • Unit - Order (Killing unit) to Right-Click (Last created item)
  • Wait 0.01 seconds
  • Unit Group - Add (Killing unit) to SLIDING GROUP

Cool, though I'm sure you could just create the item at the unit you want to have it, then do what I said about using the trigger to give it to the unit in question. However, if it works this way, it's probably best to leave it that way :p.

Sounds like you're creating a Maze map. I had no idea the unit would be constantly on the go, sliding like that and all lol.
 
Level 2
Joined
Apr 5, 2008
Messages
10
Cool, though I'm sure you could just create the item at the unit you want to have it, then do what I said about using the trigger to give it to the unit in question. However, if it works this way, it's probably best to leave it that way :p.

Sounds like you're creating a Maze map. I had no idea the unit would be constantly on the go, sliding like that and all lol.

I improved the trigger so Unit A doesn't stop moving. When Unit B is killed, Unit A instantly gets Item.

Trigger working perfectly.

SOLVED
 
Level 2
Joined
Apr 5, 2008
Messages
10
What the fuck.

Did you even bother looking at my map searingshadow?

I did something just for you and you're not even bothering me...

Yes I did. Thanks a lot. I've taken ideas from your map and ideas from my own to make what I think is a efficient trigger.

I just didn't want to create a new post to say "Thanks a lot!!" because I consider this spam.

SOLVED!
 
Level 17
Joined
Aug 20, 2007
Messages
1,122
Yes I did. Thanks a lot. I've taken ideas from your map and ideas from my own to make what I think is a efficient trigger.

I just didn't want to create a new post to say "Thanks a lot!!" because I consider this spam.

SOLVED!

oh... the reason I got mad was cause you haven't mentioned anything about my post yet...

rep me please
 
Status
Not open for further replies.
Top