Skip to content

Commit

Permalink
Fixed Various Issues [M]
Browse files Browse the repository at this point in the history
- Fixed plugin reload softlock from Waiting for Players
- Fixed overriding custom set mp_waitingforplayers_time
- Fixed Mad Milk description
- Closes #50
- Closes #51
- Closes #52
- Closes #53
- Closes #54
  • Loading branch information
Batfoxkid committed May 14, 2023
1 parent e27dee0 commit f58268b
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 62 deletions.
11 changes: 1 addition & 10 deletions addons/sourcemod/scripting/ff2r_default_abilities.sp
Original file line number Diff line number Diff line change
Expand Up @@ -770,16 +770,7 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
{
Address address = TF2Attrib_GetByDefIndex(client, 252);
if(address == Address_Null || TF2Attrib_GetValue(address) == 0.0)
{
if(AnchorLastAttrib[client] != 1.0)
{
TF2Attrib_SetByDefIndex(client, 252, AnchorLastAttrib[client]);
}
else if(address != Address_Null)
{
TF2Attrib_RemoveByDefIndex(client, 252);
}
}
TF2Attrib_SetByDefIndex(client, 252, AnchorLastAttrib[client]);

AnchorLastAttrib[client] = -69.42;
}
Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/ff2r_menu_abilities.sp
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,11 @@ public void ShowMenu(int target, int client, BossData boss, AbilityData ability,

if(maximum > 0.0)
{
Format(buffer1, sizeof(buffer1), "%s%d / %d %s\n", buffer1, amount, maximum, buffer2);
Format(buffer1, sizeof(buffer1), "%s%d / %d %s\n", buffer1, RoundToFloor(amount), RoundToFloor(maximum), buffer2);
}
else
{
Format(buffer1, sizeof(buffer1), "%s%d %s\n", buffer1, amount, buffer2);
Format(buffer1, sizeof(buffer1), "%s%d %s\n", buffer1, RoundToFloor(amount), buffer2);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/freak_fortress_2.sp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ public void OnPluginEnd()
ConVar_Disable();
Database_PluginEnd();
DHook_PluginEnd();
Gamemode_PluginEnd();
Music_PlaySongToAll();
}

Expand Down
26 changes: 13 additions & 13 deletions addons/sourcemod/scripting/freak_fortress_2/attributes.sp
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,22 @@ bool Attributes_OnBackstabBoss(int attacker, int victim, float &damage, int weap

if(Attributes_FindOnWeapon(attacker, weapon, 217)) // sanguisuge
{
int maxoverheal = TF2U_GetMaxOverheal(attacker); // 250% overheal (from 200% overheal)
int maxoverheal = TF2U_GetMaxOverheal(attacker) * 2; // 250% overheal (from 200% overheal)
int health = GetClientHealth(attacker);
if(health < maxoverheal * 2)
if(health < maxoverheal)
{
SetEntityHealth(attacker, health + maxoverheal);
ApplySelfHealEvent(attacker, maxoverheal);
}

if(TF2_IsPlayerInCondition(attacker, TFCond_OnFire))
TF2_RemoveCondition(attacker, TFCond_OnFire);
SetEntityHealth(attacker, maxoverheal);
ApplySelfHealEvent(attacker, maxoverheal - health);

if(TF2_IsPlayerInCondition(attacker, TFCond_OnFire))
TF2_RemoveCondition(attacker, TFCond_OnFire);

if(TF2_IsPlayerInCondition(attacker, TFCond_Bleeding))
TF2_RemoveCondition(attacker, TFCond_Bleeding);
if(TF2_IsPlayerInCondition(attacker, TFCond_Bleeding))
TF2_RemoveCondition(attacker, TFCond_Bleeding);

if(TF2_IsPlayerInCondition(attacker, TFCond_Plague))
TF2_RemoveCondition(attacker, TFCond_Plague);
if(TF2_IsPlayerInCondition(attacker, TFCond_Plague))
TF2_RemoveCondition(attacker, TFCond_Plague);
}
}

float value = Attributes_FindOnPlayer(attacker, 296); // sapper kills collect crits
Expand Down Expand Up @@ -744,4 +744,4 @@ public Action Attributes_BoostDrainStack(Handle timer, DataPack pack)
return Plugin_Continue;
}
return Plugin_Stop;
}
}
42 changes: 28 additions & 14 deletions addons/sourcemod/scripting/freak_fortress_2/convars.sp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,19 @@ static void ConVar_Add(const char[] name, const char[] value, bool enforce = tru
if(CvarHooked)
{
info.cvar.GetString(info.defaul, sizeof(info.defaul));
info.cvar.SetString(info.value);

bool setValue = true;
if(!info.enforce)
{
char buffer[sizeof(info.defaul)];
info.cvar.GetDefault(buffer, sizeof(buffer));
if(!StrEqual(buffer, info.defaul))
setValue = false;
}

if(setValue)
info.cvar.SetString(info.value);

info.cvar.AddChangeHook(ConVar_OnChanged);
}

Expand Down Expand Up @@ -210,7 +222,18 @@ void ConVar_Enable()
info.cvar.GetString(info.defaul, sizeof(info.defaul));
CvarList.SetArray(i, info);

info.cvar.SetString(info.value);
bool setValue = true;
if(!info.enforce)
{
char buffer[sizeof(info.defaul)];
info.cvar.GetDefault(buffer, sizeof(buffer));
if(!StrEqual(buffer, info.defaul))
setValue = false;
}

if(setValue)
info.cvar.SetString(info.value);

info.cvar.AddChangeHook(ConVar_OnChanged);
}

Expand Down Expand Up @@ -248,20 +271,11 @@ public void ConVar_OnChanged(ConVar cvar, const char[] oldValue, const char[] ne

if(!StrEqual(info.value, newValue))
{
strcopy(info.defaul, sizeof(info.defaul), newValue);
CvarList.SetArray(index, info);

if(info.enforce)
{
strcopy(info.defaul, sizeof(info.defaul), newValue);
CvarList.SetArray(index, info);
info.cvar.SetString(info.value);
}
else
{
char buffer[64];
cvar.GetName(buffer, sizeof(buffer));
Debug("Removed ConVar %s", buffer);
info.cvar.RemoveChangeHook(ConVar_OnChanged);
CvarList.Erase(index);
}
}
}
}
11 changes: 10 additions & 1 deletion addons/sourcemod/scripting/freak_fortress_2/gamemode.sp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ void Gamemode_PluginStart()
}
}

void Gamemode_PluginEnd()
{
if(Enabled && GameRules_GetProp("m_bInWaitingForPlayers", 1))
{
ServerCommand("mp_waitingforplayers_cancel 1");
TF2_OnWaitingForPlayersEnd();
}
}

void Gamemode_MapStart()
{
RoundStatus = -1;
Expand Down Expand Up @@ -216,7 +225,7 @@ void Gamemode_RoundSetup()

public void TF2_OnWaitingForPlayersStart()
{
if(Enabled)
if(Enabled && GameRules_GetProp("m_bInWaitingForPlayers", 1)) // Yes, m_bInWaitingForPlayers is needed here
{
Waiting = false;
Cvar[Tournament].BoolValue = false;
Expand Down
17 changes: 2 additions & 15 deletions addons/sourcemod/scripting/freak_fortress_2/sdkhooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ public void OnEntityCreated(int entity, const char[] classname)
{
SDKHook(entity, SDKHook_Spawn, SDKHook_TimerSpawn);
}
else if(Enabled && StrEqual(classname, "obj_attachment_sapper"))
{
SDKHook(entity, SDKHook_Spawn, SDKHook_SapperSpawn);
SDKHook(entity, SDKHook_SpawnPost, SDKHook_SapperSpawnPost);
}
else
{
DHook_EntityCreated(entity, classname);
Expand Down Expand Up @@ -361,6 +356,8 @@ public Action TF2_OnTakeDamage(int victim, int &attacker, int &inflictor, float
EmitGameSoundToAll("Player.Spy_Shield_Break", victim, _, victim, pos);

TF2_RemoveCondition(victim, TFCond_Zoomed);

damage = 0.0;
return Plugin_Handled;
}

Expand Down Expand Up @@ -551,13 +548,3 @@ public Action SDKHook_TimerSpawn(int entity)
DispatchKeyValue(entity, "auto_countdown", "0");
return Plugin_Continue;
}

public void SDKHook_SapperSpawn(int entity)
{
GameRules_SetProp("m_bPlayingMannVsMachine", true);
}

public void SDKHook_SapperSpawnPost(int entity)
{
GameRules_SetProp("m_bPlayingMannVsMachine", false);
}
12 changes: 6 additions & 6 deletions addons/sourcemod/scripting/freak_fortress_2/tf2utils.sp
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ stock bool TF2U_GetWearable(int client, int &entity, int &index)
stock int TF2U_GetMaxOverheal(int client)
{
if(Client(client).IsBoss)
return Client(client).MaxHealth * Client(client).MaxLives;
return Client(client).MaxHealth * (1 + Client(client).MaxLives - Client(client).Lives);

// 100% overheal
// 75% overheal from 50%
#if defined __nosoop_tf2_utils_included
if(Loaded)
return TF2Util_GetPlayerMaxHealthBoost(client, true, true);
return RoundToFloor(TF2Util_GetPlayerMaxHealthBoost(client, true, true) / 4.285714) * 5;
#endif

int maxhealth = SDKCall_GetMaxHealth(client);
float maxoverheal = float(SDKCall_GetMaxHealth(client)) * 0.75;
float maxoverheal = float(maxhealth) * 0.75;
maxoverheal *= Attributes_FindOnPlayer(client, 800, true, 1.0);
maxoverheal *= Attributes_FindOnWeapon(client, GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"), 853, true, 1.0);
return maxhealth + (RoundFloat(maxoverheal / 5.0) * 5);
return maxhealth + (RoundToFloor(maxoverheal / 5.0) * 5);
}

void TF2U_EquipPlayerWearable(int client, int entity)
Expand All @@ -128,4 +128,4 @@ void TF2U_EquipPlayerWearable(int client, int entity)
{
SDKCall_EquipWearable(client, entity);
}
}
}
2 changes: 1 addition & 1 deletion addons/sourcemod/translations/ff2_rewrite.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@
"milk limit DISPLAY ONLY"
{
"#format" "{1:s},{2:s},{3:s},{4:s}"
"en" "Healing is limited to {4} health when applied to a boss"
"en" "Milk effect only lasts {4} seconds when applied to a boss"
}
"hit stale DISPLAY ONLY"
{
Expand Down

0 comments on commit f58268b

Please sign in to comment.