Files
source/Strategic/Game Clock.h
T
Overhaul 7a27e7105d New attack busy system
Added missing #includes

Added LUA scripting and console

Changed the way tracers are visualized, so they work more like real tracers instead of a light fountain

Fixed signedness of many grid variables used in GetMouseMapPos calls

Fixed enemy weapon choosing:  Sometimes a mortar is chosen but later rejected, but the grenade class was not reset.  Caused assertion failure

Added checks so enemies don't try to chuck RPG grenades with their hands

Now possible to shoot a someone in the head if he's in water

Fixed InitSightArrays to also clear soldier interrupt duel points.  This was causing an assertion failure elsewhere in the code because the interrupt list still had soldiers on it sometimes when this function was called.

Soldiers are much less willing to forfeit their turn over an attempt to use more APs than they have

Removed early setting of muzzle flash.  This would allow enemies to get an interrupt before you even fired.

Fixed item dropping by AI.  If AI tried to drop something while standing it would cause deadlock

Change to greatly speed up closing the sector inventory window in an unloaded sector

Added conditional compile flag to always give robot weapon ready advantage, even for 360 degree sighting


Check builddefines.h for the conditional flags.  Of greatest interest might be LUA_CONSOLE.  This will cause the game to bring up a command console when run.  However this console is severely lacking in many areas.  If anybody knows of an open-source terminal/console that could be used instead, it would be appreciated.  The existing console does bad things when you try to close it, and since it counts as a separate app, it pauses the game while it has focus.

LUA scripting is very limited, basically just proof of concept.  There is one global variable, the Soldiers array.  An array index gives you the soldier in that slot in the currently loaded sector.  The soldier has a few things that can be accessed:  name (short name); fullname (long name); grid (current grid #, can be changed); walkto(grid) (function to walk to another grid); runto(grid) (function to run to another grid)


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@924 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2007-06-09 09:01:04 +00:00

205 lines
7.6 KiB
C

#ifndef __WORLD_CLOCK
#define __WORLD_CLOCK
#include "FileMan.h"
// where the time string itself is rendered
#define CLOCK_X (SCREEN_WIDTH - 86) //554
#define CLOCK_Y (SCREEN_HEIGHT - 21) //459
// the mouse region around the clock (bigger)
#define CLOCK_REGION_START_X (SCREEN_WIDTH - 88) //552
#define CLOCK_REGION_START_Y (SCREEN_HEIGHT - 24) //456
#define CLOCK_REGION_WIDTH ((SCREEN_WIDTH - 20) - CLOCK_REGION_START_X) // ( 620 - CLOCK_REGION_START_X )
#define CLOCK_REGION_HEIGHT ((SCREEN_HEIGHT - 12) - CLOCK_REGION_START_Y) //( 468 - CLOCK_REGION_START_Y )
#define NUM_SEC_IN_DAY 86400
#define NUM_SEC_IN_HOUR 3600
#define NUM_SEC_IN_MIN 60
#define ROUNDTO_MIN 5
#define NUM_MIN_IN_DAY 1440
#define NUM_MIN_IN_HOUR 60
//Kris:
//This is the plan for game time...
//Game time should be restricted to outside code. Think of it as encapsulation. Anyway, using these
//simple functions, you will be able to change the amount of time that passes per frame. The gameloop will
//automatically update the clock once per cycle, regardless of the mode you are in.
//This does pose potential problems in modes such as the editor, or similar where time shouldn't pass, and
//isn't currently handled. The best thing to do in these cases is call the PauseGame() function when entering
//such a mode, and UnPauseGame() when finished. Everything will be restored just the way you left it. This
//is much simpler to handle in the overall scheme of things.
//PAUSE FEATURES
//Pauses and unpauses the game. It sets and clears a flag which preserves the time rate.
extern void PauseGame();
extern void UnPauseGame();
extern void TogglePause();
extern BOOLEAN GamePaused();
extern void LockPauseState( UINT32 uiUniqueReasonId );
extern void UnLockPauseState();
extern BOOLEAN PauseStateLocked();
//USING HIGH RESOLUTION TIME RATE MANIPULATION/ACCESS
//Allows external code to change the time rate.
void SetGameHoursPerSecond( UINT32 uiGameHoursPerSecond );
void SetGameMinutesPerSecond( UINT32 uiGameMinutesPerSecond );
void SetGameSecondsPerSecond( UINT32 uiGameSecondsPerSecond );
//Allows access to the current time rate.
UINT32 GetGameSecondsPerFrame();
void RenderPausedGameBox( void );
void StopTimeCompression( void );
void StartTimeCompression( void );
BOOLEAN IsTimeBeingCompressed( void ); // returns FALSE if time isn't currently being compressed for ANY reason (various pauses, etc.)
BOOLEAN IsTimeCompressionOn( void ); // returns TRUE if the player currently wants time to be compressing
//USING TIME COMPRESSION
//Allows the setting/changing/access of time rate via predefined compression values.
//These functions change the index in giTimeCompressSpeeds which aren't in any
//particular mathematical pattern. The higher the index, the faster the time is processed
//per frame. These functions have their limits, so game time will also be between
//TIME_COMPRESS_X1 to TIME_COMPRESS_X8 based in the laptop time compression.
void SetGameTimeCompressionLevel( UINT32 uiCompressionRate );
void DecreaseGameTimeCompressionRate();
void IncreaseGameTimeCompressionRate();
//USING CLOCK RESOLUTION
//Note, that changing the clock resolution doesn't effect the amount of game time that passes per
//real second, but how many times per second the clock is updated. This rate will break up the actual
//time slices per second into smaller chunks. This is useful for animating strategic movement under
//fast time compression, so objects don't warp around.
void SetClockResolutionToDefault(); //1 time per second
//Valid range is 1 - 60 times per second.
void SetClockResolutionPerSecond( UINT8 ubNumTimesPerSecond );
//Function for accessing the current rate
UINT8 ClockResolution();
//time compression defines
enum
{
NOT_USING_TIME_COMPRESSION = -1,
TIME_COMPRESS_X0,
TIME_COMPRESS_X1,
TIME_COMPRESS_5MINS,
TIME_COMPRESS_30MINS,
TIME_COMPRESS_60MINS,
TIME_SUPER_COMPRESS,
NUM_TIME_COMPRESS_SPEEDS
};
//dereferenced with the above enumerations to provide the actual time compression rate.
extern INT32 giTimeCompressSpeeds[ NUM_TIME_COMPRESS_SPEEDS ];
//Lalien: externalized game starting time
//#define STARTING_TIME ( ( 1 * NUM_SEC_IN_HOUR ) + ( 0 * NUM_SEC_IN_MIN ) + NUM_SEC_IN_DAY ) // 1am
//#define FIRST_ARRIVAL_DELAY ( ( 6 * NUM_SEC_IN_HOUR ) + ( 0 * NUM_SEC_IN_MIN ) ) // 7am ( 6hours later)
#define WORLDTIMESTR gswzWorldTimeStr
// compress mode now in use
extern INT32 giTimeCompressMode;
enum
{
WARPTIME_NO_PROCESSING_OF_EVENTS,
WARPTIME_PROCESS_EVENTS_NORMALLY,
WARPTIME_PROCESS_TARGET_TIME_FIRST,
};
void WarpGameTime( UINT32 uiAdjustment, UINT8 ubWarpCode );
void AdvanceToNextDay();
//This function is called once per cycle in the game loop. This determine how often the clock should be
//as well as how much to update the clock by.
void UpdateClock();
extern CHAR16 gswzWorldTimeStr[ 20 ]; //Day 99, 23:55
extern UINT32 guiDay;
extern UINT32 guiHour;
extern UINT32 guiMin;
//Advanced function used by certain event callbacks. In the case where time is warped, certain event
//need to know how much time was warped since the last query to the event list.
//This function returns that value
extern UINT32 guiTimeOfLastEventQuery;
//This value represents the time that the sector was loaded. If you are in sector A9, and leave
//the game clock at that moment will get saved into the temp file associated with it. The next time you
//enter A9, this value will contain that time. Used for scheduling purposes.
extern UINT32 guiTimeCurrentSectorWasLastLoaded;
// is the current pause state due to the player?
extern BOOLEAN gfPauseDueToPlayerGamePause;
// we've just clued up a pause by the player, the tactical screen will need a full one shot refresh to remove a 2 frame update problem
extern BOOLEAN gfJustFinishedAPause;
extern BOOLEAN gfResetAllPlayerKnowsEnemiesFlags;
extern UINT32 guiLockPauseStateLastReasonId;
UINT32 GetWorldTotalMin( );
UINT32 GetWorldTotalSeconds( );
UINT32 GetWorldHour( );
UINT32 GetWorldDay( );
UINT32 GetWorldMinutesInDay( );
UINT32 GetWorldDayInSeconds( );
UINT32 GetWorldDayInMinutes( );
UINT32 GetFutureDayInMinutes( UINT32 uiDay );
UINT32 GetMidnightOfFutureDayInMinutes( UINT32 uiDay );
BOOLEAN DayTime();
BOOLEAN NightTime();
void InitNewGameClock( );
void GotoNextTimeOfDay( UINT32 uiTOD );
void RenderClock( INT16 sX, INT16 sY );
void ToggleSuperCompression();
//IMPORTANT FUNCTION: Used whenever an event or situation is deemed important enough to cancel the
//further processing of time in this current time slice! This can only be used inside of event callback
//functions -- otherwise, it'll be ignored and automatically reset. An example of this would be when arriving
//in a new sector and being prompted to attack or retreat.
void InterruptTime();
void PauseTimeForInterupt();
extern BOOLEAN gfTimeInterrupt;
BOOLEAN DidGameJustStart();
BOOLEAN SaveGameClock( HWFILE hFile, BOOLEAN fGamePaused, BOOLEAN fLockPauseState );
BOOLEAN LoadGameClock( HWFILE hFile );
// time compress flag stuff
BOOLEAN HasTimeCompressOccured( void );
void ResetTimeCompressHasOccured( void );
void SetFactTimeCompressHasOccured( void );
// create mouse region to pause game
void CreateMouseRegionForPauseOfClock( INT16 sX, INT16 sY );
// remove mouse region for pause game
void RemoveMouseRegionForPauseOfClock( void );
// handle pausing and unpausing of game
void HandlePlayerPauseUnPauseOfGame( void );
void ClearTacticalStuffDueToTimeCompression( void );
#endif