PDA

View Full Version : Globals, random spawns and skeletons


Dibalamin
07-31-2009, 07:23 PM
Hey folks, I have a quest file that I cannot for the life of me figure out what is wrong. I need a pair of fresh eyes cause mine are crossing at this point.


my $a;
my $b;
my $c;
my $d;
my $e;
my $f;
my $g;
my $MobToSpawn;
$Night = undef;

sub EVENT_SPAWN {
if (($zonetime >= 0)&&($zonetime <= 800)){ #nighttime
quest::setglobal(Night,1,3,F);}
elsif (($zonetime >= 2000)&&($zonetime <= 2359)){ #nighttime
quest::setglobal(Night,1,3,F);}
else{ #daytime
quest::setglobal(Night,0,3,F);}}

sub EVENT_WAYPOINT {
if (($zonetime >= 0)&&($zonetime <= 800)){ #nighttime
quest::setglobal(Night,1,3,F);}
# quest::say("Night Global is $Night");} #undead are 1
elsif (($zonetime >= 2000)&&($zonetime <= 2359)){ #nighttime
quest::setglobal(Night,1,3,F);}
#quest::say("Night Global is $Night");} #undead are 1
else{ #daytime
quest::setglobal(Night,0,3,F);}}
#quest::say("Night Global is $Night");}}
## End spawn Script

sub EVENT_SIGNAL {
if ($signal == 1){
quest::settimer("1", 10);
quest::shout("Got Signal");
quest::shout("Timer is $timer");
}
}

sub EVENT_TIMER {
if($timer eq "1"){
quest::shout("Timer Triggered!");
if(defined $qglobals{Night} && $qglobals{Night} == 1){
my $random_result = int(rand(100));
my $a = 1526; #npc - ##a_decaying_skeleton
my $b = 1528; #npc - ##a_restless_skeleton
my $c = 1530; #npc - ##a_putrid_skeleton
my $d = 1532; #npc - ##a_dread_corpse
my $e = 1534; #npc - ##a_skeleton
my $f = 4171; #npc - Varsoon
my $g = 4147; #npc - Pyzjn
my $MobToSpawn = quest::ChooseRandom($a,$d,$f,$a,$b,$c,$d,$e,$f,$a, $b,$c,$d,$e,$f,$g);
if($random_result<16){
quest::say("Spawning mariner trigger1");
quest::spawn2($MobToSpawn,5,0,-1028.3,5120,115.2,112);
}elsif(($random_result>=16) && ($random_result<32)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,6,0,-877.4,4058.1,-41.3,.5);
}elsif(($random_result>=32) && ($random_result<48)){
quest::say("Spawning shaman trigger3");
quest::spawn2($MobToSpawn,7,0,32.6,4695.1,2.1,190. 5);
}elsif(($random_result>=48) && ($random_result<64)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-464.1,4492.2,95.8,202.1);
}elsif(($random_result>=64) && ($random_result<80)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}elsif(($random_result>=80) && ($random_result<101)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}
} else {
my $random_result = int(rand(100));
my $a=1524; #npc - ##a mangy Rat
my $b=1525; #npc - ##a_brown_bear
my $c=1527; #npc - ##a_grizzly_bea
my $d=1529; #npc - ##a_large_rat
my $e=1531; #npc - ##a_fire_beetle
my $f=1533; #npc - ##a_gray_wolf
my $g=1535; #npc - ##a_giant_rat
my $MobToSpawn = quest::ChooseRandom($a,$d,$f,$a,$b,$c,$d,$e,$f,$a, $b,$c,$d,$e,$f,$g);
if($random_result<16){
quest::say("Spawning mariner trigger1");
quest::spawn2($MobToSpawn,5,0,-1028.3,5120,115.2,112);
}elsif(($random_result>=16) && ($random_result<32)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,6,0,-877.4,4058.1,-41.3,.5);
}elsif(($random_result>=32) && ($random_result<48)){
quest::say("Spawning shaman trigger3");
quest::spawn2($MobToSpawn,7,0,32.6,4695.1,2.1,190. 5);
}elsif(($random_result>=48) && ($random_result<64)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-464.1,4492.2,95.8,202.1);
}elsif(($random_result>=64) && ($random_result<80)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}else{(($random_result>=80) && ($random_result<101))
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}
}
}
}


My timer receives the signal but does not start the timer, at all. Nothing in the timer section will fire, not even the shout.

thepoetwarrior
07-31-2009, 07:47 PM
I've always used names instead of numbers for the label of the timer. I could be way off, might not be the problem.

trevius
07-31-2009, 08:04 PM
For numbers, you would use:


quest::settimer(1, 10);
...
if($timer == 10)

For strings, you would use:


quest::settimer("string", 10);
...
if($timer eq "string")

When you set a timer, you can set them to numbers or strings.

Since you have a number in a string, it should probably work the way you have it set, but you might want to try changing that up a bit to see if it makes a difference.

A good way to check if you have other issues is to try simplifying your timer. Try just setting the entire timer section to this, and work from there if the timer triggers this time:

sub EVENT_TIMER {
if($timer eq "1"){
quest::shout("Timer Triggered!");
}
}

If that works, then you know the problem is something inside the timer itself.

Also, you probably don't want to check if a qglobal is defined and also check what it is equal to in the same if line. Instead, maybe break it up by doing this:
if(defined($qglobals{Night})) {
if($qglobals{Night} == 1) {

I also noticed you didn't have the parenthesis for the define around the qglobal, so I added them to the example above.

Dibalamin
07-31-2009, 08:36 PM
Sweet, thanks for the tips on the qglobal check, I actually copy and pasted that from the wiki =o.

I'd tested absolutely every combination of timer names from flat numbers, to copying what I used for other PL files that work completely. This was a recent additional failure.

Ok, I got the First part of the PL working.


#-1028.3,5120,115.2,112
#-877.4,4058.1,-41.3,.5
#32.6,4695.1,2.1,190.5
#.4,4113.4,-25.8,201.3
#-464.1,4492.2,95.8,202.1
#-917.1,4679.2,43.4,74.9,1

#Aeolwind
my $a;
my $b;
my $c;
my $d;
my $e;
my $f;
my $g;
my $MobToSpawn;
$Night = undef;

sub EVENT_SPAWN {
if (($zonetime >= 0)&&($zonetime <= 800)){ #nighttime
quest::setglobal(Night,1,3,F);}
elsif (($zonetime >= 2000)&&($zonetime <= 2359)){ #nighttime
quest::setglobal(Night,1,3,F);}
else{ #daytime
quest::setglobal(Night,0,3,F);}}

sub EVENT_WAYPOINT {
if (($zonetime >= 0)&&($zonetime <= 800)){ #nighttime
quest::setglobal(Night,1,3,F);}
# quest::say("Night Global is $Night");} #undead are 1
elsif (($zonetime >= 2000)&&($zonetime <= 2359)){ #nighttime
quest::setglobal(Night,1,3,F);}
#quest::say("Night Global is $Night");} #undead are 1
else{ #daytime
quest::setglobal(Night,0,3,F);}}
#quest::say("Night Global is $Night");}}
## End spawn Script

sub EVENT_SIGNAL {
if ($signal == 1){
quest::settimer(1, 10);
quest::shout("Got Signal");
quest::shout("Timer is $timer");
}
}

sub EVENT_TIMER {
if($timer eq "1"){
if(defined ($qglobals{Night})) {
if($qglobals{Night} == 1) {
my $random_result = int(rand(100));
my $a = 1526; #npc - ##a_decaying_skeleton
my $b = 1528; #npc - ##a_restless_skeleton
my $c = 1530; #npc - ##a_putrid_skeleton
my $d = 1532; #npc - ##a_dread_corpse
my $e = 1534; #npc - ##a_skeleton
my $f = 4171; #npc - Varsoon
my $g = 4147; #npc - Pyzjn
my $MobToSpawn = quest::ChooseRandom($a,$d,$f,$a,$b,$c,$d,$e,$f,$a, $b,$c,$d,$e,$f,$g);
quest::shout("$random_result, $MobToSpawn");
if($random_result<16){
quest::say("Spawning mariner trigger1");
quest::spawn2($MobToSpawn,5,0,-1028.3,5120,115.2,112);
}elsif(($random_result>=16) && ($random_result<32)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,6,0,-877.4,4058.1,-41.3,.5);
}elsif(($random_result>=32) && ($random_result<48)){
quest::say("Spawning shaman trigger3");
quest::spawn2($MobToSpawn,7,0,32.6,4695.1,2.1,190. 5);
}elsif(($random_result>=48) && ($random_result<64)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-464.1,4492.2,95.8,202.1);
}elsif(($random_result>=64) && ($random_result<80)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}elsif(($random_result>=80) && ($random_result<101)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}
}
}
}
}




When I add in the else for the qglobal it stops working.


else {
my $random_result = int(rand(100));
my $a=1524; #npc - ##a mangy Rat
my $b=1525; #npc - ##a_brown_bear
my $c=1527; #npc - ##a_grizzly_bea
my $d=1529; #npc - ##a_large_rat
my $e=1531; #npc - ##a_fire_beetle
my $f=1533; #npc - ##a_gray_wolf
my $g=1535; #npc - ##a_giant_rat
my $MobToSpawn = quest::ChooseRandom($a,$d,$f,$a,$b,$c,$d,$e,$f,$a, $b,$c,$d,$e,$f,$g);
if($random_result<16){
quest::say("Spawning mariner trigger1");
quest::spawn2($MobToSpawn,5,0,-1028.3,5120,115.2,112);
}elsif(($random_result>=16) && ($random_result<32)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,6,0,-877.4,4058.1,-41.3,.5);
}elsif(($random_result>=32) && ($random_result<48)){
quest::say("Spawning shaman trigger3");
quest::spawn2($MobToSpawn,7,0,32.6,4695.1,2.1,190. 5);
}elsif(($random_result>=48) && ($random_result<64)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-464.1,4492.2,95.8,202.1);
}elsif(($random_result>=64) && ($random_result<80)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}else{(($random_result>=80) && ($random_result<101))
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}
}

Dibalamin
07-31-2009, 09:21 PM
Nailed it, thanks guys, I shall share! You can use this for your Pzyjn, you'll need some special mobs so you'll have to modify the NPC ID's for your usage as well as the grids. You'll also need a "walker" mob, I hid mine on one of the pillars. Their might be one in your DB already, named 2_ with NPC ID 51150. You can adjust your locs, these are based on our own experiences at Project1999.


#-1028.3,5120,115.2,112
#-877.4,4058.1,-41.3,.5
#32.6,4695.1,2.1,190.5
#.4,4113.4,-25.8,201.3
#-464.1,4492.2,95.8,202.1
#-917.1,4679.2,43.4,74.9,1

#Aeolwind
my $a;
my $b;
my $c;
my $d;
my $e;
my $f;
my $g;
my $MobToSpawn;
$Night = undef;

sub EVENT_SPAWN {
if (($zonetime >= 0)&&($zonetime <= 800)){ #nighttime
quest::setglobal(Night,1,3,F);}
elsif (($zonetime >= 2000)&&($zonetime <= 2359)){ #nighttime
quest::setglobal(Night,1,3,F);}
else{ #daytime
quest::setglobal(Night,0,3,F);}}

sub EVENT_WAYPOINT {
if (($zonetime >= 0)&&($zonetime <= 800)){ #nighttime
quest::setglobal(Night,1,3,F);}
# quest::say("Night Global is $Night");} #undead are 1
elsif (($zonetime >= 2000)&&($zonetime <= 2359)){ #nighttime
quest::setglobal(Night,1,3,F);}
#quest::say("Night Global is $Night");} #undead are 1
else{ #daytime
quest::setglobal(Night,0,3,F);}}
#quest::say("Night Global is $Night");}}
## End spawn Script

sub EVENT_SIGNAL {
if ($signal == 1){
quest::settimer(1, 360);
}
}

sub EVENT_TIMER {
if($timer eq "1"){
if(defined ($qglobals{Night})) {
if($qglobals{Night} == 1) {
my $random_result = int(rand(100));
my $a = 1526; #npc - ##a_decaying_skeleton
my $b = 1528; #npc - ##a_restless_skeleton
my $c = 1530; #npc - ##a_putrid_skeleton
my $d = 1532; #npc - ##a_dread_corpse
my $e = 1534; #npc - ##a_skeleton
my $f = 4171; #npc - Varsoon
my $g = 4147; #npc - Pyzjn
my $MobToSpawn = quest::ChooseRandom($a,$d,$f,$a,$b,$c,$d,$e,$f,$a, $b,$c,$d,$e,$f,$g);
quest::shout("$random_result, $MobToSpawn");
if($random_result<16){
quest::say("Spawning mariner trigger1");
quest::spawn2($MobToSpawn,5,0,-1028.3,5120,115.2,112);
}elsif(($random_result>=16) && ($random_result<32)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,6,0,-877.4,4058.1,-41.3,.5);
}elsif(($random_result>=32) && ($random_result<48)){
quest::say("Spawning shaman trigger3");
quest::spawn2($MobToSpawn,7,0,32.6,4695.1,2.1,190. 5);
}elsif(($random_result>=48) && ($random_result<64)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-464.1,4492.2,95.8,202.1);
}elsif(($random_result>=64) && ($random_result<80)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}elsif(($random_result>=80) && ($random_result<101)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
quest::stoptimer(1);
}
}
if($qglobals{Night} != 1) {
my $random_result = int(rand(100));
my $a=1524; #npc - ##a mangy Rat
my $b=1525; #npc - ##a_brown_bear
my $c=1527; #npc - ##a_grizzly_bea
my $d=1529; #npc - ##a_large_rat
my $e=1531; #npc - ##a_fire_beetle
my $f=1533; #npc - ##a_gray_wolf
my $g=1535; #npc - ##a_giant_rat
my $MobToSpawn = quest::ChooseRandom($a,$d,$f,$a,$b,$c,$d,$e,$f,$a, $b,$c,$d,$e,$f,$g);
if($random_result<16){
quest::say("Spawning mariner trigger1");
quest::spawn2($MobToSpawn,5,0,-1028.3,5120,115.2,112);
}elsif(($random_result>=16) && ($random_result<32)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,6,0,-877.4,4058.1,-41.3,.5);
}elsif(($random_result>=32) && ($random_result<48)){
quest::say("Spawning shaman trigger3");
quest::spawn2($MobToSpawn,7,0,32.6,4695.1,2.1,190. 5);
}elsif(($random_result>=48) && ($random_result<64)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-464.1,4492.2,95.8,202.1);
}elsif(($random_result>=64) && ($random_result<80)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}elsif(($random_result>=80) && ($random_result<101)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
quest::stoptimer(1);
}
}
}
}
}

Dibalamin
07-31-2009, 09:49 PM
Woops! I had the stop timer out of place, it was only stopping it on certain randoms.


#-1028.3,5120,115.2,112
#-877.4,4058.1,-41.3,.5
#32.6,4695.1,2.1,190.5
#.4,4113.4,-25.8,201.3
#-464.1,4492.2,95.8,202.1
#-917.1,4679.2,43.4,74.9,1

#Aeolwind
my $a;
my $b;
my $c;
my $d;
my $e;
my $f;
my $g;
my $MobToSpawn;
$Night = undef;

sub EVENT_SPAWN {
if (($zonetime >= 0)&&($zonetime <= 800)){ #nighttime
quest::setglobal(Night,1,3,F);}
elsif (($zonetime >= 2000)&&($zonetime <= 2359)){ #nighttime
quest::setglobal(Night,1,3,F);}
else{ #daytime
quest::setglobal(Night,0,3,F);}}

sub EVENT_WAYPOINT {
if (($zonetime >= 0)&&($zonetime <= 800)){ #nighttime
quest::setglobal(Night,1,3,F);}
# quest::say("Night Global is $Night");} #undead are 1
elsif (($zonetime >= 2000)&&($zonetime <= 2359)){ #nighttime
quest::setglobal(Night,1,3,F);}
#quest::say("Night Global is $Night");} #undead are 1
else{ #daytime
quest::setglobal(Night,0,3,F);}}
#quest::say("Night Global is $Night");}}
## End spawn Script

sub EVENT_SIGNAL {
if ($signal == 1){
quest::settimer(1, 360);
}
}

sub EVENT_TIMER {
if($timer eq "1"){
if(defined ($qglobals{Night})) {
if($qglobals{Night} == 1) {
my $random_result = int(rand(100));
my $a = 1526; #npc - ##a_decaying_skeleton
my $b = 1528; #npc - ##a_restless_skeleton
my $c = 1530; #npc - ##a_putrid_skeleton
my $d = 1532; #npc - ##a_dread_corpse
my $e = 1534; #npc - ##a_skeleton
my $f = 4171; #npc - Varsoon
my $g = 4147; #npc - Pyzjn
my $MobToSpawn = quest::ChooseRandom($a,$d,$f,$a,$b,$c,$d,$e,$f,$a, $b,$c,$d,$e,$f,$g);
quest::shout("$random_result, $MobToSpawn");
quest::stoptimer(1);
if($random_result<16){
quest::say("Spawning mariner trigger1");
quest::spawn2($MobToSpawn,5,0,-1028.3,5120,115.2,112);
}elsif(($random_result>=16) && ($random_result<32)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,6,0,-877.4,4058.1,-41.3,.5);
}elsif(($random_result>=32) && ($random_result<48)){
quest::say("Spawning shaman trigger3");
quest::spawn2($MobToSpawn,7,0,32.6,4695.1,2.1,190. 5);
}elsif(($random_result>=48) && ($random_result<64)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-464.1,4492.2,95.8,202.1);
}elsif(($random_result>=64) && ($random_result<80)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}elsif(($random_result>=80) && ($random_result<101)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}
}
if($qglobals{Night} != 1) {
my $random_result = int(rand(100));
my $a=1524; #npc - ##a mangy Rat
my $b=1525; #npc - ##a_brown_bear
my $c=1527; #npc - ##a_grizzly_bea
my $d=1529; #npc - ##a_large_rat
my $e=1531; #npc - ##a_fire_beetle
my $f=1533; #npc - ##a_gray_wolf
my $g=1535; #npc - ##a_giant_rat
my $MobToSpawn = quest::ChooseRandom($a,$d,$f,$a,$b,$c,$d,$e,$f,$a, $b,$c,$d,$e,$f,$g);
quest::stoptimer(1);
if($random_result<16){
quest::say("Spawning mariner trigger1");
quest::spawn2($MobToSpawn,5,0,-1028.3,5120,115.2,112);
}elsif(($random_result>=16) && ($random_result<32)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,6,0,-877.4,4058.1,-41.3,.5);
}elsif(($random_result>=32) && ($random_result<48)){
quest::say("Spawning shaman trigger3");
quest::spawn2($MobToSpawn,7,0,32.6,4695.1,2.1,190. 5);
}elsif(($random_result>=48) && ($random_result<64)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-464.1,4492.2,95.8,202.1);
}elsif(($random_result>=64) && ($random_result<80)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}elsif(($random_result>=80) && ($random_result<101)){
quest::say("Spawning skeleton trigger2");
quest::spawn2($MobToSpawn,8,0,-917.1,4679.2,43.4,74.9,1);
}
}
}
}
}