sv_pistol_damage

This commit is contained in:
def 2014-03-31 20:34:54 +02:00
parent 9503587a11
commit a5449c9af0
4 changed files with 92 additions and 7 deletions

View file

@ -240,6 +240,7 @@ MACRO_CONFIG_INT(SvNetlimit, sv_netlimit, 0, 0, 10000, CFGFLAG_SERVER, "Netlimit
MACRO_CONFIG_INT(SvNetlimitAlpha, sv_netlimit_alpha, 50, 1, 100, CFGFLAG_SERVER, "Netlimit: Alpha of Exponention moving average") MACRO_CONFIG_INT(SvNetlimitAlpha, sv_netlimit_alpha, 50, 1, 100, CFGFLAG_SERVER, "Netlimit: Alpha of Exponention moving average")
MACRO_CONFIG_INT(SvJetpack, sv_jetpack, 400, -10000, 10000, CFGFLAG_SERVER, "Jetpack strength") MACRO_CONFIG_INT(SvJetpack, sv_jetpack, 400, -10000, 10000, CFGFLAG_SERVER, "Jetpack strength")
MACRO_CONFIG_INT(SvPistolDamage, sv_pistol_damage, 0, 0, 1, CFGFLAG_SERVER, "Pistol damage")
MACRO_CONFIG_INT(ClUnpredictedShadow, cl_unpredicted_shadow, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show unpredicted shadow tee to estimate your delay") MACRO_CONFIG_INT(ClUnpredictedShadow, cl_unpredicted_shadow, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show unpredicted shadow tee to estimate your delay")
MACRO_CONFIG_INT(ClPredictDDRace, cl_predict_ddrace, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict some DDRace tiles") MACRO_CONFIG_INT(ClPredictDDRace, cl_predict_ddrace, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict some DDRace tiles")
MACRO_CONFIG_INT(ClShowNinja, cl_show_ninja, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show ninja skin") MACRO_CONFIG_INT(ClShowNinja, cl_show_ninja, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show ninja skin")

View file

@ -857,10 +857,8 @@ void CCharacter::Die(int Killer, int Weapon)
bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
{ {
/*m_Core.m_Vel += Force; /*
m_Core.m_Vel += Force;
if(GameServer()->m_pController->IsFriendlyFire(m_pPlayer->GetCID(), From) && !g_Config.m_SvTeamdamage)
return false;
// m_pPlayer only inflicts half damage on self // m_pPlayer only inflicts half damage on self
if(From == m_pPlayer->GetCID()) if(From == m_pPlayer->GetCID())
@ -963,6 +961,89 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
return true; return true;
} }
bool CCharacter::TakeDamageOrig(vec2 Force, int Dmg, int From, int Weapon)
{
m_Core.m_Vel += Force;
// m_pPlayer only inflicts half damage on self
if(From == m_pPlayer->GetCID())
Dmg = max(1, Dmg/2);
m_DamageTaken++;
// create healthmod indicator
if(Server()->Tick() < m_DamageTakenTick+25)
{
// make sure that the damage indicators doesn't group together
GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, Dmg);
}
else
{
m_DamageTaken = 0;
GameServer()->CreateDamageInd(m_Pos, 0, Dmg);
}
if(Dmg)
m_Health -= Dmg;
m_DamageTakenTick = Server()->Tick();
// do damage Hit sound
if(From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From])
{
int64_t Mask = CmaskOne(From);
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS && GameServer()->m_apPlayers[i]->m_SpectatorID == From)
Mask |= CmaskOne(i);
}
GameServer()->CreateSound(GameServer()->m_apPlayers[From]->m_ViewPos, SOUND_HIT, Mask);
}
// check for death
if(m_Health <= 0)
{
Die(From, Weapon);
// set attacker's face to happy (taunt!)
if (From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From])
{
CCharacter *pChr = GameServer()->m_apPlayers[From]->GetCharacter();
if (pChr)
{
pChr->m_EmoteType = EMOTE_HAPPY;
pChr->m_EmoteStop = Server()->Tick() + Server()->TickSpeed();
}
}
return false;
}
if (Dmg > 2)
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG);
else
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_SHORT);
if (!m_Jetpack || m_ActiveWeapon != WEAPON_GUN)
{
m_EmoteType = EMOTE_PAIN;
m_EmoteStop = Server()->Tick() + 500 * Server()->TickSpeed() / 1000;
}
vec2 Temp = m_Core.m_Vel + Force;
if(Temp.x > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA)))
Temp.x = 0;
if(Temp.x < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA)))
Temp.x = 0;
if(Temp.y < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA)))
Temp.y = 0;
if(Temp.y > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA)))
Temp.y = 0;
m_Core.m_Vel = Temp;
return true;
}
void CCharacter::Snap(int SnappingClient) void CCharacter::Snap(int SnappingClient)
{ {
int id = m_pPlayer->GetCID(); int id = m_pPlayer->GetCID();

View file

@ -60,6 +60,7 @@ public:
void Die(int Killer, int Weapon); void Die(int Killer, int Weapon);
bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon); bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon);
bool TakeDamageOrig(vec2 Force, int Dmg, int From, int Weapon);
bool Spawn(class CPlayer *pPlayer, vec2 Pos); bool Spawn(class CPlayer *pPlayer, vec2 Pos);
bool Remove(); bool Remove();

View file

@ -32,7 +32,6 @@ CProjectile::CProjectile
m_LifeSpan = Span; m_LifeSpan = Span;
m_Owner = Owner; m_Owner = Owner;
m_Force = Force; m_Force = Force;
//m_Damage = Damage;
m_SoundImpact = SoundImpact; m_SoundImpact = SoundImpact;
m_Weapon = Weapon; m_Weapon = Weapon;
m_StartTick = Server()->Tick(); m_StartTick = Server()->Tick();
@ -177,7 +176,10 @@ void CProjectile::Tick()
} }
else if (m_Weapon == WEAPON_GUN) else if (m_Weapon == WEAPON_GUN)
{ {
GameServer()->CreateDamageInd(CurPos, -atan2(m_Direction.x, m_Direction.y), 10, (m_Owner != -1)? TeamMask : -1LL); if (g_Config.m_SvPistolDamage && pTargetChr)
pTargetChr->TakeDamageOrig(m_Direction * max(0.001f, m_Force), 1, m_Owner, m_Weapon);
else
GameServer()->CreateDamageInd(CurPos, -atan2(m_Direction.x, m_Direction.y), 10, (m_Owner != -1)? TeamMask : -1LL);
GameServer()->m_World.DestroyEntity(this); GameServer()->m_World.DestroyEntity(this);
} }
else else