Skip to content

Commit

Permalink
Merge pull request #70 from Hedgefog/master
Browse files Browse the repository at this point in the history
Release 1.3.0
  • Loading branch information
Hedgefog committed Feb 28, 2021
2 parents 23dc099 + 72b5541 commit f0df5fc
Show file tree
Hide file tree
Showing 39 changed files with 497 additions and 263 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Zombie Panic Mod for Counter-Strike 1.6
__Version:__ 1.2.0
__Version:__ 1.3.0

### Download latest:
- [Releases](../../releases)
Expand Down
1 change: 1 addition & 0 deletions assets/addons/amxmodx/configs/zombiepanic.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ zp_flashlight_consumption_rate 0.5
zp_flashlight_recovery_rate 0.5

// [Zombie Panic] Gamerules
zp_competitive 0
zp_zombie_lives 0
zp_zombie_lives_per_player 2

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zombiepanic",
"version": "1.2.0",
"version": "1.3.0",
"description": "Zombie Panic Mod",
"scripts": {
"gulp": "gulp",
Expand Down
26 changes: 26 additions & 0 deletions src/include/zombiepanic.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/*
1.3.0
Additions and improvements:
Removed default pain sound
Infected players no longer bleed
Increased fade in time for win message
Increased objective mark max velocity
Weapons and items are now respawnable
Reduced pickups respawn time
Pickups will no longer respawn when players are nearby
Added competitive mode
Reduced 556ar spread
Cvars:
zombiepanic_version cvar is now visible for monitoring
Added zp_competitive cvar
Fixes:
Fixed win conditions for spectators
Fixed death sound for infected players
Fixed melee secondary attack for bots
Fixed first shot spread calculation
Fixed death sound on transformation
Fixed death message icons
1.2.0
Additions and improvements:
Reduced crowbar damage to 25
Expand Down Expand Up @@ -104,6 +128,8 @@ native ZP_GameRules_GetZombieLives();
native ZP_GameRules_SetZombieLives(iLives);
native ZP_GameRules_RespawnAsZombie(pPlayer);
native ZP_GameRules_DispatchWin(iTeam);
native ZP_GameRules_CanItemRespawn(pItem);
native ZP_GameRules_IsCompetitive();

// Map Info

Expand Down
6 changes: 4 additions & 2 deletions src/include/zombiepanic_const.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define ZP_TITLE "Zombie Panic"
#define ZP_VERSION "1.2.0"
#define ZP_VERSION "1.3.0"

#define ZP_HUMAN_TEAM 2
#define ZP_ZOMBIE_TEAM 1
Expand All @@ -11,7 +11,9 @@
#define ZP_HUMAN_HEALTH 100.0
#define ZP_ZOMBIE_HEALTH 200.0
#define ZP_NEW_ROUND_DELAY 5.0
#define ZP_AMMO_RESPAWN_TIME 150.0
#define ZP_AMMO_RESPAWN_TIME 40.0
#define ZP_WEAPONS_RESPAWN_TIME 60.0
#define ZP_ITEMS_RESPAWN_TIME 60.0
#define ZP_BUTTON_FLAG_HUMAN_ONLY BIT(9)

#define ZP_MODE 1 // 1 - classic, 2 - zps
Expand Down
86 changes: 64 additions & 22 deletions src/include/zombiepanic_utils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ stock UTIL_CreateAmmoBox(iAmmoId, iAmount) {
return pWeaponBox;
}

stock UTIL_CreateZpAmmoBox(iAmmoHandler, iAmount = 0) {
static szModel[64];
ZP_Ammo_GetPackModel(iAmmoHandler, szModel, charsmax(szModel));

if (!iAmount) {
iAmount = ZP_Ammo_GetPackSize(iAmmoHandler);
}

new iAmmoId = ZP_Ammo_GetId(iAmmoHandler);

new pWeaponBox = UTIL_CreateAmmoBox(iAmmoId, iAmount);
engfunc(EngFunc_SetModel, pWeaponBox, szModel);

return pWeaponBox;
}

stock UTIL_BeamPoints(const Float:vecStart[3], const Float:vecEnd[3], const color[3], iLifetime = 30) {
message_begin(MSG_BROADCAST ,SVC_TEMPENTITY);
write_byte(TE_BEAMPOINTS);
Expand Down Expand Up @@ -113,35 +129,39 @@ stock bool:UTIL_IsMasterTriggered(const szMaster[], pActivator) {
return true;
}

stock UTIL_CalculateWeaponSpread(pWeapon, const Float:vecSpread[3], Float:flMovementFactor, Float:flFirstShotModifier, Float:flDuckFactor, Float:flAirFactor, Float:vecOut[3]) {
new pPlayer = get_member(pWeapon, m_pPlayer);
new iShotsFired = get_member(pWeapon, m_Weapon_iShotsFired);
new iPlayerFlags = pev(pPlayer, pev_flags);

xs_vec_copy(vecSpread, vecOut);

static Float:vecVelocity[3];
pev(pPlayer, pev_velocity, vecVelocity);
if (xs_vec_len(vecVelocity) > 0) {
if (iShotsFired == 0) {
flMovementFactor *= flFirstShotModifier;
stock Float:UTIL_CalculateWeaponSpread(pWeapon, const Float:vecSpread[3], Float:flMovementFactor, Float:flFirstShotModifier, Float:flDuckFactor, Float:flAirFactor, Float:vecOut[3]) {
new pPlayer = get_member(pWeapon, m_pPlayer);
new iShotsFired = get_member(pWeapon, m_Weapon_iShotsFired);
new iPlayerFlags = pev(pPlayer, pev_flags);

new Float:flSpreadRatio = 1.0;

static Float:vecVelocity[3];
pev(pPlayer, pev_velocity, vecVelocity);
if (xs_vec_len(vecVelocity) > 0) {
flSpreadRatio *= flMovementFactor;
}

if (iPlayerFlags & FL_DUCKING) {
flSpreadRatio *= flDuckFactor;
}

xs_vec_mul_scalar(vecOut, flMovementFactor, vecOut);
}
if (~iPlayerFlags & FL_ONGROUND) {
flSpreadRatio *= flAirFactor;
}

if (!iShotsFired) {
flSpreadRatio *= flFirstShotModifier;
}

if (iPlayerFlags & FL_DUCKING) {
xs_vec_mul_scalar(vecOut, flDuckFactor, vecOut);
}
xs_vec_mul_scalar(vecSpread, flSpreadRatio, vecOut);

if (~iPlayerFlags & FL_ONGROUND) {
xs_vec_mul_scalar(vecOut, flAirFactor, vecOut);
}
return flSpreadRatio;
}

stock bool:UTIL_IsPlayerSpectator(pPlayer) {
new iTeam = get_member(pPlayer, m_iTeam);
return iTeam < 1 || iTeam > 2;
new iTeam = get_member(pPlayer, m_iTeam);
return iTeam < 1 || iTeam > 2;
}

stock UTIL_PlayerKnockback(pVictim, pAttacker, Float:flForce) {
Expand All @@ -164,3 +184,25 @@ stock UTIL_PlayerKnockback(pVictim, pAttacker, Float:flForce) {

set_pev(pVictim, pev_velocity, vecVelocity);
}

stock UTIL_InitWithSpawner(pEntity, pSpawner) {
new Float:vecOrigin[3];
pev(pSpawner, pev_origin, vecOrigin);
engfunc(EngFunc_SetOrigin, pEntity, vecOrigin);

new Float:vecAngles[3];
pev(pSpawner, pev_angles, vecAngles);
set_pev(pEntity, pev_angles, vecAngles);

set_pev(pEntity, pev_owner, pSpawner);

engfunc(EngFunc_DropToFloor, pEntity);
}

stock UTIL_SetupSpawnerRespawn(pEntity) {
new pOwner = pev(pEntity, pev_owner);
if (pev_valid(pOwner) && CE_GetHandlerByEntity(pOwner) != -1) {
CE_Kill(pOwner);
}
}

8 changes: 5 additions & 3 deletions src/scripts/api/api_custom_weapons.sma
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ new const g_rgszWeaponNames[CSW_LAST_WEAPON + 1][] = {
"weapon_p90"
};

new gmsgWeaponList;
new gmsgDeathMsg;

new g_iszWeaponNames[CSW_LAST_WEAPON + 1];
new bool:g_bWeaponHooks[CSW_LAST_WEAPON + 1];
new g_weaponListDefaults[CSW_LAST_WEAPON + 1][WeaponListMessage];
Expand All @@ -100,7 +103,6 @@ new g_iszWeaponBox;
new g_pNewWeaponboxEnt = -1;
new g_pKillerItem = -1;

new gmsgWeaponList;
new bool:g_bPrecache;

new Array:g_irgDecals;
Expand All @@ -121,8 +123,6 @@ public plugin_precache() {
RegisterHam(Ham_TakeDamage, "player", "OnPlayerTakeDamage", .Post = 0);
RegisterHam(Ham_TakeDamage, "player", "OnPlayerTakeDamage_Post", .Post = 1);

register_message(get_user_msgid("DeathMsg"), "OnMessage_DeathMsg");

precache_model(WALL_PUFF_SPRITE);
}

Expand All @@ -132,8 +132,10 @@ public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);

gmsgWeaponList = get_user_msgid("WeaponList");
gmsgDeathMsg = get_user_msgid("DeathMsg");

register_message(gmsgWeaponList, "OnMessage_WeaponList");
register_message(gmsgDeathMsg, "OnMessage_DeathMsg");

InitWeaponHooks();
}
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/core/zombiepanic.sma
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ new g_iFwResult;
new g_pCvarVersion;

public plugin_precache() {
g_pCvarVersion = register_cvar("zombiepanic_version", ZP_VERSION);
hook_cvar_change(g_pCvarVersion, "OnVersionCvarChange");

for (new i = 0; i < sizeof(ZP_HUD_SPRITES); ++i) {
precache_generic(ZP_HUD_SPRITES[i]);
}
Expand All @@ -26,6 +23,9 @@ public plugin_precache() {
public plugin_init() {
register_plugin(PLUGIN, ZP_VERSION, AUTHOR);

g_pCvarVersion = register_cvar("zombiepanic_version", ZP_VERSION, FCVAR_SERVER);
hook_cvar_change(g_pCvarVersion, "OnVersionCvarChange");

register_forward(FM_GetGameDescription, "OnGetGameDescription");

register_cvar("mp_flashlight", "1");
Expand Down
7 changes: 6 additions & 1 deletion src/scripts/core/zp_characters.sma
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public plugin_init() {

RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn_Post", .Post = 1);
RegisterHam(Ham_Killed, "player", "OnPlayerKilled_Post", .Post = 1);
RegisterHam(Ham_PainSound, "player", "OnPlayerPainSound_Post", .Post = 1);
RegisterHam(Ham_Item_Deploy, "weapon_knife", "OnKnifeDeploy_Post", .Post = 1);

register_forward(FM_SetClientKeyValue, "OnSetClientKeyValue");
Expand Down Expand Up @@ -116,10 +117,14 @@ public OnPlayerSpawn_Post(pPlayer) {
}

public OnPlayerKilled_Post(pPlayer) {
PlayVoiceFromCharacterData(pPlayer, ZP_Player_IsZombie(pPlayer) ? Character_ZombieDeathSounds : Character_HumanDeathSounds);
PlayVoiceFromCharacterData(pPlayer, ZP_Player_IsZombie(pPlayer) && !ZP_Player_IsInfected(pPlayer) ? Character_ZombieDeathSounds : Character_HumanDeathSounds);
return HAM_HANDLED;
}

public OnPlayerPainSound_Post(pPlayer) {
emit_sound(pPlayer, CHAN_VOICE, "common/null.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}

public OnKnifeDeploy_Post(pKnife) {
if (CW_GetHandlerByEntity(pKnife) == g_iCwSwipeHandler) {
new pPlayer = CW_GetPlayer(pKnife);
Expand Down
49 changes: 48 additions & 1 deletion src/scripts/core/zp_gamerules.sma
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <hamsandwich>
#include <fun>
#include <reapi>
#include <xs>

#include <api_rounds>

Expand All @@ -27,6 +28,7 @@ enum TeamPreference {

new g_pCvarLives;
new g_pCvarLivesPerPlayer;
new g_pCvarCompetitive;

new g_pFwPlayerJoined;
new g_iFwResult;
Expand Down Expand Up @@ -57,6 +59,7 @@ public plugin_init() {

g_pCvarLives = register_cvar("zp_zombie_lives", "0");
g_pCvarLivesPerPlayer = register_cvar("zp_zombie_lives_per_player", "2");
g_pCvarCompetitive = register_cvar("zp_competitive", "0");

g_pFwPlayerJoined = CreateMultiForward("ZP_Fw_PlayerJoined", ET_IGNORE, FP_CELL);

Expand All @@ -67,6 +70,8 @@ public plugin_natives() {
register_native("ZP_GameRules_DispatchWin", "Native_DispatchWin");
register_native("ZP_GameRules_GetObjectiveMode", "Native_GetObjectiveMode");
register_native("ZP_GameRules_SetObjectiveMode", "Native_SetObjectiveMode");
register_native("ZP_GameRules_CanItemRespawn", "Native_CanItemRespawn");
register_native("ZP_GameRules_IsCompetitive", "Native_IsCompetitive");
}

/*--------------------------------[ Natives ]--------------------------------*/
Expand All @@ -84,6 +89,42 @@ public bool:Native_GetObjectiveMode(iPluginId, iArgc) {
return g_bObjectiveMode;
}

public bool:Native_IsCompetitive(iPluginId, iArgc) {
return !!get_pcvar_num(g_pCvarCompetitive);
}

public bool:Native_CanItemRespawn(iPluginId, iArgc) {
new pItem = get_param(1);

if (get_gametime() - Float:get_member_game(m_fRoundStartTime) <= 1.0) {
return true;
}

new Float:vecOrigin[3];
pev(pItem, pev_origin, vecOrigin);

for (new pPlayer = 1; pPlayer <= MaxClients; ++pPlayer) {
if (!is_user_connected(pPlayer)) {
continue;
}

if (!is_user_alive(pPlayer)) {
continue;
}

new Float:flMinRange = ZP_Player_IsZombie(pPlayer) ? 256.0 : 512.0;

static Float:vecPlayerOrigin[3];
pev(pPlayer, pev_origin, vecPlayerOrigin);

if (xs_vec_distance(vecOrigin, vecPlayerOrigin) <= flMinRange) {
return false;
}
}

return true;
}

/*--------------------------------[ Forwards ]--------------------------------*/

public client_disconnected(pPlayer) {
Expand Down Expand Up @@ -236,7 +277,8 @@ DistributeTeams() {
log_amx("Respawned %d zombies", iZombieCount);
}

new iRequiredZombieCount = floatround(float(pPlayerCount) / PLAYERS_PER_ZOMBIE, floatround_ceil);
new iPlayersPerZombie = get_pcvar_num(g_pCvarCompetitive) ? 2 : PLAYERS_PER_ZOMBIE;
new iRequiredZombieCount = floatround(float(pPlayerCount) / iPlayersPerZombie, floatround_ceil);
if (iZombieCount < iRequiredZombieCount) {
if (pPlayerCount > 1) {
log_amx("Not enough zombies, a random players will be moved to the zombie team...");
Expand Down Expand Up @@ -343,6 +385,11 @@ CheckWinConditions(pIgnorePlayer = 0) {
continue;
}

new iTeam = get_member(pPlayer, m_iTeam);
if (iTeam != ZP_HUMAN_TEAM && iTeam != ZP_ZOMBIE_TEAM) {
continue;
}

if (ZP_Player_IsZombie(pPlayer)) {
iZombieCount++;

Expand Down
Loading

0 comments on commit f0df5fc

Please sign in to comment.