Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int SUNRISE = 1;
- const int DAY = 0;
- const int SUNSET = 2;
- const int NIGHT = 3;
- const int DAY_PAL = 0;
- const int SUNRISET_PAL = 32;
- const int NIGHT_PAL = 33;
- const int NIGHT_OVERLAY_LAYER = 6;
- const int CLOCK_FRAMES = 0;
- const int CLOCK_SECONDS = 1;
- const int CR_SECONDS = 30;
- const int CLOCK_MINUTES = 2;
- const int CR_MINUTES = 29;
- const int CLOCK_HOURS = 3;
- const int CR_HOURS = 28;
- const int CLOCK_DAYS = 4;
- const int CLOCK_MAX = 5;
- int CYCLE = 0;
- int CURRENTDMAP = -1;
- int CURRENTSCREEN = -1;
- const int TIME_FRAME = 0;
- const int TIME_SEC = 1;
- const int TIME_MINUTE = 2;
- const int TIME_HOUR = 3;
- const int TIME_DAY = 4;
- const int TIME_MONTH = 5;
- const int TIME_YEAR = 6;
- const int TIME_MAX = 7;
- const int DMT_DUNGEON = 2;
- const int DMT_INTERIOR = 3;
- int Time[TIME_MAX]={-1, 0, 0, 0, 1, 1, 1};
- global script a
- {
- void run()
- {
- while(1)
- {
- Do_Time();
- DayNightCycle();
- Waitdraw();
- Waitframe();
- }
- }
- }
- void DayNightCycle()
- {
- dmapdata dm = Game->LoadDMapData(Game->GetCurDMap());
- int type = dm->Type;
- if ( CURRENTDMAP != Game->GetCurDMap() || CURRENTSCREEN != Game->GetCurScreen() )
- {
- TraceNL();
- TraceS("Detected DMap Type: "); Trace(type);
- CURRENTDMAP = Game->GetCurDMap();
- CURRENTSCREEN = Game->GetCurScreen();
- }
- if ( type == DMT_INTERIOR )
- {
- TraceS("Interior DMap found by DayNightCycle()"); return;
- }
- if ( type == DMT_DUNGEON )
- {
- TraceNL(); TraceS("Dungeon DMap found by DayNightCycle()"); return;
- }
- else
- {
- if (Time[TIME_HOUR] <= 5)
- {
- if (CYCLE != SUNRISE)
- {
- CYCLE = SUNRISE;
- TraceNL(); Game->DMapPalette[CURRENTDMAP] = SUNRISET_PAL;
- return;
- }
- }
- else if (Time[TIME_HOUR] <= 11)
- {
- if (CYCLE != DAY)
- {
- CYCLE = DAY;
- Game->DMapPalette[CURRENTDMAP] = DAY_PAL;
- return;
- }
- }
- else if (Time[TIME_HOUR] <= 17)
- {
- if (CYCLE != SUNSET)
- {
- CYCLE = SUNSET;
- Game->DMapPalette[CURRENTDMAP] = SUNRISET_PAL;
- return;
- }
- }
- else
- {
- if (CYCLE != NIGHT)
- {
- CYCLE = NIGHT;
- Game->DMapPalette[CURRENTDMAP] = NIGHT_PAL;
- return;
- }
- }
- return;
- }
- }
- void Do_Time()
- {
- int f = ++Time[TIME_FRAME];
- if ( f % 2 ) ++Time[TIME_SEC];
- if ( f >= 60 ) Time[TIME_FRAME] = 0;
- if ( Time[TIME_SEC] > 59 )
- {
- Time[TIME_SEC] = 0;
- ++Time[TIME_MINUTE];
- }
- if ( Time[TIME_MINUTE] > 59 )
- {
- Time[TIME_MINUTE] = 0;
- ++Time[TIME_HOUR];
- }
- if ( Time[TIME_HOUR] > 23 )
- {
- Time[TIME_HOUR] = 0;
- ++Time[TIME_DAY];
- }
- if ( Time[TIME_DAY] > 30 )
- {
- Time[TIME_DAY] = 1;
- ++Time[TIME_MONTH];
- }
- if ( Time[TIME_MONTH] > 12 )
- {
- Time[TIME_MONTH] = 1;
- ++Time[TIME_YEAR];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement