Thread: NPC HP Lock
View Single Post
  #3  
Old 11-27-2010, 08:34 PM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 539
Default

I had a few events which locked HP at certain stages, when adds were involved I would use a foreach loop(assume 121212 for your add NPCTypeID that you want the HP to lock when they spawn):

Code:
sub EVENT_COMBAT
{
	if($combat_state == 1) {
		quest::setnexthpevent(50);
	}
}

sub EVENT_HP
{
	if($hpevent == 50) {
		quest:settimer("hplock", 6);
		##Spawn mobs here
		quest::setnexthpevent(25);
	}
	elsif ($hpevent == 25) {
		##Spawn mobs here
	}
}

sub EVENT_TIMER
{
	if($timer eq "hplock") {
		my @npcsInZone = $entity_list->GetNPCList();
		my $stopTimer = 0;
		## Search through all npcs in zone
		foreach $npcs(@npcsInZone) {
			## If we find an add, then set HP to 50%
			if($npcs->GetNPCTypeID() == 121212) {
				$mob->SetHP($mob->GetMaxHP() / 2);
				$stopTimer = 1;
			}
		}
		if($stopTimer == 0) {
			quest:stoptimer("hplock");
		}
	}
}
** I havent wrote a perl script in a few months so I make no claims this doesnt contain a few syntax errors **
Reply With Quote