Skip to content

Commit

Permalink
Release 1.2.0 (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedgefog authored Feb 23, 2021
2 parents 1826b47 + b848332 commit 23dc099
Show file tree
Hide file tree
Showing 27 changed files with 307 additions and 101 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.0.0
__Version:__ 1.2.0

### Download latest:
- [Releases](../../releases)
Expand Down
3 changes: 2 additions & 1 deletion assets/addons/amxmodx/configs/zombiepanic.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ zp_flashlight_consumption_rate 0.5
zp_flashlight_recovery_rate 0.5

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

// [Zombie Panic] Infection
zp_infection_chance 10
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.1.0",
"version": "1.2.0",
"description": "Zombie Panic Mod",
"scripts": {
"gulp": "gulp",
Expand Down
26 changes: 25 additions & 1 deletion src/include/zombiepanic.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
/*
1.2.0
Additions and improvements:
Reduced crowbar damage to 25
Added crowbar knockback
Zombie lives are now related to the number of survivors
Zombies number are now related to the number of survivors
Added chooseteam command for spectators
Zombies no longer respawn after round ends
Magnum no longer eject brass when shooting
Added blink effect at the end of the transformation
Added unselectable characters support
Cvars:
Added zp_zombie_lives_per_player cvar
Fixes:
Fixed client crashes related to weapon icon names
Fixed crosshair flickering
Fixed zombie vision external fade handling
Fixed zombie vision fade effect when respawning
1.1.0
Additions and improvements:
Added infection (10% chance by default)
Expand Down Expand Up @@ -34,7 +55,9 @@ native bool:ZP_Player_ToggleFlashlight(pPlayer);
native bool:ZP_Player_ToggleZombieVision(pPlayer);
native bool:ZP_Player_IsInfected(pPlayer);
native bool:ZP_Player_IsTransforming(pPlayer);
native ZP_Player_SetInfected(pPlayer, bool:bValue);
native bool:ZP_Player_IsPartialZombie(pPlayer);
native ZP_Player_SetInfected(pPlayer, bool:bValue, pInfector = 0);
native bool:ZP_Player_SetCharacter(pPlayer, const szCharacter[]);

forward ZP_Fw_PlayerJoined(pPlayer);
forward ZP_Fw_PlayerPanic(pPlayer);
Expand All @@ -43,6 +66,7 @@ forward ZP_Fw_Player_AimItem(pPlayer, pItem);
forward ZP_Fw_PlayerInfected(pPlayer, pInfector);
forward ZP_Fw_PlayerTransformationDeath(pPlayer);
forward ZP_Fw_PlayerTransformed(pPlayer);
forward ZP_Fw_PlayerEquiped(pPlayer);

// Player inventory

Expand Down
2 changes: 1 addition & 1 deletion 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.1.0"
#define ZP_VERSION "1.2.0"

#define ZP_HUMAN_TEAM 2
#define ZP_ZOMBIE_TEAM 1
Expand Down
21 changes: 21 additions & 0 deletions src/include/zombiepanic_utils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,24 @@ stock bool:UTIL_IsPlayerSpectator(pPlayer) {
new iTeam = get_member(pPlayer, m_iTeam);
return iTeam < 1 || iTeam > 2;
}

stock UTIL_PlayerKnockback(pVictim, pAttacker, Float:flForce) {
static Float:vecOrigin[3];
pev(pVictim, pev_origin, vecOrigin);

static Float:vecAttackerOrigin[3];
pev(pAttacker, pev_origin, vecAttackerOrigin);

static Float:vecDir[3];
xs_vec_sub(vecOrigin, vecAttackerOrigin, vecDir);

new Float:flLen = xs_vec_len_2d(vecDir);

static Float:vecVelocity[3];
pev(pVictim, pev_velocity, vecVelocity);
for (new i = 0; i < 2; ++i) {
vecVelocity[i] = (vecDir[i] / flLen) * flForce;
}

set_pev(pVictim, pev_velocity, vecVelocity);
}
17 changes: 12 additions & 5 deletions src/scripts/api/api_custom_weapons.sma
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,11 @@ public OnPlayerPreThink_Post(pPlayer) {
}

public OnPlayerTakeDamage(pPlayer, pInflictor, pAttacker) {
g_pKillerItem = pInflictor;
if (pAttacker && ExecuteHam(Ham_IsPlayer, pAttacker) && pInflictor == pAttacker) {
g_pKillerItem = get_member(pAttacker, m_pActiveItem);
} else {
g_pKillerItem = pInflictor;
}
}

public OnPlayerTakeDamage_Post() {
Expand Down Expand Up @@ -600,10 +604,12 @@ public OnMessage_DeathMsg(iMsgId, iDest, pPlayer) {

static szIcon[64];
GetStringData(iHandler, CW_Data_Icon, szIcon, charsmax(szIcon));

if (szIcon[0] == '^0') {
GetStringData(iHandler, CW_Data_Name, szIcon, charsmax(szIcon));
}


set_msg_arg_string(4, szIcon);

return PLUGIN_CONTINUE;
Expand Down Expand Up @@ -736,16 +742,16 @@ ItemPostFrame(this) {
new iPrimaryAmmoAmount = get_member(pPlayer, m_rgAmmo, iPrimaryAmmoIndex);
new iSecondaryAmmoAmount = get_member(pPlayer, m_rgAmmo, iSecondaryAmmoIndex);

if (flInReload && flNextAttack <= 0.0) {
CompleteReload(this);
}

new Float:flReloadEndTime = get_member(this, m_Weapon_flNextReload);
if (flReloadEndTime && flReloadEndTime < get_gametime()) {
set_member(this, m_Weapon_flNextReload, 0.0);
ExecuteBindedFunction(CWB_Pump, this);
}

if (flInReload && flNextAttack <= 0.0) {
CompleteReload(this);
}

if ((button & IN_ATTACK2) && flNextSecondaryAttack <= 0) {
if (iSecondaryAmmoIndex > 0 && !iSecondaryAmmoAmount) {
set_member(this, m_Weapon_fFireOnEmpty, 1);
Expand Down Expand Up @@ -822,6 +828,7 @@ WeaponHolster(this) {
SetWeaponPrediction(pPlayer, true);
set_member(this, m_Weapon_fInReload, 0);
set_member(this, m_Weapon_fInSpecialReload, 0);
set_member(this, m_Weapon_flNextReload, 0.0);

if (ExecuteBindedFunction(CWB_Holster, this) > PLUGIN_CONTINUE) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/core/zombiepanic.sma
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define AUTHOR "Hedgehog Fog"

new g_pFwConfigLoaded;
new g_pFwResult;
new g_iFwResult;

new g_pCvarVersion;

Expand Down Expand Up @@ -50,7 +50,7 @@ public plugin_cfg() {
server_cmd("exec %s/zombiepanic.cfg", szConfigDir);
server_exec();

ExecuteForward(g_pFwConfigLoaded, g_pFwResult);
ExecuteForward(g_pFwConfigLoaded, g_iFwResult);
}

public OnVersionCvarChange() {
Expand Down
48 changes: 45 additions & 3 deletions src/scripts/core/zp_characters.sma
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ enum CharacterData {
Character_HumanDeathSounds,
Character_PanicSounds,
Character_ZombieAmbientSounds,
Character_ZombieDeathSounds
Character_ZombieDeathSounds,
Character_IsSelectable
}

new gmsgClCorpse;
Expand All @@ -36,6 +37,7 @@ new g_szCharacterDir[MAX_RESOURCE_PATH_LENGTH];

new Array:g_rgCharactersData[CharacterData];
new Trie:g_iCharactersMap;
new Array:g_iSelectableCharacters;
new g_iCharacterCount = 0;

new g_iPlayerCharacter[MAX_PLAYERS + 1] = { -1, ... };
Expand Down Expand Up @@ -68,10 +70,25 @@ public plugin_init() {
g_iCwSwipeHandler = CW_GetHandler(ZP_WEAPON_SWIPE);
}

public plugin_natives() {
register_native("ZP_Player_SetCharacter", "Native_SetCharacter");
}

public plugin_end() {
DestroyCharactersStore();
}

/*--------------------------------[ Natives ]--------------------------------*/

public bool:Native_SetCharacter(iPluginId, iArgc) {
new pPlayer = get_param(1);

new szCharacter[32];
get_string(2, szCharacter, charsmax(szCharacter));

return SetCharacter(pPlayer, szCharacter);
}

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

public client_connect(pPlayer) {
Expand Down Expand Up @@ -148,6 +165,17 @@ public Task_Ambient(iTaskId) {

/*--------------------------------[ Methods ]--------------------------------*/

bool:SetCharacter(pPlayer, const szCharacter[]) {
new iCharacter;
if (!TrieGetCell(g_iCharactersMap, szCharacter, iCharacter)) {
return false;
}

g_iPlayerCharacter[pPlayer] = iCharacter;

return true;
}

UpdatePlayerModel(pPlayer) {
new iCharacter = g_iPlayerCharacter[pPlayer];

Expand All @@ -174,12 +202,13 @@ UpdatePlayerCharacter(pPlayer, bool:bOverride = false) {
get_user_info(pPlayer, CHARACTER_KEY, szCharacter, charsmax(szCharacter));

new iCharacter;
if (!TrieGetCell(g_iCharactersMap, szCharacter, iCharacter)) {
if (!TrieGetCell(g_iCharactersMap, szCharacter, iCharacter)
|| !ArrayGetCell(Array:g_rgCharactersData[Character_IsSelectable], iCharacter)) {
if (!bOverride) {
return;
}

iCharacter = random(g_iCharacterCount);
iCharacter = ArrayGetCell(g_iSelectableCharacters, random(ArraySize(g_iSelectableCharacters)));
}

g_iPlayerCharacter[pPlayer] = iCharacter;
Expand Down Expand Up @@ -219,6 +248,8 @@ CreateCharacter() {
CrateCharacterSoundsData(iCharacter, Character_ZombieAmbientSounds);
CrateCharacterSoundsData(iCharacter, Character_ZombieDeathSounds);

ArraySetCell(Array:g_rgCharactersData[Character_IsSelectable], iCharacter, true);

g_iCharacterCount++;

return iCharacter;
Expand Down Expand Up @@ -289,6 +320,14 @@ LoadCharacter(const szName[]) {
LoadCharacterSoundsData(iCharacter, iSoundsDoc, "zombie.ambient", Character_ZombieAmbientSounds);
LoadCharacterSoundsData(iCharacter, iSoundsDoc, "zombie.death", Character_ZombieDeathSounds);

if (json_object_has_value(iDoc, "selectable")) {
ArraySetCell(Array:g_rgCharactersData[Character_IsSelectable], iCharacter, json_object_get_bool(iDoc, "selectable"));
}

if (ArrayGetCell(Array:g_rgCharactersData[Character_IsSelectable], iCharacter)) {
ArrayPushCell(g_iSelectableCharacters, iCharacter);
}

return iCharacter;
}

Expand All @@ -315,6 +354,7 @@ LoadCharacterSoundsData(iCharacter, JSON:iSoundDoc, const szKey[], CharacterData

InitializeCharactersStore() {
g_iCharactersMap = TrieCreate();
g_iSelectableCharacters = ArrayCreate(_, RESERVED_CHARACTER_COUNT);

g_rgCharactersData[Character_HumanModel] = ArrayCreate(MAX_RESOURCE_PATH_LENGTH, RESERVED_CHARACTER_COUNT);
g_rgCharactersData[Character_ZombieModel] = ArrayCreate(MAX_RESOURCE_PATH_LENGTH, RESERVED_CHARACTER_COUNT);
Expand All @@ -323,6 +363,7 @@ InitializeCharactersStore() {
g_rgCharactersData[Character_PanicSounds] = ArrayCreate(_, RESERVED_CHARACTER_COUNT);
g_rgCharactersData[Character_ZombieAmbientSounds] = ArrayCreate(_, RESERVED_CHARACTER_COUNT);
g_rgCharactersData[Character_ZombieDeathSounds] = ArrayCreate(_, RESERVED_CHARACTER_COUNT);
g_rgCharactersData[Character_IsSelectable] = ArrayCreate(_, RESERVED_CHARACTER_COUNT);
}

DestroyCharactersStore() {
Expand All @@ -331,6 +372,7 @@ DestroyCharactersStore() {
}

TrieDestroy(g_iCharactersMap);
ArrayDestroy(g_iSelectableCharacters);

ArrayDestroy(Array:g_rgCharactersData[Character_HumanModel]);
ArrayDestroy(Array:g_rgCharactersData[Character_ZombieModel]);
Expand Down
31 changes: 17 additions & 14 deletions src/scripts/core/zp_flashlight.sma
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

#define TASKID_FLASHLIGHT_HUD 100

#define FLASHLIGHT_CHARGE_MAX 100.0
#define FLASHLIGHT_CHARGE_DEF FLASHLIGHT_CHARGE_MAX
#define FLASHLIGHT_MAX_BRIGHTNESS 160.0
#define FLASHLIGHT_RATE 0.025
#define FLASHLIGHT_MAX_DISTANCE 1024.0
#define FLASHLIGHT_MAX_DISTANCE 768.0
#define FLASHLIGHT_MAX_CHARGE 100.0
#define FLASHLIGHT_MIN_CHARGE 0.0
#define FLASHLIGHT_DEF_CHARGE FLASHLIGHT_MAX_CHARGE
#define FLASHLIGHT_MIN_CHARGE_TO_ACTIVATE 10.0

enum PlayerFlashlight {
Expand Down Expand Up @@ -74,7 +74,7 @@ public OnPlayerSpawn_Post(pPlayer) {
}

SetPlayerFlashlight(pPlayer, false);
g_rgPlayerFlashlight[pPlayer][PlayerFlashlight_Charge] = FLASHLIGHT_CHARGE_DEF;
g_rgPlayerFlashlight[pPlayer][PlayerFlashlight_Charge] = FLASHLIGHT_DEF_CHARGE;
set_pev(pPlayer, pev_framerate, 1.0);

return HAM_HANDLED;
Expand Down Expand Up @@ -223,17 +223,20 @@ CreatePlayerFlashlightLight(pPlayer) {
new Float:flDistance = get_distance_f(vecStart, vecEnd);
if (flDistance <= FLASHLIGHT_MAX_DISTANCE) {
// TODO: Remove this hardcoded shit
new Float:flRadius = 4.0 + (flDistance / 64.0);
new Float:flBrightness = floatmax(255.0 - flDistance / 4.0, 0.0);

new iColor[3];
for (new i = 0; i < 3; ++i) {
iColor[i] = floatround(flBrightness);
new Float:flDistanceRatio = (flDistance / FLASHLIGHT_MAX_DISTANCE);
new Float:flBrightness = FLASHLIGHT_MAX_BRIGHTNESS * (1.0 - flDistanceRatio);
if (flBrightness > 1.0) {
new iColor[3];
for (new i = 0; i < 3; ++i) {
iColor[i] = floatround(flBrightness);
}

new Float:flRadius = 4.0 + (16.0 * flDistanceRatio);
new iLifeTime = max(1, floatround(FLASHLIGHT_RATE * 10));
new iDecayRate = 10 / iLifeTime;

UTIL_Message_Dlight(vecEnd, floatround(flRadius), iColor, iLifeTime, iDecayRate);
}

new iLifeTime = max(1, floatround(FLASHLIGHT_RATE * 10));
new iDecayRate = 10 / iLifeTime;
UTIL_Message_Dlight(vecEnd, floatround(flRadius), iColor, iLifeTime, iDecayRate);
}
}

Expand Down
Loading

0 comments on commit 23dc099

Please sign in to comment.