[Change] Improved some of the shooting handling.
This commit is contained in:
parent
81fd657540
commit
f0336e14af
@ -196,7 +196,7 @@ static int board_fail(void) {
|
|||||||
/**
|
/**
|
||||||
* @fn static void board_update(void)
|
* @fn static void board_update(void)
|
||||||
*
|
*
|
||||||
* @brief Updates the boarding window fields.
|
* @brief Updates the boarding window.
|
||||||
*/
|
*/
|
||||||
static void board_update(void) {
|
static void board_update(void) {
|
||||||
int i;
|
int i;
|
||||||
|
39
src/pilot.c
39
src/pilot.c
@ -163,7 +163,7 @@ Fleet* fleet_get(const char* name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Attempt to turn the pilot to face dir. */
|
/* Attempt to turn the pilot to face dir. */
|
||||||
double pilot_face(Pilot* p, const float dir) {
|
double pilot_face(Pilot* p, const double dir) {
|
||||||
double diff, turn;
|
double diff, turn;
|
||||||
|
|
||||||
diff = angle_diff(p->solid->dir, dir);
|
diff = angle_diff(p->solid->dir, dir);
|
||||||
@ -219,6 +219,14 @@ void pilot_shoot(Pilot* p, const unsigned int target, const int secondary) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t)
|
||||||
|
*
|
||||||
|
* @brief Actually handles the shooting, how often the player can shoot and such.
|
||||||
|
* @param p Pilot that is shooting.
|
||||||
|
* @param w Pilot's outfit to shoot.
|
||||||
|
* @param t Pilot's target.
|
||||||
|
*/
|
||||||
static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t) {
|
static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t) {
|
||||||
int quantity, delay;
|
int quantity, delay;
|
||||||
/* WElll... Trying to shoot when you have no ammo?? FUUU */
|
/* WElll... Trying to shoot when you have no ammo?? FUUU */
|
||||||
@ -227,28 +235,29 @@ static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t) {
|
|||||||
|
|
||||||
/* Check to see if weapon is ready. */
|
/* Check to see if weapon is ready. */
|
||||||
if((SDL_GetTicks() - w->timer) < (unsigned int)(delay/quantity)) return;
|
if((SDL_GetTicks() - w->timer) < (unsigned int)(delay/quantity)) return;
|
||||||
/* Regular weapons. */
|
/* Regular bolt weapons. */
|
||||||
if(outfit_isWeapon(w->outfit) || (outfit_isTurret(w->outfit))) {
|
if(outfit_isBolt(w->outfit)) {
|
||||||
/* Different weapons. */
|
|
||||||
switch(w->outfit->type) {
|
|
||||||
case OUTFIT_TYPE_TURRET_BOLT:
|
|
||||||
case OUTFIT_TYPE_BOLT:
|
|
||||||
/* Enough energy? */
|
/* Enough energy? */
|
||||||
if(outfit_energy(w->outfit) > p->energy) return;
|
if(outfit_energy(w->outfit) > p->energy) return;
|
||||||
|
|
||||||
p->energy -= outfit_energy(w->outfit);
|
p->energy -= outfit_energy(w->outfit);
|
||||||
weapon_add(w->outfit, p->solid->dir, &p->solid->pos,
|
weapon_add(w->outfit, p->solid->dir,
|
||||||
&p->solid->vel, p->id, t);
|
&p->solid->pos, &p->solid->vel, p->id, t);
|
||||||
|
|
||||||
/* Can't shoot for a while. */
|
/* Can't shoot it for a bit. */
|
||||||
w->timer = SDL_GetTicks();
|
w->timer = SDL_GetTicks();
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Beam Weapons. */
|
||||||
|
else if(outfit_isBeam(w->outfit)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
/* Missile launchers. */
|
|
||||||
/* Must be secondary weapon. */
|
/*
|
||||||
|
* Missile Launchers.
|
||||||
|
*
|
||||||
|
* Must be a secondary weapon.
|
||||||
|
*/
|
||||||
else if(outfit_isLauncher(w->outfit) && (w == p->secondary)) {
|
else if(outfit_isLauncher(w->outfit) && (w == p->secondary)) {
|
||||||
/* Shooter can't be the target - Sanity check for the player. */
|
/* Shooter can't be the target - Sanity check for the player. */
|
||||||
if((w->outfit->type != OUTFIT_TYPE_MISSILE_DUMB) && (p->id == t))
|
if((w->outfit->type != OUTFIT_TYPE_MISSILE_DUMB) && (p->id == t))
|
||||||
|
@ -204,7 +204,7 @@ void pilot_hit(Pilot* p, const Solid* w, const unsigned int shooter,
|
|||||||
void pilot_setSecondary(Pilot* p, const char* secondary);
|
void pilot_setSecondary(Pilot* p, const char* secondary);
|
||||||
void pilot_setAmmo(Pilot* p);
|
void pilot_setAmmo(Pilot* p);
|
||||||
void pilot_setAfterburner(Pilot* p);
|
void pilot_setAfterburner(Pilot* p);
|
||||||
double pilot_face(Pilot* p, const float dir);
|
double pilot_face(Pilot* p, const double dir);
|
||||||
/* Outfits. */
|
/* Outfits. */
|
||||||
int pilot_freeSpace(Pilot* p); /* Pilot space. */
|
int pilot_freeSpace(Pilot* p); /* Pilot space. */
|
||||||
int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity);
|
int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity);
|
||||||
|
Loading…
Reference in New Issue
Block a user