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.
|