2007-01-15 12:09:25 -08:00
/*
This file is part of Warzone 2100.
Copyright ( C ) 1999 - 2004 Eidos Interactive
2009-02-10 10:01:48 -08:00
Copyright ( C ) 2005 - 2009 Warzone Resurrection Project
2007-01-15 12:09:25 -08:00
Warzone 2100 is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
Warzone 2100 is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with Warzone 2100 ; if not , write to the Free Software
Foundation , Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 USA
*/
2008-02-16 05:05:34 -08:00
/**
* @ file drive . c
* Routines for player driving units about the map .
*/
2007-06-28 10:47:08 -07:00
# define DEFINE_DRIVE_INLINE
2006-05-27 09:37:17 -07:00
# include "lib/framework/frame.h"
2006-09-23 10:24:55 -07:00
# include "lib/framework/strres.h"
2008-03-23 12:08:49 -07:00
# include "lib/framework/input.h"
2006-09-23 10:24:55 -07:00
# include "lib/ivis_common/rendmode.h"
2008-03-16 05:39:08 -07:00
# include "lib/gamelib/gtime.h"
# include "lib/gamelib/animobj.h"
# include "lib/sound/audio.h"
# include "drive.h"
2007-06-28 10:47:08 -07:00
# include "objects.h"
# include "move.h"
# include "visibility.h"
# include "map.h"
# include "loop.h"
# include "geometry.h"
# include "anim_id.h"
# include "formationdef.h"
# include "formation.h"
# include "action.h"
# include "order.h"
# include "combat.h"
# include "mapgrid.h"
2007-11-20 14:18:17 -08:00
# include "display.h"
2007-06-28 10:47:08 -07:00
# include "effects.h"
# include "hci.h"
# include "warcam.h"
# include "radar.h"
# include "display3ddef.h"
# include "display3d.h"
# include "console.h"
# include "intdisplay.h"
2007-07-14 12:09:44 -07:00
# include "multiplay.h"
# include "target.h"
2007-06-28 10:47:08 -07:00
// all the bollox needed for script callbacks
2006-05-27 09:37:17 -07:00
# include "lib/script/parse.h" // needed to define types in scripttabs.h (Arse!)
2007-06-28 10:47:08 -07:00
# include "scripttabs.h" // needed to define the callback
# include "scriptextern.h" // needed to include the GLOBAL for checking bInTutorial
# include "group.h"
# define DRIVENOISE // Enable driving noises.
2006-05-27 09:37:17 -07:00
# define ENGINEVOL (0xfff)
2007-06-28 10:47:08 -07:00
# define MINPITCH (768)
# define PITCHCHANGE (512)
static SWORD DrivingAudioTrack = - 1 ; // Which hardware channel are we using for the car driving noise
extern UDWORD selectedPlayer ;
extern BOOL DirectControl ;
// Driving characteristics.
# define DRIVE_TURNSPEED (4)
# define DRIVE_ACCELERATE (16)
# define DRIVE_BRAKE (32)
# define DRIVE_DECELERATE (16)
# define FOLLOW_STOP_RANGE (256) // How close followers need to get to the driver before they can stop.
# define DRIVE_TURNDAMP (32) // Damping value for analogue turning.
# define MAX_IDLE (GAME_TICKS_PER_SEC*60) // Start to orbit if idle for 60 seconds.
DROID * psDrivenDroid = NULL ; // The droid that's being driven.
2008-03-24 09:51:17 -07:00
static BOOL bDriveMode = false ;
2007-06-28 10:47:08 -07:00
static SDWORD driveDir ; // Driven droid's direction.
static SDWORD driveSpeed ; // Driven droid's speed.
2007-03-16 09:20:16 -07:00
static UDWORD driveBumpTime ; // Time that followers get a kick up the ass.
2008-03-24 09:51:17 -07:00
static BOOL DoFollowRangeCheck = true ;
static BOOL AllInRange = true ;
static BOOL ClearFollowRangeCheck = false ;
static BOOL DriveControlEnabled = false ;
static BOOL DriveInterfaceEnabled = false ;
2007-06-28 10:47:08 -07:00
static UDWORD IdleTime ;
2008-03-24 09:51:17 -07:00
static BOOL TacticalActive = false ;
static BOOL WasDriving = false ;
2007-06-28 10:47:08 -07:00
enum {
CONTROLMODE_POINTNCLICK ,
CONTROLMODE_DRIVE ,
} ;
2007-07-14 12:09:44 -07:00
static UWORD ControlMode = CONTROLMODE_DRIVE ;
2008-03-24 09:51:17 -07:00
static BOOL TargetFeatures = false ;
2007-06-28 10:47:08 -07:00
2008-03-24 09:51:17 -07:00
// Intialise drive statics, call with true if coming from frontend, false if
2007-06-28 10:47:08 -07:00
// coming from a mission.
//
void driveInitVars ( BOOL Restart )
{
if ( WasDriving & & ! Restart )
{
2006-08-22 07:28:49 -07:00
debug ( LOG_NEVER , " driveInitVars: WasDriving \n " ) ;
2007-06-28 10:47:08 -07:00
DrivingAudioTrack = - 1 ;
psDrivenDroid = NULL ;
2008-03-24 09:51:17 -07:00
DoFollowRangeCheck = true ;
ClearFollowRangeCheck = false ;
bDriveMode = false ;
DriveControlEnabled = true ; //false;
DriveInterfaceEnabled = false ; //true;
TacticalActive = false ;
2007-06-28 10:47:08 -07:00
ControlMode = CONTROLMODE_DRIVE ;
2008-03-24 09:51:17 -07:00
TargetFeatures = false ;
2007-06-28 10:47:08 -07:00
Patch #968: Basic Battle-View aka Drive-Mode support, by Buginator.
Right now, to enable this, you must select a unit, and be in debug mode, and hit left shift D. Then you move the unit with arrow keys, and use right mouse button or S to target things.
Note: While you can test in SP, you will lose control of your droid if a mission briefing comes on. You just have to hit the hotkey again to regain control.
This is NOT finished. Just something to play around with, or if you got the time, reintegrate the missing PSX code.
* NOTE: You have to delete/reset your current keymap file, so backup your old one if you modified something.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3707 4a71c877-e1ca-e34f-864e-861f7616d084
2008-02-07 04:35:50 -08:00
}
else
{
2006-08-22 07:28:49 -07:00
debug ( LOG_NEVER , " driveInitVars: Driving \n " ) ;
2007-06-28 10:47:08 -07:00
DrivingAudioTrack = - 1 ;
psDrivenDroid = NULL ;
2008-03-24 09:51:17 -07:00
DoFollowRangeCheck = true ;
ClearFollowRangeCheck = false ;
bDriveMode = false ;
DriveControlEnabled = true ; //false;
DriveInterfaceEnabled = false ;
TacticalActive = false ;
2007-06-28 10:47:08 -07:00
ControlMode = CONTROLMODE_DRIVE ;
2008-03-24 09:51:17 -07:00
TargetFeatures = false ;
WasDriving = false ;
2007-06-28 10:47:08 -07:00
}
}
void setDrivingStatus ( BOOL val )
{
bDriveMode = val ;
}
BOOL getDrivingStatus ( void )
{
return ( bDriveMode ) ;
}
// Start droid driving mode.
//
BOOL StartDriverMode ( DROID * psOldDroid )
{
DROID * psDroid ;
DROID * psLastDriven ;
IdleTime = gameTime ;
psLastDriven = psDrivenDroid ;
psDrivenDroid = NULL ;
// Find a selected droid and make that the driven one.
for ( psDroid = apsDroidLists [ selectedPlayer ] ; psDroid ; psDroid = psDroid - > psNext )
{
if ( psDroid - > selected ) {
if ( ( psDrivenDroid = = NULL ) & & ( psDroid ! = psOldDroid ) ) {
// The first droid found becomes the driven droid.
if ( ! ( DroidIsBuilding ( psDroid ) | | DroidGoingToBuild ( psDroid ) ) ) {
// psDroid->sMove.Status = MOVEDRIVE;
}
psDrivenDroid = psDroid ;
2006-08-22 07:28:49 -07:00
debug ( LOG_NEVER , " New driven droid \n " ) ;
2007-06-28 10:47:08 -07:00
}
}
}
// If that failed then find any droid and make it the driven one.
if ( psDrivenDroid = = NULL ) {
psLastDriven = NULL ;
2008-03-24 09:51:17 -07:00
psDrivenDroid = intGotoNextDroidType ( NULL , DROID_ANY , true ) ;
2007-06-28 10:47:08 -07:00
// If it's the same droid then try again
if ( psDrivenDroid = = psOldDroid ) {
2008-03-24 09:51:17 -07:00
psDrivenDroid = intGotoNextDroidType ( NULL , DROID_ANY , true ) ;
2007-06-28 10:47:08 -07:00
}
if ( psDrivenDroid = = psOldDroid ) {
psDrivenDroid = NULL ;
}
// If it failed then try for a transporter.
if ( psDrivenDroid = = NULL ) {
2008-03-24 09:51:17 -07:00
psDrivenDroid = intGotoNextDroidType ( NULL , DROID_TRANSPORTER , true ) ;
2007-06-28 10:47:08 -07:00
}
// DBPRINTF(("Selected a new driven droid : %p\n",psDrivenDroid));
}
if ( psDrivenDroid ) {
2007-04-27 03:21:17 -07:00
driveDir = ( int ) psDrivenDroid - > direction % 360 ;
2007-06-28 10:47:08 -07:00
driveSpeed = 0 ;
driveBumpTime = gameTime ;
2008-03-24 09:51:17 -07:00
setDrivingStatus ( true ) ;
2007-06-28 10:47:08 -07:00
Patch #968: Basic Battle-View aka Drive-Mode support, by Buginator.
Right now, to enable this, you must select a unit, and be in debug mode, and hit left shift D. Then you move the unit with arrow keys, and use right mouse button or S to target things.
Note: While you can test in SP, you will lose control of your droid if a mission briefing comes on. You just have to hit the hotkey again to regain control.
This is NOT finished. Just something to play around with, or if you got the time, reintegrate the missing PSX code.
* NOTE: You have to delete/reset your current keymap file, so backup your old one if you modified something.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3707 4a71c877-e1ca-e34f-864e-861f7616d084
2008-02-07 04:35:50 -08:00
if ( DriveInterfaceEnabled )
{
2006-08-22 07:28:49 -07:00
debug ( LOG_NEVER , " Interface enabled1 ! Disabling drive control \n " ) ;
2008-03-24 09:51:17 -07:00
DriveControlEnabled = false ;
DirectControl = false ;
Patch #968: Basic Battle-View aka Drive-Mode support, by Buginator.
Right now, to enable this, you must select a unit, and be in debug mode, and hit left shift D. Then you move the unit with arrow keys, and use right mouse button or S to target things.
Note: While you can test in SP, you will lose control of your droid if a mission briefing comes on. You just have to hit the hotkey again to regain control.
This is NOT finished. Just something to play around with, or if you got the time, reintegrate the missing PSX code.
* NOTE: You have to delete/reset your current keymap file, so backup your old one if you modified something.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3707 4a71c877-e1ca-e34f-864e-861f7616d084
2008-02-07 04:35:50 -08:00
}
else
{
2008-03-24 09:51:17 -07:00
DriveControlEnabled = true ;
DirectControl = true ; // we are taking over the unit.
2007-06-28 10:47:08 -07:00
}
if ( psLastDriven ! = psDrivenDroid ) {
2006-08-22 07:28:49 -07:00
debug ( LOG_NEVER , " camAllignWithTarget \n " ) ;
2007-06-28 10:47:08 -07:00
camAllignWithTarget ( ( BASE_OBJECT * ) psDrivenDroid ) ;
}
2008-03-24 09:51:17 -07:00
return true ;
2007-06-28 10:47:08 -07:00
} else {
}
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
2007-03-16 13:23:35 -07:00
static void ChangeDriver ( void )
2007-06-28 10:47:08 -07:00
{
DROID * psDroid ;
if ( psDrivenDroid ! = NULL ) {
2006-08-22 07:28:49 -07:00
debug ( LOG_NEVER , " Driver Changed \n " ) ;
2007-06-28 10:47:08 -07:00
// audio_StopObjTrack(psDrivenDroid,ID_SOUND_SMALL_DROID_RUN);
// psDrivenDroid = NULL;
for ( psDroid = apsDroidLists [ selectedPlayer ] ; psDroid ; psDroid = psDroid - > psNext ) {
if ( ( psDroid - > sMove . Status = = MOVEDRIVE ) ) {
2006-08-23 05:58:48 -07:00
ASSERT ( ( psDroid - > droidType ! = DROID_TRANSPORTER ) , " Tried to control a transporter " ) ;
2007-06-28 10:47:08 -07:00
secondarySetState ( psDroid , DSO_HALTTYPE , DSS_HALT_GUARD ) ;
psDroid - > sMove . Status = MOVEINACTIVE ;
}
}
}
2008-03-24 09:51:17 -07:00
// setDrivingStatus(false);
// DriveControlEnabled = false;
2007-06-28 10:47:08 -07:00
}
// Stop droid driving mode.
//
void StopDriverMode ( void )
{
DROID * psDroid ;
Patch #968: Basic Battle-View aka Drive-Mode support, by Buginator.
Right now, to enable this, you must select a unit, and be in debug mode, and hit left shift D. Then you move the unit with arrow keys, and use right mouse button or S to target things.
Note: While you can test in SP, you will lose control of your droid if a mission briefing comes on. You just have to hit the hotkey again to regain control.
This is NOT finished. Just something to play around with, or if you got the time, reintegrate the missing PSX code.
* NOTE: You have to delete/reset your current keymap file, so backup your old one if you modified something.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3707 4a71c877-e1ca-e34f-864e-861f7616d084
2008-02-07 04:35:50 -08:00
if ( psDrivenDroid ! = NULL )
{
2006-08-22 07:28:49 -07:00
debug ( LOG_NEVER , " Drive mode canceled \n " ) ;
2008-03-30 10:59:13 -07:00
addConsoleMessage ( " Driver mode canceled. " , LEFT_JUSTIFY , SYSTEM_MESSAGE ) ;
2007-06-28 10:47:08 -07:00
// audio_StopObjTrack(psDrivenDroid,ID_SOUND_SMALL_DROID_RUN);
psDrivenDroid = NULL ;
for ( psDroid = apsDroidLists [ selectedPlayer ] ; psDroid ; psDroid = psDroid - > psNext ) {
if ( ( psDroid - > sMove . Status = = MOVEDRIVE ) ) {
2006-08-23 05:58:48 -07:00
ASSERT ( ( psDroid - > droidType ! = DROID_TRANSPORTER ) , " Tried to control a transporter " ) ;
2007-06-28 10:47:08 -07:00
secondarySetState ( psDroid , DSO_HALTTYPE , DSS_HALT_GUARD ) ;
psDroid - > sMove . Status = MOVEINACTIVE ;
}
}
}
2008-03-24 09:51:17 -07:00
setDrivingStatus ( false ) ;
driveInitVars ( false ) ; // reset everything again
DriveControlEnabled = false ;
DirectControl = false ;
2007-06-28 10:47:08 -07:00
}
// Call this whenever a droid gets killed or removed.
2008-03-24 09:51:17 -07:00
// returns true if ok, returns false if resulted in driving mode being stopped, ie could'nt find
2007-06-28 10:47:08 -07:00
// a selected droid to drive.
//
BOOL driveDroidKilled ( DROID * psDroid )
{
if ( driveModeActive ( ) ) {
if ( psDroid = = psDrivenDroid ) {
ChangeDriver ( ) ;
// StopDriverMode();
psDrivenDroid = NULL ;
DeSelectDroid ( psDroid ) ;
2008-03-16 05:39:08 -07:00
if ( ! StartDriverMode ( psDroid ) )
2007-07-14 12:09:44 -07:00
{
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
}
}
2008-03-24 09:51:17 -07:00
return true ;
2007-06-28 10:47:08 -07:00
}
// Call whenever the selections change to re initialise drive mode.
//
void driveSelectionChanged ( void )
{
if ( driveModeActive ( ) ) {
if ( psDrivenDroid ) {
// StopDriverMode();
ChangeDriver ( ) ;
StartDriverMode ( NULL ) ;
driveTacticalSelectionChanged ( ) ;
}
}
}
// Cycle to next droid in group and make it the driver.
//
2007-07-14 12:09:44 -07:00
static void driveNextDriver ( void )
2007-06-28 10:47:08 -07:00
{
DROID * psDroid ;
// Start from the current driven droid.
for ( psDroid = psDrivenDroid ; psDroid ; psDroid = psDroid - > psNext ) {
if ( ( psDroid - > selected ) & & ( psDroid ! = psDrivenDroid ) ) {
// Found one so make it the driven droid.
// psDrivenDroid->sMove.Status = MOVEINACTIVE;
// psDroid->sMove.Status = MOVEDRIVE;
psDrivenDroid = psDroid ;
camAllignWithTarget ( ( BASE_OBJECT * ) psDroid ) ;
driveTacticalSelectionChanged ( ) ;
return ;
}
}
2006-05-27 09:37:17 -07:00
for ( psDroid = apsDroidLists [ selectedPlayer ] ;
2007-06-28 10:47:08 -07:00
psDroid & & ( psDroid ! = psDrivenDroid ) ;
psDroid = psDroid - > psNext ) {
if ( psDroid - > selected ) {
// Found one so make it the driven droid.
// psDrivenDroid->sMove.Status = MOVEINACTIVE;
// psDroid->sMove.Status = MOVEDRIVE;
psDrivenDroid = psDroid ;
camAllignWithTarget ( ( BASE_OBJECT * ) psDroid ) ;
driveTacticalSelectionChanged ( ) ;
return ;
}
}
// No other selected droids found. Oh well...
}
static BOOL driveControl ( DROID * psDroid )
{
2008-03-24 09:51:17 -07:00
BOOL Input = false ;
2007-06-28 10:47:08 -07:00
SDWORD MaxSpeed = moveCalcDroidSpeed ( psDroid ) ;
if ( ! DriveControlEnabled ) {
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
if ( keyPressed ( KEY_N ) ) {
driveNextDriver ( ) ;
}
if ( keyDown ( KEY_LEFTARROW ) ) {
driveDir + = DRIVE_TURNSPEED ;
2008-03-24 09:51:17 -07:00
Input = true ;
2007-06-28 10:47:08 -07:00
} else if ( keyDown ( KEY_RIGHTARROW ) ) {
driveDir - = DRIVE_TURNSPEED ;
if ( driveDir < 0 ) {
driveDir + = 360 ;
}
2008-03-24 09:51:17 -07:00
Input = true ;
2006-05-27 09:37:17 -07:00
}
2007-06-28 10:47:08 -07:00
driveDir = driveDir % 360 ;
if ( keyDown ( KEY_UPARROW ) ) {
if ( driveSpeed > = 0 ) {
driveSpeed + = DRIVE_ACCELERATE ;
if ( driveSpeed > MaxSpeed ) {
driveSpeed = MaxSpeed ;
}
} else {
driveSpeed + = DRIVE_BRAKE ;
if ( driveSpeed > 0 ) {
driveSpeed = 0 ;
}
}
2008-03-24 09:51:17 -07:00
Input = true ;
2007-06-28 10:47:08 -07:00
} else if ( keyDown ( KEY_DOWNARROW ) ) {
if ( driveSpeed < = 0 ) {
driveSpeed - = DRIVE_ACCELERATE ;
if ( driveSpeed < - MaxSpeed ) {
driveSpeed = - MaxSpeed ;
}
} else {
driveSpeed - = DRIVE_BRAKE ;
if ( driveSpeed < 0 ) {
driveSpeed = 0 ;
}
}
2008-03-24 09:51:17 -07:00
Input = true ;
2007-06-28 10:47:08 -07:00
} else {
if ( driveSpeed > 0 ) {
driveSpeed - = DRIVE_DECELERATE ;
if ( driveSpeed < 0 ) {
driveSpeed = 0 ;
}
} else {
driveSpeed + = DRIVE_DECELERATE ;
if ( driveSpeed > 0 ) {
driveSpeed = 0 ;
}
}
}
return Input ;
}
static BOOL driveInDriverRange ( DROID * psDroid )
{
2007-12-15 07:39:29 -08:00
if ( ( abs ( psDroid - > pos . x - psDrivenDroid - > pos . x ) < FOLLOW_STOP_RANGE ) & &
( abs ( psDroid - > pos . y - psDrivenDroid - > pos . y ) < FOLLOW_STOP_RANGE ) ) {
2008-03-24 09:51:17 -07:00
return true ;
2007-06-28 10:47:08 -07:00
}
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
static void driveMoveFollower ( DROID * psDroid )
{
if ( driveBumpTime < gameTime ) {
// Update the driven droid's followers.
if ( ! driveInDriverRange ( psDroid ) ) {
//psDroid->secondaryOrder&=~DSS_MOVEHOLD_SET; // Remove secondary order ... this stops the droid from jumping back to GUARD mode ... see order.c #111 - tjc
secondarySetState ( psDroid , DSO_HALTTYPE , DSS_HALT_GUARD ) ;
// if the droid is currently guarding we need to change the order to a move
if ( psDroid - > order = = DORDER_GUARD )
{
2007-12-15 07:39:29 -08:00
orderDroidLoc ( psDroid , DORDER_MOVE , psDrivenDroid - > pos . x , psDrivenDroid - > pos . y ) ;
2007-06-28 10:47:08 -07:00
}
else
{
// otherwise we just adjust its move-to location
2007-12-15 07:39:29 -08:00
moveDroidTo ( psDroid , psDrivenDroid - > pos . x , psDrivenDroid - > pos . y ) ;
2007-06-28 10:47:08 -07:00
}
}
}
// Stop it when it gets within range of the driver.
if ( DoFollowRangeCheck ) {
if ( driveInDriverRange ( psDroid ) ) {
psDroid - > sMove . Status = MOVEINACTIVE ;
} else {
2008-03-24 09:51:17 -07:00
AllInRange = false ;
2007-06-28 10:47:08 -07:00
}
}
}
static void driveMoveCommandFollowers ( DROID * psDroid )
{
DROID * psCurr ;
DROID_GROUP * psGroup = psDroid - > psGroup ;
for ( psCurr = psGroup - > psList ; psCurr ! = NULL ; psCurr = psCurr - > psGrpNext )
{
driveMoveFollower ( psCurr ) ;
}
}
// Call once per frame.
//
void driveUpdate ( void )
{
DROID * psDroid ;
PROPULSION_STATS * psPropStats ;
2008-03-24 09:51:17 -07:00
AllInRange = true ;
2007-06-28 10:47:08 -07:00
if ( DirectControl ) {
if ( psDrivenDroid ! = NULL ) {
2009-12-31 18:57:50 -08:00
if ( driveBumpTime < gameTime ) // send latest info about driven droid.
2007-06-28 10:47:08 -07:00
{
2007-12-15 07:39:29 -08:00
SendDroidInfo ( psDrivenDroid , DORDER_MOVE , psDrivenDroid - > pos . x , psDrivenDroid - > pos . y , NULL ) ;
2007-06-28 10:47:08 -07:00
}
//TO BE DONE:
//clear the order on taking over the droid, to stop attacks..
//send some sort of message when droids stopo and get inrange.
// Check the driven droid is still selected
2008-03-24 09:51:17 -07:00
if ( psDrivenDroid - > selected = = false ) {
2007-06-28 10:47:08 -07:00
// if it's not then reset the driving system.
driveSelectionChanged ( ) ;
return ;
}
// Update the driven droid.
if ( driveControl ( psDrivenDroid ) ) {
// If control did something then force the droid's move status.
if ( psDrivenDroid - > sMove . Status ! = MOVEDRIVE ) {
psDrivenDroid - > sMove . Status = MOVEDRIVE ;
2006-08-23 05:58:48 -07:00
ASSERT ( ( psDrivenDroid - > droidType ! = DROID_TRANSPORTER ) , " Tried to control a transporter " ) ;
2007-04-27 03:21:17 -07:00
driveDir = ( int ) psDrivenDroid - > direction % 360 ;
2007-06-28 10:47:08 -07:00
}
2006-05-27 09:37:17 -07:00
2008-03-24 09:51:17 -07:00
DoFollowRangeCheck = true ;
2007-06-28 10:47:08 -07:00
}
// Is the driven droid under user control?
if ( psDrivenDroid - > sMove . Status = = MOVEDRIVE ) {
// Is it a command droid
if ( ( psDrivenDroid - > droidType = = DROID_COMMAND ) & &
( psDrivenDroid - > psGroup ! = NULL ) ) {
driveMoveCommandFollowers ( psDrivenDroid ) ;
}
for ( psDroid = apsDroidLists [ selectedPlayer ] ; psDroid ; psDroid = psDroid - > psNext ) {
psPropStats = asPropulsionStats + psDroid - > asBits [ COMP_PROPULSION ] . nStat ;
if ( ( psDroid - > selected ) & &
( psDroid ! = psDrivenDroid ) & &
( psDroid - > droidType ! = DROID_TRANSPORTER ) & &
2008-07-10 10:59:35 -07:00
//((psPropStats->propulsionType != PROPULSION_TYPE_LIFT) || (psDroid->droidType == DROID_CYBORG)) ) {
( ( psPropStats - > propulsionType ! = PROPULSION_TYPE_LIFT ) | | cyborgDroid ( psDroid ) ) )
2007-06-28 10:47:08 -07:00
{
// Send new orders to it's followers.
driveMoveFollower ( psDroid ) ;
}
}
}
if ( AllInRange ) {
2008-03-24 09:51:17 -07:00
DoFollowRangeCheck = false ;
2007-06-28 10:47:08 -07:00
}
if ( driveBumpTime < gameTime ) {
// Send next order in 1 second.
driveBumpTime = gameTime + GAME_TICKS_PER_SEC ;
}
} else {
2008-03-24 09:51:17 -07:00
if ( StartDriverMode ( NULL ) = = false ) {
2007-07-14 12:09:44 -07:00
// nothing
2007-06-28 10:47:08 -07:00
}
}
}
}
SDWORD driveGetMoveSpeed ( void )
{
return driveSpeed ;
}
SDWORD driveGetMoveDir ( void )
{
return driveDir ;
}
void driveSetDroidMove ( DROID * psDroid )
{
2007-12-22 15:13:05 -08:00
// psDroid->sMove.speed = (float)driveSpeed;
2007-06-28 10:47:08 -07:00
// psDroid->sMove.dir = driveDir;
2007-04-27 03:21:17 -07:00
psDroid - > direction = driveDir ;
2007-06-28 10:47:08 -07:00
}
// Dissable user control of droid, ie when interface is up.
void driveDisableControl ( void )
{
2008-03-24 09:51:17 -07:00
DriveControlEnabled = false ;
DirectControl = false ;
DriveInterfaceEnabled = true ;
2007-06-28 10:47:08 -07:00
}
// Enable user control of droid, ie when interface is down.
//
void driveEnableControl ( void )
{
2008-03-24 09:51:17 -07:00
DriveControlEnabled = true ;
DirectControl = true ;
DriveInterfaceEnabled = false ;
2007-06-28 10:47:08 -07:00
}
2008-03-24 09:51:17 -07:00
// Return true if drive control is enabled.
2007-06-28 10:47:08 -07:00
//
BOOL driveControlEnabled ( void )
{
return DriveControlEnabled ;
}
// Bring up the reticule.
//
void driveEnableInterface ( BOOL AddReticule )
{
if ( AddReticule ) {
intAddReticule ( ) ;
}
2008-03-24 09:51:17 -07:00
DriveInterfaceEnabled = true ;
2007-06-28 10:47:08 -07:00
}
// Get rid of the reticule.
//
void driveDisableInterface ( void )
{
2008-03-24 09:51:17 -07:00
intResetScreen ( false ) ;
2007-06-28 10:47:08 -07:00
intRemoveReticule ( ) ;
2008-03-24 09:51:17 -07:00
DriveInterfaceEnabled = false ;
2007-06-28 10:47:08 -07:00
}
2008-03-24 09:51:17 -07:00
// Return true if the reticule is up.
2007-06-28 10:47:08 -07:00
//
BOOL driveInterfaceEnabled ( void )
{
return DriveInterfaceEnabled ;
}
// Check for and process a user request for a new target.
//
void driveProcessAquireButton ( void )
{
Patch #968: Basic Battle-View aka Drive-Mode support, by Buginator.
Right now, to enable this, you must select a unit, and be in debug mode, and hit left shift D. Then you move the unit with arrow keys, and use right mouse button or S to target things.
Note: While you can test in SP, you will lose control of your droid if a mission briefing comes on. You just have to hit the hotkey again to regain control.
This is NOT finished. Just something to play around with, or if you got the time, reintegrate the missing PSX code.
* NOTE: You have to delete/reset your current keymap file, so backup your old one if you modified something.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3707 4a71c877-e1ca-e34f-864e-861f7616d084
2008-02-07 04:35:50 -08:00
if ( mouseReleased ( MOUSE_RMB ) | | keyPressed ( KEY_S ) )
{
2007-06-28 10:47:08 -07:00
BASE_OBJECT * psObj ;
2007-06-19 09:27:10 -07:00
psObj = targetAquireNearestObjView ( ( BASE_OBJECT * ) psDrivenDroid ) ;
2008-02-08 03:05:31 -08:00
// driveMarkTarget();
2008-03-30 08:44:50 -07:00
// pie_SetMouse(CURSOR_ATTACK, true);
2007-06-28 10:47:08 -07:00
}
}
// Start structure placement for drive mode.
//
void driveStartBuild ( void )
{
intRemoveReticule ( ) ;
2008-03-24 09:51:17 -07:00
DriveInterfaceEnabled = false ;
2007-06-28 10:47:08 -07:00
// driveDisableInterface();
driveEnableControl ( ) ;
}
2008-03-24 09:51:17 -07:00
// Return true if all the conditions for allowing user control of the droid are met.
2007-06-28 10:47:08 -07:00
//
BOOL driveAllowControl ( void )
{
2007-07-14 12:09:44 -07:00
if ( TacticalActive | | DriveInterfaceEnabled | | ! DriveControlEnabled )
{
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
2008-03-24 09:51:17 -07:00
return true ;
2007-06-28 10:47:08 -07:00
}
// Disable Tactical order mode.
2008-03-16 05:39:08 -07:00
//
2007-06-28 10:47:08 -07:00
void driveDisableTactical ( void )
{
2008-03-16 05:39:08 -07:00
if ( driveModeActive ( ) & & TacticalActive )
2007-07-14 12:09:44 -07:00
{
2007-06-28 10:47:08 -07:00
CancelTacticalScroll ( ) ;
2008-03-24 09:51:17 -07:00
TacticalActive = false ;
2007-06-28 10:47:08 -07:00
}
}
2008-03-24 09:51:17 -07:00
// Return true if Tactical order mode is active.
2007-06-28 10:47:08 -07:00
//
BOOL driveTacticalActive ( void )
{
return TacticalActive ;
}
void driveTacticalSelectionChanged ( void )
{
if ( TacticalActive & & psDrivenDroid ) {
2008-03-24 09:51:17 -07:00
StartTacticalScrollObj ( true , ( BASE_OBJECT * ) psDrivenDroid ) ;
2006-08-22 07:28:49 -07:00
debug ( LOG_NEVER , " driveTacticalSelectionChanged \n " ) ;
2007-06-28 10:47:08 -07:00
}
}
// Player clicked in the radar window.
//
void driveProcessRadarInput ( int x , int y )
{
2008-08-02 08:17:22 -07:00
int PosX , PosY ;
2007-06-28 10:47:08 -07:00
// when drive mode is active, clicking on the radar orders all selected droids
// to move to this position.
2008-08-02 08:17:22 -07:00
CalcRadarPosition ( x , y , & PosX , & PosY ) ;
2007-06-28 10:47:08 -07:00
orderSelectedLoc ( selectedPlayer , PosX * TILE_UNITS , PosY * TILE_UNITS ) ;
}
2008-02-08 03:05:31 -08:00
/*
void driveMarkTarget ( void )
{
BASE_OBJECT * psObj = targetGetCurrent ( ) ;
if ( psObj ! = NULL )
{
if ( driveAllowControl ( ) )
{
2008-03-24 09:51:17 -07:00
// MouseMovement(false);
2008-02-08 03:05:31 -08:00
targetMarkCurrent ( ) ;
SetMousePos ( 0 , psObj - > sDisplay . screenX , psObj - > sDisplay . screenY ) ;
// pie_DrawMouse(psObj->sDisplay.screenX,psObj->sDisplay.screenY);
}
}
}
*/