[Spell help] Teleport to the nearest enemy hero

johnnymra

New Member
Reaction score
14
1)Exactly as the title says... i want to make a spell (actually an item with this spell) that when used it will teleport the caster right to the nearest enemy hero, even tough you don't see the target enemy hero.
I realize it's by triggers, and i hope it can be done in GUI because i don't know JASS.
The thing is that i somehow want to pick every enemy hero and check the distance between the caster and that picked hero, then see which distance is the shortest and move the caster to the target. Can you help me make this trigger?

2)And by the way, i would like the spell to be based on war stomp so that it will also stun the target when teleported. My question is: is the event "unit uses item" good if i set the spell's casting time 0.1? i mean will the trigger take effect before or after the spell itself is casted?
 

Necrach

You can change this now in User CP.
Reaction score
62
I guess you could find your nearest hero like this

Trigger:
  • Actions
    • For each (Integer A) from 1 to 100000000, do (Actions)
      • Loop - Actions
        • Set temp_point = (Position of (Triggering unit))
        • Set temp_group = (Units within (Real((Integer A))) of temp_point matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)))
        • Unit Group - Pick every unit in temp_group and do (Actions)
          • Loop - Actions
            • -------- YOUR TELEPORT & STUN TRIGGERS --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in temp_group) Greater than 0
          • Then - Actions
            • Custom script: call DestroyGroup (udg_temp_group)
            • Skip remaining actions
          • Else - Actions


And if you want a maximum range, just set the Integer A loop to something less than 100000000 :eek:

I think this won't even bug if there is two heroes at the exact same integer range from your caster, as it will activate for one of the heroes picked and then skip remaining actions (not sure about that though, don't remember how well Skip remaining actions works inside loops)
 

Inflicted

Currently inactive
Reaction score
63
I was going to suggest something else, but Necrach's idea is actually really good haha, unless there is a chance of lag possibly from running too many times?
I don't know, but very clever:)
 

johnnymra

New Member
Reaction score
14
I will try this :) thanks a lot... it seems very good yet inflicted is right... would't it lag if running so many times?(my map is 256x256) I will try with 1000000000 and if it lags i will induce a maximum range (even tough it will ruin the idea a bit... it was an special item so that some hunters can teleport near they're prey instantly without the condition of being in X range of the target)
 

Necrach

You can change this now in User CP.
Reaction score
62
I don't think it will lag if the Skip Remaining action works as intended, as it doesn't really do anything until it finds a nearby hero and then it will not run anymore.

EDIT: But then again, that's a hundred million integers it counts to, so I see your concern :D
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Isn't there a *break* action or something in loops? I don't think Skip Remaining Actions works in this case.

Also, why not just put all enemy heroes into a unit group, then check through each one to see if its distance from the caster is the shortest? If it's less than the current TempUnit's distance/it's the first unit picked, then set it to be TempUnit. At the end of the loop, do the action onto TempUnit.
 

johnnymra

New Member
Reaction score
14
That's more work than is needed to be done, although I would approach it differently.

Care to explain how you would approach it? In GUI i hope... I don't mean to be rude but if you think there is a easier method i would like to see it.
 

NeuroToxin

New Member
Reaction score
46
Well, What I would do, is do the looping method, just, instead of picking the units, I'd set the group, if the group is larger than 0, then I'd do another if nested in that one, and if its greater than 1, then I'd pick a random unit, if its not, then I'd pick the units in the group (Unit in this case) and do what you want. If theres nothing then I'd remove the group.
 

johnnymra

New Member
Reaction score
14
Yes but i don't want the unit to be random... i want it to be the closest to the caster. Anyway thanks to everyone :)
 

SanKakU

Member
Reaction score
21
you should save heroes to variables of some sort when player picks them.
you can then check the distance between points for the caster and each enemy hero. then you compare to find which is the lowest. that's my thought.
 

johnnymra

New Member
Reaction score
14
you should save heroes to variables of some sort when player picks them.
you can then check the distance between points for the caster and each enemy hero. then you compare to find which is the lowest. that's my thought.

You basically united necrach's and neurotoxin's ideas... Did you even read what they said before posting? No offence.
 

Necrach

You can change this now in User CP.
Reaction score
62
Isn't there a *break* action or something in loops? I don't think Skip Remaining Actions works in this case.

What do you mean? :nuts: Loops are what they sound like, running one at a time for each picked unit, first one, then the next, etc, although in game it all happens in the same time. But it still reads one loop first, then repeats it, etc. And the skip remaining actions should affect the whole trigger, so.. :eek:

And if it doesn't work, maybe you could
- Run another trigger
- Turn off this trigger

and the other trigger is like
- Wait 0.00 seconds.
- Turn on "check nearest hero <gen>

(I think the 0 second wait should make it run after the first trigger actually have been turned of, otherwise I guess a 0.01 seconds wait wouldn't be too much of a deal)
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Oof. Tried it - Skip Remaining Actions does break the loop. But,
1). The loop would be more efficient if there was a check to see if there was any unit in the group before even doing anything.
2). TempPoint and TempUnitGroup should be cleared at the end of the For Loop, not only when a target is found.
3). Pick Every Unit means that if more than 1 enemy Hero is within the same range, then it would happen for both of them, not just one. It should be Random Unit From TempUnitGroup that the effects happen on - if there's only 1 unit, it will always be that unit no matter what.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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