mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-10 04:27:10 +03:00
Try to play pain animation in DamageFeedback
This commit is contained in:
parent
8d41b58635
commit
a56d74814b
1 changed files with 203 additions and 47 deletions
|
@ -1716,7 +1716,7 @@ void Player::Obituary(Entity *attacker, Entity *inflictor, int meansofdeath, int
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MOD_FAST_BULLET:
|
case MOD_FAST_BULLET:
|
||||||
if (iLocation == -1 || iLocation == -2) {
|
if (iLocation == HITLOC_GENERAL || iLocation == HITLOC_MISS) {
|
||||||
s1 = "shot himself";
|
s1 = "shot himself";
|
||||||
} else {
|
} else {
|
||||||
s1 = "shot himself in the";
|
s1 = "shot himself in the";
|
||||||
|
@ -1924,7 +1924,7 @@ void Player::Obituary(Entity *attacker, Entity *inflictor, int meansofdeath, int
|
||||||
break;
|
break;
|
||||||
case MOD_BULLET:
|
case MOD_BULLET:
|
||||||
case MOD_FAST_BULLET:
|
case MOD_FAST_BULLET:
|
||||||
if (iLocation == -2 || iLocation == -1) {
|
if (iLocation == HITLOC_GENERAL || iLocation == HITLOC_MISS) {
|
||||||
s1 = "was shot";
|
s1 = "was shot";
|
||||||
} else {
|
} else {
|
||||||
s1 = "was shot in the";
|
s1 = "was shot in the";
|
||||||
|
@ -3370,9 +3370,8 @@ void Player::ClientThink(void)
|
||||||
|| g_medal3->modificationCount > 1 || g_medal4->modificationCount > 1 || g_medal5->modificationCount > 1
|
|| g_medal3->modificationCount > 1 || g_medal4->modificationCount > 1 || g_medal5->modificationCount > 1
|
||||||
|| g_medalbt1->modificationCount > 1 || g_medalbt2->modificationCount > 1
|
|| g_medalbt1->modificationCount > 1 || g_medalbt2->modificationCount > 1
|
||||||
|| g_medalbt3->modificationCount > 1 || g_medalbt4->modificationCount > 1
|
|| g_medalbt3->modificationCount > 1 || g_medalbt4->modificationCount > 1
|
||||||
|| g_medalbt5->modificationCount > 1
|
|| g_medalbt5->modificationCount > 1 || g_eogmedal0->modificationCount > 1
|
||||||
|| g_eogmedal0->modificationCount > 1 || g_eogmedal1->modificationCount > 1
|
|| g_eogmedal1->modificationCount > 1 || g_eogmedal2->modificationCount > 1) {
|
||||||
|| g_eogmedal2->modificationCount > 1) {
|
|
||||||
gi.Cvar_Set("g_gotmedal", "0");
|
gi.Cvar_Set("g_gotmedal", "0");
|
||||||
} else {
|
} else {
|
||||||
gi.Cvar_Set("g_gotmedal", "1");
|
gi.Cvar_Set("g_gotmedal", "1");
|
||||||
|
@ -4607,19 +4606,27 @@ void Player::GodCheat(Event *ev)
|
||||||
if (ev->GetInteger(1)) {
|
if (ev->GetInteger(1)) {
|
||||||
flags |= FL_GODMODE;
|
flags |= FL_GODMODE;
|
||||||
// Also enable the god mode for the vehicle
|
// Also enable the god mode for the vehicle
|
||||||
if (m_pVehicle) m_pVehicle->flags |= FL_GODMODE;
|
if (m_pVehicle) {
|
||||||
|
m_pVehicle->flags |= FL_GODMODE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
flags &= ~FL_GODMODE;
|
flags &= ~FL_GODMODE;
|
||||||
// Also disable the god mode for the vehicle
|
// Also disable the god mode for the vehicle
|
||||||
if (m_pVehicle) m_pVehicle->flags &= ~FL_GODMODE;
|
if (m_pVehicle) {
|
||||||
|
m_pVehicle->flags &= ~FL_GODMODE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (flags & FL_GODMODE) {
|
if (flags & FL_GODMODE) {
|
||||||
flags &= ~FL_GODMODE;
|
flags &= ~FL_GODMODE;
|
||||||
if (m_pVehicle) m_pVehicle->flags &= ~FL_GODMODE;
|
if (m_pVehicle) {
|
||||||
|
m_pVehicle->flags &= ~FL_GODMODE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
flags |= FL_GODMODE;
|
flags |= FL_GODMODE;
|
||||||
if (m_pVehicle) m_pVehicle->flags |= FL_GODMODE;
|
if (m_pVehicle) {
|
||||||
|
m_pVehicle->flags |= FL_GODMODE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4977,6 +4984,7 @@ void Player::DamageFeedback(void)
|
||||||
float count;
|
float count;
|
||||||
vec3_t vDir;
|
vec3_t vDir;
|
||||||
str painAnim;
|
str painAnim;
|
||||||
|
int animnum;
|
||||||
|
|
||||||
// if we are dead, don't setup any feedback
|
// if we are dead, don't setup any feedback
|
||||||
if (IsDead()) {
|
if (IsDead()) {
|
||||||
|
@ -4987,8 +4995,7 @@ void Player::DamageFeedback(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damage_count)
|
if (damage_count) {
|
||||||
{
|
|
||||||
// decay damage_count over time
|
// decay damage_count over time
|
||||||
damage_count *= 0.8f;
|
damage_count *= 0.8f;
|
||||||
damage_from *= 0.8f;
|
damage_from *= 0.8f;
|
||||||
|
@ -5007,13 +5014,16 @@ void Player::DamageFeedback(void)
|
||||||
|
|
||||||
VectorNormalize2(damage_from, vDir);
|
VectorNormalize2(damage_from, vDir);
|
||||||
|
|
||||||
damage_angles.x -= DotProduct(vDir, orientation[0]) * damage_blood * g_viewkick_pitch->value * g_viewkick_dmmult->value;
|
damage_angles.x -=
|
||||||
|
DotProduct(vDir, orientation[0]) * damage_blood * g_viewkick_pitch->value * g_viewkick_dmmult->value;
|
||||||
damage_angles.x = Q_clamp_float(damage_angles.x, -30, 30);
|
damage_angles.x = Q_clamp_float(damage_angles.x, -30, 30);
|
||||||
|
|
||||||
damage_angles.y -= DotProduct(vDir, orientation[1]) * damage_blood * g_viewkick_yaw->value * g_viewkick_dmmult->value;
|
damage_angles.y -=
|
||||||
|
DotProduct(vDir, orientation[1]) * damage_blood * g_viewkick_yaw->value * g_viewkick_dmmult->value;
|
||||||
damage_angles.y = Q_clamp_float(damage_angles.y, -30, 30);
|
damage_angles.y = Q_clamp_float(damage_angles.y, -30, 30);
|
||||||
|
|
||||||
damage_angles.z += DotProduct(vDir, orientation[2]) * damage_blood * g_viewkick_roll->value * g_viewkick_dmmult->value;
|
damage_angles.z +=
|
||||||
|
DotProduct(vDir, orientation[2]) * damage_blood * g_viewkick_roll->value * g_viewkick_dmmult->value;
|
||||||
damage_angles.z = Q_clamp_float(damage_angles.y, -25, 25);
|
damage_angles.z = Q_clamp_float(damage_angles.y, -25, 25);
|
||||||
|
|
||||||
damage_count += damage_blood;
|
damage_count += damage_blood;
|
||||||
|
@ -5045,10 +5055,156 @@ void Player::DamageFeedback(void)
|
||||||
damage_blend += (damage_blood / realcount) * bcolor;
|
damage_blend += (damage_blood / realcount) * bcolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Since 2.0: Try to find and play pain animation
|
||||||
|
//
|
||||||
|
if (getMoveType() == MOVETYPE_PORTABLE_TURRET) {
|
||||||
|
// use mg42 pain animation
|
||||||
|
painAnim = "mg42_tripod_";
|
||||||
|
} else {
|
||||||
|
Weapon *pWeap;
|
||||||
|
const char *itemName;
|
||||||
|
// try to find an animation
|
||||||
|
|
||||||
|
pWeap = GetActiveWeapon(WEAPON_MAIN);
|
||||||
|
if (pWeap) {
|
||||||
|
int weapon_class;
|
||||||
|
|
||||||
|
weapon_class = pWeap->GetWeaponClass();
|
||||||
|
if (weapon_class & WEAPON_CLASS_PISTOL) {
|
||||||
|
painAnim = "pistol_";
|
||||||
|
} else if (weapon_class & WEAPON_CLASS_RIFLE) {
|
||||||
|
painAnim = "rifle_";
|
||||||
|
} else if (weapon_class & WEAPON_CLASS_SMG) {
|
||||||
|
// get the animation name from the item name
|
||||||
|
itemName = pWeap->GetItemName();
|
||||||
|
|
||||||
|
if (!Q_stricmp(itemName, "MP40")) {
|
||||||
|
painAnim = "mp40_";
|
||||||
|
} else if (!Q_stricmp(itemName, "Sten Mark II")) {
|
||||||
|
painAnim = "sten_";
|
||||||
|
} else {
|
||||||
|
painAnim = "smg_";
|
||||||
|
}
|
||||||
|
} else if (weapon_class & WEAPON_CLASS_MG) {
|
||||||
|
itemName = pWeap->GetItemName();
|
||||||
|
|
||||||
|
if (!Q_stricmp(itemName, "StG 44")) {
|
||||||
|
painAnim = "mp44_";
|
||||||
|
} else {
|
||||||
|
painAnim = "mg_";
|
||||||
|
}
|
||||||
|
} else if (weapon_class & WEAPON_CLASS_GRENADE) {
|
||||||
|
itemName = pWeap->GetItemName();
|
||||||
|
|
||||||
|
// 2.30: use landmine animations
|
||||||
|
if (!Q_stricmp(itemName, "Minedetector")) {
|
||||||
|
painAnim = "minedetector_";
|
||||||
|
} else if (!Q_stricmp(itemName, "Minensuchgerat")) {
|
||||||
|
painAnim = "minedetectoraxis_";
|
||||||
|
} else if (!Q_stricmp(itemName, "LandmineAllies")) {
|
||||||
|
painAnim = "mine_";
|
||||||
|
} else if (!Q_stricmp(itemName, "LandmineAxis")) {
|
||||||
|
painAnim = "mine_";
|
||||||
|
} else if (!Q_stricmp(itemName, "LandmineAxis")) {
|
||||||
|
painAnim = "grenade_";
|
||||||
|
}
|
||||||
|
} else if (weapon_class & WEAPON_CLASS_HEAVY) {
|
||||||
|
itemName = pWeap->GetItemName();
|
||||||
|
|
||||||
|
if (!Q_stricmp(itemName, "Shotgun")) {
|
||||||
|
painAnim = "shotgun_";
|
||||||
|
} else {
|
||||||
|
// Defaults to bazooka
|
||||||
|
painAnim = "bazooka_";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
itemName = pWeap->GetItemName();
|
||||||
|
|
||||||
|
if (!Q_stricmp(itemName, "Packed MG42 Turret")) {
|
||||||
|
painAnim = "mg42_";
|
||||||
|
} else {
|
||||||
|
// Default animation if not found
|
||||||
|
painAnim = "unarmed_";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
painAnim = "unarmed_";
|
||||||
|
}
|
||||||
|
|
||||||
|
// use the animation based on the movement
|
||||||
|
if (m_iMovePosFlags & MPF_POSITION_CROUCHING) {
|
||||||
|
painAnim += "crouch_";
|
||||||
|
} else {
|
||||||
|
painAnim += "stand_";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
painAnim += "hit_";
|
||||||
|
|
||||||
|
if (pain_dir == PAIN_REAR || pain_location == HITLOC_TORSO_MID || HITLOC_TORSO_LOWER) {
|
||||||
|
painAnim += "back";
|
||||||
|
} else {
|
||||||
|
switch (pain_location) {
|
||||||
|
case HITLOC_HEAD:
|
||||||
|
case HITLOC_HELMET:
|
||||||
|
case HITLOC_NECK:
|
||||||
|
painAnim += "head";
|
||||||
|
break;
|
||||||
|
case HITLOC_TORSO_UPPER:
|
||||||
|
case HITLOC_TORSO_MID:
|
||||||
|
painAnim += "uppertorso";
|
||||||
|
break;
|
||||||
|
case HITLOC_TORSO_LOWER:
|
||||||
|
case HITLOC_PELVIS:
|
||||||
|
painAnim += "lowertorso";
|
||||||
|
break;
|
||||||
|
case HITLOC_R_ARM_UPPER:
|
||||||
|
case HITLOC_R_ARM_LOWER:
|
||||||
|
case HITLOC_R_HAND:
|
||||||
|
painAnim += "rarm";
|
||||||
|
break;
|
||||||
|
case HITLOC_L_ARM_UPPER:
|
||||||
|
case HITLOC_L_ARM_LOWER:
|
||||||
|
case HITLOC_L_HAND:
|
||||||
|
painAnim += "larm";
|
||||||
|
break;
|
||||||
|
case HITLOC_R_LEG_UPPER:
|
||||||
|
case HITLOC_L_LEG_UPPER:
|
||||||
|
case HITLOC_R_LEG_LOWER:
|
||||||
|
case HITLOC_L_LEG_LOWER:
|
||||||
|
case HITLOC_R_FOOT:
|
||||||
|
case HITLOC_L_FOOT:
|
||||||
|
painAnim += "leg";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
painAnim += "uppertorso";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
animnum = gi.Anim_NumForName(edict->tiki, painAnim.c_str());
|
||||||
|
if (animnum == -1) {
|
||||||
|
gi.DPrintf("WARNING: Could not find player pain animation '%s'\n", painAnim.c_str());
|
||||||
|
} else {
|
||||||
|
NewAnim(animnum, EV_Player_AnimLoop_Pain, ANIMSLOT_PAIN);
|
||||||
|
RestartAnimSlot(ANIMSLOT_PAIN);
|
||||||
|
m_sPainAnim = painAnim;
|
||||||
|
m_fPainBlend = 1.f;
|
||||||
|
animdone_Pain = false;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// clear totals
|
// clear totals
|
||||||
//
|
//
|
||||||
damage_blood = 0;
|
damage_blood = 0;
|
||||||
|
|
||||||
|
if (IsSubclassOfPlayer()) {
|
||||||
|
damage_count = 0;
|
||||||
|
damage_blood = 0;
|
||||||
|
damage_alpha = 0;
|
||||||
|
damage_angles = vec_zero;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::GetPlayerView(Vector *pos, Vector *angle)
|
void Player::GetPlayerView(Vector *pos, Vector *angle)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue