View Single Post
  #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