[Change] Some code cleanup.
This commit is contained in:
parent
5ae72bcacd
commit
bafed15cdc
41
src/player.c
41
src/player.c
@ -33,6 +33,7 @@
|
|||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
#include "perlin.h"
|
#include "perlin.h"
|
||||||
|
#include "ai.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
#define XML_GUI_ID "GUIs" /**< XML section identifier for GUI document. */
|
#define XML_GUI_ID "GUIs" /**< XML section identifier for GUI document. */
|
||||||
@ -1801,6 +1802,9 @@ void player_abortAutonav(char* reason) {
|
|||||||
* @param pplayer Player to think.
|
* @param pplayer Player to think.
|
||||||
*/
|
*/
|
||||||
void player_think(Pilot* pplayer) {
|
void player_think(Pilot* pplayer) {
|
||||||
|
Pilot* target;
|
||||||
|
double d;
|
||||||
|
|
||||||
/* Last I checked, the dead didn't think.. */
|
/* Last I checked, the dead didn't think.. */
|
||||||
if(pilot_isFlag(pplayer, PILOT_DEAD)) {
|
if(pilot_isFlag(pplayer, PILOT_DEAD)) {
|
||||||
/* No point in accelerating or turning. */
|
/* No point in accelerating or turning. */
|
||||||
@ -1811,24 +1815,31 @@ void player_think(Pilot* pplayer) {
|
|||||||
|
|
||||||
/* Autonav takes over normal controls. */
|
/* Autonav takes over normal controls. */
|
||||||
if(player_isFlag(PLAYER_AUTONAV)) {
|
if(player_isFlag(PLAYER_AUTONAV)) {
|
||||||
|
/* Abort if lockons detected. */
|
||||||
if(pplayer->lockons > 0)
|
if(pplayer->lockons > 0)
|
||||||
player_abortAutonav("Missile Lockon Detected");
|
player_abortAutonav("Missile Lockon Detected");
|
||||||
|
|
||||||
if(space_canHyperspace(pplayer)) {
|
/* Try to jump. */
|
||||||
|
if(space_canHyperspace(pplayer))
|
||||||
player_jump();
|
player_jump();
|
||||||
} else {
|
else { /* Keep on moving. */
|
||||||
pilot_face(pplayer, VANGLE(pplayer->solid->pos));
|
/* Only accelerate if facing move dir. */
|
||||||
if(player_acc < 1.)
|
d = pilot_face(pplayer, VANGLE(pplayer->solid->pos));
|
||||||
|
if((player_acc < 1.) && (d < MIN_DIR_ERR))
|
||||||
player_accel(1.);
|
player_accel(1.);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PLAYER_FACE will take over navigation. */
|
/* PLAYER_FACE will take over navigation. */
|
||||||
else if(player_isFlag(PLAYER_FACE)) {
|
else if(player_isFlag(PLAYER_FACE)) {
|
||||||
if(player->target != PLAYER_ID)
|
/* Try to face pilot target */
|
||||||
|
if(player->target != PLAYER_ID) {
|
||||||
|
target = pilot_get(player->target);
|
||||||
|
if(target != NULL)
|
||||||
pilot_face(pplayer,
|
pilot_face(pplayer,
|
||||||
vect_angle(&player->solid->pos,
|
vect_angle(&player->solid->pos, &target->solid->pos));
|
||||||
&pilot_get(player->target)->solid->pos));
|
}
|
||||||
|
/* If not try to face planet target. */
|
||||||
else if(planet_target != -1)
|
else if(planet_target != -1)
|
||||||
pilot_face(pplayer,
|
pilot_face(pplayer,
|
||||||
vect_angle(&player->solid->pos,
|
vect_angle(&player->solid->pos,
|
||||||
@ -1836,8 +1847,22 @@ void player_think(Pilot* pplayer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* PLAYER_REVERSE will take over navigation. */
|
/* PLAYER_REVERSE will take over navigation. */
|
||||||
else if(player_isFlag(PLAYER_REVERSE) && (VMOD(pplayer->solid->vel) > 0.))
|
else if(player_isFlag(PLAYER_REVERSE)) {
|
||||||
|
/* Check to see if already stopped. */
|
||||||
|
#if 0
|
||||||
|
if(VMOD(pplayer->solid->vel) < MIN_VEL_ERR)
|
||||||
|
player_accel(0.);
|
||||||
|
else {
|
||||||
|
d = pilot_face(pplayer, VANGLE(player->solid->vel) + M_PI);
|
||||||
|
if((player_acc < 1.) && (d < MAX_DIR_ERR))
|
||||||
|
player_accel(1.);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Hm, I don't think automatic braking is amy good.
|
||||||
|
*/
|
||||||
pilot_face(pplayer, VANGLE(player->solid->vel) + M_PI);
|
pilot_face(pplayer, VANGLE(player->solid->vel) + M_PI);
|
||||||
|
}
|
||||||
|
|
||||||
/* Normal navigation sheme. */
|
/* Normal navigation sheme. */
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user