Skip to content

Commit

Permalink
Improve ZR knife & revive behaviour
Browse files Browse the repository at this point in the history
- Knife skin should now match team loadout
- Give armour on revives (if configured)
- Re-strip on revives, to prevent ZM items lingering
  • Loading branch information
Vauff committed Dec 15, 2024
1 parent e92fd19 commit e4afda4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cs2_sdk/entity/cbaseplayerpawn.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CBasePlayerPawn : public CBaseModelEntity
SCHEMA_FIELD(QAngle, v_angle)

// Drops any map-spawned weapons the pawn is holding
// NOTE: Currently very broken with map items (entities parented to weapons?) due to a game bug..? Needs further investigation/work
// NOTE: This doesn't predict correctly to the weapon holder! Looks very funky when testing, but not really an issue on live servers
void DropMapWeapons()
{
if (!m_pWeaponServices())
Expand Down
22 changes: 20 additions & 2 deletions src/zombiereborn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,21 @@ void ZR_StripAndGiveKnife(CCSPlayerPawn *pPawn)

pPawn->DropMapWeapons();
pItemServices->StripPlayerWeapons(true);
pItemServices->GiveNamedItem("weapon_knife");

if (pPawn->m_iTeamNum == CS_TEAM_T)
{
pItemServices->GiveNamedItem("weapon_knife_t");
}
else if (pPawn->m_iTeamNum == CS_TEAM_CT)
{
pItemServices->GiveNamedItem("weapon_knife");

// CONVAR_TODO
ConVar* cvar = g_pCVar->GetConVar(g_pCVar->FindConVar("mp_free_armor"));
// HACK: values is actually the cvar value itself, hence this ugly cast.
if (*(int*)&cvar->values > 0)
pItemServices->GiveNamedItem("item_kevlar");
}

CUtlVector<CHandle<CBasePlayerWeapon>>* weapons = pWeaponServices->m_hMyWeapons();

Expand Down Expand Up @@ -1287,6 +1301,7 @@ void ZR_InfectMotherZombie(CCSPlayerController *pVictimController, std::vector<S
if (!pVictimPawn)
return;

pVictimController->SwitchTeam(CS_TEAM_T);
ZR_StripAndGiveKnife(pVictimPawn);

// pick random spawn point
Expand All @@ -1299,7 +1314,6 @@ void ZR_InfectMotherZombie(CCSPlayerController *pVictimController, std::vector<S
pVictimPawn->Teleport(&origin, &rotation, &vec3_origin);
}

pVictimController->SwitchTeam(CS_TEAM_T);
pVictimPawn->EmitSound("zr.amb.scream");

std::shared_ptr<ZRZombieClass> pClass = g_pZRPlayerClassManager->GetZombieClass("MotherZombie");
Expand Down Expand Up @@ -2006,7 +2020,11 @@ CON_COMMAND_CHAT_FLAGS(revive, "- Revive a player", ADMFLAG_GENERIC)
CCSPlayerController* pTarget = CCSPlayerController::FromSlot(pSlots[i]);
CCSPlayerPawn* pPawn = (CCSPlayerPawn*)pTarget->GetPawn();

if (!pPawn)
continue;

ZR_Cure(pTarget);
ZR_StripAndGiveKnife(pPawn);

if (iNumClients == 1)
PrintSingleAdminAction(pszCommandPlayerName, pTarget->GetPlayerName(), "revived", "", ZR_PREFIX);
Expand Down

0 comments on commit e4afda4

Please sign in to comment.