EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   One NPC spawning another (https://www.eqemulator.org/forums/showthread.php?t=29015)

sirjason99 07-25-2009 09:57 AM

One NPC spawning another
 
Hello,

I'm attempting to make a quest where once the PC talks to an NPC, another NPC spawns outside the room and then walks in and the two NPCs have a chat. Is this done with the quest:settimer option or is there another way to do this that I'm missing.

neiv2 07-25-2009 01:08 PM

You could include it as part of the sub EVENT_SAY
Code:

if($text=~/What other NPC?/i)
        {
        quest::say("Ah, here he is now.");
        quest::spawn2(999151,0,0,1722,1556,231,190);
        }

The first # is npc_type (create the npc first),then grid # (create grid and waypoints first), then guildwarset (keep at 0),then x,y,z,then heading

neiv2 07-25-2009 01:12 PM

After I posted this, it occurred to me that you may have meant how to do the chat part. This would likely be done by quest::signal() or quest::signalwith() and then a sub EVENT_SIGNAL, not by a timer.

joligario 07-25-2009 01:27 PM

And if you want him to "walk" in, you could create waypoints. The NPC could spawn (not on the grid) somewhere outside the room, upon spawn, do a start(grid#) and set timer, once he reaches a certain x,y spot, have him stop() and stop the timer, and signal the NPC to talk with. Make sure the grid is a full pause and have him pause longer than the timer at the last waypoint which is inside the room.

Justsomeguy 07-27-2009 02:24 AM

This script doesn't spawn an npc. Spawning is mentioned above though. And do remember you need to take into account players hailing quest npc when the npc is moving back and forth, so adding a $busy variable or something could be helpful too. Here is a basic script with a captain and a guard. Player hails captain and asks for help back to the camp. Captain calls guard. Guard walks into room and then takes player back.

Captain.pl

Code:

my $npcvariable = 0;

sub EVENT_SAY {
        if ($text=~/hail/i) {
                quest::say("Hello, $name.  Do I need to call a guard to help you?");
        }
        elsif ($text=~/yes/i) {
                #signals guard
                quest::say("Very well.  Guard!!!");
                quest::signal(1001);
        }
}


 
sub EVENT_SIGNAL {
       
        #Captain signals guard to move up
       
        if($npcvariable < 1) {
        quest::say("Please show our new recruit to the main post.");
        quest::signal(1001);
        $npcvariable = 0;
        }
}

Guard.pl

Code:

my $npcwaypoint = 0;
 
sub EVENT_SIGNAL {
       
        if($npcwaypoint < 1) {        #Captain signals guard to move up
        quest::moveto(600, 200, 12);
        $npcwaypoint = 1;
        }
        elsif($npcwaypoint == 3) {        #Guard is told to take player back.  See timer
        quest::say("Yes, sir, right away!");
        quest::settimer("movement",3);
        }
}

sub EVENT_WAYPOINT {


  $npc->SaveGuardSpot(0);        #this is so npcs don't not walk to waypoint and return immediately

        if($npcwaypoint == 1) {        #npc turns corner
        $npcwaypoint = 2;
        quest::moveto(600, 100, 12);
        }
        elsif($npcwaypoint == 2) {        #npc turns corner
        quest::moveto(340, 100, 12);
        $npcwaypoint = 3;
        }
        #npc arrives at captain
        elsif($npcwaypoint == 3) {
        quest::say("Yes, sir?!");
        quest::signal(1000);
        }
        elsif($npcwaypoint == 4) {        #npc turns corner
        quest::moveto(340, 100, 12);
        $npcwaypoint = 5;
        }
        #guard has taken player back with him.  Resets script for next user
        elsif($npcwaypoint == 5) {        #npc turns corner
        $npcwaypoint = 6;
        quest::moveto(600, 100, 12);
        $npcwaypoint = 0;
        }
}

sub EVENT_TIMER {
        quest::stoptimer("$timer");

        if($npcwaypoint == 3) {                #just used a timer here since players may need some time to react.
        quest::moveto(340, 100, 12);
        $npcwaypoint = 4;
        }
}



All times are GMT -4. The time now is 03:40 PM.

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