Files
source/aniviewscreen.cpp
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

404 lines
8.3 KiB
C++

#ifdef PRECOMPILEDHEADERS
#include "JA2 All.h"
#else
#include "builddefines.h"
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include "sgp.h"
#include "gameloop.h"
#include "himage.h"
#include "vobject.h"
#include "vobject_private.h"
#include "vobject_blitters.h"
#include "wcheck.h"
#include "worlddef.h"
#include "renderworld.h"
#include "input.h"
#include "font.h"
#include "screenids.h"
#include "container.h"
#include "overhead.h"
#include "Isometric Utils.h"
#include "sysutil.h"
#include "Font Control.h"
#include "Radar Screen.h"
#include "Soldier Control.h"
#include "Animation Control.h"
#include "Animation Data.h"
#include "Event Pump.h"
#include "Timer Control.h"
#include "Render Dirty.h"
#include "Sys Globals.h"
#include "interface.h"
#include "soldier ani.h"
#include <wchar.h>
#include <tchar.h>
#include "english.h"
#include "Fileman.h"
#include "messageboxscreen.h"
#endif
void BuildListFile( );
BOOLEAN gfAniEditMode = FALSE;
static UINT16 usStartAnim = 0;
static UINT8 ubStartHeight = 0;
static SOLDIERTYPE *pSoldier;
static BOOLEAN fOKFiles = FALSE;
static UINT8 ubNumStates = 0;
static UINT16 *pusStates = NULL;
static INT8 ubCurLoadedState = 0;
void CycleAnimations( )
{
INT32 cnt;
// FInd the next animation with start height the same...
for ( cnt = usStartAnim + 1; cnt < NUMANIMATIONSTATES; cnt++ )
{
if ( gAnimControl[ cnt ].ubHeight == ubStartHeight )
{
usStartAnim = ( UINT8) cnt;
EVENT_InitNewSoldierAnim( pSoldier, usStartAnim, 0 , TRUE );
return;
}
}
usStartAnim = 0;
EVENT_InitNewSoldierAnim( pSoldier, usStartAnim, 0 , TRUE );
}
UINT32 AniEditScreenInit(void)
{
return TRUE;
}
// The ShutdownGame function will free up/undo all things that were started in InitializeGame()
// It will also be responsible to making sure that all Gaming Engine tasks exit properly
UINT32 AniEditScreenShutdown(void)
{
return TRUE;
}
UINT32 AniEditScreenHandle(void)
{
InputAtom InputEvent;
static BOOLEAN fFirstTime = TRUE;
static UINT16 usOldState;
static BOOLEAN fToggle = FALSE;
static BOOLEAN fToggle2 = FALSE;
// EV_S_SETPOSITION SSetPosition;
// Make backups
if ( fFirstTime )
{
gfAniEditMode = TRUE;
usStartAnim = 0;
ubStartHeight = ANIM_STAND;
fFirstTime = FALSE;
fToggle = FALSE;
fToggle2 = FALSE;
ubCurLoadedState = 0;
pSoldier = MercPtrs[ gusSelectedSoldier ];
gTacticalStatus.uiFlags |= LOADING_SAVED_GAME;
EVENT_InitNewSoldierAnim( pSoldier, usStartAnim, 0 , TRUE );
BuildListFile( );
}
/////////////////////////////////////////////////////
StartFrameBufferRender( );
RenderWorld( );
ExecuteBaseDirtyRectQueue( );
/////////////////////////////////////////////////////
EndFrameBufferRender( );
SetFont( LARGEFONT1 );
mprintf( 0,0,L"SOLDIER ANIMATION VIEWER" );
gprintfdirty( (INT16)0,(INT16)0,L"SOLDIER ANIMATION VIEWER" );
mprintf( 0,20,L"Current Animation: %S %S", gAnimControl[ usStartAnim ].zAnimStr, gAnimSurfaceDatabase[ pSoldier->usAnimSurface ].Filename );
gprintfdirty( (INT16)0,(INT16)20,L"Current Animation: %S %S", gAnimControl[ usStartAnim ].zAnimStr, gAnimSurfaceDatabase[ pSoldier->usAnimSurface ].Filename );
switch( ubStartHeight )
{
case ANIM_STAND:
mprintf( 0,40,L"Current Stance: STAND" );
break;
case ANIM_CROUCH:
mprintf( 0,40,L"Current Stance: CROUCH" );
break;
case ANIM_PRONE:
mprintf( 0,40,L"Current Stance: PRONE" );
break;
}
gprintfdirty( (INT16)0,(INT16)40,L"Current Animation: %S", gAnimControl[ usStartAnim ].zAnimStr );
if ( fToggle )
{
mprintf( 0,60,L"FORCE ON" );
gprintfdirty( (INT16)0,(INT16)60,L"FORCE OFF" );
}
if ( fToggle2 )
{
mprintf( 0,70,L"LOADED ORDER ON" );
gprintfdirty( (INT16)0,(INT16)70,L"LOADED ORDER ON" );
mprintf( 0,90,L"LOADED ORDER : %S", gAnimControl[ pusStates[ ubCurLoadedState ] ].zAnimStr );
gprintfdirty( (INT16)0,(INT16)90,L"LOADED ORDER : %S", gAnimControl[ pusStates[ ubCurLoadedState ] ].zAnimStr );
}
if (DequeueEvent(&InputEvent) == TRUE)
{
if ((InputEvent.usEvent == KEY_DOWN)&&(InputEvent.usParam == ESC))
{
fFirstTime = TRUE;
gfAniEditMode = FALSE;
fFirstTimeInGameScreen = TRUE;
gTacticalStatus.uiFlags &= (~LOADING_SAVED_GAME);
if ( fOKFiles )
{
MemFree( pusStates );
}
fOKFiles = FALSE;
return( GAME_SCREEN );
}
if ((InputEvent.usEvent == KEY_UP) && (InputEvent.usParam == SPACE ))
{
if ( !fToggle && !fToggle2 )
{
CycleAnimations( );
}
}
if ((InputEvent.usEvent == KEY_UP) && (InputEvent.usParam == 's' ))
{
if ( !fToggle )
{
UINT16 usAnim=0;
usOldState = usStartAnim;
switch( ubStartHeight )
{
case ANIM_STAND:
usAnim = STANDING;
break;
case ANIM_CROUCH:
usAnim = CROUCHING;
break;
case ANIM_PRONE:
usAnim = PRONE;
break;
}
EVENT_InitNewSoldierAnim( pSoldier, usAnim, 0 , TRUE );
}
else
{
EVENT_InitNewSoldierAnim( pSoldier, usOldState, 0 , TRUE );
}
fToggle = !fToggle;
}
if ((InputEvent.usEvent == KEY_UP) && (InputEvent.usParam == 'l' ))
{
if ( !fToggle2 )
{
usOldState = usStartAnim;
EVENT_InitNewSoldierAnim( pSoldier, pusStates[ ubCurLoadedState ], 0 , TRUE );
}
else
{
EVENT_InitNewSoldierAnim( pSoldier, usOldState, 0 , TRUE );
}
fToggle2 = !fToggle2;
}
if ((InputEvent.usEvent == KEY_UP) && (InputEvent.usParam == PGUP ))
{
if ( fOKFiles && fToggle2 )
{
ubCurLoadedState++;
if ( ubCurLoadedState == ubNumStates )
{
ubCurLoadedState = 0;
}
EVENT_InitNewSoldierAnim( pSoldier, pusStates[ ubCurLoadedState ], 0 , TRUE );
}
}
if ((InputEvent.usEvent == KEY_UP) && (InputEvent.usParam == PGDN ))
{
if ( fOKFiles && fToggle2 )
{
ubCurLoadedState--;
if ( ubCurLoadedState == 0 )
{
ubCurLoadedState = ubNumStates;
}
EVENT_InitNewSoldierAnim( pSoldier, pusStates[ ubCurLoadedState ], 0 , TRUE );
}
}
if ((InputEvent.usEvent == KEY_UP) && (InputEvent.usParam == 'c' ))
{
// CLEAR!
usStartAnim = 0;
EVENT_InitNewSoldierAnim( pSoldier, usStartAnim, 0 , TRUE );
}
if ((InputEvent.usEvent == KEY_UP) && (InputEvent.usParam == ENTER ))
{
if ( ubStartHeight == ANIM_STAND )
{
ubStartHeight = ANIM_CROUCH;
}
else if ( ubStartHeight == ANIM_CROUCH )
{
ubStartHeight = ANIM_PRONE;
}
else
{
ubStartHeight = ANIM_STAND;
}
}
}
return( ANIEDIT_SCREEN );
}
UINT16 GetAnimStateFromName( STR8 zName )
{
INT32 cnt;
// FInd the next animation with start height the same...
for ( cnt = 0; cnt < NUMANIMATIONSTATES; cnt++ )
{
if ( _stricmp( gAnimControl[ cnt ].zAnimStr, zName ) == 0 )
{
return( (UINT16) cnt );
}
}
return( 5555 );
}
void BuildListFile( )
{
FILE *infoFile;
CHAR8 currFilename[128];
int numEntries = 0;
int cnt;
UINT16 usState;
CHAR16 zError[128];
//Verify the existance of the header text file.
infoFile = fopen( "ANITEST.DAT", "rb");
if(!infoFile)
{
return;
}
//count STIs inside header and verify each one's existance.
while( !feof( infoFile ) )
{
fgets( currFilename, 128, infoFile );
//valid entry in header, continue on...
numEntries++;
}
fseek( infoFile, 0, SEEK_SET ); //reset header file
// Allocate array
pusStates = (UINT16 *) MemAlloc( sizeof( UINT16 ) * numEntries );
fOKFiles = TRUE;
cnt = 0;
while( !feof( infoFile ) )
{
fgets( currFilename, 128, infoFile );
// Remove newline
currFilename[ strlen( currFilename ) -1 ] = '\0';
currFilename[ strlen( currFilename ) -1 ] = '\0';
usState = GetAnimStateFromName( currFilename );
if ( usState != 5555 )
{
cnt++;
ubNumStates = (UINT8)cnt;
pusStates[ cnt ] = usState;
}
else
{
swprintf( zError, L"Animation str %S is not known: ", currFilename );
DoMessageBox( MSG_BOX_BASIC_STYLE, zError, ANIEDIT_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, NULL, NULL );
fclose( infoFile );
return;
}
}
}