|
||
|
|||||||
| Custom Script Release Archive This is a pre-script database archive of what our users had released. |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Novice
Join Date: May 2003
Location: Milwaukee, WI
Age: 28
Posts: 766
|
Time System v1.1.12
Released: February 18, 2006 @ 11:30 PM CST Description: A fully customizable date and time system that keeps track of it's own time or use real time. It loads it's data from a file at world load, and saves it's data on every world save. Updates: v1.1.12:
v1.1.11:
v1.1.1:
v1.1.01:
v1.1.0:
v1.0.4:
v1.0.3:
v1.0.2:
v1.0.1:
Features:
Information: To customize the system in-game, please use the [TS SET <variable> <value> command. Type [TS SET for a list of variables that can be set. Use the [TIME command to see the current date/time/moonphase. Players are able to use this command. If you wish to disable them from using it, change the accesslevel in the Initialize function. The only lights that will be toggled on/off are BaseLight types LampPost1, LampPost2, and LampPost3. You can add/remove types by changing the Type array m_ItemLightTypes. If any lights are deleted from the world, they will not be removed from the m_LightsList array unless the PerformRandomLightOutage() method just so happens to come across a deleted light. I will look into another method for handling this without modifying BaseLight.cs and without being a resource hog. If any lights are added to the world, they will not be controlled by the system unless the system wipes and repopulates the m_LightsList. You can force the list to be repopulated by typing [TS REPOPLIGHTSLIST. For formatting help, please view the Formatting.txt inside the zip file. TODO:
Suggestions From Community: Install: Please see 2nd post in the thread. Last edited by Morxeton; 02-21-2006 at 01:03 AM. |
|
|
|
|
#2 (permalink) |
|
Forum Novice
Join Date: May 2003
Location: Milwaukee, WI
Age: 28
Posts: 766
|
Install:
To install, just extract the zip file into anywhere in the scripts directory. You must make changes to distro files. Please see below. To make changes to LightCycle.cs located in Scripts/Misc: Find the Initialize() method: Code:
public static void Initialize()
{
new LightCycleTimer().Start();
EventSink.Login += new LoginEventHandler( OnLogin );
Server.Commands.Register( "GlobalLight", AccessLevel.GameMaster, new CommandEventHandler( Light_OnCommand ) );
}
Code:
public static void Initialize()
{
//new LightCycleTimer().Start();
//EventSink.Login += new LoginEventHandler( OnLogin );
Server.Commands.Register( "GlobalLight", AccessLevel.GameMaster, new CommandEventHandler( Light_OnCommand ) );
}
Code:
public static int ComputeLevelFor( Mobile from )
{
if (m_LevelOverride > int.MinValue)
return m_LevelOverride;
int hours, minutes;
Server.Items.Clock.GetTime(from.Map, from.X, from.Y, out hours, out minutes);
/* OSI times:
*
* Midnight -> 3:59 AM : Night
* 4:00 AM -> 11:59 PM : Day
*
* RunUO times:
*
* 10:00 PM -> 11:59 PM : Scale to night
* Midnight -> 3:59 AM : Night
* 4:00 AM -> 5:59 AM : Scale to day
* 6:00 AM -> 9:59 PM : Day
*/
if (hours < 4)
return NightLevel;
if (hours < 6)
return NightLevel + (((((hours - 4) * 60) + minutes) * (DayLevel - NightLevel)) / 120);
if (hours < 22)
return DayLevel;
if (hours < 24)
return DayLevel + (((((hours - 22) * 60) + minutes) * (NightLevel - DayLevel)) / 120);
return NightLevel; // should never be
}
Code:
public static int ComputeLevelFor( Mobile from )
{
if (m_LevelOverride > int.MinValue)
return m_LevelOverride;
// ** EDIT ** Time System
if (TimeSystem.System.Enabled)
{
return TimeSystem.System.ComputeLevelFor(from);
}
else
{
int hours, minutes;
Server.Items.Clock.GetTime(from.Map, from.X, from.Y, out hours, out minutes);
/* OSI times:
*
* Midnight -> 3:59 AM : Night
* 4:00 AM -> 11:59 PM : Day
*
* RunUO times:
*
* 10:00 PM -> 11:59 PM : Scale to night
* Midnight -> 3:59 AM : Night
* 4:00 AM -> 5:59 AM : Scale to day
* 6:00 AM -> 9:59 PM : Day
*/
if (hours < 4)
return NightLevel;
if (hours < 6)
return NightLevel + (((((hours - 4) * 60) + minutes) * (DayLevel - NightLevel)) / 120);
if (hours < 22)
return DayLevel;
if (hours < 24)
return DayLevel + (((((hours - 22) * 60) + minutes) * (NightLevel - DayLevel)) / 120);
return NightLevel; // should never be
}
// ** END ***
}
At the very top of the file above the namespace, find: Code:
using System; using Server; Code:
using System; using Server; // ** EDIT ** Time System using Server.Network; using Server.Mobiles; // ** END *** Code:
public static void GetTime( Map map, int x, int y, out int hours, out int minutes, out int totalMinutes )
{
TimeSpan timeSpan = DateTime.Now - WorldStart;
totalMinutes = (int)(timeSpan.TotalSeconds / SecondsPerUOMinute);
if ( map != null )
totalMinutes += map.MapIndex * 320;
// Really on OSI this must be by subserver
totalMinutes += x / 16;
hours = (totalMinutes / 60) % 24;
minutes = totalMinutes % 60;
}
Code:
public static void GetTime( Map map, int x, int y, out int hours, out int minutes, out int totalMinutes )
{
// ** EDIT ** Time System
if (TimeSystem.System.Enabled)
{
totalMinutes = 0;
TimeSystem.System.GetTime(x, out hours, out minutes);
}
else
{
TimeSpan timeSpan = DateTime.Now - WorldStart;
totalMinutes = (int)(timeSpan.TotalSeconds / SecondsPerUOMinute);
if ( map != null )
totalMinutes += map.MapIndex * 320;
// Really on OSI this must be by subserver
totalMinutes += x / 16;
hours = (totalMinutes / 60) % 24;
minutes = totalMinutes % 60;
}
// ** END ***
}
Code:
public override void OnDoubleClick( Mobile from )
{
int genericNumber;
string exactTime;
GetTime( from, out genericNumber, out exactTime );
SendLocalizedMessageTo( from, genericNumber );
SendLocalizedMessageTo( from, 1042958, exactTime ); // ~1_TIME~ to be exact
}
Code:
public override void OnDoubleClick( Mobile from )
{
// ** EDIT ** Time System
if (TimeSystem.System.Enabled)
{
NetState state = from.NetState;
MessageType type = Network.MessageType.Regular;
int hue = 0x3B2;
string text = TimeSystem.System.GetTime(from.X, true);
state.Send(new UnicodeMessage( Serial, ItemID, type, hue, 3, "ENU", Name, text ));
}
else
{
int genericNumber;
string exactTime;
GetTime( from, out genericNumber, out exactTime );
SendLocalizedMessageTo( from, genericNumber );
SendLocalizedMessageTo( from, 1042958, exactTime ); // ~1_TIME~ to be exact
}
// ** END ***
}
Find the OnDoubleClick( Mobile from ) method: Code:
public override void OnDoubleClick( Mobile from )
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1008155); // You peer into the heavens, seeking the moons...
from.Send(new MessageLocalizedAffix(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase(Map.Trammel, from.X, from.Y), "", AffixType.Prepend, "Trammel : ", ""));
from.Send(new MessageLocalizedAffix(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase(Map.Felucca, from.X, from.Y), "", AffixType.Prepend, "Felucca : ", ""));
PlayerMobile player = from as PlayerMobile;
if ( player != null )
{
QuestSystem qs = player.Quest;
if ( qs is WitchApprenticeQuest )
{
FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective;
if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.StarChart )
{
int hours, minutes;
Clock.GetTime( from.Map, from.X, from.Y, out hours, out minutes );
if ( hours < 5 || hours > 17 )
{
player.SendLocalizedMessage( 1055040 ); // You gaze up into the glittering night sky. With great care, you compose a chart of the most prominent star patterns.
obj.Complete();
}
else
{
player.SendLocalizedMessage( 1055039 ); // You gaze up into the sky, but it is not dark enough to see any stars.
}
}
}
}
}
Code:
public override void OnDoubleClick( Mobile from )
{
// ** EDIT ** Time System
if (TimeSystem.System.Enabled)
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, String.Format("You peer into the sky and see the moon is {0}.", TimeSystem.System.GetMoonPhaseName(from.X)));
}
else
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1008155); // You peer into the heavens, seeking the moons...
from.Send(new MessageLocalizedAffix(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase(Map.Trammel, from.X, from.Y), "", AffixType.Prepend, "Trammel : ", ""));
from.Send(new MessageLocalizedAffix(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase(Map.Felucca, from.X, from.Y), "", AffixType.Prepend, "Felucca : ", ""));
}
// ** END ***
PlayerMobile player = from as PlayerMobile;
if ( player != null )
{
QuestSystem qs = player.Quest;
if ( qs is WitchApprenticeQuest )
{
FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective;
if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.StarChart )
{
int hours, minutes;
Clock.GetTime( from.Map, from.X, from.Y, out hours, out minutes );
if ( hours < 5 || hours > 17 )
{
player.SendLocalizedMessage( 1055040 ); // You gaze up into the glittering night sky. With great care, you compose a chart of the most prominent star patterns.
obj.Complete();
}
else
{
player.SendLocalizedMessage( 1055039 ); // You gaze up into the sky, but it is not dark enough to see any stars.
}
}
}
}
}
Last edited by Morxeton; 02-18-2006 at 04:40 PM. |
|
|
|
|
#5 (permalink) |
|
Forum Expert
Join Date: Nov 2004
Location: Beyond the Gates of Hell
Age: 37
Posts: 3,509
|
Nice work! I'm glade to see you back
Looking forward to the updates specially seasons.Beneath: (The comma comes before "And" you were correct)
__________________
Leader of the Anti-OSI Movement. Inventing a new game experience in an EA Games-free environment. Don Juan Matus "The basic difference between an ordinary man and a warrior is that a warrior takes everything as a challenge, while an ordinary man takes everything as a blessing or as a curse." My Customs:
|
|
|
|
|
#8 (permalink) |
|
Forum Novice
Join Date: May 2003
Location: Milwaukee, WI
Age: 28
Posts: 766
|
v1.0.1 released:
|
|
|
|
|
#10 (permalink) | |
|
Forum Novice
Join Date: May 2003
Location: Milwaukee, WI
Age: 28
Posts: 766
|
Quote:
|
|
|
|
|
|
#12 (permalink) | |||
|
Forum Novice
Join Date: May 2003
Location: Milwaukee, WI
Age: 28
Posts: 766
|
Quote:
Quote:
Quote:
Please note: If you take your server offline for x amount of time, after bringing it back online, the Time System will pick up where it left off, since it's not based on real time. You would have to set your hour and minute again. Now that I think about it, maybe adding an option to use real time isn't a bad idea. Last edited by Morxeton; 02-13-2006 at 01:40 AM. |
|||
|
|
|
|
#13 (permalink) |
|
Join Date: Dec 2005
Posts: 181
|
if you add an option for real time this will be very good.because for example in world of warcraft it uses real time lighting and its very realistic.and in this version if i have to set the amount of hour and minute in every restarts it will be very annoying after a period of time.
|
|
|
|
|
#16 (permalink) |
|
Forum Novice
Join Date: May 2003
Location: Milwaukee, WI
Age: 28
Posts: 766
|
v1.0.2 released:
|
|
|
|
|
#17 (permalink) | ||
|
Forum Novice
Join Date: May 2003
Location: Milwaukee, WI
Age: 28
Posts: 766
|
Quote:
Quote:
|
||
|
|
|
|
#22 (permalink) |
|
Forum Expert
|
Wonderful concept and useful for roleplay shards in that the date is configurable. Ill be using this, thanks a bunch. <3
edit- Only thing I can think to suggest is more formatting options. I see in the script where to change the output from [time, but Im not familiar with the best way to change it. For example, from 'The time is 5:11 on day 10 of month 2 of year 300.' to 'It is 5:11am on the 10th of february, 300.' The only problem I see with this would be the need to have options for am/pm and a value for when to switch between the two, 12 or 24 hour formatting..or a way to decide if using more/less than 24 hours per day, detecting the day and displaying the proper th/rd/st/nd..and custom months if not using realtime. o_. I think Im rambling now. Last edited by Rhexis; 02-13-2006 at 01:55 PM. |
|
|
|
|
#24 (permalink) |
|
Forum Expert
|
Well, thats only really useful if you're using a 12 hour format. 24 hour format is just obvious as any hour above 12 is pm. What comes to mind as far as being able to format is like with php on forums where you can do mm/dd/yy or dd-mm-yyyy or how my forums are now as M, jS yyyy (Feb, 13th 2006)
Thanks for listening all the same. Looking forward to updates. :3 |
|
|