diff --git a/README.md b/README.md index c93b29ad..30cb75c8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ### Zombie Panic Mod for Counter-Strike 1.6 -__Version:__ 1.2.0 +__Version:__ 1.3.0 ### Download latest: - [Releases](../../releases) diff --git a/assets/addons/amxmodx/configs/zombiepanic.cfg b/assets/addons/amxmodx/configs/zombiepanic.cfg index 4f3eaae2..068ca08b 100644 --- a/assets/addons/amxmodx/configs/zombiepanic.cfg +++ b/assets/addons/amxmodx/configs/zombiepanic.cfg @@ -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 diff --git a/package.json b/package.json index c9ddc158..e0a91013 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zombiepanic", - "version": "1.2.0", + "version": "1.3.0", "description": "Zombie Panic Mod", "scripts": { "gulp": "gulp", diff --git a/src/include/zombiepanic.inc b/src/include/zombiepanic.inc index ef6389d7..22b863f2 100644 --- a/src/include/zombiepanic.inc +++ b/src/include/zombiepanic.inc @@ -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 @@ -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 diff --git a/src/include/zombiepanic_const.inc b/src/include/zombiepanic_const.inc index 5634d1a3..a3170c5e 100644 --- a/src/include/zombiepanic_const.inc +++ b/src/include/zombiepanic_const.inc @@ -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 @@ -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 diff --git a/src/include/zombiepanic_utils.inc b/src/include/zombiepanic_utils.inc index 0f2888e2..7ac9a687 100644 --- a/src/include/zombiepanic_utils.inc +++ b/src/include/zombiepanic_utils.inc @@ -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); @@ -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) { @@ -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); + } +} + diff --git a/src/scripts/api/api_custom_weapons.sma b/src/scripts/api/api_custom_weapons.sma index 8284a109..b13a5fae 100644 --- a/src/scripts/api/api_custom_weapons.sma +++ b/src/scripts/api/api_custom_weapons.sma @@ -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]; @@ -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; @@ -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); } @@ -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(); } diff --git a/src/scripts/core/zombiepanic.sma b/src/scripts/core/zombiepanic.sma index 13861401..36c5a477 100644 --- a/src/scripts/core/zombiepanic.sma +++ b/src/scripts/core/zombiepanic.sma @@ -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]); } @@ -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"); diff --git a/src/scripts/core/zp_characters.sma b/src/scripts/core/zp_characters.sma index 8b36e0cb..a223042f 100644 --- a/src/scripts/core/zp_characters.sma +++ b/src/scripts/core/zp_characters.sma @@ -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"); @@ -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); diff --git a/src/scripts/core/zp_gamerules.sma b/src/scripts/core/zp_gamerules.sma index cae8519f..9442f6e8 100644 --- a/src/scripts/core/zp_gamerules.sma +++ b/src/scripts/core/zp_gamerules.sma @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -27,6 +28,7 @@ enum TeamPreference { new g_pCvarLives; new g_pCvarLivesPerPlayer; +new g_pCvarCompetitive; new g_pFwPlayerJoined; new g_iFwResult; @@ -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); @@ -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 ]--------------------------------*/ @@ -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) { @@ -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..."); @@ -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++; diff --git a/src/scripts/core/zp_infection.sma b/src/scripts/core/zp_infection.sma index 21880346..50b52c42 100644 --- a/src/scripts/core/zp_infection.sma +++ b/src/scripts/core/zp_infection.sma @@ -63,6 +63,7 @@ public plugin_init() { RegisterHam(Ham_TraceAttack, "player", "OnPlayerTraceAttack", .Post = 0); RegisterHam(Ham_TakeDamage, "player", "OnPlayerTakeDamage", .Post = 0); RegisterHam(Ham_TakeDamage, "player", "OnPlayerTakeDamage_Post", .Post = 0); + RegisterHam(Ham_BloodColor, "player", "OnPlayerBloodColor", .Post = 0); g_pCvarInfectionChance = register_cvar("zp_infection_chance", "10"); @@ -245,8 +246,21 @@ public OnPlayerTakeDamage_Post(pPlayer, pInflictor, pAttacker) { return HAM_HANDLED; } +public OnPlayerBloodColor(pPlayer) { + if (g_iPlayerInfectionState[pPlayer] < InfectionState_PartialZombie) { + return HAM_IGNORED; + } + + SetHamReturnInteger(-1); + return HAM_SUPERCEDE; +} + bool:SetInfected(pPlayer, bool:bValue, pInfector = 0) { if (bValue) { + if (ZP_GameRules_IsCompetitive()) { + return false; + } + if (IsPlayerInfected(pPlayer)) { return false; } @@ -275,9 +289,9 @@ bool:SetInfected(pPlayer, bool:bValue, pInfector = 0) { } bool:IsPlayerInfected(pPlayer) { - if (ZP_Player_IsZombie(pPlayer)) { - return false; - } + // if (ZP_Player_IsZombie(pPlayer)) { + // return false; + // } return g_iPlayerInfectionState[pPlayer] > InfectionState_None; } @@ -290,6 +304,7 @@ TransformPlayer(pPlayer) { ExecuteForward(g_pFwTransformationDeath, g_iFwResult, pPlayer); ExecuteHamB(Ham_Killed, pPlayer, g_pPlayerInfector[pPlayer], 0); + emit_sound(pPlayer, CHAN_VOICE, "common/null.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); } EndPlayerTransformation(pPlayer) { diff --git a/src/scripts/core/zp_use_pickup.sma b/src/scripts/core/zp_use_pickup.sma index f4e9680a..6825e4a0 100644 --- a/src/scripts/core/zp_use_pickup.sma +++ b/src/scripts/core/zp_use_pickup.sma @@ -90,6 +90,10 @@ public OnPlayerPreThink_Post(pPlayer) { new pPrevAimItem = g_pPlayerAimItem[pPlayer]; g_pPlayerAimItem[pPlayer] = -1; + + if (!is_user_alive(pPlayer)) { + return HAM_IGNORED; + } if (ZP_Player_IsZombie(pPlayer)) { return HAM_IGNORED; diff --git a/src/scripts/core/zp_weapons.sma b/src/scripts/core/zp_weapons.sma index c93c40db..7742a59d 100644 --- a/src/scripts/core/zp_weapons.sma +++ b/src/scripts/core/zp_weapons.sma @@ -1,3 +1,4 @@ +#pragma semicolon 1 #include diff --git a/src/scripts/core/zp_zombie_lives.sma b/src/scripts/core/zp_zombie_lives.sma index e6009a3c..b254d8cf 100644 --- a/src/scripts/core/zp_zombie_lives.sma +++ b/src/scripts/core/zp_zombie_lives.sma @@ -70,6 +70,10 @@ public OnPlayerKilled_Post(pPlayer) { } SetupRespawnTask(pPlayer) { + if (ZP_GameRules_IsCompetitive() && !ZP_Player_IsZombie(pPlayer)) { + return; + } + remove_task(TASKID_PLAYER_RESPAWN + pPlayer); set_task(get_pcvar_float(g_pCvarRespawnTime), "Task_RespawnPlayer", TASKID_PLAYER_RESPAWN + pPlayer); } diff --git a/src/scripts/core/zp_zombie_vision.sma b/src/scripts/core/zp_zombie_vision.sma index f89a0cb0..b3c252fe 100644 --- a/src/scripts/core/zp_zombie_vision.sma +++ b/src/scripts/core/zp_zombie_vision.sma @@ -1,3 +1,5 @@ +#pragma semicolon 1 + #include #include #include diff --git a/src/scripts/entities/zp_entity_ammo_357.sma b/src/scripts/entities/zp_entity_ammo_357.sma index 540b2186..5470a54c 100644 --- a/src/scripts/entities/zp_entity_ammo_357.sma +++ b/src/scripts/entities/zp_entity_ammo_357.sma @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -14,30 +15,29 @@ #define ENTITY_NAME "ammo_357" #define ZP_AMMO_TYPE ZP_AMMO_MAGNUM -#define AMMO_BOX_MODEL ZP_AMMO_MAGNUM_MODEL public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { - precache_model(AMMO_BOX_MODEL); CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_AMMO_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); - - new iAmmoHandler = ZP_Ammo_GetHandler(ZP_AMMO_TYPE); - new pWeaponBox = UTIL_CreateAmmoBox(ZP_Ammo_GetId(iAmmoHandler), ZP_Ammo_GetPackSize(iAmmoHandler)); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); - engfunc(EngFunc_SetModel, pWeaponBox, AMMO_BOX_MODEL); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new pWeaponBox = UTIL_CreateZpAmmoBox(ZP_Ammo_GetHandler(ZP_AMMO_TYPE)); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + } else { + CE_Kill(pEntity); + } +} - CE_Kill(pEntity); +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } } diff --git a/src/scripts/entities/zp_entity_ammo_556AR.sma b/src/scripts/entities/zp_entity_ammo_556AR.sma index 85368e1a..36b4368b 100644 --- a/src/scripts/entities/zp_entity_ammo_556AR.sma +++ b/src/scripts/entities/zp_entity_ammo_556AR.sma @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -14,30 +15,29 @@ #define ENTITY_NAME "ammo_556AR" #define ZP_AMMO_TYPE ZP_AMMO_RIFLE -#define AMMO_BOX_MODEL ZP_AMMO_RIFLE_MODEL public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { - precache_model(AMMO_BOX_MODEL); CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_AMMO_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); - - new iAmmoHandler = ZP_Ammo_GetHandler(ZP_AMMO_TYPE); - new pWeaponBox = UTIL_CreateAmmoBox(ZP_Ammo_GetId(iAmmoHandler), ZP_Ammo_GetPackSize(iAmmoHandler)); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); - engfunc(EngFunc_SetModel, pWeaponBox, AMMO_BOX_MODEL); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new pWeaponBox = UTIL_CreateZpAmmoBox(ZP_Ammo_GetHandler(ZP_AMMO_TYPE)); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + } else { + CE_Kill(pEntity); + } +} - CE_Kill(pEntity); +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } } diff --git a/src/scripts/entities/zp_entity_ammo_556box.sma b/src/scripts/entities/zp_entity_ammo_556box.sma index cdc1edab..5d4798c9 100644 --- a/src/scripts/entities/zp_entity_ammo_556box.sma +++ b/src/scripts/entities/zp_entity_ammo_556box.sma @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -18,28 +19,34 @@ public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { precache_model(AMMO_BOX_MODEL); + CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_AMMO_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); - - new iAmmoHandler = ZP_Ammo_GetHandler(ZP_AMMO_TYPE); - new pWeaponBox = UTIL_CreateAmmoBox(ZP_Ammo_GetId(iAmmoHandler), ZP_Ammo_GetPackSize(iAmmoHandler)); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); - engfunc(EngFunc_SetModel, pWeaponBox, AMMO_BOX_MODEL); - - CE_Kill(pEntity); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new iAmmoHandler = ZP_Ammo_GetHandler(ZP_AMMO_TYPE); + new iAmount = ZP_Ammo_GetPackSize(iAmmoHandler) * 5; + + new pWeaponBox = UTIL_CreateZpAmmoBox(iAmmoHandler, iAmount); + engfunc(EngFunc_SetModel, pWeaponBox, AMMO_BOX_MODEL); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + + set_pev(pWeaponBox, pev_owner, pEntity); + } else { + CE_Kill(pEntity); + } } - +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } +} diff --git a/src/scripts/entities/zp_entity_ammo_9mmclip.sma b/src/scripts/entities/zp_entity_ammo_9mmclip.sma index 740982c9..fac2cd2f 100644 --- a/src/scripts/entities/zp_entity_ammo_9mmclip.sma +++ b/src/scripts/entities/zp_entity_ammo_9mmclip.sma @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -14,31 +15,29 @@ #define ENTITY_NAME "ammo_9mmclip" #define ZP_AMMO_TYPE ZP_AMMO_PISTOL -#define AMMO_BOX_MODEL ZP_AMMO_PISTOL_MODEL public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { - precache_model(AMMO_BOX_MODEL); - CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_AMMO_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); - - new iAmmoHandler = ZP_Ammo_GetHandler(ZP_AMMO_PISTOL); - new pWeaponBox = UTIL_CreateAmmoBox(ZP_Ammo_GetId(iAmmoHandler), ZP_Ammo_GetPackSize(iAmmoHandler)); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); - engfunc(EngFunc_SetModel, pWeaponBox, AMMO_BOX_MODEL); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new pWeaponBox = UTIL_CreateZpAmmoBox(ZP_Ammo_GetHandler(ZP_AMMO_TYPE)); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + } else { + CE_Kill(pEntity); + } +} - CE_Kill(pEntity); +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } } diff --git a/src/scripts/entities/zp_entity_ammo_buckshot.sma b/src/scripts/entities/zp_entity_ammo_buckshot.sma index 8e908de8..56e8eaf2 100644 --- a/src/scripts/entities/zp_entity_ammo_buckshot.sma +++ b/src/scripts/entities/zp_entity_ammo_buckshot.sma @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -14,30 +15,29 @@ #define ENTITY_NAME "ammo_buckshot" #define ZP_AMMO_TYPE ZP_AMMO_SHOTGUN -#define AMMO_BOX_MODEL ZP_AMMO_SHOTGUN_MODEL public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { - precache_model(AMMO_BOX_MODEL); CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_AMMO_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); - - new iAmmoHandler = ZP_Ammo_GetHandler(ZP_AMMO_TYPE); - new pWeaponBox = UTIL_CreateAmmoBox(ZP_Ammo_GetId(iAmmoHandler), ZP_Ammo_GetPackSize(iAmmoHandler)); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); - engfunc(EngFunc_SetModel, pWeaponBox, AMMO_BOX_MODEL); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new pWeaponBox = UTIL_CreateZpAmmoBox(ZP_Ammo_GetHandler(ZP_AMMO_TYPE)); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + } else { + CE_Kill(pEntity); + } +} - CE_Kill(pEntity); +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } } diff --git a/src/scripts/entities/zp_entity_item_battery.sma b/src/scripts/entities/zp_entity_item_battery.sma index f4420c00..20759c54 100644 --- a/src/scripts/entities/zp_entity_item_battery.sma +++ b/src/scripts/entities/zp_entity_item_battery.sma @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -35,6 +36,12 @@ public OnSpawn_Post(pEntity) { set_pev(pEntity, pev_solid, SOLID_TRIGGER); set_pev(pEntity, pev_effects, pev(pEntity, pev_effects) & ~EF_NODRAW); + SetThink(pEntity, ""); + + if (!ZP_GameRules_CanItemRespawn(pEntity)) { + Kill(pEntity); + } + return HAM_HANDLED; } @@ -57,10 +64,9 @@ public OnTouch(pEntity, pToucher) { set_member(pToucher, m_iKevlar, 1); set_pev(pToucher, pev_armorvalue, flArmorValue); - set_pev(pEntity, pev_effects, pev(pEntity, pev_effects) | EF_NODRAW); - set_pev(pEntity, pev_solid, SOLID_NOT); - emit_sound(pToucher, CHAN_ITEM, "items/tr_kevlar.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); + + Kill(pEntity); } } } @@ -68,9 +74,21 @@ public OnTouch(pEntity, pToucher) { return HAM_SUPERCEDE; } +public RespawnThink(pEntity) { + dllfunc(DLLFunc_Spawn, pEntity); + SetThink(pEntity, ""); +} + public Round_Fw_NewRound() { new pEntity; while ((pEntity = engfunc(EngFunc_FindEntityByString, pEntity, "classname", ENTITY_NAME)) != 0) { ExecuteHamB(Ham_Spawn, pEntity); } } + +Kill(pEntity) { + set_pev(pEntity, pev_effects, pev(pEntity, pev_effects) | EF_NODRAW); + set_pev(pEntity, pev_solid, SOLID_NOT); + SetThink(pEntity, "RespawnThink"); + set_pev(pEntity, pev_nextthink, get_gametime() + ZP_ITEMS_RESPAWN_TIME); +} diff --git a/src/scripts/entities/zp_entity_item_healthkit.sma b/src/scripts/entities/zp_entity_item_healthkit.sma index fd193d81..a85f7082 100644 --- a/src/scripts/entities/zp_entity_item_healthkit.sma +++ b/src/scripts/entities/zp_entity_item_healthkit.sma @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -39,6 +40,12 @@ public OnSpawn_Post(pEntity) { set_pev(pEntity, pev_solid, SOLID_TRIGGER); set_pev(pEntity, pev_effects, pev(pEntity, pev_effects) & ~EF_NODRAW); + SetThink(pEntity, ""); + + if (!ZP_GameRules_CanItemRespawn(pEntity)) { + Kill(pEntity); + } + return HAM_HANDLED; } @@ -63,9 +70,6 @@ public OnTouch(pEntity, pToucher) { flHealth = floatmin(flMaxHealth, flHealth + 25.0); set_pev(pToucher, pev_health, flHealth); - set_pev(pEntity, pev_effects, pev(pEntity, pev_effects) | EF_NODRAW); - set_pev(pEntity, pev_solid, SOLID_NOT); - if (ZP_Player_IsInfected(pToucher) && !ZP_Player_IsTransforming(pToucher)) { if (random(100) < get_pcvar_num(g_pCvarCureChance)) { ZP_Player_SetInfected(pToucher, false); @@ -73,6 +77,7 @@ public OnTouch(pEntity, pToucher) { } emit_sound(pToucher, CHAN_ITEM, "items/smallmedkit1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM); + Kill(pEntity); } } } @@ -80,9 +85,21 @@ public OnTouch(pEntity, pToucher) { return HAM_SUPERCEDE; } +public RespawnThink(pEntity) { + dllfunc(DLLFunc_Spawn, pEntity); + SetThink(pEntity, ""); +} + public Round_Fw_NewRound() { new pEntity; while ((pEntity = engfunc(EngFunc_FindEntityByString, pEntity, "classname", ENTITY_NAME)) != 0) { ExecuteHamB(Ham_Spawn, pEntity); } } + +Kill(pEntity) { + set_pev(pEntity, pev_effects, pev(pEntity, pev_effects) | EF_NODRAW); + set_pev(pEntity, pev_solid, SOLID_NOT); + SetThink(pEntity, "RespawnThink"); + set_pev(pEntity, pev_nextthink, get_gametime() + ZP_ITEMS_RESPAWN_TIME); +} diff --git a/src/scripts/entities/zp_entity_weapon_357.sma b/src/scripts/entities/zp_entity_weapon_357.sma index c3ff7f30..0513ddd2 100644 --- a/src/scripts/entities/zp_entity_weapon_357.sma +++ b/src/scripts/entities/zp_entity_weapon_357.sma @@ -2,11 +2,13 @@ #include #include +#include #include #include #include +#include #define PLUGIN "[Entity] weapon_357" #define AUTHOR "Hedgehog Fog" @@ -17,6 +19,8 @@ new CW:g_iCwHandler; public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { @@ -25,23 +29,21 @@ public plugin_precache() { return; } - CE_Register( - .szName = ENTITY_NAME, - .vMins = Float:{-8.0, -8.0, 0.0}, - .vMaxs = Float:{8.0, 8.0, 8.0} - ); - + CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_WEAPONS_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + } else { + CE_Kill(pEntity); + } +} - new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } } diff --git a/src/scripts/entities/zp_entity_weapon_556AR.sma b/src/scripts/entities/zp_entity_weapon_556AR.sma index 0fb0e7d3..cbbf29d8 100644 --- a/src/scripts/entities/zp_entity_weapon_556AR.sma +++ b/src/scripts/entities/zp_entity_weapon_556AR.sma @@ -2,11 +2,13 @@ #include #include +#include #include #include #include +#include #define PLUGIN "[Entity] weapon_556AR" #define AUTHOR "Hedgehog Fog" @@ -17,6 +19,8 @@ new CW:g_iCwHandler; public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { @@ -25,23 +29,21 @@ public plugin_precache() { return; } - CE_Register( - .szName = ENTITY_NAME, - .vMins = Float:{-8.0, -8.0, 0.0}, - .vMaxs = Float:{8.0, 8.0, 8.0} - ); - + CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_WEAPONS_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + } else { + CE_Kill(pEntity); + } +} - new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } } diff --git a/src/scripts/entities/zp_entity_weapon_9mmhandgun.sma b/src/scripts/entities/zp_entity_weapon_9mmhandgun.sma index 154fa603..c2acaf0d 100644 --- a/src/scripts/entities/zp_entity_weapon_9mmhandgun.sma +++ b/src/scripts/entities/zp_entity_weapon_9mmhandgun.sma @@ -2,11 +2,13 @@ #include #include +#include #include #include #include +#include #define PLUGIN "[Entity] weapon_9mmhandgun" #define AUTHOR "Hedgehog Fog" @@ -17,6 +19,8 @@ new CW:g_iCwHandler; public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { @@ -25,23 +29,21 @@ public plugin_precache() { return; } - CE_Register( - .szName = ENTITY_NAME, - .vMins = Float:{-8.0, -8.0, 0.0}, - .vMaxs = Float:{8.0, 8.0, 8.0} - ); - + CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_WEAPONS_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + } else { + CE_Kill(pEntity); + } +} - new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } } diff --git a/src/scripts/entities/zp_entity_weapon_handgrenade.sma b/src/scripts/entities/zp_entity_weapon_handgrenade.sma index 990882bf..1b8678d3 100644 --- a/src/scripts/entities/zp_entity_weapon_handgrenade.sma +++ b/src/scripts/entities/zp_entity_weapon_handgrenade.sma @@ -3,11 +3,13 @@ #include #include +#include #include #include #include +#include #define PLUGIN "[Entity] weapon_handgrenade" #define AUTHOR "Hedgehog Fog" @@ -18,6 +20,8 @@ new CW:g_iCwHandler; public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { @@ -26,23 +30,21 @@ public plugin_precache() { return; } - CE_Register( - .szName = ENTITY_NAME, - .vMins = Float:{-8.0, -8.0, 0.0}, - .vMaxs = Float:{8.0, 8.0, 8.0} - ); - + CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_WEAPONS_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + } else { + CE_Kill(pEntity); + } +} - new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); -} \ No newline at end of file +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } +} diff --git a/src/scripts/entities/zp_entity_weapon_satchel.sma b/src/scripts/entities/zp_entity_weapon_satchel.sma index 5943fd17..c0640c47 100644 --- a/src/scripts/entities/zp_entity_weapon_satchel.sma +++ b/src/scripts/entities/zp_entity_weapon_satchel.sma @@ -3,11 +3,13 @@ #include #include +#include #include #include #include +#include #define PLUGIN "[Entity] weapon_satchel" #define AUTHOR "Hedgehog Fog" @@ -18,6 +20,8 @@ new CW:g_iCwHandler; public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { @@ -26,23 +30,21 @@ public plugin_precache() { return; } - CE_Register( - .szName = ENTITY_NAME, - .vMins = Float:{-8.0, -8.0, 0.0}, - .vMaxs = Float:{8.0, 8.0, 8.0} - ); - + CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_WEAPONS_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + } else { + CE_Kill(pEntity); + } +} - new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } } diff --git a/src/scripts/entities/zp_entity_weapon_shotgun.sma b/src/scripts/entities/zp_entity_weapon_shotgun.sma index f3180fc1..51b61146 100644 --- a/src/scripts/entities/zp_entity_weapon_shotgun.sma +++ b/src/scripts/entities/zp_entity_weapon_shotgun.sma @@ -2,11 +2,13 @@ #include #include +#include #include #include #include +#include #define PLUGIN "[Entity] weapon_shotgun" #define AUTHOR "Hedgehog Fog" @@ -17,6 +19,8 @@ new CW:g_iCwHandler; public plugin_init() { register_plugin(PLUGIN, ZP_VERSION, AUTHOR); + + RegisterHam(Ham_Touch, "weaponbox", "OnWeaponBoxTouch_Post", .Post = 1); } public plugin_precache() { @@ -25,23 +29,21 @@ public plugin_precache() { return; } - CE_Register( - .szName = ENTITY_NAME, - .vMins = Float:{-8.0, -8.0, 0.0}, - .vMaxs = Float:{8.0, 8.0, 8.0} - ); - + CE_Register(ENTITY_NAME, _, Float:{-8.0, -8.0, 0.0}, Float:{8.0, 8.0, 8.0}, _, ZP_WEAPONS_RESPAWN_TIME); CE_RegisterHook(CEFunction_Spawn, ENTITY_NAME, "OnSpawn"); } public OnSpawn(pEntity) { - new Float:vecOrigin[3]; - pev(pEntity, pev_origin, vecOrigin); - - new Float:vecAngles[3]; - pev(pEntity, pev_angles, vecAngles); + if (ZP_GameRules_CanItemRespawn(pEntity)) { + new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); + UTIL_InitWithSpawner(pWeaponBox, pEntity); + } else { + CE_Kill(pEntity); + } +} - new pWeaponBox = CW_SpawnWeaponBox(g_iCwHandler); - engfunc(EngFunc_SetOrigin, pWeaponBox, vecOrigin); - set_pev(pWeaponBox, pev_angles, vecAngles); +public OnWeaponBoxTouch_Post(pEntity) { + if (pev(pEntity, pev_flags) & FL_KILLME) { + UTIL_SetupSpawnerRespawn(pEntity); + } } diff --git a/src/scripts/extra/zp_objective_marks.sma b/src/scripts/extra/zp_objective_marks.sma index bff3e9a1..74f20604 100644 --- a/src/scripts/extra/zp_objective_marks.sma +++ b/src/scripts/extra/zp_objective_marks.sma @@ -18,8 +18,8 @@ #define SPRITE_SCALE 0.03125 #define SPRITE_AMT 50.0 #define MARK_UPDATE_DELAY 0.1 -#define MARK_MAX_VELOCITY 200.0 -#define MARK_MAX_MOVE_STEP_LENGTH 1000.0 +#define MARK_MAX_VELOCITY 250.0 +#define MARK_MAX_MOVE_STEP_LENGTH 800.0 #define MARK_MAX_SCALE_STEP 0.125 #define MARK_MAX_SCALE_STEP_LENGTH 100.0 diff --git a/src/scripts/hud/zp_hud_deathmsg.sma b/src/scripts/hud/zp_hud_deathmsg.sma index 93dbcf43..c0bdfaec 100644 --- a/src/scripts/hud/zp_hud_deathmsg.sma +++ b/src/scripts/hud/zp_hud_deathmsg.sma @@ -1,3 +1,5 @@ +#pragma semicolon 1 + #include #include #include @@ -35,7 +37,7 @@ public OnMessage_DeathMsg(iMsgId, iDest, pPlayer) { continue; } - if (!ZP_Player_IsZombie(pPlayer) && !UTIL_IsPlayerSpectator(pPlayer)) { + if (!ZP_GameRules_IsCompetitive() && !ZP_Player_IsZombie(pPlayer) && !UTIL_IsPlayerSpectator(pPlayer)) { continue; } diff --git a/src/scripts/hud/zp_hud_radar.sma b/src/scripts/hud/zp_hud_radar.sma index ff4a5915..a9ce1fd5 100644 --- a/src/scripts/hud/zp_hud_radar.sma +++ b/src/scripts/hud/zp_hud_radar.sma @@ -1,3 +1,5 @@ +#pragma semicolon 1 + #include #include #include diff --git a/src/scripts/hud/zp_hud_scoreattrib.sma b/src/scripts/hud/zp_hud_scoreattrib.sma index 74c20334..ba0fc373 100644 --- a/src/scripts/hud/zp_hud_scoreattrib.sma +++ b/src/scripts/hud/zp_hud_scoreattrib.sma @@ -1,3 +1,5 @@ +#pragma semicolon 1 + #include #include diff --git a/src/scripts/hud/zp_hud_scoreinfo.sma b/src/scripts/hud/zp_hud_scoreinfo.sma index 9b016a98..59867691 100644 --- a/src/scripts/hud/zp_hud_scoreinfo.sma +++ b/src/scripts/hud/zp_hud_scoreinfo.sma @@ -1,3 +1,5 @@ +#pragma semicolon 1 + #include #include #include @@ -54,7 +56,11 @@ Update(pPlayer, pTargetPlayer) { new iScore = get_user_frags(pTargetPlayer); new iDeaths = ZP_Player_IsZombie(pPlayer) || pTargetPlayer == pPlayer ? get_member(pTargetPlayer, m_iDeaths) : 0; new iClassId = 0; - new bool:bShowTeam = ZP_Player_IsZombie(pPlayer) || is_user_bot(pPlayer) || UTIL_IsPlayerSpectator(pPlayer); + new bool:bShowTeam = ZP_Player_IsZombie(pPlayer) + || ZP_GameRules_IsCompetitive() + || is_user_bot(pPlayer) + || UTIL_IsPlayerSpectator(pPlayer); + new iTeam = bShowTeam ? get_member(pTargetPlayer, m_iTeam) : get_member(pPlayer, m_iTeam); SendMessage(pPlayer, pTargetPlayer, iScore, iDeaths, iClassId, iTeam); diff --git a/src/scripts/hud/zp_hud_statusvalue.sma b/src/scripts/hud/zp_hud_statusvalue.sma index 905d5d1c..6ce06cca 100644 --- a/src/scripts/hud/zp_hud_statusvalue.sma +++ b/src/scripts/hud/zp_hud_statusvalue.sma @@ -1,3 +1,5 @@ +#pragma semicolon 1 + #include #include @@ -46,7 +48,7 @@ public OnMessage(iMsgId, iDest, pPlayer) { g_statusValue[iFlag] = iValue; - if (g_statusValue[StatusValueFlag_IsTeammate] == 2) { + if (!ZP_GameRules_IsCompetitive() && g_statusValue[StatusValueFlag_IsTeammate] == 2) { return PLUGIN_HANDLED; } diff --git a/src/scripts/hud/zp_hud_teaminfo.sma b/src/scripts/hud/zp_hud_teaminfo.sma index dc5bfab3..aa765031 100644 --- a/src/scripts/hud/zp_hud_teaminfo.sma +++ b/src/scripts/hud/zp_hud_teaminfo.sma @@ -1,3 +1,5 @@ +#pragma semicolon 1 + #include #include #include @@ -52,7 +54,10 @@ public OnEvent() { } new iTeam = get_member(pPlayer, m_iTeam); - new bool:bShowTeam = ZP_Player_IsZombie(pPlayer) || is_user_bot(pPlayer) || UTIL_IsPlayerSpectator(pPlayer) + new bool:bShowTeam = ZP_Player_IsZombie(pPlayer) + || ZP_GameRules_IsCompetitive() + || is_user_bot(pPlayer) + || UTIL_IsPlayerSpectator(pPlayer); SendMessage(pPlayer, pTargetPlayer, bShowTeam ? szTeam : g_rgszTeams[iTeam]); } diff --git a/src/scripts/hud/zp_hud_winmessage.sma b/src/scripts/hud/zp_hud_winmessage.sma index b3f939d3..e527cdea 100644 --- a/src/scripts/hud/zp_hud_winmessage.sma +++ b/src/scripts/hud/zp_hud_winmessage.sma @@ -1,3 +1,5 @@ +#pragma semicolon 1 + #include #include @@ -70,5 +72,5 @@ ShowWinMessage(const szMessage[], any:...) { set_dhudmessage(255, 255, 255, -1.0, -1.0); show_dhudmessage(0, szBuffer); - UTIL_ScreenFade(0, {0, 0, 0}, 1.0, ZP_NEW_ROUND_DELAY, 255, FFADE_OUT, .bExternal = true); + UTIL_ScreenFade(0, {0, 0, 0}, 2.0, ZP_NEW_ROUND_DELAY, 255, FFADE_OUT, .bExternal = true); } diff --git a/src/scripts/weapons/zp_weapon_556ar.sma b/src/scripts/weapons/zp_weapon_556ar.sma index 16b15865..cf3a9ab6 100644 --- a/src/scripts/weapons/zp_weapon_556ar.sma +++ b/src/scripts/weapons/zp_weapon_556ar.sma @@ -60,7 +60,7 @@ public @Weapon_Idle(this) { public @Weapon_PrimaryAttack(this) { static Float:vecSpread[3]; - UTIL_CalculateWeaponSpread(this, Float:VECTOR_CONE_5DEGREES, 1.1125, 0.5, 0.95, 3.5, vecSpread); + UTIL_CalculateWeaponSpread(this, Float:VECTOR_CONE_4DEGREES, 1.1125, 0.5, 0.95, 3.5, vecSpread); if (CW_DefaultShot(this, 26.0, 0.85, 0.095, Float:vecSpread)) { CW_PlayAnimation(this, 5 + random(3), 0.7); diff --git a/src/scripts/weapons/zp_weapon_crowbar.sma b/src/scripts/weapons/zp_weapon_crowbar.sma index fe7cf4aa..fdc9d2d9 100644 --- a/src/scripts/weapons/zp_weapon_crowbar.sma +++ b/src/scripts/weapons/zp_weapon_crowbar.sma @@ -68,39 +68,15 @@ public @Weapon_Idle(this) { } public @Weapon_PrimaryAttack(this) { - new pPlayer = CW_GetPlayer(this); - new pHit = CW_DefaultSwing(this, 25.0, 0.5, 38.0); - CW_PlayAnimation(this, 4, 0.25); - - if (pHit < 0) { - switch (random(3)) { - case 0: CW_PlayAnimation(this, 4, 11.0 / 22.0); - case 1: CW_PlayAnimation(this, 5, 14.0 / 22.0); - case 2: CW_PlayAnimation(this, 7, 19.0 / 24.0); - } - - emit_sound(pPlayer, CHAN_ITEM, ZP_WEAPON_CROWBAR_MISS_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM); - } else { - switch (random(3)) { - case 0: CW_PlayAnimation(this, 3, 11.0 / 22.0); - case 1: CW_PlayAnimation(this, 6, 14.0 / 22.0); - case 2: CW_PlayAnimation(this, 8, 19.0 / 24.0); - } - - if (UTIL_IsPlayer(pHit)) { - emit_sound(pPlayer, CHAN_ITEM, ZP_WEAPON_CROWBAR_HITBODY_SOUNDS[random(sizeof(ZP_WEAPON_CROWBAR_HITBODY_SOUNDS))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM); - } else { - emit_sound(pPlayer, CHAN_ITEM, ZP_WEAPON_CROWBAR_HIT_SOUNDS[random(sizeof(ZP_WEAPON_CROWBAR_HIT_SOUNDS))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM); - } - } - + Swing(this); set_member(this, m_Weapon_flNextSecondaryAttack, 0.5); } public @Weapon_SecondaryAttack(this) { new pPlayer = CW_GetPlayer(this); if (is_user_bot(pPlayer)) { - CW_PrimaryAttack(this); + Swing(this); + set_member(this, m_Weapon_flNextSecondaryAttack, 0.5); } } @@ -146,3 +122,32 @@ public OnPlayerTakeDamage_Post(this, pInflictor, pAttacker) { return HAM_HANDLED; } + + +Swing(this) { + new pPlayer = CW_GetPlayer(this); + new pHit = CW_DefaultSwing(this, 25.0, 0.5, 38.0); + CW_PlayAnimation(this, 4, 0.25); + + if (pHit < 0) { + switch (random(3)) { + case 0: CW_PlayAnimation(this, 4, 11.0 / 22.0); + case 1: CW_PlayAnimation(this, 5, 14.0 / 22.0); + case 2: CW_PlayAnimation(this, 7, 19.0 / 24.0); + } + + emit_sound(pPlayer, CHAN_ITEM, ZP_WEAPON_CROWBAR_MISS_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM); + } else { + switch (random(3)) { + case 0: CW_PlayAnimation(this, 3, 11.0 / 22.0); + case 1: CW_PlayAnimation(this, 6, 14.0 / 22.0); + case 2: CW_PlayAnimation(this, 8, 19.0 / 24.0); + } + + if (UTIL_IsPlayer(pHit)) { + emit_sound(pPlayer, CHAN_ITEM, ZP_WEAPON_CROWBAR_HITBODY_SOUNDS[random(sizeof(ZP_WEAPON_CROWBAR_HITBODY_SOUNDS))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM); + } else { + emit_sound(pPlayer, CHAN_ITEM, ZP_WEAPON_CROWBAR_HIT_SOUNDS[random(sizeof(ZP_WEAPON_CROWBAR_HIT_SOUNDS))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM); + } + } +} diff --git a/src/scripts/weapons/zp_weapon_swipe.sma b/src/scripts/weapons/zp_weapon_swipe.sma index b86c6194..c372ac1e 100644 --- a/src/scripts/weapons/zp_weapon_swipe.sma +++ b/src/scripts/weapons/zp_weapon_swipe.sma @@ -50,41 +50,15 @@ public plugin_init() { } public @Weapon_PrimaryAttack(this) { - new pPlayer = CW_GetPlayer(this); - - if (random(2) == 0) { - set_member(pPlayer, m_szAnimExtention, "grenade"); - } else { - set_member(pPlayer, m_szAnimExtention, "shieldgren"); - } - - new pHit = CW_DefaultSwing(this, 25.0, 0.5, 36.0); - - if (pHit < 0) { - switch (random(3)) { - case 0: CW_PlayAnimation(this, 4, 11.0 / 22.0); - case 1: CW_PlayAnimation(this, 5, 14.0 / 22.0); - case 2: CW_PlayAnimation(this, 7, 19.0 / 24.0); - } - - emit_sound(pPlayer, CHAN_ITEM, ZP_WEAPON_SWIPE_MISS_SOUNDS[random(sizeof(ZP_WEAPON_SWIPE_MISS_SOUNDS))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM); - } else { - switch (random(3)) { - case 0: CW_PlayAnimation(this, 3, 11.0 / 22.0); - case 1: CW_PlayAnimation(this, 6, 14.0 / 22.0); - case 2: CW_PlayAnimation(this, 8, 19.0 / 24.0); - } - - emit_sound(pPlayer, CHAN_ITEM, ZP_WEAPON_SWIPE_HIT_SOUNDS[random(sizeof(ZP_WEAPON_SWIPE_HIT_SOUNDS))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM); - } - + Swing(this); set_member(this, m_Weapon_flNextSecondaryAttack, 0.5); } public @Weapon_SecondaryAttack(this) { new pPlayer = CW_GetPlayer(this); if (is_user_bot(pPlayer)) { - CW_PrimaryAttack(this); + Swing(this); + set_member(this, m_Weapon_flNextSecondaryAttack, 0.5); } } @@ -143,6 +117,36 @@ public OnPlayerTraceAttack(this, pAttacker, Float:flDamage, Float:vecDir[3], pTr return HAM_HANDLED; } +Swing(this) { + new pPlayer = CW_GetPlayer(this); + + if (random(2) == 0) { + set_member(pPlayer, m_szAnimExtention, "grenade"); + } else { + set_member(pPlayer, m_szAnimExtention, "shieldgren"); + } + + new pHit = CW_DefaultSwing(this, 25.0, 0.5, 36.0); + + if (pHit < 0) { + switch (random(3)) { + case 0: CW_PlayAnimation(this, 4, 11.0 / 22.0); + case 1: CW_PlayAnimation(this, 5, 14.0 / 22.0); + case 2: CW_PlayAnimation(this, 7, 19.0 / 24.0); + } + + emit_sound(pPlayer, CHAN_ITEM, ZP_WEAPON_SWIPE_MISS_SOUNDS[random(sizeof(ZP_WEAPON_SWIPE_MISS_SOUNDS))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM); + } else { + switch (random(3)) { + case 0: CW_PlayAnimation(this, 3, 11.0 / 22.0); + case 1: CW_PlayAnimation(this, 6, 14.0 / 22.0); + case 2: CW_PlayAnimation(this, 8, 19.0 / 24.0); + } + + emit_sound(pPlayer, CHAN_ITEM, ZP_WEAPON_SWIPE_HIT_SOUNDS[random(sizeof(ZP_WEAPON_SWIPE_HIT_SOUNDS))], VOL_NORM, ATTN_NORM, 0, PITCH_NORM); + } +} + UpdateZombieLives() { for (new pPlayer = 1; pPlayer <= MaxClients; ++pPlayer) { if (!is_user_connected(pPlayer)) {