2016-12-02 23:12:10 +00:00
|
|
|
/*
|
|
|
|
OpenCS Project
|
|
|
|
Copyright (C) 2015 Marco "eukara" Hladik
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2016-12-09 23:03:13 +00:00
|
|
|
void Damage_CastOrbituary( entity eAttacker, entity eTarget, float fWeapon, float fHeadShot ) {
|
|
|
|
WriteByte( MSG_BROADCAST, SVC_CGAMEPACKET );
|
|
|
|
WriteByte( MSG_BROADCAST, EV_ORBITUARY );
|
|
|
|
WriteByte( MSG_BROADCAST, num_for_edict( eAttacker ) - 1 );
|
|
|
|
WriteByte( MSG_BROADCAST, eAttacker.team );
|
|
|
|
WriteByte( MSG_BROADCAST, num_for_edict( eTarget ) - 1 );
|
|
|
|
WriteByte( MSG_BROADCAST, eTarget.team );
|
|
|
|
WriteByte( MSG_BROADCAST, fWeapon );
|
|
|
|
WriteByte( MSG_BROADCAST, fHeadShot );
|
|
|
|
msg_entity = self;
|
|
|
|
multicast( '0 0 0', MULTICAST_ALL );
|
|
|
|
}
|
|
|
|
|
2016-12-04 01:27:15 +00:00
|
|
|
void Damage_Apply( entity eTarget, entity eAttacker, int iDamage, vector vHitPos ) {
|
2016-12-02 23:12:10 +00:00
|
|
|
|
2016-12-04 01:27:15 +00:00
|
|
|
eTarget.health = eTarget.health - iDamage; // TODO: Body part multipliers
|
2016-12-02 23:12:10 +00:00
|
|
|
|
|
|
|
if ( eTarget.iBleeds == TRUE ) {
|
|
|
|
makevectors( eAttacker.angles );
|
|
|
|
pointparticles( EFFECT_BLOOD, vHitPos, v_forward * -1, 1 );
|
|
|
|
}
|
|
|
|
|
2016-12-09 23:03:13 +00:00
|
|
|
if ( eTarget.health <= 0 ) {
|
|
|
|
if ( eTarget.flags & FL_CLIENT && eAttacker.flags & FL_CLIENT ) {
|
|
|
|
Damage_CastOrbituary( eAttacker, eTarget, eAttacker.weapon, FALSE );
|
|
|
|
eAttacker.fKills++;
|
|
|
|
eTarget.fDeaths++;
|
|
|
|
|
|
|
|
forceinfokey( eAttacker, "*score", ftos( eAttacker.fKills ) );
|
|
|
|
forceinfokey( eTarget, "*deaths", ftos( eTarget.fDeaths ) );
|
|
|
|
|
|
|
|
Money_AddMoney( eAttacker, 300 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-07 23:09:50 +00:00
|
|
|
entity eOld = self;
|
2016-12-02 23:12:10 +00:00
|
|
|
self = eTarget;
|
|
|
|
|
2016-12-07 23:09:50 +00:00
|
|
|
if ( self.health <= 0 ) {
|
|
|
|
self.health = 0;
|
|
|
|
self.vDeath();
|
2016-12-02 23:12:10 +00:00
|
|
|
} else {
|
2016-12-07 23:09:50 +00:00
|
|
|
self.vPain();
|
2016-12-02 23:12:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self = eOld;
|
|
|
|
}
|
2016-12-07 02:35:01 +00:00
|
|
|
|
|
|
|
void Damage_Radius( vector vOrigin, entity eAttacker, float fDamage, float fRadius ) {
|
|
|
|
entity eDChain = findradius( vOrigin, fRadius );
|
|
|
|
|
|
|
|
while( eDChain ) {
|
|
|
|
|
|
|
|
if ( eDChain.takedamage == DAMAGE_YES ) {
|
|
|
|
float fDiff = vlen( vOrigin - eDChain.origin );
|
|
|
|
|
|
|
|
fDiff = ( fRadius - fDiff ) / fRadius;
|
|
|
|
|
|
|
|
fDamage = fDamage * fDiff;
|
|
|
|
|
|
|
|
bprint( sprintf("[DEBUG] EXPLOSION! Hit Radius: %d, Damage Multiplier: %f\n", vlen( vOrigin - eDChain.origin ), fDiff ) );
|
|
|
|
|
|
|
|
if ( fDiff > 0 ) {
|
|
|
|
Damage_Apply( eDChain, eAttacker, fDamage, eDChain.origin );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eDChain = eDChain.chain;
|
|
|
|
}
|
|
|
|
}
|