Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-14-2008, 07:51 PM
Knightly
Accomplished Programmer
 
Join Date: Nov 2006
Location: Honolulu, HI
Posts: 91
Default Make time available to quests

In the world building thread for the PEQ database (http://www.eqemulator.net/forums/showthread.php?t=23534) Angelox said:

Quote:
Something like a new variable called $time would be nice. (if $time >=800 and <=1900, then it would be day time, or you could say , if $time==1936 , you could spawn some mob and start something )- $time would just return the current EqEmu time.
Which I thought was a good idea. I also don't like running shifts.pl outside of the emulator to take care of the day/night shift. Therefore I added two variables to my quests: $zonehour and $zonemin which return the hour and minute respectively. Similarly, I created $zonetime to return the time in military time as above. However, I'm not sure if the $zonetime calculation would be better off in the .pl script where you need it vs the .cpp (since it's really a calculation using the two variables I've already given quests access to). I'm not good at benchmarking so if putting it in the .pl each time it is better than putting it in the .cpp, let me know.

To make this change you'll need to open zone\embparser.cpp and find the following:
Code:
	if (zone) {
// SCORPIOUS2K- added variable zoneid
		ExportVar(packagename.c_str(), "zoneid", zone->GetZoneID());
		ExportVar(packagename.c_str(), "zoneln", zone->GetLongName());
		ExportVar(packagename.c_str(), "zonesn", zone->GetShortName());
	}
Changing it to the following will give you the three variables I mentioned above:
Code:
	if (zone) {
// SCORPIOUS2K- added variable zoneid
		ExportVar(packagename.c_str(), "zoneid", zone->GetZoneID());
		ExportVar(packagename.c_str(), "zoneln", zone->GetLongName());
		ExportVar(packagename.c_str(), "zonesn", zone->GetShortName());
		TimeOfDay_Struct eqTime;
		zone->zone_time.getEQTimeOfDay( time(0), &eqTime);
		ExportVar(packagename.c_str(), "zonehour", eqTime.hour - 1);
		ExportVar(packagename.c_str(), "zonemin", eqTime.minute);
		ExportVar(packagename.c_str(), "zonetime", (eqTime.hour - 1) * 100 + eqTime.minute);
	}
To test this, I used templates\Priest_of_Discord.pl and added the following to sub EVENT_SAY:
Code:
if($text=~/time/i){
	quest::say("The hour is currently $zonehour , the minute is currently $zonemin and the time is currently $zonetime .");
}
I then created a macro with:
#time
/say time
/time

And went and talked to the POD. Here's what happened:
Quote:
You say, '#time'
To set the Time: #time HH [MM]
It is now 01:03pm (Timzeone: 0h 0m).

You say, 'time'
Priest of Discord says 'The hour is currently 13 , the minute is currently 3 and the time is currently 1303 .'
Game Time: Sunday, January 01, 3100 - 1PM
Keep in mind that I have already applied my other fix for #time to make it match for /time so if you haven't used the code from http://www.eqemulator.net/forums/showthread.php?t=24108 then #time will be one hour off of /time.

At any rate, since this lets us use $zonetime in quests, we can replace the (PEQ & AX Quests) kithicor\20250.pl:
Code:
if ($shifter==20) {										#start night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(20,0);
}
elsif ($shifter==21){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(21,0);
}
elsif ($shifter==22){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(22,0);
}
elsif ($shifter==23){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(23,0);
}
elsif ($shifter==24){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(24,0);
}
elsif ($shifter==1){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(1,0);
}
elsif ($shifter==2){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(2,0);
}
elsif ($shifter==3){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(3,0);
}
elsif ($shifter==4){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(4,0);
}
elsif ($shifter==5){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(5,0);
}
elsif ($shifter==6){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(6,0);
}
elsif ($shifter==7){			#night spawn
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
	quest::settime(7,0);
}
elsif ($shifter==8){										#start day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(8,0);
}
elsif ($shifter==9){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(9,0);
}
elsif ($shifter==10){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(10,0);
}
elsif ($shifter==11){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(11,0);
}
elsif ($shifter==12){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(12,0);
}
elsif ($shifter==13){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(13,0);
}
elsif ($shifter==14){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(14,0);
}
elsif ($shifter==15){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(15,0);
}
elsif ($shifter==16){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(16,0);
}
elsif ($shifter==17){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(17,0);
}
elsif ($shifter==18){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(18,0);
}
elsif ($shifter==19){		#day spawn
	quest::spawn_condition(kithicor,2,1);
	quest::spawn_condition(kithicor,1,0);
	quest::settime(19,0);
 }
With (this assumes 8pm is night and 8am is day):
Code:
if ($zonetime < 800 || $zonetime > 1999) {
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
}
else {
	quest::spawn_condition(kithicor,2,1); #live are 2
	quest::spawn_condition(kithicor,1,0); #undead are 1
}
There's two places in that file where this occurs: EVENT_SPAWN and EVENT_ENTER.

Now, just so you're aware, there's one thing that Angelox's shifter does that this won't do and that's synchronize the time for dynamic zones.
Reply With Quote
  #2  
Old 01-14-2008, 08:42 PM
Knightly
Accomplished Programmer
 
Join Date: Nov 2006
Location: Honolulu, HI
Posts: 91
Default

Quote:
Now, just so you're aware, there's one thing that Angelox's shifter does that this won't do and that's synchronize the time for dynamic zones.
I could have sworn that while I was testing, I went into a dynamic zone and the clock had reset itself to 8:00am. However, now I can't seem to make it do it again...maybe I was dreaming.
Reply With Quote
  #3  
Old 01-15-2008, 02:27 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

You know, this is exactly the sort of thing I've been stuck with in regards to the Greenmist quest line. I knocked out all but two of the quests, and was trying to figure out a good way to work Tracker Azeal for the fifth quest. He goes patrolling (depops, a new version pops instantly, and starts pathing) at 9 PM game time, but I couldn't find a way to tie Angelox's time code in to him.

This would be incredibly helpful stuff, because I've been hesitant to implement a work-around of any kind, and then have it become completely obsolete once someone figured out how to get time and quests working together... And it seems you have!

You and Angelox have really put together some great work on time recently, and I hope this all gets implemented soon. Keep it up!
Reply With Quote
  #4  
Old 01-15-2008, 11:26 AM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

That script you are looking at does two things: spawns night or day creatures and sets the zone time. The full 20250.pl script is broken in three parts;EVENT_SPAWN- set time on zone boot/spawn, and spawn the proper NPCs . Next, I had set invisible "Watcher" NPC's in key areas around the zone that check $shifter when there's PC movement (EVENT_ENTER and EVENT_EXIT), they update what NPCs should be up.

What you have is very good and needed, my shifter scripts are sort of a hack to satisfy what I want. They work fine, but should be merged into the code.
I think for this, we need two things to work;

1st and most important> Time always be synchronized across the zones, even dynamic: when a dynamic zone loads and a static zone says it 1:00pm, then the dynamic zone needs to catch that and set the same time - there should be some sort of "main time" that starts at EQ8:00am on EqEmu boot up, regardless if we have statics or not. Another words, when a static loads, it looks at this "central time" and synchronizes with it. This way, if a zone reboots (static or not), it finds the proper time again. The shifter scripts already do this, but in a rather awkward way - so awkward to me (and I made them), I thought was too stupid to mention, so I kept it to myself tell Cavedude saw and liked.

2nd > "Central time" will always have a variable available for time checks via Perl scripts ($zonetime).

If you all could create a Central time that applies on zone boot up to any zone (dynamic or not), then all we would need for day and night creatures is something like you said;
Code:
if ($zonetime < 800 || $zonetime > 1999) {
	quest::spawn_condition(kithicor, 2,0); #live are 2
	quest::spawn_condition(kithicor, 1,1); #undead are 1
}
else {
	quest::spawn_condition(kithicor,2,1); #live are 2
	quest::spawn_condition(kithicor,1,0); #undead are 1
}
And even the above code could be debatable if needed; you could create a general setting in spawn2 table, that would define night or day npcs, and you know the rest.

Also, there's many more watchers across the zones - look in "server/quests/templates" there are the PoD and Nexus_Scion scripts which end in this;
Code:
# Night and Day checker
#Angelox's 
#This script will re-sync zone time 
sub EVENT_SPAWN { 
if ($shifter==20) {quest::settime(20,0);}
elsif ($shifter==21){quest::settime(21,0);}
elsif ($shifter==22){quest::settime(22,0);}
elsif ($shifter==23){quest::settime(23,0);}
elsif ($shifter==24){quest::settime(24,0);}
elsif ($shifter==1){quest::settime(1,0);}
elsif ($shifter==2){quest::settime(2,0);}
elsif ($shifter==3){quest::settime(3,0);}
elsif ($shifter==4){quest::settime(4,0);}
elsif ($shifter==5){quest::settime(5,0);}
elsif ($shifter==6){quest::settime(6,0);}
elsif ($shifter==7){quest::settime(7,0);}
elsif ($shifter==8){quest::settime(8,0);}
elsif ($shifter==9){quest::settime(9,0);}
elsif ($shifter==10){quest::settime(10,0);}
elsif ($shifter==11){quest::settime(11,0);}
elsif ($shifter==12){quest::settime(12,0);}
elsif ($shifter==13){quest::settime(13,0);}
elsif ($shifter==14){quest::settime(14,0);}
elsif ($shifter==15){quest::settime(15,0);}
elsif ($shifter==16){quest::settime(16,0);}
elsif ($shifter==17){quest::settime(17,0);}
elsif ($shifter==18){quest::settime(18,0);}
elsif ($shifter==19){quest::settime(19,0); }
}
This applies to any zone with a Nexus Scion or PoD.
Reply With Quote
  #5  
Old 01-15-2008, 11:31 AM
Knightly
Accomplished Programmer
 
Join Date: Nov 2006
Location: Honolulu, HI
Posts: 91
Default

I listed all of the "watchers" in my other thread about time, so I didn't repeat them here. I was using the kith one as an example.

Can you give me the conditions that a zone comes up with the wrong time? I was trying to reproduce it, but on my server the dynamic zones keep coming up with the same time as my static zones. I mentioned it above because I could have sworn this wasn't the case, that my Kith was coming up at 8:00am regardless of my static zones...but that didn't happen last night while testing.
Reply With Quote
  #6  
Old 01-15-2008, 11:37 AM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

It's a freak thing, I've seen it happen too - I think it might be the client not updating properly , usually I can zone into a "watcher" zone and back, and it sets. if you use AX_PEQ database there are a few POD scripts in the zone that shouldn't be there, in NK, there was a Nexus Scion script that was voiding or confusing the one in templates. I've also seen zones sync time with no scripts running in there (zone to Harbingers spire after zoning to a scripted zone, I saw that there)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:15 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3