Skip to content

Commit

Permalink
carbine nerf, added more stuff, modified config reader, nerf heavy da…
Browse files Browse the repository at this point in the history
…mage
  • Loading branch information
higps committed Mar 16, 2024
1 parent 10a52fb commit c74ff89
Show file tree
Hide file tree
Showing 15 changed files with 411 additions and 36 deletions.
194 changes: 194 additions & 0 deletions ability_paid_tank_stack_popper_ability.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
#pragma semicolon 1
#include <tf2_stocks>
#include <berobot_constants>
#include <berobot>
#include <sourcemod>
#include <tf2>


#define PLUGIN_VERSION "1.0"
#define ROBOT_NAME "Stack Popper"

public Plugin:myinfo =
{
name = "Stack Popper",
author = "HiGPS | Bmod.TF",
description = "Stack Popper",
version = PLUGIN_VERSION,
url = "www.sourcemod.com"
}

public OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn);
HookEvent("post_inventory_application", Event_PlayerSpawn);

}
int mostCommonClasses[TFClass_Engineer+1] = {0};

public Action Event_PlayerSpawn(Handle event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
// RequestFrame(DelayCheck, client);

if (IsRobot(client, ROBOT_NAME))
{
// PrintToChatAll("Was robot name");
GetMostCommonEnemyClasses(client,mostCommonClasses);
}


return Plugin_Continue;
}

// void DelayCheck(int client)
// {

// }
// // Function to populate an external array with the most common enemy classes
void GetMostCommonEnemyClasses(int client, int mostCommonClasses[TFClass_Engineer+1])
{
TFTeam team = GetClientTeam(client);
TFTeam enemyTeam = (team == TFTeam_Red) ? TFTeam_Blue : TFTeam_Red;
int classCounts[TFClass_Engineer+1] = {0}; // Initialize all counts to 0

// Clear the mostCommonClasses array
for (int i = TFClass_Unknown; i <= TFClass_Engineer; i++)
{
mostCommonClasses[i] = 0;
}
for(int i = 1; i <= MaxClients+1; i++)
{
if(IsValidClient(i) && GetClientTeam(i) == enemyTeam)
{
TFClassType playerClass = TF2_GetPlayerClass(i);
classCounts[playerClass]++;
PrintToChatAll("Player class count: %i for class: %i", classCounts[playerClass],playerClass);
}
}

// Find the highest class count
int maxCount = 0;
for (int i = TFClass_Scout; i <= TFClass_Engineer; i++)
{
if (classCounts[i] > maxCount)
{
maxCount = classCounts[i];
}
}

// Mark all classes with the highest count
bool found = false;
for (int i = TFClass_Scout; i <= TFClass_Engineer; i++)
{
if (classCounts[i] == maxCount && maxCount > 0)
{
mostCommonClasses[i] = 1;
found = true;
}
}

// If no enemy or class found, set the player's class as the most common
if (!found)
{
TFClassType playerClass = TF2_GetPlayerClass(client);
if (playerClass >= TFClass_Unknown && playerClass <= TFClass_Engineer)
{
mostCommonClasses[playerClass] = 1;
}
else
{
mostCommonClasses[TFClass_Unknown] = 1;
}
}
AnnounceMostCommonClasses(client, mostCommonClasses);
}



void AnnounceMostCommonClasses(int client, int mostCommonClasses[TFClass_Engineer+1])
{
char message[256];
StrCat(message, sizeof(message), "Stats boosted to destroy:\n");

bool first = true; // Track if we're adding the first class to the message

// TF2_RemoveCondition(client, TFCond_UberBulletResist);
// TF2_RemoveCondition(client, TFCond_UberBlastResist);
// TF2_RemoveCondition(client, TFCond_UberFireResist);
for (int i = TFClass_Unknown; i <= TFClass_Engineer; i++)
{
if (mostCommonClasses[i] == 1)
{
// Append class names to the message
switch(i)
{
case TFClass_Scout:
{
TF2_AddCondition(client, TFCond_UberBulletResist);
StrCat(message, sizeof(message), first ? "Scouts\n" : "Scouts\n");

}
case TFClass_Sniper:
{
TF2_AddCondition(client, TFCond_UberBulletResist);
StrCat(message, sizeof(message), first ? "Snipers\n" : "Snipers\n");

}
case TFClass_Soldier:
{
TF2_AddCondition(client, TFCond_UberBlastResist);
StrCat(message, sizeof(message), first ? "Soldiers\n" : "Soldiers\n");
}

case TFClass_DemoMan:
{
TF2_AddCondition(client, TFCond_UberBlastResist);
StrCat(message, sizeof(message), first ? "Demomen\n" : "Demomen\n");

}
case TFClass_Medic:
{
TF2_AddCondition(client, TFCond_UberBulletResist);
StrCat(message, sizeof(message), first ? "Medics\n" : "Medics\n");

}

case TFClass_Heavy:
{
TF2_AddCondition(client, TFCond_UberBulletResist);
StrCat(message, sizeof(message), first ? "Heavies\n" : "Heavies\n");

}
case TFClass_Pyro:
{
TF2_AddCondition(client, TFCond_UberFireResist);
StrCat(message, sizeof(message), first ? "Pyros\n" : "Pyros\n");


}
case TFClass_Spy:
{

TF2_AddCondition(client, TFCond_UberBulletResist);
StrCat(message, sizeof(message), first ? "Spies\n" : "Spies\n");
}
case TFClass_Engineer:
{

TF2_AddCondition(client, TFCond_UberBulletResist);
// TF2_AddCondition(client, TFCond_CritCanteen,-1.0);
StrCat(message, sizeof(message), first ? "Engineers\n" : "Engineers\n");
}
}
if (first) first = false;
}
}

if (first) // If no class was marked as most common
{
StrCat(message, sizeof(message), "Error not a number");
}

PrintCenterText(client, message);
}
10 changes: 8 additions & 2 deletions berobot_config_reader.sp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ MakeRobotFrame(client)



if (i_hConfig.JumpToKey("weapons"))
if (i_hConfig.JumpToKey("weapons"))
{

if (i_hConfig.GotoFirstSubKey())
Expand Down Expand Up @@ -733,6 +733,12 @@ MakeRobotFrame(client)
i_hConfig.GoBack();
}

int health = 1000;
if(i_hConfig.GetNum("health"))
{
health = i_hConfig.GetNum("health", health);
}

int bonus_hp = 0;
if(i_hConfig.GetNum("health_bonus_per_player"))
{
Expand All @@ -741,7 +747,7 @@ MakeRobotFrame(client)
bonus_hp *= GetCurrentHumanCount();
}

RoboSetHealth(client, iRobot_class, robot.health + bonus_hp);
RoboSetHealth(client, iRobot_class, health + bonus_hp);

// Reading player attributes and setting them.
if (i_hConfig.JumpToKey("player_attributes"))
Expand Down
77 changes: 59 additions & 18 deletions berobot_dmg_handler.sp
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ float g_protection_rune_duration = 1.0;

float g_electric_rage_reduction = 5.0;

float g_HumanMiniGunDmGPenalty = 0.8;
// float g_HumanMiniGunDmGPenalty = 0.55;

float g_wrap_duration = 5.0;

float g_crit_a_cola_duration = 2.0;

#define SPY_ROBOT_STAB "weapons/saxxy_impact_gen_01.wav"
// #define SPY_ROBOT_STAB "weapons/saxxy_impact_gen_01.wav"
// #define SPY_ROBOT_STAB ")mvm/giant_demoman/giant_demoman_grenade_shoot.wav"

int ParticleStorage[MAXPLAYERS + 1] = {0, ...};
Expand Down Expand Up @@ -147,7 +147,7 @@ public Action Event_PlayerDeath(Event event, char[] name, bool dontBroadcast){

public void OnMapStart()
{
PrecacheSound(SPY_ROBOT_STAB);
// PrecacheSound(SPY_ROBOT_STAB);
}

public Action Command_ToggleMMHumanDisplay(int client, int args)
Expand Down Expand Up @@ -939,22 +939,22 @@ public Action TF2_OnTakeDamageModifyRules(int victim, int &attacker, int &inflic

}
}
/*Damage code for Heavy*/
if (iClassAttacker == TFClass_Heavy)
{
int iWeapon = GetPlayerWeaponSlot(attacker, TFWeaponSlot_Primary);
// /*Damage code for Heavy*/
// if (iClassAttacker == TFClass_Heavy)
// {
// int iWeapon = GetPlayerWeaponSlot(attacker, TFWeaponSlot_Primary);

if (weapon == iWeapon)
{
if (g_cv_bDebugMode)PrintToChatAll("Damage before change %f", damage);
damage *= g_HumanMiniGunDmGPenalty;
if (g_cv_bDebugMode)PrintToChatAll("Set damage to %f", damage);
return Plugin_Changed;
// if (weapon == iWeapon)
// {
// if (g_cv_bDebugMode)PrintToChatAll("Damage before change %f", damage);
// damage *= g_HumanMiniGunDmGPenalty;
// if (g_cv_bDebugMode)PrintToChatAll("Set damage to %f", damage);
// return Plugin_Changed;

}
// }


}
// }

if (IsElectric(weapon))
{
Expand Down Expand Up @@ -1352,12 +1352,18 @@ public Action Event_post_inventory_application(Event event, const char[] name, b

if (TF2_GetPlayerClass(client) == TFClass_Heavy)
{
Format(chat_display, sizeof(chat_display), "%s\n{teamcolor}Your minigun deals {orange}-%0.00f %%%% damage{teamcolor} vs robots",chat_display, LessIsMore(g_HumanMiniGunDmGPenalty));
if (IsAnyMinigun(Weapon1))
{
stat1 = 0.6;
TF2Attrib_SetByName(Weapon1, "dmg penalty vs players", stat1);
Format(chat_display, sizeof(chat_display), "%s\n{teamcolor}Minigun deal {orange}-%0.00f %%%% damage{teamcolor} vs robots",chat_display, LessIsMore(stat1));
}


if (IsNatascha(Weapon1))
{
stat1 = 3.0;
stat2 = 1.2;
stat2 = 1.3;
TF2Attrib_SetByName(Weapon1, "speed_boost_on_hit", stat1);
TF2Attrib_SetByName(Weapon1, "aiming movespeed increased", stat2);

Expand All @@ -1366,7 +1372,7 @@ public Action Event_post_inventory_application(Event event, const char[] name, b

if (IsTomiSlav(Weapon1))
{
stat1 = 0.4;
stat1 = 0.25;
stat2 = 1.0;

TF2Attrib_SetByName(Weapon1, "minigun spinup time decreased", stat1);
Expand Down Expand Up @@ -1452,6 +1458,11 @@ public Action Event_post_inventory_application(Event event, const char[] name, b

}

if (IsHeatmaker(Weapon1))
{
Format(chat_display, sizeof(chat_display), "%s\n{teamcolor}Hitman's Heatmaker: {orange}Gain focus on damage",chat_display);
}

if (IsBazaar(Weapon1))
{
Format(chat_display, sizeof(chat_display), "%s\n{teamcolor}Bazaar Bargin: {orange}On Headshot: +1 head{teamcolor}, {orange}On Bodyshot: -2 heads{teamcolor}",chat_display);
Expand Down Expand Up @@ -2146,6 +2157,21 @@ bool IsClassic(int weapon)
return false;
}

bool IsMachina(int weapon)
{
if (weapon == -1 && weapon <= MaxClients) return false;

switch(GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"))
{

case 1098:
{
return true;
}
}
return false;
}

bool IsEyelander(int weapon)
{
if (weapon == -1 && weapon <= MaxClients) return false;
Expand Down Expand Up @@ -2922,6 +2948,21 @@ bool IsBackScratcher(int weapon)
return false;
}

bool IsAnyMinigun(int weapon)
{
if (weapon == -1 && weapon <= MaxClients) return false;

switch(GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"))
{

case 15, 202, 41, 298, 312, 424, 654, 793, 802, 811, 832, 850, 882, 891, 900, 909, 958, 967, 15004, 15020, 15026, 15031, 15040, 15055, 15086, 15087, 15088, 15098, 15099, 15123, 15124, 15125, 15147:
{
return true;
}
}
return false;
}

bool IsNatascha(int weapon)
{
if (weapon == -1 && weapon <= MaxClients) return false;
Expand Down
Loading

0 comments on commit c74ff89

Please sign in to comment.