EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Passing a random player on bosses hate list to another npc? (https://www.eqemulator.org/forums/showthread.php?t=33570)

Astal 05-16-2011 08:46 PM

Passing a random player on bosses hate list to another npc?
 
Can this be done?

I have 4 mobs which im going to have cast a spell at random times between every 60 - 120 seconds.

I want them to cast them on random targets on the mobs hate list.

Im not too sure how to go about doing that.

This is the code for the mobs which will be casting the spells.

I assume ill use GetHateList(); on the main mobs script when hes attacked or?

Im not sure how I would store the hate list, ive never done much with arrays ect..

I assume how it would work is get the hate list and store each person on it as a variable, then randomly pick a variable each time the timer triggers and have the mob cast the spell on that person

Any help will be appreciated

Code:

##Child of Laiboch

sub EVENT_SPAWN {
        quest::settimer("CastPlague", 60);
}



sub EVENT_TIMER {
       
        my $range = 120; #maximum number
        my $minimum = 60; #minimum number

        my $random_number = int(rand($range)) + $minimum; #generate a number between $minimum and $range
 
        if (($timer eq "CastPlague" ) && (defined($entity_list->GetNPCByNPCTypeID(999426))))
        {
                plugin::CastOnTarget(21480); #Virulent Plague
                quest::shout("You cannot defeat our mother!!!");
                quest::settimer("CastPlague", $random_number);
        }       
}


Astal 05-16-2011 08:59 PM

Would this be on the right track

Code:

sub EVENT_ATTACK {

        $entity_list->@GetHateList($c1->GetClientByID(1),$c2->GetClientByID(2),$c3->GetClientByID(3),$c4->GetClientByID(4),$c5->GetClientByID(5),$c6->GetClientByID(6));


}


joligario 05-16-2011 09:33 PM

Actually, there is a Mob::GetHateRandom()

KLS 05-16-2011 09:46 PM

What Joligario says is the best solution. Get your npc with the entity list and hate random.

That said here is some quick untested code for manual hate list manipulation...

Code:

#hate_clone(npc1, npc2) = npc2 gains npc1's hate list
sub hate_clone
{
        my $cloned = shift;
        my $other = shift;
        my @hatelist1 = $cloned->GetHateList();

        foreach $ent (@hatelist)
        {
                my $h_ent = $ent->GetEnt();
                my $h_dmg = $ent->GetDamage();
                my $h_hate = $ent->GetHate();
                if($h_ent)
                {
                        if($other->CheckAggro($h_ent)) {
                                $other->SetHate($h_ent, $h_hate, $h_dmg);
                        }
                        else {
                                $other->AddToHateList($h_ent, $h_hate, $h_dmg, 0, 0, 0);
                        }
                }
        }
}


joligario 05-16-2011 09:58 PM

I've also used signals before. On your mob with the hatelist, he can select the random player, and then send the name or id to one of the other NPCs. Then that other NPC would add that player to his own hatelist.

Astal 05-16-2011 10:00 PM

Quote:

Originally Posted by KLS (Post 200059)
What Joligario says is the best solution. Get your npc with the entity list and hate random.

That said here is some quick untested code for manual hate list manipulation...

Code:

#hate_clone(npc1, npc2) = npc2 gains npc1's hate list
sub hate_clone
{
        my $cloned = shift;
        my $other = shift;
        my @hatelist1 = $cloned->GetHateList();

        foreach $ent (@hatelist)
        {
                my $h_ent = $ent->GetEnt();
                my $h_dmg = $ent->GetDamage();
                my $h_hate = $ent->GetHate();
                if($h_ent)
                {
                        if($other->CheckAggro($h_ent)) {
                                $other->SetHate($h_ent, $h_hate, $h_dmg);
                        }
                        else {
                                $other->AddToHateList($h_ent, $h_hate, $h_dmg, 0, 0, 0);
                        }
                }
        }
}



what are $cloned and $other?

c0ncrete 05-16-2011 10:10 PM

$cloned = $npc1 (npc you're cloning hate from)
$other = $npc2 (npc you're cloning hate to)

Astal 05-16-2011 10:12 PM

ok, what event would i put that in?

I see you define your own sub, i didnt even know you could do that

also does the npc getting the list automatically set a target?

Like would this be the correct usage

Sorry for being dumb, i cant exactly tell whats going on in the code.

Not sure how i can then use that code to get a target in the hatelist on either the npc with the hatelist code or the casting npc.

Would you guys be able to explain your sub better or help me do it an easier way with getentity list and randomhate?

Code:

sub EVENT_TIMER {
       
        my $range = 120; #maximum number
        my $minimum = 60; #minimum number

        my $random_number = int(rand($range)) + $minimum; #generate a number between $minimum and $range
 
        if (($timer eq "CastPlague" ) && (defined($entity_list->GetNPCByNPCTypeID(999426))))
        {
                hate_clone(999426, 2700253); #target player on hatelist
                plugin::CastOnTarget(21480); #Virulent Plague
                quest::shout("You cannot defeat our mother!!!");
                quest::settimer("CastPlague", $random_number);
        }       
}


Astal 05-16-2011 10:30 PM

Sorry im just confused the hell out of :(

KLS 05-16-2011 10:48 PM

It was mostly used as an example of how to manipulate the hate lists. To give an idea of how to do what you want to do that way I still suggest Joli's idea.

Ex:

Code:

        #find npc of npc type 123456
        my $parent_npc = $entity_list->GetMobByNpcTypeID(123456);
        if($parent_npc) {
                my $random_target = $parent_npc->GetHateRandom();
                #do something
        }


Astal 05-16-2011 11:13 PM

Quote:

Originally Posted by KLS (Post 200067)
It was mostly used as an example of how to manipulate the hate lists. To give an idea of how to do what you want to do that way I still suggest Joli's idea.

Ex:

Code:

        #find npc of npc type 123456
        my $parent_npc = $entity_list->GetMobByNpcTypeID(123456);
        if($parent_npc) {
                my $random_target = $parent_npc->GetHateRandom();
                #do something
        }


oh, ok i have that so far, couldnt figure out how to sent the $random_target to the other mob though.

Code:

sub EVENT_ATTACK {
        $laibach = $entity_list->GetMobByNpcTypeID(999424);
        if($laibach) {
                $random_hate = $mob->GetHateRandom();
        }
}


trevius 05-16-2011 11:27 PM

Try something like this, where 999424 is the NPCID of your main boss, which I assume is named Laibach. This script would be placed on each of your add NPCs. This assumes that they are attacked as well, to trigger this event, otherwise you can just signal them from your main boss to trigger this same bit of code instead.

Code:

sub EVENT_ATTACK {

        # Get Laibach if he is up
        my $laibach = $entity_list->GetMobByNpcTypeID(999424);
        # Make sure you got him before using $laibach as a pointer
        if($laibach)
        {
                # Get a random entry on Laibach's hate list
                my $HateTarget = $laibach->GetHateRandom();
                # Get the ID of that hate entry for use with CastSpell
                my $HateTargetID = $HateTarget->GetID();
                # Cast a spell on the random hate target (Courage in this example)
                $npc->CastSpell(11, $HateTargetID);
        }
}


Astal 05-16-2011 11:32 PM

Quote:

Originally Posted by trevius (Post 200071)
Try something like this, where 999424 is the NPCID of your main boss, which I assume is named Laibach. This script would be placed on each of your add NPCs. This assumes that they are attacked as well, to trigger this event, otherwise you can just signal them from your main boss to trigger this same bit of code instead.

Code:

sub EVENT_ATTACK {

        # Get Laibach if he is up
        my $laibach = $entity_list->GetMobByNpcTypeID(999424);
        # Make sure you got him before using $laibach as a pointer
        if($laibach)
        {
                # Get a random entry on Laibach's hate list
                my $HateTarget = $laibach->GetHateRandom();
                # Get the ID of that hate entry for use with CastSpell
                my $HateTargetID = $HateTarget->GetID();
                # Cast a spell on the random hate target (Courage in this example)
                $npc->CastSpell(11, $HateTargetID);
        }
}


oh, so i can put that on my other mobs not liabach and it will work the same?

the other mobs are immune to melee, only damaged by spells

trevius 05-16-2011 11:47 PM

Personally, I like to run everything from 1 NPC so there is less scripts involved, but sometimes that can get a little tricky and it is probably best for you to start off as simple as possible until you are comfortable moving to more complex stuff.

To run it all from the boss, would take a bit more information. But, a simple example would be like this:

Code:

sub EVENT_ATTACK {

        # Get each of the NPC casters:
        my $AddNPC1 = $entity_list->GetMobByNpcTypeID(999425);
        my $AddNPC2 = $entity_list->GetMobByNpcTypeID(999426);
        my $AddNPC3 = $entity_list->GetMobByNpcTypeID(999427);
        my $AddNPC4 = $entity_list->GetMobByNpcTypeID(999428);
       
        # Get a random entry on Laibach's hate list
        my $HateTarget = $npc->GetHateRandom();
        # Get the ID of that hate entry for use with CastSpell
        my $HateTargetID = $HateTarget->GetID();
       
        # Make sure you got him before using $laibach as a pointer
        if($AddNPC1)
        {
                # Cast a spell on the random hate target (Courage in this example)
                $AddNPC1->CastSpell(11, $HateTargetID);
        }
        if($AddNPC2)
        {
                # Cast a spell on the random hate target (Courage in this example)
                $AddNPC2->CastSpell(11, $HateTargetID);
        }
        if($AddNPC3)
        {
                # Cast a spell on the random hate target (Courage in this example)
                $AddNPC3->CastSpell(11, $HateTargetID);
        }
        if($AddNPC4)
        {
                # Cast a spell on the random hate target (Courage in this example)
                $AddNPC4->CastSpell(11, $HateTargetID);
        }

}

That will be run from your boss and you will need to edit the NPC ID for each of the adds that you have, assuming they each have their own unique NPC Type IDs. This version will make it so that each of your adds all concentrate on the same random hate target instead of each of them choosing a separate random hate target. You can get separate random hate targets for each one if you want easy enough though.

Astal 05-16-2011 11:50 PM

Quote:

Originally Posted by trevius (Post 200074)
Personally, I like to run everything from 1 NPC so there is less scripts involved, but sometimes that can get a little tricky and it is probably best for you to start off as simple as possible until you are comfortable moving to more complex stuff.

To run it all from the boss, would take a bit more information. But, a simple example would be like this:

Code:

sub EVENT_ATTACK {

        # Get each of the NPC casters:
        my $AddNPC1 = $entity_list->GetMobByNpcTypeID(999425);
        my $AddNPC2 = $entity_list->GetMobByNpcTypeID(999426);
        my $AddNPC3 = $entity_list->GetMobByNpcTypeID(999427);
        my $AddNPC4 = $entity_list->GetMobByNpcTypeID(999428);
       
        # Get a random entry on Laibach's hate list
        my $HateTarget = $npc->GetHateRandom();
        # Get the ID of that hate entry for use with CastSpell
        my $HateTargetID = $HateTarget->GetID();
       
        # Make sure you got him before using $laibach as a pointer
        if($AddNPC1)
        {
                # Cast a spell on the random hate target (Courage in this example)
                $AddNPC1->CastSpell(11, $HateTargetID);
        }
        if($AddNPC2)
        {
                # Cast a spell on the random hate target (Courage in this example)
                $AddNPC2->CastSpell(11, $HateTargetID);
        }
        if($AddNPC3)
        {
                # Cast a spell on the random hate target (Courage in this example)
                $AddNPC3->CastSpell(11, $HateTargetID);
        }
        if($AddNPC4)
        {
                # Cast a spell on the random hate target (Courage in this example)
                $AddNPC4->CastSpell(11, $HateTargetID);
        }

}

That will be run from your boss and you will need to edit the NPC ID for each of the adds that you have, assuming they each have their own unique NPC Type IDs. This version will make it so that each of your adds all concentrate on the same random hate target instead of each of them choosing a separate random hate target. You can get separate random hate targets for each one if you want easy enough though.

Ok cool, I can understand that, im sure with a bit of reading i can get em to get random hate targets. (thats what im lookin for)

thanks trev

oh what if they have the same Id? its based off of one mob i made multiple spawns of, just use the one Id then?

Also does that update each time he is attacked or only the first attack?

If its just once, ill have to figure a way to maybe work a timer in, so it selects new random targets every so often


All times are GMT -4. The time now is 03:48 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.