View Single Post
  #2  
Old 11-03-2010, 09:45 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

This issue is very odd indeed. After reviewing the source code for the perl Damage function as well as the Damage and CommonDamage functions in attack.cpp and seeing where the HP Events get parsed as well, I cannot figure out how this issue is occurring. I don't see why the perl Damage command would be any different than any other type of damage, and I really don't see what it would have to do with setting the hp event to -1.

Here is an example script that reproduces the problem 100%:

Code:
my $nexthp = 99;

sub EVENT_SPAWN {

	quest::setnexthpevent($nexthp);

}


sub EVENT_HP {
	my $HP_RATIO_CHK = int($npc->GetHPRatio());
	quest::gmsay("Script Debug - HPEvent $hpevent, HPRatio $HP_RATIO_CHK");
	
	if ($hpevent == -1)
	{
		quest::setnexthpevent($HP_RATIO_CHK);
		$nexthp = $HP_RATIO_CHK;
		quest::gmsay("Script Debug - Correcting Next HP Event to $HP_RATIO_CHK");
	}
	
	# Set a new HP Event to occur with every 1% of NPC HP loss
	if($hpevent == $nexthp) {
		
		$nexthp = $hpevent - 1;
		quest::gmsay("Script Debug - HPEvent $hpevent, HPRatio $HP_RATIO_CHK, NextHPEvent $nexthp");
		if ($hpevent == -1)
		{
			quest::setnexthpevent($HP_RATIO_CHK);
		}
		else
		{
			quest::setnexthpevent($nexthp);
		}
	}

}


sub EVENT_AGGRO_SAY {

	if ($status > 80) {

		if($text =~ /Damage/i)
		{
			$npc->Damage($client, 1000, 0, 28, 0);
			quest::say("Damaging now");
		}

	}

}

sub EVENT_SAY {

	if ($status > 80) {

		if($text =~ /Damage/i)
		{
			$npc->Damage($client, 1000, 0, 28, 0);
			quest::say("Damaging now");
		}

	}

}
Just put that on an NPC that has 100k HPs, and say "damage" to it a few times. You can attack normally or even #damage it and the HP Events will function as they should, but as soon as you say "damage" to it, it will set $hpevent to -1.

I set this example script to automatically recover from $hpevent getting set to -1, but that isn't a real solution to the problem. This is just puzzling the heck out of me. As far as I can tell, the only times that $hpevent are set to -1 is when the NPC is first spawned and when the last quest::setnexthpevent() in the script has been used.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote