Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/game/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ set(MS_Headers
"shield.h"
"store.h"
"svglobals.h"
"vehicle.cpp"
#"SteamServerHelper.h"
"../shared/ms/groupfile.h"
"../shared/ms/mscharacter.h"
Expand Down
24 changes: 18 additions & 6 deletions src/game/server/gamerules/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "ms/angelscript/CAngelScriptManager.h"
#include "ms/angelscript/ASModuleSystem.h"
#include "ms/scriptmgr.h"
#include "trains.h" // for CFuncVehicle
#include <asbind20/asbind.hpp>

#include <climits>
Expand Down Expand Up @@ -593,22 +594,33 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller,
FireTargets( "game_playerdie", pVictim, pVictim, USE_TOGGLE, 0 );
CBasePlayer *peKiller = NULL;
CBaseEntity *ktmp = CBaseEntity::Instance( pKiller );
if ( ktmp && (ktmp->Classify() == CLASS_PLAYER) )
if (ktmp && (ktmp->Classify() == CLASS_PLAYER))
peKiller = (CBasePlayer*)ktmp;

if ( pVictim->pev == pKiller )
if (pVictim->pev == pKiller)
{ // killed self
pKiller->frags -= 1;
}
else if ( ktmp && ktmp->IsPlayer() )
else if (ktmp && ktmp->IsPlayer())
{
// if a player dies in a deathmatch game and the killer is a client, award the killer some points
pKiller->frags += IPointsForKill( peKiller, pVictim );
pKiller->frags += IPointsForKill(peKiller, pVictim);

FireTargets( "game_playerkill", ktmp, ktmp, USE_TOGGLE, 0 );
FireTargets("game_playerkill", ktmp, ktmp, USE_TOGGLE, 0);
}
else if (ktmp && FBitSet(ktmp->pev->flags, FL_MONSTER))
{
}
else if ( ktmp && FBitSet( ktmp->pev->flags, FL_MONSTER ) )
else if (ktmp && (ktmp->Classify() == CLASS_VEHICLE))
{
CBasePlayer* pDriver = ((CFuncVehicle*)ktmp)->m_pDriver;

if (pDriver != NULL)
{
peKiller = pDriver;
ktmp = pDriver;
pKiller = pDriver->pev;
}
}
else
{ // killed by the world
Expand Down
1 change: 1 addition & 0 deletions src/game/server/hl/cbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ typedef void (CBaseEntity::*USEPTR)(CBaseEntity *pActivator, CBaseEntity *pCalle
#define CLASS_ALIEN_BIOWEAPON 15 // hornets and snarks.launched by the alien menace
#define CLASS_BARNACLE 99 // special because no one pays attention to it, and it eats a wide cross-section of creatures.
#define CHAR_LEVEL_CAP 45 // MiB JAN2010_15 Global Level Cap
#define CLASS_VEHICLE 16 // we use 16 because of MS class defines.

class CBaseEntity;
class CBaseMonster;
Expand Down
74 changes: 74 additions & 0 deletions src/game/server/hl/trains.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,78 @@ class CFuncTrackTrain : public CBaseEntity
unsigned short m_usAdjustPitch;
};

class CFuncVehicle : public CBaseEntity
{
public:
void Spawn(void);
void Precache(void);

void Blocked(CBaseEntity* pOther);
void Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value);
void KeyValue(KeyValueData* pkvd);

void EXPORT Next(void);
void EXPORT Find(void);
void EXPORT NearestPath(void);
void EXPORT DeadEnd(void);

void NextThink(float thinkTime, bool alwaysThink);
int Classify(void);
void CollisionDetection(void);
void TerrainFollowing(void);
void CheckTurning(void);

void SetTrack(CPathTrack* track) { m_ppath = track->Nearest(pev->origin); }
void SetControls(entvars_t* pevControls);
BOOL OnControls(entvars_t* pev);

void StopSound(void);
void UpdateSound(void);

static CFuncVehicle* Instance(edict_t* pent);

static TYPEDESCRIPTION m_SaveData[];
int ObjectCaps() { return (CBaseEntity ::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DIRECTIONAL_USE; }

void OverrideReset();

CPathTrack* m_ppath;
float m_length;
float m_width;
float m_height;
float m_speed;
float m_dir;
float m_startSpeed;
Vector m_controlMins;
Vector m_controlMaxs;
int m_soundPlaying;
int m_sounds;
int m_acceleration;
float m_flVolume;
float m_flBank;
float m_oldSpeed;
int m_iTurnAngle;
float m_flSteeringWheelDecay;
float m_flAcceleratorDecay;
float m_flTurnStartTime;
float m_flLaunchTime; // Time at which the vehicle has become airborne
float m_flLastNormalZ;
float m_flCanTurnNow;
float m_flUpdateSound;
Vector m_vFrontLeft;
Vector m_vFront;
Vector m_vFrontRight;
Vector m_vBackLeft;
Vector m_vBack;
Vector m_vBackRight;
Vector m_vSurfaceNormal;
Vector m_vVehicleDirection;
CBasePlayer* m_pDriver;

// GOOSEMAN
void Restart();

private:
unsigned short m_usAdjustPitch;
};
#endif
60 changes: 49 additions & 11 deletions src/game/server/player/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,9 @@ void CBasePlayer::PlayerUse(void)
{
m_afPhysicsFlags &= ~PFLAG_ONTRAIN;
m_iTrain = TRAIN_NEW | TRAIN_OFF;
CBaseEntity* pTrain = CBaseEntity::Instance(pev->groundentity);
if (pTrain && (pTrain->Classify() == CLASS_VEHICLE))
((CFuncVehicle*)pTrain)->m_pDriver = NULL;
return;
}
else
Expand Down Expand Up @@ -1210,13 +1213,10 @@ void CBasePlayer::PlayerUse(void)

void CBasePlayer::Jump()
{
//if( FBitSet(m_StatusFlags, PLAYER_MOVE_NOJUMP) ) return;

Vector vecWallCheckDir; // direction we're tracing a line to find a wall when walljumping
Vector vecAdjustedVelocity;
Vector vecSpot;
TraceResult tr;
//BOOL bCanJump = TRUE;

if (FBitSet(pev->flags, FL_WATERJUMP))
return;
Expand All @@ -1232,7 +1232,7 @@ void CBasePlayer::Jump()
if (!FBitSet(m_afButtonPressed, IN_JUMP))
return; // don't pogo stick

if (!(pev->flags & FL_ONGROUND) || !pev->groundentity)
if ((pev->flags & FL_ONGROUND) == 0 || !pev->groundentity)
return;

SetBits(m_StatusFlags, PLAYER_MOVE_JUMPING);
Expand All @@ -1252,6 +1252,15 @@ void CBasePlayer::Jump()
{
pev->velocity = pev->velocity + pev->basevelocity;
}

// JoshA: CS behaviour does this for tracktrain + train as well,
// but let's just do this for func_vehicle to avoid breaking existing content.
//
// If you're standing on a moving train... then add the velocity of the train to yours.
if (pevGround && (/*(!strcmp( "func_tracktrain", STRING(pevGround->classname))) ||
(!strcmp( "func_train", STRING(pevGround->classname))) ) ||*/
(!strcmp("func_vehicle", STRING(pevGround->classname)))))
pev->velocity = pev->velocity + pevGround->velocity;
}

// This is a glorious hack to find free space when you've crouched into some solid space
Expand Down Expand Up @@ -1565,28 +1574,57 @@ void CBasePlayer::PreThink(void)
//ALERT( at_error, "In train mode with no train!\n" );
m_afPhysicsFlags &= ~PFLAG_ONTRAIN;
m_iTrain = TRAIN_NEW | TRAIN_OFF;
if (pTrain->Classify() == CLASS_VEHICLE)
((CFuncVehicle*)pTrain)->m_pDriver = NULL;
return;
}
}
else if (!FBitSet(pev->flags, FL_ONGROUND) || FBitSet(pTrain->pev->spawnflags, SF_TRACKTRAIN_NOCONTROL) || (pev->button & (IN_MOVELEFT | IN_MOVERIGHT)))
else if (!FBitSet(pev->flags, FL_ONGROUND) || FBitSet(pTrain->pev->spawnflags, SF_TRACKTRAIN_NOCONTROL) || ((pev->button & (IN_MOVELEFT | IN_MOVERIGHT)) != 0 && pTrain->Classify() != CLASS_VEHICLE))
{
// Turn off the train if you jump, strafe, or the train controls go dead
// and it isn't a func_vehicle
m_afPhysicsFlags &= ~PFLAG_ONTRAIN;
m_iTrain = TRAIN_NEW | TRAIN_OFF;
return;
}

pev->velocity = g_vecZero;
vel = 0;
if (m_afButtonPressed & IN_FORWARD)
if (pTrain->Classify() == CLASS_VEHICLE)
{
vel = 1;
pTrain->Use(this, this, USE_SET, (float)vel);
if (pev->button & IN_FORWARD)
{
vel = 1;
pTrain->Use(this, this, USE_SET, (float)vel);
}
if (pev->button & IN_BACK)
{
vel = -1;
pTrain->Use(this, this, USE_SET, (float)vel);
}
if (pev->button & IN_MOVELEFT)
{
vel = 20;
pTrain->Use(this, this, USE_SET, (float)vel);
}
if (pev->button & IN_MOVERIGHT)
{
vel = 30;
pTrain->Use(this, this, USE_SET, (float)vel);
}
}
else if (m_afButtonPressed & IN_BACK)
else
{
vel = -1;
pTrain->Use(this, this, USE_SET, (float)vel);
if ((m_afButtonPressed & IN_FORWARD) != 0)
{
vel = 1;
pTrain->Use(this, this, USE_SET, (float)vel);
}
else if ((m_afButtonPressed & IN_BACK) != 0)
{
vel = -1;
pTrain->Use(this, this, USE_SET, (float)vel);
}
}

if (vel)
Expand Down
Loading