Skip to content

Commit

Permalink
1.7.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mentrillum committed Jan 9, 2022
1 parent 08be6b2 commit 34a8cdc
Show file tree
Hide file tree
Showing 13 changed files with 444 additions and 238 deletions.
8 changes: 4 additions & 4 deletions addons/sourcemod/scripting/sf2.sp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ bool steamworks;
#include <sf2>
#pragma newdecls required

#define PLUGIN_VERSION "1.7.1.2 M"
#define PLUGIN_VERSION_DISPLAY "1.7.1.2 M"
#define PLUGIN_VERSION "1.7.1.3 M"
#define PLUGIN_VERSION_DISPLAY "1.7.1.3 M"

#define TFTeam_Spectator 1
#define TFTeam_Red 2
Expand Down Expand Up @@ -6534,7 +6534,7 @@ public Action Event_PlayerDeathPre(Event event, const char[] name, bool dB)
event.SetInt("attacker", userid);
g_hTimerChangeClientName[iTarget] = CreateTimer(0.6, Timer_RevertClientName, iTarget, TIMER_FLAG_NO_MAPCHANGE);

if(!IsClientSourceTV(iTarget))
if(IsValidClient(iTarget))
{
event.SetInt("ignore", iTarget);

Expand Down Expand Up @@ -6656,7 +6656,7 @@ public Action Event_PlayerDeathPre(Event event, const char[] name, bool dB)
event.SetInt("attacker", userid);
g_hTimerChangeClientName[iTarget] = CreateTimer(0.6, Timer_RevertClientName, iTarget, TIMER_FLAG_NO_MAPCHANGE);

if(!IsClientSourceTV(iTarget))
if(IsValidClient(iTarget))
{
event.SetInt("ignore", iTarget);

Expand Down
4 changes: 2 additions & 2 deletions addons/sourcemod/scripting/sf2/client.sp
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ public Action CH_PassFilter(int ent1,int ent2, bool &result)
SF2RoundState state = GetRoundState();
if (state == SF2RoundState_Intro || state == SF2RoundState_Outro) return Plugin_Continue;

if (MaxClients >= ent1 > 0)
if (IsValidClient(ent1))
{
if (IsClientInGhostMode(ent1))
{
result = false;
return Plugin_Changed;
}
}
if (MaxClients >= ent2 > 0)
if (IsValidClient(ent2))
{
if (IsClientInGhostMode(ent2))
{
Expand Down
21 changes: 19 additions & 2 deletions addons/sourcemod/scripting/sf2/extras/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ public void OnPluginStart()
AddTempEntHook("Entity Decal", Hook_BlockDecals);
//AddTempEntHook("TFExplosion", Hook_DebugExplosion);

g_bNBActionFactory = new NextBotActionFactory("SlenderBossAction");
g_bNBActionFactory.SetEventCallback(EventResponderType_OnStuck, CBaseNPC_OnStuck);

for (int i = 0; i < MAX_BOSSES; i++) g_pPath[i] = PathFollower(_, TraceRayDontHitAnyEntity_Pathing, Path_FilterOnlyActors);

// Get offsets.
g_offsPlayerFOV = FindSendPropInfo("CBasePlayer", "m_iFOV");
if (g_offsPlayerFOV == -1) SetFailState("Couldn't find CBasePlayer offset for m_iFOV.");
Expand Down Expand Up @@ -131,7 +134,7 @@ public void OnPluginStart()
g_cvIgnoreRedPlayerDeathSwap = CreateConVar("sf2_ignore_red_player_death_team_switch", "0", "If set to 1, RED players will not switch back to the BLU team.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
g_cvIgnoreRedPlayerDeathSwap.AddChangeHook(OnConVarChanged);

g_cvDisableBossCrushFix = CreateConVar("sf2_disable_boss_crush_fix", "0", "Enables/disables the boss crushing patch from Secret Update 4, should only be turned on if the server introduces players getting stuck in bosses.", _, true, 0.0, true, 1.0);
g_cvDisableBossCrushFix = CreateConVar("sf2_disable_boss_crush_fix", "1", "Enables/disables the boss crushing patch from Secret Update 4, should only be off if absolutely necessary.", _, true, 0.0, true, 1.0);

g_cvEnableWallHax = CreateConVar("sf2_enable_wall_hax", "0", "Enables/disables the Wall Hax special round without needing to turn on Wall Hax. This will not force the difficulty to Insane and will show player + boss outlines.", _, true, 0.0, true, 1.0);

Expand Down Expand Up @@ -191,6 +194,20 @@ public void OnPluginStart()
g_hRoundTimerSync = CreateHudSynchronizer();
g_hCookie = RegClientCookie("sf2_newcookies", "", CookieAccess_Private);

switch(g_cvDifficulty.IntValue)
{
case Difficulty_Easy: g_flRoundDifficultyModifier = DIFFICULTYMODIFIER_NORMAL;
case Difficulty_Hard: g_flRoundDifficultyModifier = DIFFICULTYMODIFIER_HARD;
case Difficulty_Insane: g_flRoundDifficultyModifier = DIFFICULTYMODIFIER_INSANE;
case Difficulty_Nightmare: g_flRoundDifficultyModifier = DIFFICULTYMODIFIER_NIGHTMARE;
case Difficulty_Apollyon:
{
if (g_bRestartSessionEnabled) g_flRoundDifficultyModifier = DIFFICULTYMODIFIER_RESTARTSESSION;
else g_flRoundDifficultyModifier = DIFFICULTYMODIFIER_APOLLYON;
}
default: g_flRoundDifficultyModifier = DIFFICULTYMODIFIER_NORMAL;
}

// Register console commands.
RegConsoleCmd("sm_sf2", Command_MainMenu);
RegConsoleCmd("sm_sl", Command_MainMenu);
Expand Down
74 changes: 48 additions & 26 deletions addons/sourcemod/scripting/sf2/npc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ static bool g_bNPCProxySpawnEffectEnabled[MAX_BOSSES];
static float g_flNPCProxySpawnEffectLifetime[MAX_BOSSES];
static float g_flNPCProxySpawnEffectZOffset[MAX_BOSSES];

NextBotActionFactory g_bNBActionFactory;

Handle hTimerMusic = null;//Planning to add a bosses array on.

int g_iBossPathingColor[MAX_BOSSES][4];
Expand Down Expand Up @@ -2411,22 +2413,27 @@ void ChangeAllSlenderModels()
}
if (NPCGetType(iNPCIndex) == SF2BossType_Chaser)
{
float flTempHitboxMins[3];
NPCChaserUpdateBossAnimation(iNPCIndex, slender, g_iSlenderState[iNPCIndex]);
if (NPCGetRaidHitbox(iNPCIndex) == 1)
{
SetEntPropVector(slender, Prop_Send, "m_vecMins", g_flSlenderDetectMins[iNPCIndex]);
SetEntPropVector(slender, Prop_Send, "m_vecMaxs", g_flSlenderDetectMaxs[iNPCIndex]);
CopyVector(g_flSlenderDetectMins[iNPCIndex], flTempHitboxMins);
flTempHitboxMins[2] = 10.0;
SetEntPropVector(g_iSlenderHitbox[iNPCIndex], Prop_Send, "m_vecMins", flTempHitboxMins);
SetEntPropVector(g_iSlenderHitbox[iNPCIndex], Prop_Send, "m_vecMaxs", g_flSlenderDetectMaxs[iNPCIndex]);

SetEntPropVector(slender, Prop_Send, "m_vecMinsPreScaled", g_flSlenderDetectMins[iNPCIndex]);
SetEntPropVector(slender, Prop_Send, "m_vecMaxsPreScaled", g_flSlenderDetectMaxs[iNPCIndex]);
SetEntPropVector(g_iSlenderHitbox[iNPCIndex], Prop_Send, "m_vecMinsPreScaled", flTempHitboxMins);
SetEntPropVector(g_iSlenderHitbox[iNPCIndex], Prop_Send, "m_vecMaxsPreScaled", g_flSlenderDetectMaxs[iNPCIndex]);
}
else if (NPCGetRaidHitbox(iNPCIndex) == 0)
{
SetEntPropVector(slender, Prop_Send, "m_vecMins", HULL_HUMAN_MINS);
SetEntPropVector(slender, Prop_Send, "m_vecMaxs", HULL_HUMAN_MAXS);
CopyVector(HULL_HUMAN_MINS, flTempHitboxMins);
flTempHitboxMins[2] = 10.0;
SetEntPropVector(g_iSlenderHitbox[iNPCIndex], Prop_Send, "m_vecMins", flTempHitboxMins);
SetEntPropVector(g_iSlenderHitbox[iNPCIndex], Prop_Send, "m_vecMaxs", HULL_HUMAN_MAXS);

SetEntPropVector(slender, Prop_Send, "m_vecMinsPreScaled", HULL_HUMAN_MINS);
SetEntPropVector(slender, Prop_Send, "m_vecMaxsPreScaled", HULL_HUMAN_MAXS);
SetEntPropVector(g_iSlenderHitbox[iNPCIndex], Prop_Send, "m_vecMinsPreScaled", flTempHitboxMins);
SetEntPropVector(g_iSlenderHitbox[iNPCIndex], Prop_Send, "m_vecMaxsPreScaled", HULL_HUMAN_MAXS);
}
}
}
Expand Down Expand Up @@ -2722,6 +2729,7 @@ void SpawnSlender(SF2NPC_BaseNPC Npc, const float pos[3])
CBaseNPC_Locomotion locomotion = npcBoss.GetLocomotion();
npcEntity.DispatchAnimEvents(npcEntity);
npcEntity.Hook_HandleAnimEvent(CBaseAnimating_HandleAnimEvent);
CBaseNPC_RemoveAllLayers(npcBoss.GetEntity());

npcEntity.Teleport(flTruePos, flVecAng);
npcEntity.SetModel(sBuffer);
Expand Down Expand Up @@ -2755,22 +2763,28 @@ void SpawnSlender(SF2NPC_BaseNPC Npc, const float pos[3])
locomotion.SetCallback(LocomotionCallback_JumpAcrossGap, JumpAcrossGapsCBase);
locomotion.SetCallback(LocomotionCallback_ClimbUpToLedge, ClimbUpCBase);

float flSlenderBoxMins[3], flSlenderBoxMaxs[3];
flSlenderBoxMins[0] = -1.0;
flSlenderBoxMins[1] = -1.0;
flSlenderBoxMaxs[0] = 1.0;
flSlenderBoxMaxs[1] = 1.0;
flSlenderBoxMaxs[2] = 1.0;
if (NPCGetRaidHitbox(iBossIndex) == 1)
{
npcEntity.SetPropVector(Prop_Send, "m_vecMins", g_flSlenderDetectMins[iBossIndex]);
npcEntity.SetPropVector(Prop_Send, "m_vecMaxs", g_flSlenderDetectMaxs[iBossIndex]);

npcEntity.SetPropVector(Prop_Send, "m_vecMinsPreScaled", g_flSlenderDetectMins[iBossIndex]);
npcEntity.SetPropVector(Prop_Send, "m_vecMaxsPreScaled", g_flSlenderDetectMaxs[iBossIndex]);
npcBoss.SetBodyMins(g_flSlenderDetectMins[iBossIndex]);
npcBoss.SetBodyMaxs(g_flSlenderDetectMaxs[iBossIndex]);
}
else if (NPCGetRaidHitbox(iBossIndex) == 0)
{
npcEntity.SetPropVector(Prop_Send, "m_vecMins", HULL_HUMAN_MINS);
npcEntity.SetPropVector(Prop_Send, "m_vecMaxs", HULL_HUMAN_MAXS);

npcEntity.SetPropVector(Prop_Send, "m_vecMinsPreScaled", HULL_HUMAN_MINS);
npcEntity.SetPropVector(Prop_Send, "m_vecMaxsPreScaled", HULL_HUMAN_MAXS);
npcBoss.SetBodyMins(HULL_HUMAN_MINS);
npcBoss.SetBodyMaxs(HULL_HUMAN_MAXS);
}

npcEntity.SetPropVector(Prop_Send, "m_vecMins", flSlenderBoxMins);
npcEntity.SetPropVector(Prop_Send, "m_vecMaxs", flSlenderBoxMaxs);

npcEntity.SetPropVector(Prop_Send, "m_vecMinsPreScaled", flSlenderBoxMins);
npcEntity.SetPropVector(Prop_Send, "m_vecMaxsPreScaled", flSlenderBoxMaxs);

if (NPCGetModelSkinMax(iBossIndex) > 0)
{
Expand All @@ -2794,7 +2808,7 @@ void SpawnSlender(SF2NPC_BaseNPC Npc, const float pos[3])
}

g_hSDKUpdateTransmitState.HookEntity(Hook_Pre, npcEntity.iEnt, Hook_BossUpdateTransmitState);
npcEntity.AddFlag(FL_NPC);
SetEntityFlags(npcEntity.iEnt, FL_NPC);
SetEntityTransmitState(npcEntity.iEnt, FL_EDICT_ALWAYS);

//if (!g_cvDisableBossCrushFix.BoolValue) SetEntData(iBoss, FindSendPropInfo("CTFBaseBoss", "m_lastHealthPercentage") + 28, false, 4, true);
Expand Down Expand Up @@ -2842,23 +2856,25 @@ void SpawnSlender(SF2NPC_BaseNPC Npc, const float pos[3])
float flTempHitboxMins[3];
g_iSlenderHitbox[iBossIndex] = CreateEntityByName("base_boss");
Address aLocomotion = SF2_GetLocomotionInterface(g_iSlenderHitbox[iBossIndex]);

SetEntityModel(g_iSlenderHitbox[iBossIndex], sBuffer);
TeleportEntity(g_iSlenderHitbox[iBossIndex], flTruePos, flVecAng, NULL_VECTOR);
DispatchKeyValue(g_iSlenderHitbox[iBossIndex],"TeamNum","1");
DispatchSpawn(g_iSlenderHitbox[iBossIndex]);
ActivateEntity(g_iSlenderHitbox[iBossIndex]);
SetEntityMoveType(g_iSlenderHitbox[iBossIndex], MOVETYPE_NONE);
SetEntityMoveType(g_iSlenderHitbox[iBossIndex],MOVETYPE_NONE);
SetEntityRenderMode(g_iSlenderHitbox[iBossIndex], RENDER_TRANSCOLOR);
SetEntityRenderColor(g_iSlenderHitbox[iBossIndex], 0, 0, 0, 0);
SetVariantString("!activator");
AcceptEntityInput(g_iSlenderHitbox[iBossIndex], "SetParent", npcEntity.iEnt);
AcceptEntityInput(g_iSlenderHitbox[iBossIndex], "EnableShadow");
AcceptEntityInput(g_iSlenderHitbox[iBossIndex], "DisableShadow");
if (SF_IsBoxingMap()) SetEntProp(g_iSlenderHitbox[iBossIndex], Prop_Send, "m_CollisionGroup", COLLISION_GROUP_DEBRIS_TRIGGER);
//Block base_boss's ai.
SetEntProp(g_iSlenderHitbox[iBossIndex], Prop_Data,"m_nNextThinkTick",-1);
g_iSlenderHitboxOwner[g_iSlenderHitbox[iBossIndex]] = npcEntity.iEnt;
SDKHook(g_iSlenderHitbox[iBossIndex], SDKHook_OnTakeDamageAlive, Hook_HitboxOnTakeDamage);
//SDKHook(g_iSlenderHitbox[iBossIndex], SDKHook_ShouldCollide, Hook_HitBoxShouldCollide);
DHookRaw(g_hShouldCollide, true, aLocomotion);
if (SF_SpecialRound(SPECIALROUND_TINYBOSSES))
{
Expand Down Expand Up @@ -3307,7 +3323,12 @@ public Action Timer_BossMarked(Handle timer, any entref)

public bool Hook_HitBoxShouldCollide(int slender,int collisiongroup,int contentsmask, bool originalResult)
{
return false;
if ((contentsmask & CONTENTS_MONSTERCLIP) || (contentsmask & CONTENTS_PLAYERCLIP))
{
//CONTENTS_MOVEABLE seems to make the hitbox bullet proof
return false;
}
return originalResult;
}

public bool Hook_BossShouldCollide(int slender,int collisiongroup,int contentsmask, bool originalResult)
Expand Down Expand Up @@ -4567,7 +4588,7 @@ stock int SpawnSlenderModel(int iBossIndex, const float pos[3], bool bDeathCam =
char buffer[PLATFORM_MAX_PATH], sProfile[SF2_MAX_PROFILE_NAME_LENGTH];
NPCGetProfile(iBossIndex, sProfile, sizeof(sProfile));

float flPlaybackRate, flTempFootsteps;
float flPlaybackRate, flTempFootsteps, flCycle;
int iDifficulty = GetLocalGlobalDifficulty(iBossIndex);

GetSlenderModel(iBossIndex, _, buffer, sizeof(buffer));
Expand Down Expand Up @@ -4599,14 +4620,14 @@ stock int SpawnSlenderModel(int iBossIndex, const float pos[3], bool bDeathCam =
ActivateEntity(iSlenderModel);
if (!bDeathCam)
{
GetProfileAnimation(iBossIndex, sProfile, ChaserAnimation_IdleAnimations, buffer, sizeof(buffer), flPlaybackRate, iDifficulty, _, g_flSlenderIdleFootstepTime[iBossIndex]);
GetProfileAnimation(iBossIndex, sProfile, ChaserAnimation_IdleAnimations, buffer, sizeof(buffer), flPlaybackRate, iDifficulty, _, g_flSlenderIdleFootstepTime[iBossIndex], flCycle);
}
else
{
bool bAnimationFound = GetProfileAnimation(iBossIndex, sProfile, ChaserAnimation_DeathcamAnimations, buffer, sizeof(buffer), flPlaybackRate, 1, _, flTempFootsteps);
bool bAnimationFound = GetProfileAnimation(iBossIndex, sProfile, ChaserAnimation_DeathcamAnimations, buffer, sizeof(buffer), flPlaybackRate, 1, _, flTempFootsteps, flCycle);
if (!bAnimationFound || strcmp(buffer,"") <= 0)
{
GetProfileAnimation(iBossIndex, sProfile, ChaserAnimation_IdleAnimations, buffer, sizeof(buffer), flPlaybackRate, iDifficulty, _, g_flSlenderIdleFootstepTime[iBossIndex]);
GetProfileAnimation(iBossIndex, sProfile, ChaserAnimation_IdleAnimations, buffer, sizeof(buffer), flPlaybackRate, iDifficulty, _, g_flSlenderIdleFootstepTime[iBossIndex], flCycle);
}
}
if (buffer[0] != '\0')
Expand All @@ -4620,6 +4641,7 @@ stock int SpawnSlenderModel(int iBossIndex, const float pos[3], bool bDeathCam =

SetVariantFloat(flPlaybackRate);
AcceptEntityInput(iSlenderModel, "SetPlaybackRate");
SetEntPropFloat(iSlenderModel, Prop_Data, "m_flCycle", flCycle);

if (SF_SpecialRound(SPECIALROUND_TINYBOSSES))
{
Expand Down
Loading

0 comments on commit 34a8cdc

Please sign in to comment.