Locational damage, fall-damage, some fixes here and there... kinda unstable ATM

This commit is contained in:
Marco Cawthorne 2017-01-03 02:02:00 +01:00
parent 2b9aef8167
commit 249eb2d94f
11 changed files with 155 additions and 21 deletions

View file

@ -52,15 +52,6 @@ void ClientDisconnect( void ) {
}
}
void PlayerPreThink( void ) {
Input_Handle();
OpenCSGunBase_ShotMultiplierUpdate();
}
void PlayerPostThink( void ) {
Animation_PlayerUpdate();
}
void PutClientInServer( void ) {
entity eTarget = world;

View file

@ -31,6 +31,34 @@ void Damage_CastOrbituary( entity eAttacker, entity eTarget, float fWeapon, floa
multicast( '0 0 0', MULTICAST_ALL );
}
string Damage_GetHitLocation( int iSurface ) {
switch ( iSurface ) {
case BODY_HEAD:
return "Head";
break;
case BODY_CHEST:
return "Chest";
break;
case BODY_STOMACH:
return "Stomach";
break;
case BODY_ARMLEFT:
return "Left Arm";
break;
case BODY_ARMRIGHT:
return "Right Arm";
break;
case BODY_LEGLEFT:
return "Left leg";
break;
case BODY_LEGRIGHT:
return "Right Leg";
break;
default:
return "Generic";
}
}
void Damage_Apply( entity eTarget, entity eAttacker, int iDamage, vector vHitPos ) {
eTarget.health = eTarget.health - iDamage; // TODO: Body part multipliers
@ -44,10 +72,24 @@ void Damage_Apply( entity eTarget, entity eAttacker, int iDamage, vector vHitPos
}
}
if ( trace_surface_id == BODY_HEAD ) {
iDamage *= 4;
} else if ( iDamage == BODY_STOMACH ) {
iDamage *= 0.9;
} else if ( iDamage == BODY_LEGLEFT ) {
iDamage *= 0.9;
} else if ( iDamage == BODY_LEGRIGHT ) {
iDamage *= 0.9;
}
bprint( sprintf( "[DEBUG] Hit Bodypart: %s\n", Damage_GetHitLocation( trace_surface_id ) ) );
// Don't be like Q1 and make everything bleed.
if ( eTarget.iBleeds == TRUE ) {
makevectors( eAttacker.angles );
pointparticles( EFFECT_BLOOD, vHitPos, v_forward * -1, 1 );
} else {
pointparticles( EFFECT_GUNSHOT, trace_endpos, trace_plane_normal, 1 );
}
// Target is dead and a client....

View file

@ -34,6 +34,18 @@ var float autocvar_mp_c4timer = 45;
var float autocvar_mp_roundtime = 5;
var float autocvar_mp_fillweapons = 0;
// Hit Group standards
enum {
BODY_DEFAULT,
BODY_HEAD,
BODY_CHEST,
BODY_STOMACH,
BODY_ARMLEFT,
BODY_ARMRIGHT,
BODY_LEGLEFT,
BODY_LEGRIGHT
};
// Particle Fields
float EFFECT_GUNSHOT;
float EFFECT_BLOOD;
@ -68,6 +80,7 @@ float fGameTime;
.float fSlotMelee, fSlotPrimary, fSlotSecondary, fSlotGrenade;
.float fAttackFinished;
.float fAccuracy;
.float fFallVelocity;
// Game specific fields
int iHostagesMax;
@ -126,15 +139,22 @@ void OpenCSGunBase_AccuracyCalc( void );
void OpenCSGunBase_Draw( void );
float OpenCSGunBase_PrimaryFire( void );
float OpenCSGunBase_Reload( void );
void BaseMelee_Draw( void );
void BaseMelee_Attack( void );
float Player_GetMaxSpeed( float fWeapon );
void TraceAttack_FireBullets( int iShots );
void Damage_Radius( vector vOrigin, entity eAttacker, float fDamage, float fRadius );
void Damage_Apply( entity eTarget, entity eAttacker, int iDamage, vector vHitPos );
void Entities_InitRespawnable( void() vRespawnFunc );
void Entities_Respawn( void );
void Ammo_BuyPrimary( float fFree );
void Ammo_BuySecondary( float fFree );
void Input_Handle( void );
// WIP
string __fullspawndata;

View file

@ -47,6 +47,7 @@ void hostage_die( void ) {
self.frame = 30 + floor( random( 1, 6 ) );
self.solid = SOLID_NOT;
self.takedamage = DAMAGE_NO;
//skel_delete( self.skeletonindex );
if ( other.eTargetPoint != other.eUser ) {
remove( other.eTargetPoint );
@ -78,7 +79,7 @@ void hostage_physics( void ) {
input_impulse = 0;
input_buttons = 0;
input_angles = self.angles;
// Are we meant to follow someone and AREN'T dead?
if ( ( self.eUser != world ) && ( self.health > 0 ) ) {
// Which direction we have to face
@ -157,6 +158,8 @@ void hostage_physics( void ) {
// Calculate physstuff
runstandardplayerphysics( self );
//self.frame1time += frametime;
//skel_build( self.skeletonindex, self, self.modelindex, 1, 0, 0 );
}
/*
@ -174,8 +177,11 @@ void hostage_entity( void ) {
self.movetype = MOVETYPE_WALK;
setmodel( self, self.model );
setsize( self, VEC_HULL_MIN + '0 0 36', VEC_HULL_MAX + '0 0 36' );
self.customphysics = hostage_physics;
//self.basebone = -1; // Debug: Network that shit
//self.skeletonindex = skel_create( self.modelindex );
self.customphysics = hostage_physics;
self.eUser = world;
self.eTargetPoint = world;
self.iUsable = TRUE;

View file

@ -44,7 +44,7 @@ void Footsteps_Update( void ) {
dDelay = clamp( 0.1, 1 / ( fForce / 90 ), 1 );
traceline( self.origin + self.view_ofs, self.origin + '0 0 -48', FALSE, self );
sound( self, CHAN_BODY, sprintf( "player/pl_step%d.wav", random( 1, 5 ) ), 0.5, ATTN_IDLE );
sound( self, CHAN_BODY, sprintf( "player/pl_step%d.wav", floor( ( random() * 4 ) + 1 ) ), 0.5, ATTN_IDLE );
self.fSteptime = time + dDelay;
}

View file

@ -198,3 +198,25 @@ void Player_UseUp( void ) {
self.fProgressBar = 0;
}
}
void PlayerPreThink( void ) {
Input_Handle();
OpenCSGunBase_ShotMultiplierUpdate();
if ( !( self.flags & FL_ONGROUND ) ){
self.fFallVelocity = -self.velocity_z;
}
}
void PlayerPostThink( void ) {
Animation_PlayerUpdate();
if ( ( self.flags & FL_ONGROUND ) && ( self.health > 0 ) && ( self.fFallVelocity > 100 )) {
if ( self.fFallVelocity > 580 ) {
self.fFallVelocity -= 580;
float fFallDamage = self.fFallVelocity * ( 200 / ( 1024 - 580 ) );
Damage_Apply( self, world, fFallDamage, self.origin );
}
self.fFallVelocity = 0;
}
}

View file

@ -28,7 +28,7 @@ void TraceAttack_FireBullets( int iShots ) {
while ( iShots > 0) {
vDir = aim( self, 100000 ) + Math_CRandom()*self.fAccuracy*v_right + Math_CRandom()*self.fAccuracy*v_up;
traceline( vSrc, vSrc + ( vDir * 2048 ), FALSE, self);
traceline( vSrc, vSrc + ( vDir * 2048 ), MOVE_HITMODEL, self);
if (trace_fraction != 1.0) {
if ( trace_ent.takedamage == DAMAGE_YES ) {
Damage_Apply( trace_ent, self, wptTable[ self.weapon ].iDamage, trace_endpos );

View file

@ -36,6 +36,7 @@ Money.c
../Shared/WeaponUSP45.c
../Shared/WeaponXM1014.c
../Shared/WeaponBase.c
../Shared/BaseMelee.c
../Shared/Weapons.c
../Shared/Effects.c
../Shared/Equipment.c

55
Source/Shared/BaseMelee.c Normal file
View file

@ -0,0 +1,55 @@
/*
Copyright (C) 2015, 2016, 2017 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.
*/
#ifdef SSQC
void BaseMelee_Draw( void ) {
self.iCurrentMag = 0;
self.iCurrentCaliber = 0;
Client_SendEvent( self, EV_WEAPON_DRAW );
}
void BaseMelee_Attack( void ) {
vector vSource;
vector vOrigin;
makevectors( self.v_angle );
vSource = ( self.origin + self.view_ofs );
traceline( vSource, vSource + ( v_forward * 64 ), FALSE, self );
if ( trace_fraction == 1.0 )
return;
vOrigin = trace_endpos - v_forward * 2;
if ( trace_ent.takedamage ) {
Damage_Apply( trace_ent, self, wptTable[ self.weapon ].iDamage, trace_endpos );
return;
}
}
void BaseMelee_Delayed( float fDelay ) {
static void BaseMelee_Delayed_Trigger( void ) {
BaseMelee_Attack();
}
self.think = BaseMelee_Delayed_Trigger;
self.nextthink = time + fDelay;
}
#endif

View file

@ -18,11 +18,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Because padding...
weaponinfo_t wptDEFAULT = { 0, 0, 0, 0, 240, 0, 0, 0, 0, 0.0, 0.0, 0, 0.0, 0.0, iAmmo_9MM, iAmmo_9MM, 0.0, 0.0, 0.0, 0, 0 };
weaponinfo_t wptTable[ CS_WEAPON_COUNT ] = {
wptDEFAULT,
{ 0, 0, 0, 0, 240, 0, 0, 0, 0, 0.0, 0.0, 0, 0.0, 0.0, iAmmo_9MM, iAmmo_9MM, 0.0, 0.0, 0.0, 0, 0 },
wptKNIFE,
wptUSP45,
wptGLOCK18,

View file

@ -32,7 +32,7 @@ weaponinfo_t wptKNIFE = {
64, // Bullet Range
0.75, // Range Modifier
TYPE_SEMI, // Firing Type
0.15, // Attack-Delay
0.3, // Attack-Delay
1.0, // Reload-Delay
iAmmo_9MM, // Caliber Pointer
iMag_GLOCK18, // Clip Pointer
@ -58,9 +58,7 @@ enum {
void WeaponKNIFE_Draw( void ) {
#ifdef SSQC
Client_SendEvent( self, EV_WEAPON_DRAW );
self.iCurrentMag = 0;
self.iCurrentCaliber = 0;
BaseMelee_Draw();
#else
View_PlayAnimation( ANIM_KNIFE_DRAW );
#endif
@ -68,6 +66,7 @@ void WeaponKNIFE_Draw( void ) {
void WeaponKNIFE_PrimaryFire( void ) {
#ifdef SSQC
BaseMelee_Attack();
Client_SendEvent( self, EV_WEAPON_PRIMARYATTACK );
self.fAttackFinished = time + wptKNIFE.fAttackFinished;
#else
@ -81,6 +80,7 @@ void WeaponKNIFE_PrimaryFire( void ) {
void WeaponKNIFE_Secondary( void ) {
#ifdef SSQC
BaseMelee_Attack();
Client_SendEvent( self, EV_WEAPON_SECONDARYATTACK );
self.fAttackFinished = time + wptKNIFE.fAttackFinished;
#else