From 2d37c7f4994ade4f69c318ebb05435b556e3b19f Mon Sep 17 00:00:00 2001 From: Haxton Date: Sat, 11 Jul 2020 00:52:50 +0300 Subject: [PATCH] Make sure ghosts can't collide with players --- scripting/instagib.sp | 29 +++++++++++++++++++++++ scripting/instagib/rounds/limitedlives.sp | 12 ++++++++++ 2 files changed, 41 insertions(+) diff --git a/scripting/instagib.sp b/scripting/instagib.sp index 32739de..b85517f 100644 --- a/scripting/instagib.sp +++ b/scripting/instagib.sp @@ -30,6 +30,35 @@ #pragma newdecls required // ------------------------------------------------------------------- +enum +{ + SOLID_NONE = 0, // no solid model + SOLID_BSP = 1, // a BSP tree + SOLID_BBOX = 2, // an AABB + SOLID_OBB = 3, // an OBB (not implemented yet) + SOLID_OBB_YAW = 4, // an OBB, constrained so that it can only yaw + SOLID_CUSTOM = 5, // Always call into the entity for tests + SOLID_VPHYSICS = 6, // solid vphysics object, get vcollide from the model and collide with that + SOLID_LAST, +} + +enum +{ + FSOLID_CUSTOMRAYTEST = 0x0001, // Ignore solid type + always call into the entity for ray tests + FSOLID_CUSTOMBOXTEST = 0x0002, // Ignore solid type + always call into the entity for swept box tests + FSOLID_NOT_SOLID = 0x0004, // Are we currently not solid? + FSOLID_TRIGGER = 0x0008, // This is something may be collideable but fires touch functions + // even when it's not collideable (when the FSOLID_NOT_SOLID flag is set) + FSOLID_NOT_STANDABLE = 0x0010, // You can't stand on this + FSOLID_VOLUME_CONTENTS = 0x0020, // Contains volumetric contents (like water) + FSOLID_FORCE_WORLD_ALIGNED = 0x0040, // Forces the collision rep to be world-aligned even if it's SOLID_BSP or SOLID_VPHYSICS + FSOLID_USE_TRIGGER_BOUNDS = 0x0080, // Uses a special trigger bounds separate from the normal OBB + FSOLID_ROOT_PARENT_ALIGNED = 0x0100, // Collisions are defined in root parent's local coordinate space + FSOLID_TRIGGER_TOUCH_DEBRIS = 0x0200, // This trigger will touch debris objects + + FSOLID_MAX_BITS = 10 +} + enum struct Config { char ChatColor[16]; diff --git a/scripting/instagib/rounds/limitedlives.sp b/scripting/instagib/rounds/limitedlives.sp index 3216136..e0b6b08 100644 --- a/scripting/instagib/rounds/limitedlives.sp +++ b/scripting/instagib/rounds/limitedlives.sp @@ -175,6 +175,10 @@ void SR_Lives_OnSpawn(int client, TFTeam team) // Turn people with no lives to ghosts. if (g_IsRoundActive && PlayerLives[client] <= 0 && IsClientPlaying(client)) { TF2_AddCondition(client, TFCond_HalloweenGhostMode); + + // Apparently sometimes ghosts keep their player collisions, so let's take care of that. + SetEntProp(client, Prop_Send, "m_nSolidType", SOLID_NONE); + SetEntProp(client, Prop_Send, "m_usSolidFlags", FSOLID_NOT_SOLID); } } @@ -212,6 +216,14 @@ void SR_Lives_OnDisconnect(int client) void SR_Lives_OnEnd(TFTeam winner_team, int score, int time_left) { + for (int i = 1; i <= MaxClients; i++) { + if (IsClientInGame(i)) { + // Reset the collisions. + SetEntProp(i, Prop_Send, "m_nSolidType", SOLID_BBOX); + SetEntProp(i, Prop_Send, "m_usSolidFlags", FSOLID_NOT_STANDABLE); + } + } + if (score == -1) { // score = -1 if the round time had ran out and EndWithTimer == false int red_lives; int blue_lives;