Skip to content

Commit

Permalink
Merge branch 'SirPlease:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
cH1yoi authored Jan 16, 2025
2 parents 44cf63a + 3ddbf36 commit afbc3d1
Show file tree
Hide file tree
Showing 12 changed files with 330 additions and 16 deletions.
Binary file not shown.
140 changes: 140 additions & 0 deletions addons/sourcemod/scripting/l4d_return_thrown_items.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdkhooks>
#include <sdktools_functions>
#include <left4dhooks>

#define PLUGIN_VERSION "1.0"

public Plugin myinfo =
{
name = "[L4D & 2] Return Thrown Items",
author = "Forgetest",
description = "Return pills/adrenalines thrown through shoving key if not successfully given.",
version = PLUGIN_VERSION,
url = "https://github.com/Target5150/MoYu_Server_Stupid_Plugins",
}

methodmap CountdownTimer {
public bool HasStarted() {
return this.m_timestamp > 0.0;
}
public bool IsElasped() {
return GetGameTime() >= this.m_timestamp;
}
property float m_duration {
public get() { return LoadFromAddress(view_as<Address>(this) + view_as<Address>(4), NumberType_Int32); }
}
property float m_timestamp {
public get() { return LoadFromAddress(view_as<Address>(this) + view_as<Address>(8), NumberType_Int32); }
}
}

public void OnMapStart()
{
for (int i = 1; i <= MaxClients; ++i)
{
if (IsClientInGame(i)) OnClientPutInServer(i);
}
}

public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_WeaponDropPost, SDK_OnWeaponDrop_Post);
}

void SDK_OnWeaponDrop_Post(int client, int weapon)
{
if (GetClientTeam(client) == 3)
return;

if (weapon <= 0 || !IsWeaponGiveable(weapon))
return;

// NOTE: Next weapon giving think defaults to 0.5s later, but the drop timer lasts 5.0s long.
// TODO: Make a cvar in case? Detour `CTerrorWeapon::GiveThink` for arruracy?
CreateTimer(1.0, Timer_CheckWeaponGiving, EntIndexToEntRef(weapon), TIMER_FLAG_NO_MAPCHANGE);
}

Action Timer_CheckWeaponGiving(Handle timer, int ref)
{
int weapon = EntRefToEntIndex(ref);
if (weapon == -1)
return Plugin_Stop;

CheckWeaponGiving(weapon);

return Plugin_Stop;
}

bool CheckWeaponGiving(int weapon)
{
CountdownTimer ct = GetWeaponDropTimer(weapon);
if (!ct.HasStarted() || ct.IsElasped()) // don't bother if not dropping
return false;

if (GetEntPropEnt(weapon, Prop_Send, "m_hOwner") != -1) // somebody has grabbed it
return false;

int owner = GetWeaponDroppingPlayer(weapon);
if (owner == -1 || !IsClientInGame(owner))
return false;

// yeah if empty, actually doesn't matter though, but yeah it feels good :)
EquipPlayerWeaponIfEmpty(owner, weapon);

return true;
}

void EquipPlayerWeaponIfEmpty(int client, int weapon)
{
char cls[32];
GetEntityClassname(weapon, cls, sizeof(cls));

int slot = L4D2_GetIntWeaponAttribute(cls, L4D2IWA_Bucket);
if (GetPlayerWeaponSlot(client, slot) == -1)
{
EquipPlayerWeapon(client, weapon);
}
}

bool IsWeaponGiveable(int weapon)
{
char cls[32];
GetEntityClassname(weapon, cls, sizeof(cls));

int slot = L4D2_GetIntWeaponAttribute(cls, L4D2IWA_Bucket);
return slot == 4;
}

CountdownTimer GetWeaponDropTimer(int weapon)
{
static int s_iOffs_m_dropTimer = -1;
if (s_iOffs_m_dropTimer == -1)
s_iOffs_m_dropTimer = L4D_IsEngineLeft4Dead1() ?
FindSendPropInfo("CTerrorWeapon", "m_flVsLastSwingTime") + 20 : FindSendPropInfo("CTerrorWeapon", "m_nUpgradedPrimaryAmmoLoaded") + 16;

return view_as<CountdownTimer>(GetEntityAddress(weapon) + view_as<Address>(s_iOffs_m_dropTimer));
}

int GetWeaponDroppingPlayer(int weapon)
{
static int s_iOffs_m_hDroppingPlayer = -1;
if (s_iOffs_m_hDroppingPlayer == -1)
s_iOffs_m_hDroppingPlayer = L4D_IsEngineLeft4Dead1() ?
FindSendPropInfo("CTerrorWeapon", "m_flVsLastSwingTime") + 16 : FindSendPropInfo("CTerrorWeapon", "m_nUpgradedPrimaryAmmoLoaded") + 8;

return GetEntDataEnt2(weapon, s_iOffs_m_hDroppingPlayer);
}

// int GetWeaponDropTarget(int weapon)
// {
// static int s_iOffs_m_hDropTarget = -1;
// if (s_iOffs_m_hDropTarget == -1)
// s_iOffs_m_hDropTarget = L4D_IsEngineLeft4Dead1() ?
// FindSendPropInfo("CTerrorWeapon", "m_flVsLastSwingTime") + 12 : FindSendPropInfo("CTerrorWeapon", "m_nUpgradedPrimaryAmmoLoaded") + 12;

// return GetEntDataEnt2(weapon, s_iOffs_m_hDropTarget);
// }
13 changes: 13 additions & 0 deletions cfg/cfgogl/zonemod/mapinfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,11 @@
"min" "34"
"max" "63"
}
"may spawn in water"
{
"min" "70"
"max" "72"
}
"Late spawns"
{
"min" "78"
Expand Down Expand Up @@ -1678,6 +1683,10 @@
"start_extra_dist" "203.035721"
"end_point" "696.980591 8058.962891 0.031250"
"end_dist" "164.379135"
"ItemLimits"
{
"pain_pills" "3"
}
"tank_ban_flow"
{
"1"
Expand All @@ -1703,6 +1712,10 @@
"start_extra_dist" "123.117989"
"end_point" "-697.423767 -182.836334 214.806290"
"end_dist" "1754.263794"
"ItemLimits"
{
"pain_pills" "4"
}
}

//=======================================================================
Expand Down
1 change: 1 addition & 0 deletions cfg/cfgogl/zonemod/shared_settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ spit_block_square dcr_m2_streets -65 1538 48 1586 //dead center rebirth , map2 ,

// [l4d2_ledgeblock.smx]
ledge_block_square hf01_theforest -456.402832 -4714.641113 -345.698212 -4595.220215 // At the final ladder at the end
ledge_block_square l4d_dbd2dc_undead_center -4952 8024 -4408 8840 // Block 4 banners could cause hang on them

// [l4d2_godframes_control.smx + l4d2_getup_fixes.smx]
confogl_addcvar gfc_hittable_override 1
Expand Down
1 change: 1 addition & 0 deletions cfg/generalfixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ sm plugins load fixes/l4d_fix_rotated_physblocker.smx
sm plugins load fixes/firebulletsfix.smx
sm plugins load fixes/l4d_fix_stagger_dir.smx
sm plugins load fixes/l4d2_fix_rocket_pull.smx
sm plugins load optional/l4d_return_thrown_items.smx

sm plugins load fixes/l4d_use_priority.smx // 修复E键问题

Expand Down
22 changes: 22 additions & 0 deletions cfg/stripper/zonemod/maps/cdta_01detour.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,15 @@ add:
"initialstate" "1"
"BlockType" "0"
}
{
"classname" "env_player_blocker"
"BlockType" "0"
"initialstate" "1"
"maxs" "40 40 80"
"mins" "-40 -40 -80"
"targetname" "eb_fix_tree05"
"origin" "-720 3776 144"
}
; --- Block a perma stuck spot in some rocks in the valley
{
"classname" "env_physics_blocker"
Expand Down Expand Up @@ -579,6 +588,19 @@ add:
; =====================================================


; --- fix a broken Si ladder under the hill
; --- 修复一个山下的假爬梯
add:
{
"model" "*4"
"normal.z" "0.20"
"normal.y" "-0.97"
"normal.x" "0.00"
"team" "2"
"classname" "func_simpleladder"
"origin" "1.00 -6.00 0.00"
"angles" "0.00 0.00 0.00"
}
; ############ MAP SOUND AND GFX CHANGES ############
; =====================================================
; == SOUND REMOVAL ==
Expand Down
13 changes: 13 additions & 0 deletions cfg/stripper/zonemod/maps/dkr_m2_carnival.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ modify:
"OnVersus" "directorBeginScriptwitch_glow0-1"
}
}

; --- block a hang spot on wire hole
; --- 电线杆有挂边,需要加一个空气墙
add:
{
"classname" "env_player_blocker"
"BlockType" "1"
"initialstate" "1"
"maxs" "24 64 800"
"mins" "-24 -64 -2"
"origin" "2912 6016 312"
; "targetname" "eb_fix01"
}
13 changes: 13 additions & 0 deletions cfg/stripper/zonemod/maps/l4d2_stadium3_city1.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,16 @@ modify:
"OnTrigger" "sound_alarm,Kill,,10,-1"
}
}

; ################ ITEM SPAWN CHANGES ###############
; =====================================================
; == PILL / ITEM / WEAPON SPAWNS ==
; == Remove or change pill, item & weapon spawns ==
; =====================================================

; ---- remove too radom pills 移除过于随机的药
filter:
{
"hammerid" "338911"
"classname" "weapon_item_spawn"
}
52 changes: 51 additions & 1 deletion cfg/stripper/zonemod/maps/l4d2_vs_stadium2_riverwalk.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ add:
; == Block players getting outside / under the map ==
; =====================================================

; --- fix a Si stuck spot 修复一个特感卡住点
; --- fix a Si stuck spot before the river
; --- 修复一个特感卡住点(水前)
add:
{
"classname" "prop_dynamic"
Expand All @@ -70,4 +71,53 @@ add:
"disableshadows" "1"
}

; --- fix 2 Si stuck spots before the event
; --- 修复4个特感卡住点(机关点前)
{
"classname" "env_player_blocker"
"BlockType" "0"
"initialstate" "1"
"maxs" "32 32 300"
"mins" "-32 -32 -80"
"targetname" "eb_fix01"
"origin" "-2224 5088 -192"
}
{
"classname" "env_player_blocker"
"BlockType" "0"
"initialstate" "1"
"maxs" "32 32 20"
"mins" "-32 -32 -40"
"targetname" "eb_fix02"
"origin" "-304 4904 -192"
}
add:
{
"model" "*102"
"normal.z" "0.00"
"normal.y" "-1.00"
"normal.x" "0.00"
"team" "2"
"classname" "func_simpleladder"
"origin" "4978.50 5694.50 -20.00"
"angles" "0.00 90.00 0.00"
}
{
"classname" "prop_dynamic"
"origin" "504 5248 -232"
"angles" "0 285 0"
"solid" "6"
"rendercolor" "255 255 255"
"model" "models/props_fortifications/sandbags_line2.mdl"
"disableshadows" "1"
}
{
"classname" "prop_dynamic"
"origin" "432 5240 -208"
"angles" "0 195 90"
"solid" "6"
"rendercolor" "255 255 255"
"model" "models/props_highway/plywood_01.mdl"
"disableshadows" "1"
}

20 changes: 18 additions & 2 deletions cfg/stripper/zonemod/maps/l4d_dbd2dc_the_mall.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2643,6 +2643,22 @@ add:

; ####### MISCELLANEOUS / MAP SPECIFIC CHANGES ######
; =====================================================
; == BLANK HEADER ==
; == Blank description ==
; == NAVIGATION ==
; == make distance score work right ==
; =====================================================

; --- fix 79%-81% nav flow scores
; --- 修复79%-81%导航流分数
add:
{
"classname" "logic_auto"
"OnMapSpawn" "shortcut_blocker,BlockNav,,1,-1"
}
{
"classname" "script_nav_blocker"
"origin" "1320 2992 -500"
"extent" "32 32 32"
"targetname" "shortcut_blocker"
"teamToBlock" "-1"
"affectsFlow" "2"
}
Loading

0 comments on commit afbc3d1

Please sign in to comment.