[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
612
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
612
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.
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top