Skip to content

Commit

Permalink
Add crit compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivory42 authored Jan 28, 2024
1 parent 1ebd9e0 commit 234a753
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions mm_attribute_caber_throw.sp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <tf2_stocks>
#include <tf2attributes>
#include <tf_custom_attributes>
//#include <stocksoup/var_strings>
#include <stocksoup/var_strings>

public Plugin MyInfo =
{
Expand Down Expand Up @@ -68,13 +68,13 @@ bool HasStat(int weapon, FCaber caber)
char stat_buffer[256];
if (!TF2CustAttr_GetString(weapon, "caber-throw", stat_buffer, sizeof(stat_buffer)))
{
return false;
//return false;
}

caber.Damage = ReadFloatVar(stat_buffer, "caber_blast_damage", 100.0);
caber.Radius = ReadFloatVar(stat_buffer, "caber_blast_radius", 176.0);
caber.DetOnImpact = view_as<bool>(ReadIntVar(stat_buffer, "caber_det_impact", 0));
caber.RegenDuration = ReadFloatVar(stat_buffer, "caber_regen_time", 20.0);
caber.RegenDuration = ;ReadFloatVar(stat_buffer, "caber_regen_time", 20.0);
caber.Speed = ReadFloatVar(stat_buffer, "caber_grenade_speed", 1600.0);

return true;
Expand Down Expand Up @@ -136,7 +136,7 @@ public void OnPlayerRunCmdPost(int clientId, int buttons)
{
if (CaberGrenade[weaponId].OnCooldown)
{
if (HudTimer[clientId].Expired())
if (CaberGrenade[weaponId].RegenDuration > 1.0 && HudTimer[clientId].Expired())
{
float timeLeft = CaberGrenade[weaponId].RegenTimer.GetTimeRemaining();
SetHudTextParams(-1.0, 0.65, HudRefreshRate, 255, 255, 255, 255);
Expand Down Expand Up @@ -165,7 +165,7 @@ public void OnPlayerRunCmdPost(int clientId, int buttons)
}
}
}

//int index = 31;
void ThrowCaber(FClient client, int weaponId, FCaber caber)
{
caber.OnCooldown = true;
Expand Down Expand Up @@ -219,17 +219,46 @@ void ThrowCaber(FClient client, int weaponId, FCaber caber)

ThrownCaber[grenade.Get()] = true;

SetProjectileProperties(UBaseProjectile(grenade), caber);
bool crit = ClientHasCrits(client);

SetProjectileProperties(UBaseProjectile(grenade), caber, crit);
int iclient = client.Get();

SetViewmodelAnimation(iclient, 33);
// 32,33,35,55 throw-ish
// PrintToChatAll("Index was %i", index);
// index++;
// TE_Start("PlayerAnimEvent");
// TE_WriteEnt("m_hPlayer", client);
// TE_WriteNum("m_iEvent", 2);
// TE_SendToAll();
}

void SetProjectileProperties(UBaseProjectile grenade, FCaber caber)
bool ClientHasCrits(FClient client)
{
if (client.InCondition(TFCond_CritCanteen) || client.InCondition(TFCond_HalloweenCritCandy) || client.InCondition(TFCond_Kritzkrieged) ||
client.InCondition(TFCond_CritOnKill) || client.InCondition(TFCond_CritOnFirstBlood))
return true;

return false;
}

void SetViewmodelAnimation(int client, int sequence)
{
int ent = GetEntPropEnt(client, Prop_Send, "m_hViewModel");
if (!IsValidEdict(ent)) return;
SetEntProp(ent, Prop_Send, "m_nSequence", sequence);
// SetEntPropFloat(ent, Prop_Send, "m_flPlaybackRate", 0.5);
}
void SetProjectileProperties(UBaseProjectile grenade, FCaber caber, bool crit)
{
// If invalid, stop here
if (!grenade.Valid())
return;

// Set our properties for the newly spawned projectile
grenade.Damage = caber.Damage;
grenade.Critical = crit;

if (caber.DetOnImpact) // Pipes need m_flFullDamage set for impact damage
SetFullDamage(grenade, caber.Damage);
Expand All @@ -250,4 +279,4 @@ void SetProjectileLauncher(FObject entity, FObject child)
{
child.SetPropEnt(Prop_Send, "m_hOriginalLauncher", entity);
child.SetPropEnt(Prop_Send, "m_hLauncher", entity);
}
}

0 comments on commit 234a753

Please sign in to comment.