Log in

View Full Version : NPC Spawning


Flare83
08-09-2008, 03:52 PM
Quick question, When a certain mob dies in crushbone is there a way to make a spawn pop in say oasis?

AndMetal
08-09-2008, 11:52 PM
Anything is possible :D

You should be able to do something like this:


Mob gets killed in Crushbone
In sub EVENT_DEATH, define a Global Variable
An invisible "watcher mob" in Oasis keeps checking to see if the Global Variable is set
Once the watcher mob sees the variable has been set, spawn the next mob
Have the spawned mob delete the Global Variable (unless you want to increment it, to have separate stages)


Hope this helps point you in the right direction :-)

Flare83
08-10-2008, 07:56 AM
thanks =) i'll see if i can get something working =D

joligario
08-10-2008, 09:15 AM
Can also use the player.pl to check the global upon zoning in so you don't have to create a new NPC.

Neiv
08-11-2008, 08:14 PM
Do let us know if you get it working. I need to do something very similar. :)

Angelox
08-11-2008, 10:26 PM
You might want to look at our boat scripts (ax_classic db), things need to happen across the zones like that.
One thing you need to keep in mind is, if the zone has no players, then Perl does not work. So anything you do, scripts are on hold, tell someone zones in. Lets say you want to spawn a mob in 'zone b' and you are in 'zone a', by killing another mob;
Mob is killed in zone a, that trips a global from '0' (off) to '1' (on). We'll call it '$test'.
$test is now 1, but no spawn tell there's a PC in the zone -
How to keep a check on the global in zone b;
Take or make one NPC in the zone, either invisible or one you're sure that's not going to get killed by a PC. Spawn him, and make him a two-point grid, in the same spot he was spawned (in other words, all x,y,z coords on the spawn and waypoints are the same). put a 5 second delay on the grids. Now you can script him to watch for that global change with EVENT_WAYPOINT. This is lag free and doesn't 'ghost' like pop/depop does.
This EVENT_WAYPOINT opens up a ton of possibilities; here's some of my insanity, you could use for example to what you want;
This is and invisible skiff that sits in Timorous zin from butcher; when you zone in from butcher skiff, it holds you for that 'split second' tell the Perl scripts wake up and pop the visible skiff (the variable was already pre-set as the butcher skiff approached the zoneline to Timorous). This boat is a hair higher than the real boat, so when it de-pops, you drop on the real boat (barely noticable);
##################################\
## Zone: Timorous
## Invisible Capt Skiff (uses grid 27)
## Qadar
## Angelox
#################################

sub EVENT_WAYPOINT{
if (($skiffa >=75) && ($skiffa <=80)){quest::depop();}
if (($skiffa >=41) && ($skiffa <=43)){quest::depop();}
if ($skiffa ==0){quest::signal(96320);}
if(($debugpl2==40) && ($skiffa <=42)){quest::shout("skiffa is set at $skiffa");}
if($skiffa==40){
quest::signal(96320);
quest::spawn2(96320,25,0,-2110.9,-2123.4,-4.5,143);
quest::spawn2(96320,26,0,-2092.5,-2130.5,-4.5,143);
quest::delglobal("skiffa");
quest::setglobal("skiffa",41,7,"F");
$skiffa = undef;
quest::depop();}}

That's just 'the tip of the iceburg'


Heres and invisible NPC that watches for different boat movements in Timorous;
#############
## Watches skiffs status, starts the Island Shuttle movement, Maidens Voyage, and rouge roamer boats
## Zone: Timorous
## AngeloX
#############
sub EVENT_SPAWN{
$x = $npc->GetX();
$y = $npc->GetY();
quest::set_proximity($x - 50, $x + 50, $y - 50, $y + 50);
if (($skiffa >=40) && ($skiffa <=80)){
quest::delglobal("skiffa");
quest::setglobal("skiffa",40,7,"F");
$skiffa=undef;}}

sub EVENT_WAYPOINT {
if (($skiffc ==1) && ($skiffa >=0) && ($skiffa <=40)){
quest::settimer("skwt2",100); #wait for some grid movement.
quest::delglobal("skiffc");
quest::setglobal("skiffc",$skiffa,7,"F");#Testing for activity, set to current $skiffa
$skiffc=undef;}
if (($shuta < 40) && ($shutc ==1) && ($maidna==8)){
quest::settimer("skwt3",150); #wait for some grid movement.
quest::delglobal("shutb");
quest::setglobal("shutb",$shuta,7,"F");#Testing for activity, set to current $shuta.
$shutb=undef;
quest::delglobal("shutc");
quest::setglobal("shutc",3,7,"F");#Set timer variable 3 for check
$shutc=undef;}
if (($maidna <=39) && ($maidnc ==1)){
# quest::shout("Timer Set!");
quest::settimer("skwt4",410); #wait for some grid movement.
quest::delglobal("maidnb");
quest::setglobal("maidnb",$maidna,7,"F");#Testing for activity, set to current $maidna.
$maidnb=undef;
quest::delglobal("maidnc");
quest::setglobal("maidnc",3,7,"F");#Set timer variable to 3 for check
$maidnc=undef;}}

sub EVENT_TIMER{
if (($timer eq "skwt3") && ($shuta <=40) && ($shuta==$shutb)){
quest::delglobal("shuta");
quest::setglobal("shuta",1,7,"F"); #No activity, so ready Shuttle.
$shuta=undef;
quest::spawn2(96075,20,0,-2380,-3963,-4,103.6);
quest::delglobal("shutc");
quest::setglobal("shutc",0,7,"F");#Set timer variable to 0 for re-check
quest::stoptimer("skwt3");
$shutc=undef;}
if ($timer eq "skwt3"){
quest::delglobal("shutc");
quest::setglobal("shutc",0,7,"F");#Set timer variable to 0 for re-check
quest::stoptimer("skwt3");
$shutc=undef;}
if (($timer eq "skwt4") && ($maidna <=40) && ($maidna==$maidnb)){
# quest::shout("Supposed to spawn!");
quest::delglobal("maidna");
quest::setglobal("maidna",1,7,"F"); #No activity, so start MaidenVoyage.
$maidna=undef;
quest::spawn2(96301,30,0,-2930,-1435,-20,118.25);
quest::stoptimer("skwt4");
quest::delglobal("maidnc");
quest::setglobal("maidnc",0,7,"F");#Set timer variable to 0 for re-check
$maidnc=undef;}
if ($timer eq "skwt4"){
# quest::shout("In zone timer off!");
quest::stoptimer("skwt4");
quest::delglobal("maidnc");
quest::setglobal("maidnc",0,7,"F");#Set timer variable to 0 for re-check
$maidnc=undef;}
if (($timer eq "skwt2") && ($skiffa >=0) && ($skiffa <=39) && ($skiffc==$skiffa)){
quest::delglobal("skiffc");
quest::setglobal("skiffc",0,7,"F"); #No activity, so start Skiff in Timorous (Set to 0).
$skiffc=undef;
quest::delglobal("skiffa");
quest::setglobal("skiffa",40,7,"F");
quest::stoptimer("skwt2");
$skiffa=undef;}
else{
quest::delglobal("skiffc");
quest::setglobal("skiffc",1,7,"F"); #Skiff must be in here, but set to 1 for a recheck
quest::stoptimer("skwt2");
$skiffc=undef;}}

sub EVENT_ENTER{
if (($skiffc ==0) || ($skiffa >=0) && ($skiffa <=39)){
quest::delglobal("skiffc");
quest::setglobal("skiffc",1,7,"F");
$skiffc=undef;}}



So as not make to much crap going on in the zone, , nothing happens tell you run up the pier and look for the boat (where Deela stands, Deela sets the global that sets off the watcher);
sub EVENT_SPAWN{
$x = $npc->GetX();
$y = $npc->GetY();
quest::set_proximity($x - 50, $x + 50, $y - 50, $y + 50);
quest::delglobal("shutc");
quest::setglobal("shutc",0,7,"F");
$shutc=undef;
quest::delglobal("maidnc");
quest::setglobal("maidnc",0,7,"F");
$maidnc=undef;}

sub EVENT_SAY {
if ($text=~/Hail/i){quest::say("Hello there. The ships are working again, my work here is done and I'm waiting for my ride home.");}
{quest::say("If you want want to know more about transportation to [Overthere], [Oasis], [Firiona], or [Butcherblock], I can give you directions.");}
if ($text=~/butcher/i){quest::say("The Captains Skiffs should arrive here soon, you might have to wait a while ...") }
if ($text=~/overthere/i){quest::say("The Bloated Belly docks at the ogre camp"); }
if ($text=~/oasis/i){quest::say("Take the raft north of the ogre camp"); }
if ($text=~/firiona/i){quest::say("Take the Island Shuttle to Firiona Vie"); }}

sub EVENT_ENTER{
if (($shuta==40) && ($maidna==8) && ($shutc==0)){ # Shuttle made it's run, is idle, and MaidenV is there
quest::delglobal("shuta");
quest::setglobal("shuta",1,7,"F");
$shuta=undef;
quest::spawn2(96075,20,0,-2380,-3963,-4,103.6); #spawn the Island Shuttle
quest::delglobal("shutb");
quest::setglobal("shutb",40,7,"F");
$shutb=undef;}
if (($shuta < 40)&&($shutc==0)){ #Shuttle (shuta) not at 40 so we need to check
quest::delglobal("shutc");
quest::setglobal("shutc",1,7,"F");
$shutc=undef;}
if (($maidna==40)&&($maidnc==0)) { #MaidenV (maidna) is at 40, so not in use, spawn incoming
quest::spawn2(96301,30,0,-2930,-1435,-20,118.25);
# quest::shout("Deela spawn!");
quest::delglobal("maidna");
quest::setglobal("maidna",1,7,"F");
$maidna=undef;}
if (($maidna < 40)&&($maidnc==0)){ #MaidenV (maidna) not at 40 so we need to check
$maidna=undef;
quest::delglobal("maidnc");
quest::setglobal("maidnc",1,7,"F");
$maidnc=undef;}
if (($skiffc ==0) || ($skiffa >=0) && ($skiffa <=39)){ #Captains Skiffs
quest::delglobal("skiffc");
quest::setglobal("skiffc",1,7,"F");
$skiffc=undef;}}
I still have a lot more work in Timorous, but right now I'm in 'Bot heaven'.
I was going to do AC like this - you know AC spawns in 4 different zones, but only one instance. Just need a 'watcher' in each zone, and a global with 4 settings, when you kill a mob and AC is up for a spawn, this EVENT_DEATH would signal the watcher who can either check and see if he's spawned elsewhere or random set the global for one of the 4 zones.

Neiv
08-12-2008, 08:08 PM
I understood about half that, Angelox, but I think it's enough to get started :) In any case, it looks like it opens a world of options for things I need to do. This is going in my favorites; Thanks!

Angelox
08-12-2008, 08:13 PM
Post what you want to do, and I'll try and help out.

Neiv
08-13-2008, 11:15 PM
Post what you want to do, and I'll try and help out.
Thanks, Angelox, I will take you up on that just as soon as I return home from a business trip. :)