View Full Version : How would i get a random victim

Lightning Blade
11-04-2013, 01:40 PM
I know you can call creature:GetVictim()" is there anyway that you could get a random target in the party / raid ??

11-04-2013, 01:43 PM
yeah, you'd load all the players in the group or raid into a container, and go off that. I myself like using a List (called via std::list) Then later when you do the spell, use a random number to pick one out and target them.

One I used to do based on distance from the creature is:

std::list<Unit*> targets;

SelectTargetList(targets, 5, SELECT_TARGET_RANDOM, 25.0f, true);

for (std::list<Unit*>::const_iterator i = targets.begin(); i != targets.end(); ++i)
DoCast(*i, SPELL);

Lightning Blade
11-04-2013, 01:48 PM
Could you help me out, " how to do that :s "

11-04-2013, 01:52 PM
Edited my post above to show an example. Pretty straightforward.

Lightning Blade
11-04-2013, 01:59 PM
Alright Thanks.

- - - Updated - - -

i can use the *i in any function right ?.

- - - Updated - - -

getting a error. Syntax error near '::'

11-04-2013, 02:21 PM
because that's c++ not lua lol

11-04-2013, 02:34 PM
because that's c++ not lua lol

Shiiiit, he said Lua? My bad my nigga.

I'd suppose you'd just use a Lua table then and add in players to it to use and wipe it per death?

11-04-2013, 03:05 PM
I'll give you an example whenever I get home.

Lightning Blade
11-04-2013, 03:52 PM

11-04-2013, 04:00 PM
Use one of these
:GetAITarget(type[, playeronly, position, distance, aura]) - Get an unit in threat list
:GetAITargets() - Get units in threat list
:GetNearestTargetInAttackDistance([radius]) - Returns nearest target in attack distance and within given radius, if set
:GetNearestTarget([radius]) - Returns nearest target in sight or given radius
:GetNearestHostileTargetInAggroRange([checkLOS]) - Returns closest hostile target in aggro range of the creature


I suggest clicking the link or using the second method.

11-04-2013, 04:11 PM
That isn't the wiki link, lol. This is: http://wiki.emudevs.com/doku.php?id=eluna_unit_class

Although that has an example. I'll update EmuDevs wiki with it today.

Updated it on EmuDevs wiki: http://wiki.emudevs.com/doku.php?id=eluna_unit_class_getaitarget

11-04-2013, 04:27 PM
The link i posted contains the needed info ;p its THE link

Why weren't those moved and why is it still there ; /?

11-04-2013, 04:41 PM
This week I'll be updating the wiki on Eluna documentation. Also, every time I try to get someone to actually update EmuDevs wiki, they disappear. I'm just now getting to it. :P

Lightning Blade
11-04-2013, 05:19 PM
Thanks for updating, if i knew more about eluna i would gladly help with updating :)