Skip to content
Merged

yep #69

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 42 additions & 28 deletions addons/sourcemod/gamedata/scp_sf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
{
"library" "server"
"linux" "@_ZN16CTFDroppedWeapon18InitPickedUpWeaponEP9CTFPlayerP13CTFWeaponBase"
"windows" "\x55\x8B\xEC\x83\xEC\x08\xD9\xEE\x53\x56\x57"
"windows" "\x55\x8B\xEC\x83\xEC\x14\xD9\xEE\x53"
}
"CTFGameMovement::ProcessMovement"
{
"library" "server"
"linux" "@_ZN15CTFGameMovement15ProcessMovementEP11CBasePlayerP9CMoveData"
"windows" "\x55\x8B\xEC\x56\x57\x8B\x7D\x08\x8B\xF1\x85\xFF\x74\x2A\x53"
"windows" "\x55\x8B\xEC\x56\x57\x8B\x7D\x08\x8B\xF1\x85\xFF\x0F\x84\x2A\x2A\x2A\x2A\x83\x7D\x0C\x00"
}
"CTFPlayer::CanPickupDroppedWeapon"
{
Expand Down Expand Up @@ -106,6 +106,12 @@
"linux" "@_ZN14CWeaponMedigun19AllowedToHealTargetEP11CBaseEntity"
"windows" "\x55\x8B\xEC\x53\x8B\xD9\x56\x57\x8B\x93\x10\x02\x00\x00\x85\xD2\x0F\x84\x2A\x2A\x2A\x2A\xB9\xFF\x1F\x00\x00\x83\xFA\xFF\x74\x2A\x0F\xB7\xCA\xA1\x2A\x2A\x2A\x2A\xC1\xE1\x04\x8D\x78\x04\x03\xF9\x0F\x84\x2A\x2A\x2A\x2A\xC1\xEA\x10\x39\x57\x04\x0F\x85\x2A\x2A\x2A\x2A\x8B\x3F\x85\xFF\x0F\x84\x2A\x2A\x2A\x2A\x8B\x07\x8B\xCF\x8B\x80\x48\x01\x00\x00\xFF\xD0\x84\xC0\x0F\x84\x2A\x2A\x2A\x2A\x8B\x75\x08\x85\xF6\x74\x2A"
}
"CTraceFilterSimple::ShouldHitEntity"
{
"library" "server"
"linux" "@_ZN18CTraceFilterSimple15ShouldHitEntityEP13IHandleEntityi"
"windows" "\x55\x8B\xEC\x57\xFF\x75\x0C\x8B\xF9\xFF\x75\x08\xE8\x2A\x2A\x2A\x2A\x83\xC4\x08"
}
"AI_CriteriaSet::FindCriterionIndex"
{
"linux" "@_ZNK14AI_CriteriaSet18FindCriterionIndexEPKc"
Expand All @@ -116,12 +122,6 @@
"linux" "@_ZN14AI_CriteriaSet14RemoveCriteriaEPKc"
"windows" "\x55\x8B\xEC\x83\xEC\x48\x56\x57\xFF\x75\x08"
}
"PassServerEntityFilter"
{
"library" "server"
"linux" "@_Z22PassServerEntityFilterPK13IHandleEntityS1_"
"windows" "\x55\x8B\xEC\x56\x8B\x75\x0C\x57\x85\xF6\x74\x2A\x8B\x7D\x08"
}
}
"Functions"
{
Expand Down Expand Up @@ -356,35 +356,49 @@
}
}
}
"CBaseEntity::ModifyOrAppendCriteria"
"CWeaponMedigun::AllowedToHealTarget"
{
"offset" "CBaseEntity::ModifyOrAppendCriteria"
"hooktype" "entity"
"return" "void"
"signature" "CWeaponMedigun::AllowedToHealTarget"
"callconv" "thiscall"
"return" "bool"
"this" "entity"
"arguments"
{
"criteriaSet"
"target"
{
"type" "int"
"type" "cbaseentity"
}
}
}
"PassServerEntityFilter"
"CTraceFilterSimple::ShouldHitEntity"
{
// bool PassServerEntityFilter( const IHandleEntity *pTouch, const IHandleEntity *pPass )
"signature" "PassServerEntityFilter"
"callconv" "cdecl"
"return" "bool"
"signature" "CTraceFilterSimple::ShouldHitEntity"
"callconv" "thiscall"
"return" "bool"
"this" "address"
"arguments"
{
"touch"
"pHandleEntity"
{
"type" "cbaseentity"
}
"pass"
"contentsMask"
{
"type" "cbaseentity"
"type" "int"
}
}
}
"CBaseEntity::ModifyOrAppendCriteria"
{
"offset" "CBaseEntity::ModifyOrAppendCriteria"
"hooktype" "entity"
"return" "void"
"this" "entity"
"arguments"
{
"criteriaSet"
{
"type" "int"
}
}
}
Expand Down Expand Up @@ -418,13 +432,13 @@
}
"CTeamplayRoundBasedRules::RoundRespawn"
{
"linux" "231"
"windows" "229"
"linux" "232"
"windows" "230"
}
"CTeamplayRules::SetWinningTeam"
{
"linux" "165"
"windows" "164"
"linux" "166"
"windows" "165"
}
"CTeam::AddPlayer"
{
Expand All @@ -449,12 +463,12 @@
"linux"
{
"signature" "CTFGameMovement::ProcessMovement"
"offset" "84"
"offset" "97"
}
"windows"
{
"signature" "CTFGameMovement::ProcessMovement"
"offset" "70"
"offset" "77"
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions addons/sourcemod/scripting/include/scp_sf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ forward void SCPSF_OnWeapon(int client, int entity);
*/
forward Action SCPSF_OnReactionPre(int client, const char[] event, char sound[PLATFORM_MAX_PATH]);

/**
* Calls when listen overrides are being checked between two clients
*
* @note Does not go through if the listener has the talker muted client-side
*
* @param listener Client index of the listener
* @param talker Client index of the talker
*
* @return Plugin_Continue - No changes
* Plugin_Changed - Stops the listener from hearing the talker
* Plugin_Handled - Stops the listener from hearing the talker
* Plugin_Stop - Stops the listener from hearing the talker
*/
forward Action SCPSF_OnUpdateListenOverrides(int listener, int talker);

public SharedPlugin __pl_SCPSF =
{
name = "scp_sf",
Expand Down
13 changes: 10 additions & 3 deletions addons/sourcemod/scripting/scp_sf.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,7 @@ public Action OnBroadcast(Event event, const char[] name, bool dontBroadcast)
return Plugin_Continue;
}

public Action OnPlayerRunCmd(int client, int &buttons)
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
{
if(!Enabled || !IsPlayerAlive(client))
return Plugin_Continue;
Expand Down Expand Up @@ -2310,7 +2310,7 @@ public Action OnPlayerRunCmd(int client, int &buttons)
}

// Check if the player moved at all or is speaking
if((buttons & IN_ATTACK) || (!(buttons & IN_DUCK) && ((buttons & IN_FORWARD) || (buttons & IN_BACK) || (buttons & IN_MOVELEFT) || (buttons & IN_MOVERIGHT))))
if (buttons & IN_ATTACK || !(GetEntityFlags(client) & FL_DUCKING || (vel[0] == 0.0 && vel[1] == 0.0))) // Ignoring vertical vel[2]
Client[client].IdleAt = engineTime+2.5;

// SCP-specific buttons
Expand Down Expand Up @@ -2610,7 +2610,11 @@ public void UpdateListenOverrides(float engineTime)
continue;
}

Client[target].CanTalkTo[client] = true;
if(Forward_OnUpdateListenOverrides(client, target) != Plugin_Continue)
{
SetListenOverride(client, target, Listen_No);
continue;
}

#if defined _sourcecomms_included
if(SourceComms && SourceComms_GetClientMuteType(target)>bNot)
Expand Down Expand Up @@ -2671,6 +2675,9 @@ public void UpdateListenOverrides(float engineTime)
bool muted = (manage && IsClientMuted(client[i], client[a]));
bool blocked = muted;

if(!blocked && Forward_OnUpdateListenOverrides(client[i], client[a]) != Plugin_Continue)
blocked = true;

#if defined _basecomm_included
if(!blocked && BaseComm && BaseComm_IsClientMuted(client[a]))
blocked = true;
Expand Down
3 changes: 2 additions & 1 deletion addons/sourcemod/scripting/scp_sf/classes.sp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ void Classes_Setup(KeyValues main, KeyValues map, ArrayList whitelist)
int count;
do
{
if(!kv.GetSectionName(class.Name, sizeof(class.Name)) || StrEqual(class.Name, "default"))
if(!kv.GetSectionName(class.Name, sizeof(class.Name)) || StrEqual(class.Name, "default", false))
continue;

StrToLower(class.Name);
if(whitelist && whitelist.FindString(class.Name)==-1)
continue;

Expand Down
69 changes: 25 additions & 44 deletions addons/sourcemod/scripting/scp_sf/dhooks.sp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma semicolon 1
#pragma newdecls required

static DynamicDetour AllowedToHealTarget;
static DynamicHook RoundRespawn;
static DynamicHook ShouldCollide;
static DynamicHook ForceRespawn;
Expand All @@ -27,28 +26,9 @@ void DHook_Setup(GameData gamedata)
DHook_CreateDetour(gamedata, "CTFPlayer::RegenThink", DHook_RegenThinkPre, DHook_RegenThinkPost);
DHook_CreateDetour(gamedata, "CTFPlayer::Taunt", DHook_TauntPre, DHook_TauntPost);
DHook_CreateDetour(gamedata, "CTFPlayer::TeamFortress_CalculateMaxSpeed", DHook_CalculateMaxSpeedPre, DHook_CalculateMaxSpeedPost);
DHook_CreateDetour(gamedata, "PassServerEntityFilter", _, Detour_PassServerEntityFilterPost);
DHook_CreateDetour(gamedata, "CWeaponMedigun::AllowedToHealTarget", DHook_AllowedToHealTargetPre);
DHook_CreateDetour(gamedata, "CTraceFilterSimple::ShouldHitEntity", DHook_ShouldHitEntityPre);

// TODO: DHook_CreateDetour version of this
AllowedToHealTarget = new DynamicDetour(Address_Null, CallConv_THISCALL, ReturnType_Bool, ThisPointer_CBaseEntity);
if(AllowedToHealTarget)
{
if(AllowedToHealTarget.SetFromConf(gamedata, SDKConf_Signature, "CWeaponMedigun::AllowedToHealTarget"))
{
AllowedToHealTarget.AddParam(HookParamType_CBaseEntity);
if(!AllowedToHealTarget.Enable(Hook_Pre, DHook_AllowedToHealTarget))
LogError("[Gamedata] Failed to detour CWeaponMedigun::AllowedToHealTarget");
}
else
{
LogError("[Gamedata] Could not find CWeaponMedigun::AllowedToHealTarget");
}
}
else
{
LogError("[Gamedata] Could not find CWeaponMedigun::AllowedToHealTarget");
}

RoundRespawn = DynamicHook.FromConf(gamedata, "CTeamplayRoundBasedRules::RoundRespawn");
if(!RoundRespawn)
LogError("[Gamedata] Could not find CTeamplayRoundBasedRules::RoundRespawn");
Expand Down Expand Up @@ -131,7 +111,7 @@ public MRESReturn DHook_RoundRespawn()
return MRES_Ignored;
}

public MRESReturn DHook_AllowedToHealTarget(int weapon, DHookReturn ret, DHookParam param)
public MRESReturn DHook_AllowedToHealTargetPre(int weapon, DHookReturn ret, DHookParam param)
{
if(weapon==-1 || param.IsNull(1))
return MRES_Ignored;
Expand Down Expand Up @@ -531,41 +511,42 @@ public MRESReturn DHook_ModifyOrAppendCriteriaPost(int player, DHookParam params
return MRES_Ignored;
}

public MRESReturn Detour_PassServerEntityFilterPost(DHookReturn ret, DHookParam param)
public MRESReturn DHook_ShouldHitEntityPre(Address address, DHookReturn ret, DHookParam param)
{
if (!ret || param.IsNull(1) || param.IsNull(2))
{
int touch_ent = param.Get(1);
int pass_ent = GetEntityFromAddress(LoadFromAddress(address + view_as<Address>(4), NumberType_Int32)); // +4 from CTraceFilterSimple::m_pPassEnt
if (pass_ent == -1)
return MRES_Ignored;
}

int touch_ent = param.Get(1);
int pass_ent = param.Get(2);
int client = -1;
int entity = -1;

if (!IsValidEntity(touch_ent) || !IsValidEntity(pass_ent))
if (0 < touch_ent <= MaxClients)
{
return MRES_Ignored;
client = touch_ent;
entity = pass_ent;
}

bool touch_is_player = touch_ent > 0 && touch_ent <= MaxClients && IsPlayerAlive(touch_ent);
bool pass_is_player = pass_ent > 0 && pass_ent <= MaxClients && IsPlayerAlive(pass_ent);

if ((touch_is_player && pass_is_player) || (!touch_is_player && !pass_is_player))
else if (0 < pass_ent <= MaxClients)
{
client = pass_ent;
entity = touch_ent;
}
else
{
return MRES_Ignored;
}

int entity = touch_is_player ? pass_ent : touch_ent;

char classname[64];
GetEntityClassname(entity, classname, sizeof(classname));

if (strncmp(classname, "func_door", sizeof(classname)) != 0 && strncmp(classname, "func_movelinear", sizeof(classname)) != 0)
if (StrContains(classname, "func_door") == 0 || StrContains(classname, "func_movelinear") == 0)
{
return MRES_Ignored;
if (Classes_OnDoorWalk(client, entity))
{
ret.Value = false;
return MRES_Supercede;
}
}

int client = touch_is_player ? touch_ent : pass_ent;

ret.Value = !Classes_OnDoorWalk(client, entity);
return MRES_Supercede;
return MRES_Ignored;
}
12 changes: 12 additions & 0 deletions addons/sourcemod/scripting/scp_sf/forwards.sp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ static GlobalForward OnClass;
static GlobalForward OnClassPre;
static GlobalForward OnEscape;
static GlobalForward OnReactionPre;
static GlobalForward OnUpdateListenOverrides;
static GlobalForward OnWeapon;
static GlobalForward OnWeaponPre;

Expand All @@ -16,6 +17,7 @@ void Forward_Setup()
OnClassPre = new GlobalForward("SCPSF_OnClassPre", ET_Event, Param_Cell, Param_String, Param_Cell);
OnEscape = new GlobalForward("SCPSF_OnEscape", ET_Ignore, Param_Cell, Param_Cell);
OnReactionPre = new GlobalForward("SCPSF_OnReactionPre", ET_Event, Param_Cell, Param_String, Param_String);
OnUpdateListenOverrides = new GlobalForward("SCPSF_OnUpdateListenOverrides", ET_Ignore, Param_Cell, Param_Cell);
OnWeapon = new GlobalForward("SCPSF_OnWeapon", ET_Ignore, Param_Cell, Param_Cell);
OnWeaponPre = new GlobalForward("SCPSF_OnWeaponPre", ET_Event, Param_Cell, Param_Cell, Param_CellByRef);
}
Expand Down Expand Up @@ -103,4 +105,14 @@ void Forward_OnMessage(int client, char[] name, int nameL, char[] msg, int msgL)
Call_Finish();
}
delete iter;
}

Action Forward_OnUpdateListenOverrides(int listener, int talker)
{
Action action;
Call_StartForward(OnUpdateListenOverrides);
Call_PushCell(listener);
Call_PushCell(talker);
Call_Finish(action);
return action;
}
7 changes: 5 additions & 2 deletions addons/sourcemod/scripting/scp_sf/gamemode.sp
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,10 @@ static ArrayList GrabClassList(KeyValues kv)
{
IntToString(i, buffer, sizeof(buffer));
kv.GetString(buffer, buffer, sizeof(buffer));
if(!buffer[0])

if(buffer[0]) // Convert the string to lowercase because keyvalues might uppercase them
StrToLower(buffer);
else
break;

list.PushString(buffer);
Expand Down Expand Up @@ -1140,7 +1143,7 @@ public bool Gamemode_ConditionVip(TFTeam &team)
team = TFTeam_Blue;
group = 2;
}
else if(salive && !sescape) // SCP alive and none escaped
else if(salive && !sescape && !scapture) // SCP alive and none escaped/captured
{
team = TFTeam_Red;
group = 3;
Expand Down
Loading