Skip to content

Commit

Permalink
fix stuff i did
Browse files Browse the repository at this point in the history
  • Loading branch information
higps committed Jul 9, 2024
1 parent 8421adc commit a54c778
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 126 deletions.
1 change: 1 addition & 0 deletions berobot_teamcomptips.sp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public Plugin myinfo =
public void OnPluginStart()
{

HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
RegConsoleCmd("sm_showcomptips", Command_ShowCompTips, "Toggles showing composition tips for your team");


Expand Down
76 changes: 37 additions & 39 deletions compile_to_folder.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,60 @@
import os
import glob
import shutil
import subprocess
from pathlib import Path

sourcemod_dir = r"D:\sourcemod\addons\sourcemod"
spcomp_path = os.path.join(sourcemod_dir, r"scripting\spcomp64.exe")
plugins_path = os.path.join(sourcemod_dir, "plugins")
default_arguments = "-i 'D:\Github\robogithub\include' -i 'D:\sourcemod-custom-includes' -O2 -v2"
# Define the paths
sourcemod_dir = Path(r"D:\sourcemod\addons\sourcemod")
spcomp_path = sourcemod_dir / "scripting" / "spcomp64.exe"
plugins_path = sourcemod_dir / "plugins"
default_arguments = "-i 'D:\\Github\\robogithub\\include' -i 'D:\\sourcemod-custom-includes' -O2 -v2"

# Specify the root folder explicitly
root_folder = os.path.dirname(os.path.abspath(__file__))
sp_files = glob.glob(os.path.join(root_folder, "*.sp"))
# Define the root folder
root_folder = Path(__file__).parent

# Get all .sp files in the root folder
sp_files = root_folder.glob("*.sp")

# Filtering and processing the files
for sp_file in sp_files:
sp_file_name = os.path.basename(sp_file)

if ("joke" in sp_file_name or
"test" in sp_file_name or
"dont_compile" in sp_file_name or
"don_compile" in sp_file_name or
sp_file_name == "changeteam.sp" or
sp_file_name == "enablemvm.sp"):
if any(sub in sp_file.name for sub in ["joke", "test", "dont_compile", "don_compile"]) or \
sp_file.name in ["changeteam.sp", "enablemvm.sp"]:
continue

output_path = ""
folder_path = ""

if sp_file_name.startswith("berobot_"):
folder_path = os.path.join(root_folder, r"compiled\mm_handlers")
output_path = os.path.join(folder_path, os.path.splitext(sp_file_name)[0] + ".smx")
elif sp_file_name.startswith("ability_"):
folder_path = os.path.join(root_folder, r"compiled\mm_robots\robot_abilities")
output_path = os.path.join(folder_path, sp_file_name)
elif any(sp_file_name.startswith(prefix) for prefix in ["free_", "paid_", "boss_"]):
folder_path = os.path.join(root_folder, r"compiled\mm_robots")
output_path = os.path.join(folder_path, sp_file_name)
elif sp_file_name.startswith("mm_"):
folder_path = os.path.join(root_folder, r"compiled\mm_attributes")
output_path = os.path.join(folder_path, sp_file_name)
output_path = None
folder_path = None

if sp_file.name.startswith("berobot_"):
output_path = root_folder / f"compiled/mm_handlers/{sp_file.stem}.smx"
elif sp_file.name.startswith("ability_"):
folder_path = root_folder / "compiled/mm_robots/robot_abilities"
output_path = folder_path / sp_file.name
elif any(sp_file.name.startswith(prefix) for prefix in ["free_", "paid_", "boss_"]):
folder_path = root_folder / "compiled/mm_robots"
output_path = folder_path / sp_file.name
elif sp_file.name.startswith("mm_"):
folder_path = root_folder / "compiled/mm_attributes"
output_path = folder_path / sp_file.name
else:
continue

# Create the necessary folders if they don't exist
os.makedirs(folder_path, exist_ok=True)
if folder_path and not folder_path.exists():
folder_path.mkdir(parents=True, exist_ok=True)

arguments = f"{sp_file} -o={output_path} {default_arguments}"
command = f"{spcomp_path} {arguments}"
arguments = f'"{sp_file}" -o="{output_path}" {default_arguments}'
command = f'"{spcomp_path}" {arguments}'

print(command)
result = subprocess.run(command, shell=True)
if result.returncode != 0:
print(f"Compilation failed for {sp_file}")
exit()
result = subprocess.run(command, shell=True, capture_output=True, text=True)

if result.returncode != 0:
print(f"Compilation failed for {sp_file} with error:\n{result.stderr}")
exit(1)
print("")

# Check if the output file exists before attempting to copy
if os.path.exists(output_path):
if output_path and output_path.exists():
# Copy the compiled file to the plugins directory
shutil.copy(output_path, plugins_path)
else:
Expand Down
88 changes: 1 addition & 87 deletions mm_attribute_change_demo_speed.sp
Original file line number Diff line number Diff line change
Expand Up @@ -51,90 +51,4 @@ public void TF2_OnConditionRemoved(int client, TFCond condition)
TF2_RemoveCondition(client, TFCond_RestrictToMelee);
}
}
}
bool b_Hooked[MAXPLAYERS + 1] = {false,...};


public void OnPluginStart()
{
for(int i = 0; i <= MAXPLAYERS; i++)
{
if(IsValidClient(i))
{
SDKHook(i, SDKHook_WeaponSwitchPost, OnWeaponSwitch);
b_Hooked[i] = true;
}
}

Handle hGameData = LoadGameConfigFile("mm_no_flinch");
if (!hGameData)
SetFailState("Failed to load mm_no_flinch gamedata.");

hApplyPunchImpulseXDetour = DHookCreateFromConf(hGameData, "CTFPlayer::TeamFortress_CalculateMaxSpeed");
if (!hApplyPunchImpulseXDetour)
SetFailState("Failed to setup detour for CTFPlayer::TeamFortress_CalculateMaxSpeed ");
delete hGameData;

if (!DHookEnableDetour(hApplyPunchImpulseXDetour, false, Detour_TeamFortress_CalculateMaxSpeed))
SetFailState("Failed to detour CTFPlayer::TeamFortress_CalculateMaxSpeed .");

// if (!DHookEnableDetour(hApplyPunchImpulseXDetour, true, Detour_TeamFortress_CalculateMaxSpeed_Post))
// SetFailState("Failed to detour CTFPlayer::TeamFortress_CalculateMaxSpeed post.");

PrintToServer("TeamFortress_CalculateMaxSpeed detoured!");

}


Handle hApplyPunchImpulseXDetour;



public MRESReturn Detour_TeamFortress_CalculateMaxSpeed(int client, Handle hParams)
{
// PrintToChatAll("1 %N", client);
if(IsAnyRobot(client) && TF2_GetPlayerClass(client) == TFClass_Sniper && TF2_IsPlayerInCondition(client, TFCond_Zoomed) || TF2_IsPlayerInCondition(client, TFCond_CritCola))
{
DHookSetReturn(hParams, false);
return MRES_Supercede;
}
return MRES_Ignored;

}

public void OnClientPutInServer(int client)
{


// Hook weapon switching for this client here:
SDKHook(client, SDKHook_WeaponSwitchPost, OnWeaponSwitch);
b_Hooked[client] = true;
}

public void OnClientDisconnect(int client)
{


// Unhook our weapon switching:
SDKUnhook(client, SDKHook_WeaponSwitchPost, OnWeaponSwitch);
}

public void OnWeaponSwitch(int client, int weapon)
{
if (ActiveHasChargeSpeedStatPlayer(client) && TF2_IsPlayerInCondition(client, g_TFCond))
{
PrintToChatAll("Setting charge speed to %f", g_ChargingSpeed);
TF2_RemoveCondition(client, g_TFCond);
SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", g_ChargingSpeed);
}
}





public void OnPluginStart()
{

}

}

0 comments on commit a54c778

Please sign in to comment.