[Add] You will need permission to land on a planet.
This commit is contained in:
parent
f02a406ffc
commit
a4bca2004b
@ -466,6 +466,9 @@ void takeoff(void) {
|
|||||||
sw = planet->gfx_space->w;
|
sw = planet->gfx_space->w;
|
||||||
sh = planet->gfx_space->h;
|
sh = planet->gfx_space->h;
|
||||||
|
|
||||||
|
// No longer authorized to land.
|
||||||
|
player_rmFlag(PLAYER_LANDACK);
|
||||||
|
|
||||||
// Set player to another position with random facing direction and no velocity.
|
// Set player to another position with random facing direction and no velocity.
|
||||||
player_warp(planet->pos.x + RNG(-sw/2, sw/2), planet->pos.y + RNG(-sh/2, sh/2));
|
player_warp(planet->pos.x + RNG(-sw/2, sw/2), planet->pos.y + RNG(-sh/2, sh/2));
|
||||||
vect_pset(&player->solid->vel, 0., 0.);
|
vect_pset(&player->solid->vel, 0., 0.);
|
||||||
|
15
src/player.c
15
src/player.c
@ -909,6 +909,7 @@ void player_secondaryNext(void) {
|
|||||||
// Cycle through planet targets.
|
// Cycle through planet targets.
|
||||||
void player_targetPlanet(void) {
|
void player_targetPlanet(void) {
|
||||||
hyperspace_target = -1;
|
hyperspace_target = -1;
|
||||||
|
player_rmFlag(PLAYER_LANDACK);
|
||||||
|
|
||||||
if((planet_target == -1) && (cur_system->nplanets > 0)) {
|
if((planet_target == -1) && (cur_system->nplanets > 0)) {
|
||||||
// No target.
|
// No target.
|
||||||
@ -932,7 +933,16 @@ void player_land(void) {
|
|||||||
}
|
}
|
||||||
Planet* planet = &cur_system->planets[planet_target];
|
Planet* planet = &cur_system->planets[planet_target];
|
||||||
if(planet_target >= 0) {
|
if(planet_target >= 0) {
|
||||||
if(vect_dist(&player->solid->pos, &planet->pos) > planet->gfx_space->sw) {
|
if(!player_isFlag(PLAYER_LANDACK)) {
|
||||||
|
if(!areEnemies(player->faction, planet->faction)) {
|
||||||
|
player_message("%s> Permission to land cleared.", planet->name);
|
||||||
|
player_setFlag(PLAYER_LANDACK);
|
||||||
|
} else {
|
||||||
|
player_message("%s> Land request denied.", planet->name);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(vect_dist(&player->solid->pos, &planet->pos) > planet->gfx_space->sw) {
|
||||||
player_message("You are too far away to land on %s", planet->name);
|
player_message("You are too far away to land on %s", planet->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -958,11 +968,14 @@ void player_land(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
planet_target = tp;
|
planet_target = tp;
|
||||||
|
player_rmFlag(PLAYER_LANDACK);
|
||||||
|
player_land(); // Re-run land protocol.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void player_targetHyperspace(void) {
|
void player_targetHyperspace(void) {
|
||||||
planet_target = -1; // Remove planet target.
|
planet_target = -1; // Remove planet target.
|
||||||
|
player_rmFlag(PLAYER_LANDACK); // Get rid of landing permission.
|
||||||
hyperspace_target++;
|
hyperspace_target++;
|
||||||
|
|
||||||
if(hyperspace_target >= cur_system->njumps)
|
if(hyperspace_target >= cur_system->njumps)
|
||||||
|
@ -8,11 +8,12 @@
|
|||||||
#define PLAYER_FACE (1<<10) // Player is facing target.
|
#define PLAYER_FACE (1<<10) // Player is facing target.
|
||||||
#define PLAYER_PRIMARY (1<<11) // Player is shooting primary weapon.
|
#define PLAYER_PRIMARY (1<<11) // Player is shooting primary weapon.
|
||||||
#define PLAYER_SECONDARY (1<<12) // Player is shooting secondary weapon.
|
#define PLAYER_SECONDARY (1<<12) // Player is shooting secondary weapon.
|
||||||
|
#define PLAYER_LANDACK (1<<13) // Player has permission to land.
|
||||||
|
|
||||||
// Flag functions.
|
// Flag functions.
|
||||||
#define player_isFlag(f) (player_flags & f)
|
#define player_isFlag(f) (player_flags & f)
|
||||||
#define player_setFlag(f) (player_flags |= f)
|
#define player_setFlag(f) if(!player_isFlag(f)) (player_flags |= f)
|
||||||
#define player_rmFlag(f) (player_flags ^= f)
|
#define player_rmFlag(f) if(player_isFlag(f)) (player_flags ^= f)
|
||||||
|
|
||||||
// The player.
|
// The player.
|
||||||
extern Pilot* pilot;
|
extern Pilot* pilot;
|
||||||
|
Loading…
Reference in New Issue
Block a user