View Single Post
  #3  
Old 03-27-2012, 10:56 PM
sorvani
Dragon
 
Join Date: May 2010
Posts: 965
Default

Scripts that want to record the spawn location sometimes declare a local version of $x $y $z $h also, so be aware of the scope of your variables.

But as long as nothing was local declared then yes $x $y $z $h are always the /loc of the NPC at the moment the event is called.

to continue your druid epic example... here is an example of a waste of coding.
Code:
# tainted_seafury_cyclops.pl
my $x;
my $y;
my $z;
my $h;

sub EVENT_DEATH {
  my $x = $npc->GetX();
  my $y = $npc->GetY();
  my $z = $npc->GetZ();
  my $h = $npc->GetHeading();
  quest::spawn2(69142,0,0,$x,$y,$z,$h);
}
Whoever wrote this delcared a local version of the standard x/y/z/h and then in the death event set the 4 variables with 4 calls to $npc and then ran spawn2.

It could very simply be written
Code:
# tainted_seafury_cyclops.pl
sub EVENT_DEATH {
  quest::spawn2(69142,0,0,$x,$y,$z,$h);
}
Reply With Quote