Skip to content
Open
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,8 @@ $RECYCLE.BIN/
.DS_Store

_NCrunch*
lib/public/mathlib.lib
lib/public/raytrace.lib
lib/public/tier1.lib
lib/public/vgui_controls.lib
*.lib
149 changes: 148 additions & 1 deletion game/client/hl2mp/c_hl2mp_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,110 @@ IRagdoll* C_HL2MP_Player::GetRepresentativeRagdoll() const
return (m_pPlayerRagdoll ? m_pPlayerRagdoll->GetIRagdoll() : NULL);
}

KeyValues* C_HL2MP_Player::SkillSetKV(int iSlot)
{
KeyValues* kvSkills = new KeyValues("SkillSet");
int val;
char szBuf[8];

for (int i = 0; i < PLAYER_SKILL_ZOMBIE_HEALTH; i++)
{
Q_snprintf(szBuf, sizeof(PLAYER_SKILL_ZOMBIE_HEALTH), "%i", i);

kvSkills->SetInt(szBuf, m_iSkillSets[iSlot][i]);
}

return kvSkills;
}

void C_HL2MP_Player::SaveSkillSets()
{
KeyValues* kvSkillFile = new KeyValues("SkillSets");
int val;
char szBuf[8];

for (int set = 0; set < MAX_SKILL_SETS; set++)
{
Q_snprintf(szBuf, 12, "%i", set);
KeyValues* pSkillSet = new KeyValues(szBuf);

for (int sk = 0; sk < PLAYER_SKILL_ZOMBIE_HEALTH; sk++)
{
Q_snprintf(szBuf, sizeof(PLAYER_SKILL_ZOMBIE_HEALTH), "%i", sk);

// pSkillSet->SetInt(szBuf, GetSkillValue(sk));
pSkillSet->SetInt(szBuf, m_iSkillSets[set][sk]);
}

kvSkillFile->AddSubKey(pSkillSet);
}

kvSkillFile->SaveToFile(g_pFullFileSystem, "scripts/skillsets.txt", "MOD");
kvSkillFile->deleteThis();
}

void C_HL2MP_Player::SaveSkillsAsSet(int iSlot)
{
if (iSlot > MAX_SKILL_SETS - 1)
return;

for (int sk = 0; sk < PLAYER_SKILL_ZOMBIE_HEALTH; sk++)
{
m_iSkillSets[iSlot][sk] = GetSkillValue(sk);
}
}

void C_HL2MP_Player::LoadSkillSets()
{
KeyValues* kvLoadFile = new KeyValues("SkillSets");

if (!kvLoadFile->LoadFromFile(g_pFullFileSystem, "scripts/skillsets.txt", "MOD"))
{
kvLoadFile->deleteThis();

return;
}

char szBuf[4];
KeyValues* pSkillSet;
for (int i = 0; i < MAX_SKILL_SETS; i++)
{
Q_snprintf(szBuf, 16, "%i", i);

pSkillSet = kvLoadFile->FindKey(szBuf);

if (pSkillSet)
{
KeyValues* sub = pSkillSet->GetFirstValue();

if (!sub)
continue;

for (int k = 0; k < PLAYER_SKILL_ZOMBIE_HEALTH; k++)
{
m_iSkillSets[i][k] = sub->GetInt();

sub = sub->GetNextValue();

if (!sub && k < PLAYER_SKILL_ZOMBIE_HEALTH - 1)
{
Warning("ERROR!: Skill Set #%s not fully filled!\n", szBuf);
break;
}
}
}
}

kvLoadFile->deleteThis();
}

void C_HL2MP_Player::ActivateSkillSet(int iSlot)
{
KeyValues* kvSkills = SkillSetKV(iSlot);

engine->ServerCmdKeyValues(kvSkills);
}

void C_HL2MP_Player::UpdateClientSideAnimation()
{
m_PlayerAnimState->Update(EyeAngles()[YAW], EyeAngles()[PITCH]);
Expand Down Expand Up @@ -803,6 +907,7 @@ void C_HL2MP_Player::CalculateIKLocks(float currentTime)
partition->SuppressLists(curSuppressed, true);
}


CON_COMMAND_F(setmodel, "Set the playermodel to use, client-only. Can be a number, chooses between playermodels via script.", FCVAR_CHEAT)
{
C_HL2MP_Player *pPlayer = C_HL2MP_Player::GetLocalHL2MPPlayer();
Expand All @@ -814,4 +919,46 @@ CON_COMMAND_F(setmodel, "Set the playermodel to use, client-only. Can be a numbe
return;

pPlayer->GetNewPlayerModel()->SetModelPointer((pPlayer->GetTeamNumber() == TEAM_DECEASED) ? data->m_pClientModelPtrZombie : data->m_pClientModelPtrHuman);
}
}

#ifdef DEBUG
CON_COMMAND_F(bb2_activateskillset, "", FCVAR_CHEAT)
{
C_HL2MP_Player* pPlayer = C_HL2MP_Player::GetLocalHL2MPPlayer();

if ((pPlayer == NULL) || (args.ArgC() != 2))
return;

pPlayer->ActivateSkillSet(atof(args[1]));
}

CON_COMMAND_F(bb2_saveskillsets, "", FCVAR_CHEAT)
{
C_HL2MP_Player* pPlayer = C_HL2MP_Player::GetLocalHL2MPPlayer();

if (pPlayer == NULL)
return;

pPlayer->SaveSkillSets();
}

CON_COMMAND_F(bb2_saveskills, "Save the current allocated skill points as a skill set. Argument must be a number within the boundaries of 0 and 2.", FCVAR_CHEAT)
{
C_HL2MP_Player* pPlayer = C_HL2MP_Player::GetLocalHL2MPPlayer();

if ((pPlayer == NULL) || (args.ArgC() != 2))
return;

pPlayer->SaveSkillsAsSet(atof(args[1]));
}

CON_COMMAND_F(bb2_loadskills, "", FCVAR_CHEAT)
{
C_HL2MP_Player* pPlayer = C_HL2MP_Player::GetLocalHL2MPPlayer();

if (pPlayer == NULL)
return;

pPlayer->LoadSkillSets();
}
#endif
9 changes: 9 additions & 0 deletions game/client/hl2mp/c_hl2mp_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ class C_HL2MP_Player : public C_BaseHLPlayer
float GetSkillValue(const char* pszType, int skillType, int team = 2, int dataSubType = -1);
float GetSkillCombination(float def, float extra);


KeyValues* SkillSetKV(int iSlot);
void SaveSkillSets();
void SaveSkillsAsSet(int iSlot);
void LoadSkillSets();
void ActivateSkillSet(int iSlot);

virtual void UpdateClientSideAnimation();
void DoAnimationEvent(PlayerAnimEvent_t event, int nData = 0, bool bSkipPrediction = false, float flData = 1.0f);
float GetPlaybackRateForAnimEvent(PlayerAnimEvent_t event, int nData);
Expand Down Expand Up @@ -162,6 +169,8 @@ class C_HL2MP_Player : public C_BaseHLPlayer
int m_iModelIncrementor;
int m_iOldModelIncrementor;

int m_iSkillSets[MAX_SKILL_SETS - 1][PLAYER_SKILL_ZOMBIE_HEALTH - 1];

friend class C_Playermodel;
};

Expand Down
33 changes: 22 additions & 11 deletions game/server/fire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ ConVar fire_dmginterval( "fire_dmginterval", "1.0" );

#define VPROF_FIRE(s) VPROF( s )

class CFire : public CBaseEntity
DECLARE_AUTO_LIST(IFireAutoList);
class CFire : public CBaseEntity, public IFireAutoList
{
public:
DECLARE_CLASS( CFire, CBaseEntity );
Expand Down Expand Up @@ -479,12 +480,16 @@ void FireSystem_ExtinguishInRadius( const Vector &origin, float radius, float ra
{
// UNDONE: pass this instead of percent
float heat = (1-rate) * fire_extscale.GetFloat();
float fSqr = Sqr(radius);

CFire *pFires[32];
int fireCount = FireSystem_GetFiresInSphere( pFires, ARRAYSIZE(pFires), false, origin, radius );
for ( int i = 0; i < fireCount; i++ )
for (int i = 0; i < IFireAutoList::AutoList().Count(); i++)
{
pFires[i]->Extinguish( heat );
CFire* pFire = static_cast<CFire*>(IFireAutoList::AutoList()[i]);

if (pFire->GetAbsOrigin().DistToSqr(origin) <= fSqr)
{
pFire->Extinguish(heat);
}
}
}

Expand All @@ -498,12 +503,16 @@ void FireSystem_AddHeatInRadius( const Vector &origin, float radius, float heat
{
VPROF_FIRE( "FireSystem_AddHeatInRadius" );

CFire *pFires[32];
float fSqr = Sqr(radius);

int fireCount = FireSystem_GetFiresInSphere( pFires, ARRAYSIZE(pFires), false, origin, radius );
for ( int i = 0; i < fireCount; i++ )
for (int i = 0; i < IFireAutoList::AutoList().Count(); i++)
{
pFires[i]->AddHeat( heat );
CFire* pFire = static_cast<CFire*>(IFireAutoList::AutoList()[i]);

if (pFire->GetAbsOrigin().DistToSqr(origin) <= fSqr)
{
pFire->AddHeat(heat);
}
}
}

Expand Down Expand Up @@ -537,8 +546,8 @@ BEGIN_DATADESC( CFire )
DEFINE_KEYFIELD( m_flAttackTime, FIELD_FLOAT, "fireattack" ),
DEFINE_KEYFIELD( m_bStartDisabled, FIELD_BOOLEAN, "StartDisabled" ),

DEFINE_FUNCTION( BurnThink ),
DEFINE_FUNCTION( GoOutThink ),
DEFINE_THINKFUNC( BurnThink ),
DEFINE_THINKFUNC( GoOutThink ),

DEFINE_INPUTFUNC( FIELD_VOID, "StartFire", InputStartFire ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "Extinguish", InputExtinguish ),
Expand All @@ -554,6 +563,8 @@ END_DATADESC()

LINK_ENTITY_TO_CLASS( env_fire, CFire );

IMPLEMENT_AUTO_LIST(IFireAutoList);

//==================================================
// CFire
//==================================================
Expand Down
1 change: 1 addition & 0 deletions game/shared/bb2/skills_shareddefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define MAX_SKILL_ARRAY 40
#define MAX_PLAYER_LEVEL 500
#define MAX_PLAYER_TALENTS 150
#define MAX_SKILL_SETS 3

enum playerSkills_t
{
Expand Down
58 changes: 58 additions & 0 deletions game/shared/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,64 @@ bool CMultiplayRules::Init()
}
}

void ResetSkills(CHL2MP_Player* pPlayer)
{
pPlayer->m_BB2Local.m_iSkill_Talents = GameBaseShared()->GetSharedGameDetails()->CalculatePointsForLevel(pPlayer->GetPlayerLevel());
for (int i = 0; i < PLAYER_SKILL_ZOMBIE_HEALTH; i++)
pPlayer->m_BB2Local.m_iPlayerSkills.Set(i, 0);
}

void CMultiplayRules::ClientCommandKeyValues(edict_t* pEntity, KeyValues* pKeyValues)
{
CHL2MP_Player* pPlayer = ToHL2MPPlayer(CBaseEntity::Instance(pEntity));

if (!pPlayer)
return;

char const* pszCommand = pKeyValues->GetName();

if (pszCommand && pszCommand[0])
{
if (FStrEq(pszCommand, "SkillSet"))
{
int iAlloc = 0;
KeyValues* sub = pKeyValues->GetFirstValue();

if (!sub)
return;

ResetSkills(pPlayer);

for (int iSkillType = 0; iSkillType < PLAYER_SKILL_ZOMBIE_HEALTH; iSkillType++)
{
iAlloc = sub->GetInt();

if (iAlloc >= 10 || pPlayer->m_BB2Local.m_iSkill_Talents - iAlloc < 0)
{
Warning("ERROR!: Skill overflow for player %i: %s!\n", pPlayer->GetClientIndex(), pPlayer->GetPlayerName());

if (iSkillType > 0)
ResetSkills(pPlayer);

return;
}

pPlayer->m_BB2Local.m_iSkill_Talents -= iAlloc;
pPlayer->SetSkillValue(iSkillType, iAlloc);

sub = sub->GetNextValue();

if (!sub && iSkillType < PLAYER_SKILL_ZOMBIE_HEALTH - 1)
{
Warning("ERROR!: Skill Set not fully filled for player %i: %s!\n", pPlayer->GetClientIndex(), pPlayer->GetPlayerName());
break;
}

}
}
}
}

void CMultiplayRules::IncrementMapCycleIndex()
{
// Reset index if we've passed the end of the map list
Expand Down
2 changes: 2 additions & 0 deletions game/shared/multiplay_gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ class CMultiplayRules : public CGameRules

void SkipNextMapInCycle();

virtual void ClientCommandKeyValues(edict_t* pEntity, KeyValues* pKeyValues);

public:

virtual void GetNextLevelName( char *szNextMap, int bufsize, bool bRandom = false );
Expand Down