Skip to content

Commit

Permalink
Hunting Rifle (#684)
Browse files Browse the repository at this point in the history
* Skader

* Star Shooter update

yay

* Add star shooter pap description

* new weapon part 1

basic stuff only

* small fix

:(

* New fractued ark pap

steam happy

* fix

* tiny change

* Hunting rifle weapon

* tiny bug fix

* fix
  • Loading branch information
cookie422 authored Oct 16, 2024
1 parent c43dd9b commit de9def5
Show file tree
Hide file tree
Showing 5 changed files with 347 additions and 1 deletion.
72 changes: 72 additions & 0 deletions addons/sourcemod/configs/zombie_riot/weapons.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2674,6 +2674,78 @@
"pap_2_lag_comp_dont_move_building" "0"
"pap_2_weapon_archetype" "2"
}
"Hunting Rifle"
{
"author" "Lucella"
"tags" "Burst"
"cost" "3500"
"desc" "Hunting Rifle desc"
"classname" "tf_weapon_charged_smg"
"index" "751"
"filter" "medieval;iberia"
"author" "Lucella"

"attributes" "821 ; 0 ; 303 ; -1 ; 6 ; 5.0 ; 2 ; 80"

"ammo" "16" //sniper ammo
"no_clip" "1"
"model" "models/weapons/c_models/c_tfc_sniperrifle/c_tfc_sniperrifle.mdl"
"func_attack" "Hunting_Rifle_Attack_Main"
"int_ability_onequip" "125"

"tier" "2"
"rarity" "4"
"weapon_archetype" "5" //single pellet
"lag_comp" "1"
"lag_comp_collision" "0"
"lag_comp_extend_boundingbox" "1"
"lag_comp_dont_move_building" "0"


"pap_1_cost" "7500"
"pap_1_desc" "Hunting Rifle Pap 1 desc"
"pap_1_classname" "tf_weapon_charged_smg"
"pap_1_index" "751"

"pap_1_attributes" "821 ; 0 ; 303 ; -1 ; 6 ; 5.0 ; 2 ; 140"

"pap_1_ammo" "16" //sniper ammo
"pap_1_no_clip" "1"
"pap_1_model" "models/workshop/weapons/c_models/c_ttg_max_gun/c_ttg_max_gun.mdl"
"pap_1_func_attack" "Hunting_Rifle_Attack_Main_PAP1"
"pap_1_func_attack2" "Hunting_Rifle_Ability"
"pap_1_int_ability_onequip" "125"

"pap_1_tier" "2"
"pap_1_rarity" "4"
"pap_1_weapon_archetype" "5" //single pellet
"pap_1_lag_comp" "1"
"pap_1_lag_comp_collision" "0"
"pap_1_lag_comp_extend_boundingbox" "1"
"pap_1_lag_comp_dont_move_building" "0"

"pap_2_cost" "12000"
"pap_2_desc" "Hunting Rifle Pap 2 desc"
"pap_2_classname" "tf_weapon_charged_smg"
"pap_2_index" "751"

"pap_2_attributes" "821 ; 0 ; 303 ; -1 ; 6 ; 5.0 ; 2 ; 220"

"pap_2_ammo" "16" //sniper ammo
"pap_2_no_clip" "1"
"pap_2_model" "models/workshop/weapons/c_models/c_ttg_max_gun/c_ttg_max_gun.mdl"
"pap_2_func_attack" "Hunting_Rifle_Attack_Main_PAP2"
"pap_2_func_attack2" "Hunting_Rifle_Ability2"
"pap_2_int_ability_onequip" "125"

"pap_2_tier" "4"
"pap_2_rarity" "3"
"pap_2_lag_comp" "1"
"pap_2_lag_comp_comp_collision" "0"
"pap_2_lag_comp_extend_boundingbox" "1"
"pap_2_lag_comp_dont_move_building" "0"
"pap_2_weapon_archetype" "5" //single pellet
}
"IEM Launcher"
{
"tags" "AOE;Primary"
Expand Down
259 changes: 259 additions & 0 deletions addons/sourcemod/scripting/zombie_riot/custom/weapon_hunting_rifle.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
#pragma semicolon 1
#pragma newdecls required

static float Timetillnextbullet[MAXTF2PLAYERS];
static int IsAbilityActive[MAXTF2PLAYERS];
static int BulletsLoaded[MAXTF2PLAYERS]={5, ...};
static int CurrentMaxBullets[MAXTF2PLAYERS];
static int IsCurrentlyReloading[MAXTF2PLAYERS];
static float AmmoHudDelay[MAXPLAYERS+1]={0.0, ...};

Handle Timer_Hunting_Rifle_Management[MAXPLAYERS + 1] = { null, ... };

public void Hunting_Rifle_Attack_Main(int client, int weapon, bool crit, int slot) // stuff that happens when you press m1
{
Enable_Hunting_Rifle(client, weapon);
CurrentMaxBullets[client] = 5;
BulletsLoaded[client] -= 1;
ClientCommand(client, "playgamesound weapons/enforcer_shoot.wav");
if (IsAbilityActive[client] == 1)
{
Timetillnextbullet[client] = GetGameTime() + 1.0; // reset the reload cooldown if you attack >:3
}
else
{
Timetillnextbullet[client] = GetGameTime() + 1.25; // reset the reload cooldown if you attack >:3
}
}

public void Hunting_Rifle_Attack_Main_PAP1(int client, int weapon, bool crit, int slot) // stuff that happens when you press m1
{
Enable_Hunting_Rifle(client, weapon);
CurrentMaxBullets[client] = 7;
BulletsLoaded[client] -= 1;
ClientCommand(client, "playgamesound weapons/enforcer_shoot.wav");
if(IsAbilityActive[client] == 1)
{
Timetillnextbullet[client] = GetGameTime() + 1.0; // reset the reload cooldown if you attack >:3
}
else
{
Timetillnextbullet[client] = GetGameTime() + 1.25; // reset the reload cooldown if you attack >:3
}
}

public void Hunting_Rifle_Attack_Main_PAP2(int client, int weapon, bool crit, int slot) // stuff that happens when you press m1
{
Enable_Hunting_Rifle(client, weapon);
CurrentMaxBullets[client] = 9;
BulletsLoaded[client] -= 1;
ClientCommand(client, "playgamesound weapons/enforcer_shoot.wav");
if(IsAbilityActive[client] == 1)
{
Timetillnextbullet[client] = GetGameTime() + 1.0; // reset the reload cooldown if you attack >:3
}
else
{
Timetillnextbullet[client] = GetGameTime() + 1.25; // reset the reload cooldown if you attack >:3
}
}

public void Hunting_Rifle_Ability(int client, int weapon, bool crit, int slot) // ability stuff here
{
if (Ability_Check_Cooldown(client, slot) < 0.0)
{
Rogue_OnAbilityUse(weapon);
Ability_Apply_Cooldown(client, slot, 30.0);
ClientCommand(client, "playgamesound weapons/recon_ping.wav");
ApplyTempAttrib(weapon, 2, 3.0, 10.0); // 200% dmg buff while ability is activated
IsAbilityActive[client] = 1; // 1 for enabled, 0 for disabled
//BulletsLoaded[client] = CurrentMaxBullets[client]; // insantly fills out clip
CreateTimer(10.0, Disable_Hunting_Rifle_Ability, client, TIMER_FLAG_NO_MAPCHANGE);
}
else
{
float Ability_CD = Ability_Check_Cooldown(client, slot);

if (Ability_CD <= 0.0)
Ability_CD = 0.0;

ClientCommand(client, "playgamesound items/medshotno1.wav");
SetDefaultHudPosition(client);
SetGlobalTransTarget(client);
ShowSyncHudText(client, SyncHud_Notifaction, "%t", "Ability has cooldown", Ability_CD);
}
}
public void Hunting_Rifle_Ability2(int client, int weapon, bool crit, int slot) // ability stuff here
{
if (Ability_Check_Cooldown(client, slot) < 0.0)
{
Rogue_OnAbilityUse(weapon);
Ability_Apply_Cooldown(client, slot, 30.0);
ClientCommand(client, "playgamesound weapons/recon_ping.wav");
ApplyTempAttrib(weapon, 2, 3.0, 15.0); // 200% dmg buff while ability is activated
IsAbilityActive[client] = 1; // 1 for enabled, 0 for disabled
//BulletsLoaded[client] = CurrentMaxBullets[client]; // insantly fills out clip
CreateTimer(15.0, Disable_Hunting_Rifle_Ability, client, TIMER_FLAG_NO_MAPCHANGE);
}
else
{
float Ability_CD = Ability_Check_Cooldown(client, slot);

if (Ability_CD <= 0.0)
Ability_CD = 0.0;

ClientCommand(client, "playgamesound items/medshotno1.wav");
SetDefaultHudPosition(client);
SetGlobalTransTarget(client);
ShowSyncHudText(client, SyncHud_Notifaction, "%t", "Ability has cooldown", Ability_CD);
}
}

public Action Disable_Hunting_Rifle_Ability(Handle timer, int client)
{
IsAbilityActive[client] = 0; // 1 for enabled, 0 for disabled
return Plugin_Handled;
}

public void Enable_Hunting_Rifle(int client, int weapon) // gets triggered each time you fire the weapon
{
if (Timer_Hunting_Rifle_Management[client] != null)
{
// This timer already exists.
if (i_CustomWeaponEquipLogic[weapon] == WEAPON_HUNTING_RIFLE) // 125
{
// Is the weapon it again?
// Yes?
delete Timer_Hunting_Rifle_Management[client];
Timer_Hunting_Rifle_Management[client] = null;
DataPack pack;
Timer_Hunting_Rifle_Management[client] = CreateDataTimer(0.1, Timer_Management_Hunting_Rifle, pack, TIMER_REPEAT);
pack.WriteCell(client);
pack.WriteCell(EntIndexToEntRef(weapon));
}
return;
}

if (i_CustomWeaponEquipLogic[weapon] == WEAPON_HUNTING_RIFLE) // 125
{
DataPack pack;
Timer_Hunting_Rifle_Management[client] = CreateDataTimer(0.1, Timer_Management_Hunting_Rifle, pack, TIMER_REPEAT);
pack.WriteCell(client);
pack.WriteCell(EntIndexToEntRef(weapon));
}
}

public Action Timer_Management_Hunting_Rifle(Handle timer, DataPack pack) // triggers every 0.1 of a second
{
pack.Reset();
int client = pack.ReadCell();
int weapon = EntRefToEntIndex(pack.ReadCell());
int weapon_holding = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
if (!IsValidClient(client) || !IsClientInGame(client) || !IsPlayerAlive(client) || !IsValidEntity(weapon))
{
Timer_Hunting_Rifle_Management[client] = null;
return Plugin_Stop;
}
if(weapon_holding == weapon) //Only show if the weapon is actually in your hand right now.
{
HuntingRifleAmmoDisplay(client); //function to display current ammo in your gun
}
// ammo logic here, love how nicely this works :D
if (BulletsLoaded[client] < CurrentMaxBullets[client]) // if we have less bullets loaded than our max bullet amount
{
if (IsCurrentlyReloading[client] == 0) // only trigger if not currently reloading otherwise the timer will reset infinitely
{
if (IsAbilityActive[client] == 1) // makes the reload quicker if ability is activated
{
Timetillnextbullet[client] = GetGameTime() + 0.3;
IsCurrentlyReloading[client] = 1;
}
else
{
Timetillnextbullet[client] = GetGameTime() + 1.2;
IsCurrentlyReloading[client] = 1;
}
}

if (Timetillnextbullet[client] < GetGameTime())
{
BulletsLoaded[client] += 1; // add 1 ammo
IsCurrentlyReloading[client] = 0;
if(weapon_holding == weapon) //Only play if you are holding the weapon, but you can still reload while not equiped
{
ClientCommand(client, "playgamesound weapons/default_reload.wav");
}
}
}
if (BulletsLoaded[client] == 0)
{
TF2Attrib_SetByDefIndex(client, 821, 1.0); // makes the weapon unable to fire
}
else
{
TF2Attrib_SetByDefIndex(client, 821, 0.0); // makes the user to fire the weapon again
}
return Plugin_Continue;
}

void HuntingRifleAmmoDisplay(int client)
{

if(AmmoHudDelay[client] < GetGameTime())
{
AmmoHudDelay[client] = GetGameTime() + 0.5;
switch (BulletsLoaded[client]) // i am sorry for doing this but i dunno of a better way to achieve this result
{
case 0:
{
PrintHintText(client, "X");
StopSound(client, SNDCHAN_STATIC, "ui/hint.wav");
}
case 1:
{
PrintHintText(client, "I");
StopSound(client, SNDCHAN_STATIC, "ui/hint.wav");
}
case 2:
{
PrintHintText(client, "II");
StopSound(client, SNDCHAN_STATIC, "ui/hint.wav");
}
case 3:
{
PrintHintText(client, "III");
StopSound(client, SNDCHAN_STATIC, "ui/hint.wav");
}
case 4:
{
PrintHintText(client, "IIII");
StopSound(client, SNDCHAN_STATIC, "ui/hint.wav");
}
case 5:
{
PrintHintText(client, "IIIII");
StopSound(client, SNDCHAN_STATIC, "ui/hint.wav");
}
case 6:
{
PrintHintText(client, "IIIIII");
StopSound(client, SNDCHAN_STATIC, "ui/hint.wav");
}
case 7:
{
PrintHintText(client, "IIIIIII");
StopSound(client, SNDCHAN_STATIC, "ui/hint.wav");
}
case 8:
{
PrintHintText(client, "IIIIIIII");
StopSound(client, SNDCHAN_STATIC, "ui/hint.wav");
}
case 9:
{
PrintHintText(client, "IIIIIIIII");
StopSound(client, SNDCHAN_STATIC, "ui/hint.wav");
}
}
}
}
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/zombie_riot/store.sp
Original file line number Diff line number Diff line change
Expand Up @@ -5779,6 +5779,7 @@ int Store_GiveItem(int client, int index, bool &use=false, bool &found=false)
BlacksmithBrew_Enable(client, entity);
Yakuza_Enable(client, entity);
Enable_SkadiWeapon(client, entity);
Enable_Hunting_Rifle(client, entity);
}

return entity;
Expand Down
4 changes: 3 additions & 1 deletion addons/sourcemod/scripting/zombie_riot/zr_core.sp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ enum
WEAPON_YAKUZA = 121,
WEAPON_EXPLORER = 122,
WEAPON_FULLMOON = 123,
WEAPON_SKADI = 124
WEAPON_SKADI = 124,
WEAPON_HUNTING_RIFLE = 125
}

enum
Expand Down Expand Up @@ -556,6 +557,7 @@ int i_WaveHasFreeplay = 0;
#include "zombie_riot/custom/kit_blacksmith_brew.sp"
#include "zombie_riot/custom/weapon_yakuza.sp"
#include "zombie_riot/custom/weapon_skadi.sp"
#include "zombie_riot/custom/weapon_hunting_rifle.sp"

void ZR_PluginLoad()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4008,4 +4008,16 @@
{
"en" "She always wished to keep her teams safe and strong. Now, her dream is fulfilled. \n Unlock new ability: When used, gain 10% damage buff every hit that adds up(Max x2.0 dmg) and gain slight resistance"
}
"Hunting Rifle desc"
{
"en" "A hunting rifle with a small clip size, reloads slowly but each bullet packs a punch."
}
"Hunting Rifle Pap 1 desc"
{
"en" "Clip size, damage increased. \nUnlocks an ability which boosts reload speed and increases damage."
}
"Hunting Rifle Pap 2 desc"
{
"en" "Clip size, damage and ability duration increased."
}
}

0 comments on commit de9def5

Please sign in to comment.