PDA

View Full Version : Newby Needs a Hand


Melcrin
03-04-2014, 09:58 AM
I have recently been trying my hand at writing encounter scripts and while I have had some success I have found a few hangups I can't overcome.

My issue with the encounter I have set up is I cannot seem to get the second $hpevent variables to work. Here is a copy of my encounter. I would be much obliged if someone can help me out. Also any simple pointers would be awesome. I just started delving into this a week ago.


sub EVENT_SPAWN
{
quest::shout("You will regret trespassing in my kingdom!");
quest::setnexthpevent(75);
}
sub EVENT_HP
{
quest::emote("quaffs a magical elixir.");
quest::shout("Now you will die!");
quest::npcsize(9);
quest::modifynpcstat("min_hit",70);
quest::modifynpcstat("max_hit",120);
quest::setnexthpevent(50);
}
if($hpevent==50)
{
quest::shout("Guards!");

my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $h = $npc->GetHeading();

quest::spawn2(11174,0,0,$x+5,$y+5,$z,$h);
quest::spawn2(11175,0,0,$x+5,$y-5,$z,$h);
}
sub EVENT_AGGRO
{
quest::emote("lunges at you.");
quest::shout("Me thinks you will make an excellent $race stew!");
}
sub EVENT_DEATH
{
quest::emote("whimpers in pain.");
quest::shout("My spleen!");
}
sub EVENT_SLAY
{
quest::emote("laughts at $targetname.");
}

Dunge0nMastr
03-04-2014, 10:01 AM
Currently you are closing your sub EVENT_HP out before the next hpevent.


sub EVENT_HP
{
quest::emote("quaffs a magical elixir.");
quest::shout("Now you will die!");
quest::npcsize(9);
quest::modifynpcstat("min_hit",70);
quest::modifynpcstat("max_hit",120);
quest::setnexthpevent(50);
} #Closing the event early
if($hpevent==50)
{
quest::shout("Guards!");

my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $h = $npc->GetHeading();

quest::spawn2(11174,0,0,$x+5,$y+5,$z,$h);
quest::spawn2(11175,0,0,$x+5,$y-5,$z,$h);
}


Should be:


sub EVENT_HP {
if ($hpevent == 75) {
quest::emote("quaffs a magical elixir.");
quest::shout("Now you will die!");
quest::npcsize(9);
quest::modifynpcstat("min_hit",70);
quest::modifynpcstat("max_hit",120);
quest::setnexthpevent(50);
}
if ($hpevent == 50) {
quest::shout("Guards!");

my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $h = $npc->GetHeading();

quest::spawn2(11174,0,0,$x+5,$y+5,$z,$h);
quest::spawn2(11175,0,0,$x+5,$y-5,$z,$h);
}
}


That should work for ya

sorvani
03-04-2014, 11:40 AM
Additionally, there is no reason to create local variables for xyzh. They are already set to the values you are setting them to. Just remove those lines.

Melcrin
03-05-2014, 11:06 AM
Thanks a lot! That fixed the event. And thanks for the additional pointers, sorvani. I'll try and clean my script up a little.

sorvani
03-05-2014, 06:02 PM
What you did is littered all over the the quest code, so it is understandable where you got it from.