Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 05-16-2011, 08:46 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default 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);
	}	
}
Reply With Quote
  #2  
Old 05-16-2011, 08:59 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default

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));


}
Reply With Quote
  #3  
Old 05-16-2011, 09:33 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

Actually, there is a Mob::GetHateRandom()
Reply With Quote
  #4  
Old 05-16-2011, 09:46 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

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);
			}
		}
	}
}
Reply With Quote
  #5  
Old 05-16-2011, 10:00 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default

Quote:
Originally Posted by KLS View Post
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?
Reply With Quote
  #6  
Old 05-16-2011, 10:10 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

$cloned = $npc1 (npc you're cloning hate from)
$other = $npc2 (npc you're cloning hate to)
Reply With Quote
  #7  
Old 05-16-2011, 10:12 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default

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);
	}	
}
Reply With Quote
  #8  
Old 05-16-2011, 09:58 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

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.
Reply With Quote
  #9  
Old 05-19-2011, 09:00 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

You are looking at that part wrong. $entity_list->GetMobByNpcTypeID() passes a type Mob. Therefore, you when you call $AddNPC->CastSpell() is actually Mob::CastSpell(spellid,targetid)
Reply With Quote
  #10  
Old 05-19-2011, 09:43 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default

Quote:
Originally Posted by joligario View Post
You are looking at that part wrong. $entity_list->GetMobByNpcTypeID() passes a type Mob. Therefore, you when you call $AddNPC->CastSpell() is actually Mob::CastSpell(spellid,targetid)
so is that correct usage then?
Reply With Quote
  #11  
Old 05-19-2011, 10:15 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

Yes, at a quick glance it looks right.
Reply With Quote
  #12  
Old 05-19-2011, 10:16 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default

Quote:
Originally Posted by joligario View Post
Yes, at a quick glance it looks right.
hey i think i hit the max spell limit at 21473 can you confirm this and do you know how to change it?

Im using SoD
Reply With Quote
  #13  
Old 05-20-2011, 05:51 AM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

It doesn't seem like an integer problem... not that number. I think that may be a client thing. Are you sure SoD handles that spell? It looks pretty new according to Lucy.
Reply With Quote
  #14  
Old 05-20-2011, 04:22 PM
Astal
Hill Giant
 
Join Date: Mar 2010
Posts: 236
Default

Quote:
Originally Posted by joligario View Post
It doesn't seem like an integer problem... not that number. I think that may be a client thing. Are you sure SoD handles that spell? It looks pretty new according to Lucy.
its a custom spell, i found out the problem spell editor changed the database on me. so it was writing to a non existant one
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 08:49 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3