[Add] Pushback effect for weapons.

This commit is contained in:
Allanis 2013-02-24 16:06:19 +00:00
parent 9fc0c72e71
commit b55259321e
6 changed files with 30 additions and 14 deletions

View File

@ -4,7 +4,7 @@
<general>
<max>5</max>
<tech>2</tech>
<mass>5</mass>
<mass>0</mass>
</general>
<specific type="1">
<gfx>lasergreen</gfx>

View File

@ -20,12 +20,12 @@
</health>
<characteristics>
<crew>2</crew>
<mass>7</mass>
<mass>32</mass>
<cap_weapon>20</cap_weapon>
<cap_cargo>25</cap_cargo>
</characteristics>
<outfits>
<outfit quantity='3'>Laser</outfit>
<outfit quantity='1'>Laser</outfit>
</outfits>
</ship>
<ship name = "Leapard">
@ -48,7 +48,7 @@
</health>
<characteristics>
<crew>2</crew>
<mass>5</mass>
<mass>25</mass>
<cap_weapon>25</cap_weapon>
<cap_cargo>10</cap_cargo>
</characteristics>
@ -62,9 +62,9 @@
<sound>engine</sound>
<class>2</class>
<movement>
<thrust>180</thrust>
<turn>130</turn>
<speed>260</speed>
<thrust>320</thrust>
<turn>150</turn>
<speed>360</speed>
</movement>
<health>
<shield>160</shield>

View File

@ -1,7 +1,7 @@
<Start>
<name>Dark Tides</name>
<player>
<ship>Merchant Ship</ship>
<ship>Lancer</ship>
<credits>
<low>500</low>
<high>1500</high>

View File

@ -177,18 +177,33 @@ static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t) {
}
// Damage the pilot.
void pilot_hit(Pilot* p, const double damage_shield, const double damage_armour) {
if(p->shield - damage_shield > 0.)
void pilot_hit(Pilot* p, const Solid* w,const double damage_shield,
const double damage_armour) {
double dam_mod;
if(p->shield - damage_shield > 0.) {
p->shield -= damage_shield;
dam_mod = damage_shield/p->shield_max;
}
else if(p->shield > 0.) {
// Shields can take part of the blow.
p->armour -= p->shield/damage_shield*damage_armour;
p->shield = 0.;
dam_mod = (damage_shield+damage_armour) / (p->shield_max + p->armour_max);
}
else if(p->armour-damage_armour > 0.)
else if(p->armour-damage_armour > 0.) {
p->armour -= damage_armour;
else
dam_mod = damage_armour/p->armour_max;
}
else {
p->armour = 0.;
dam_mod = 0.;
}
vect_cadd(&p->solid->vel,
w->vel.x * (dam_mod/4. + w->mass/p->solid->mass/4.),
w->vel.y * (dam_mod/4. + w->mass/p->solid->mass/4.));
}
// Set the pilot's ammo based on their secondary weapon.

View File

@ -105,7 +105,8 @@ Fleet* fleet_get(const char* name);
// MISC.
void pilot_shoot(Pilot* p, const unsigned int target, const int secondary);
void pilot_hit(Pilot* p, const double damage_shield, const double damage_armour);
void pilot_hit(Pilot* p, const Solid* w,
const double damage_shield, const double damage_armour);
void pilot_setAmmo(Pilot* p);
double pilot_face(Pilot* p, const float dir);

View File

@ -243,7 +243,7 @@ static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer) {
pilot_setFlag(p, PILOT_HOSTILE);
// Let the ship know that is should take some kind of damage.
pilot_hit(p, w->outfit->damage_shield, w->outfit->damage_armour);
pilot_hit(p, w->solid, w->outfit->damage_shield, w->outfit->damage_armour);
// We don't need the weapon particle any longer.
weapon_destroy(w, layer);
}