EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   NPC unable to enter EVENT_TIMER (https://www.eqemulator.org/forums/showthread.php?t=33986)

Ignorance 08-10-2011 06:01 PM

NPC unable to enter EVENT_TIMER
 
I am having trouble getting a spawned mob to enter into the EVENT_TIMER subroutine. The mob executes EVENT_SPAWN and sets timers to appropriate values, but does not ever enter into EVENT_TIMER. I would be grateful if someone could look over the code and give some advice.

Code:

####################################################################################################
# Document Notes...
# Author: Ignorance (thecerealkillers@gmail.com)
# Created:  2011 08 01  Last Modified: 2011 08 08
# Related Files: Template_RemoteController, Template_LocalController, Template_Herald,
#  Template_Translocator
# General File Relationships
#  RemoteController  <-Global Variables->  LocalController
#    .                                      . --> Herald, Translocator
#    Loop                                    Loop    .      .
#                                                    X      X
# Translocator Description
#  Periodically announces when and where the in-zone translocatation will happen.
#  Executes translocation.
#  Despawns after translocation.
#  Despawns on errors.
####################################################################################################
@LocationNamesList  = ( "Freeport Arena" );
@LocationX1List    = ( -293 );
@LocationX2List    = ( -155 );
@LocationY1List    = ( -377 );
@LocationY2List    = ( -267 );
@LocationZ1List    = ( -39 );
@LocationZ2List    = ( -24 );
sub EVENT_SPAWN
{
  $timerNumber = 0;
  if( !defined $qglobals{FightClubfreportwLocationsInZone} )
  {
  # Set locations in zone
    quest::setglobal( "FightClubfreportwLocationsInZone", 1, 7, "F" );
  }
  if( defined $qglobals{FightClubFreeportPeriod} && defined $qglobals{FightClubTranslocateDuration} && defined $qglobals{FightClubTranslocatorAdPeriod} && defined $qglobals{FightClubfreportwLocationsInZone} )
  {
  # Randomize the in zone location chosen
    quest::setglobal( "FightClubfreportwActiveLocation", (int( rand( $qglobals{FightClubfreportwLocationsInZone} )) + 1), 7, "F" );
  # Set Advertizement Timers
    while( $timerNumber < $qglobals{FightClubFreeportPeriod})
    {
      quest::settimer( $timerNumber, $timerNumber );
      $timerNumber = $timerNumber + $qglobals{FightClubTranslocatorAdPeriod};
    }
  # Set Translocate Timer
    quest::settimer( $qglobals{FightClubFreeportPeriod}, $qglobals{FightClubFreeportPeriod} );
  # Set Translocation Close / Depop Timer
    quest::settimer( ($qglobals{FightClubFreeportPeriod} + $qglobals{FightClubTranslocateDuration}), ($qglobals{FightClubFreeportPeriod} + $qglobals{FightClubTranslocateDuration}) );
  }
  else
  {
  # Global Variables Undefined, Bad Execution
    quest::depop();
  }
}

sub EVENT_TIMER
{
  if( defined $qglobals{FightClubFreeportPeriod} && defined $qglobals{FightClubFreeportTranslocateDuration} && defined $qglobals{FightClubTranslocatorAdPeriod} && defined $qglobals{FightClubfreportwActiveLocation} )
  {
    $locationNumber = $qglobals{FightClubfreportwActiveLocation};
    if( $timer == $qglobals{FightClubFreeportPeriod} )
    {
      quest::shout("Executing ".$LocationNamesList[$locationNumber]." teleport.");
    # Execute Translocation
      quest::set_proximity($LocationX1List[$locationNumber], $LocationX2List[$locationNumber], $LocationY1List[$locationNumber], $LocationY2List[$locationNumber], $LocationZ1List[$locationNumber], $LocationZ2List[$locationNumber]);
    }
    else
    {
    # Prevents double advertizing upon translocate execution
      if( $timer % $qglobals{FightClubTranslocatorAdPeriod} )
      {
      # Advertize Location
        quest::shout("The ".$LocationNamesList[$locationNumber]." teleport executes in ".( $qglobals{FightClubFreeportPeriod} - $timer )." seconds.");
      }
    }
    if( $timer == ($qglobals{FightClubFreeportPeriod} + $qglobals{FightClubTranslocateDuration}) )
    {
    # Success, Despawn Mob
      quest::shout( $LocationNamesList[$locationNumber]." teleport executed.");
      quest::depop();
    }
  }
  else
  {
  # Global Variables Undefined, Bad Execution
    quest::depop();
  }
}

sub EVENT_ENTER
{
  quest::movepc( 96, 4366.94, -12256.9, -265 );
}


Congdar 08-11-2011 01:02 AM

i'm wondering if you are setting the timer correctly. I've seen them typically as quest::settimer("depop",10); and quest::stoptimer("depop"); and i'm not quite sure what you're doing here. do you have your npc qglobals enabled in the database?
one thing i've done to help me with debugging these scripts is to put quest:say("setting timer"); type of things everywhere and repop the npc and see what they say. Then you'll know how far your script is getting. Also, in your log files you will see perl errors in files with the name similar to eqemu_quest_zone_0222.log

void QuestManager::settimer(const char *timer_name, int seconds)

Ignorance 08-11-2011 01:49 AM

Yes, the mob is permitted to use qglobals.
I actually do the same as you when debugging; I just posted my non-debug file to keep things cleaner.

Pertaining to settimer...
All settimer ids represent time passed.
Despawning, advertising time passed, and determining when to translocate, $timer controls, and is used in, them all.

I do recognize that settimer wants a char for the id, and, in trying to determine if that was the problem, added "quest::settimer( 0, 0 );", which works in my other scripts, to the beginning of EVENT_SPAWN, which I know executes; still nothing happened.
I'll see about enforcing a conversion to const char and report back with the results.

Ignorance 08-11-2011 04:58 AM

It turns out that the const char requirement of settimer() was causing the issue.
Code:

quest::settimer( $timerID, $timerID );  # Does not work
quest::settimer( "$timerID", $timerID ); # Works



All times are GMT -4. The time now is 06:41 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.