How to find the enemy with in range of my hero?

micolord

You can change this now in User CP.
Reaction score
0
For example I'm making a skill that is within the range of my hero 1 random enemy units gets a damage. Please help me! I tried Unit Group thingy and I just can't do it! :(
 

Necrach

You can change this now in User CP.
Reaction score
62
Find the unit using a unit group and then picking a random unit from that group

Trigger:
  • spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • Set temp_point = (Position of (Triggering unit))
      • Set temp_group = (Units within 300.00 of temp_point matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))
      • Custom script: call RemoveLocation (udg_temp_point)
      • Custom script: call DestroyGroup (udg_temp_group)
      • Set random_enemy = (Random unit from temp_group)


You might want to add conditions for the picked unit, like not magic immune, is a ground unit, non-hero, or whatever. And then just use that "random_enemy" variable for the rest of the trigger, something like this;

Trigger:
  • [...]
    • Unit - Cause (Triggering unit) to damage random_enemy, dealing 300.00 damage of attack type Spells and damage type Normal
    • Set temp_point = (Position of random_enemy)
    • Special Effect - Create a special effect at temp_point using Abilities\Spells\Orc\SpiritLink\SpiritLinkZapTarget.mdl
    • Special Effect - Destroy (Last created special effect)
    • Custom script: call RemoveLocation (udg_temp_point)
 

micolord

You can change this now in User CP.
Reaction score
0
Necrach,

Awesome, but this is really what I'm doing, I'm making a hero with a cold power, its last skill is to get the enemy with in the range of the hero and then pick a 1 enemy random unit and then creates a dummy and then the dummy cast a spell on the picked enemy unit (Which is my custom skill.), can you please help me with that! Please!!
 

johnnymra

New Member
Reaction score
14
I don't see the point of your comment... you just explain him the whole spell... but he answered exactly your topic question. You want now to make the rest of the trigger for you? if i recall... there is a rule against asking for people to do everything for you. And also i see unnecessary posting.

Yet... in order to be nice... just use the exact trigger he gave you, then as a second trigger make something like...
Create dummy unit at position of caster.
Order dummy unit to cast spell on random_enemy.
Remove dummy unit.
 

micolord

You can change this now in User CP.
Reaction score
0
I don't see the point of your comment... you just explain him the whole spell... but he answered exactly your topic question. You want now to make the rest of the trigger for you? if i recall... there is a rule against asking for people to do everything for you. And also i see unnecessary posting.

Yet... in order to be nice... just use the exact trigger he gave you, then as a second trigger make something like...
Create dummy unit at position of caster.
Order dummy unit to cast spell on random_enemy.
Remove dummy unit.

That was a bit mean, sorry, I didn't saw the random_enemy variable thingy in the last part.
 

tommerbob

Minecraft. :D
Reaction score
110
Necrach your trigger won't work. You destroy the group before you reference the random unit.

Just do this:

Trigger:
  • Set Temp_Point = Position of (Triggering unit)
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (random 1 unit within X range of Temp_Point) and Do Actions:
      • Loop - Actions
        • ...
        • Do actions to (Picked unit)
        • ...
    • Custom script: call RemoveLocation (udg_Temp_Point)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top