From 17b3cf82163917ba6d1989ce9900a0709eac9010 Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Thu, 11 Feb 2021 13:10:46 +0100
Subject: [PATCH] [MIRROR] fixes 2 runtimes caused by holding people up with a
gun (#3283)
* fixes 2 runtimes caused by holding people up with a gun (#56800)
Fixes two runtimes, one caused by status effects always expecting a return from throw_alert, and another caused by holding yourself up (which you shouldn't even be able to do). Also fixes an issue caused by multiple people holding up the same person, when one of the perpetrators stopped holding up the victim, all of the victim's related alerts disappeared.
* fixes 2 runtimes caused by holding people up with a gun
Co-authored-by: TJatPBnJ <69724863+TJatPBnJ@users.noreply.github.com>
---
code/__DEFINES/status_effects.dm | 4 ++--
code/_onclick/hud/alert.dm | 4 ++--
code/datums/status_effects/neutral.dm | 8 ++++----
code/modules/projectiles/gun.dm | 3 +++
4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/code/__DEFINES/status_effects.dm b/code/__DEFINES/status_effects.dm
index 57c9708bff4..3e9b3fd1eff 100644
--- a/code/__DEFINES/status_effects.dm
+++ b/code/__DEFINES/status_effects.dm
@@ -109,13 +109,13 @@
#define STATUS_EFFECT_BOUNTY /datum/status_effect/bounty //rewards the person who added this to the target with refreshed spells and a fair heal
-#define STATUS_EFFECT_HELDUP /datum/status_effect/heldup // someone is currently pointing a gun at you
+#define STATUS_EFFECT_HELDUP /datum/status_effect/grouped/heldup // someone is currently pointing a gun at you
#define STATUS_EFFECT_HOLDUP /datum/status_effect/holdup // you are currently pointing a gun at someone
#define STATUS_EFFECT_HIGHFIVE /datum/status_effect/high_fiving // you are angling for a high five
-#define STATUS_EFFECT_SURRENDER /datum/status_effect/surrender // gives an alert to quickly surrender
+#define STATUS_EFFECT_SURRENDER /datum/status_effect/grouped/surrender // gives an alert to quickly surrender
/////////////
// SLIME //
/////////////
diff --git a/code/_onclick/hud/alert.dm b/code/_onclick/hud/alert.dm
index fa3deb444d5..5c89153f521 100644
--- a/code/_onclick/hud/alert.dm
+++ b/code/_onclick/hud/alert.dm
@@ -21,7 +21,7 @@
if(alerts[category])
thealert = alerts[category]
if(thealert.override_alerts)
- return 0
+ return thealert
if(new_master && new_master != thealert.master)
WARNING("[src] threw alert [category] with new_master [new_master] while already having that alert with master [thealert.master]")
@@ -35,7 +35,7 @@
clear_alert(category)
return .()
else //no need to update
- return 0
+ return thealert
else
thealert = new type()
thealert.override_alerts = override
diff --git a/code/datums/status_effects/neutral.dm b/code/datums/status_effects/neutral.dm
index 4e54ca36a40..a04bd836a24 100644
--- a/code/datums/status_effects/neutral.dm
+++ b/code/datums/status_effects/neutral.dm
@@ -111,7 +111,7 @@
rewarded.adjustCloneLoss(-25)
// heldup is for the person being aimed at
-/datum/status_effect/heldup
+/datum/status_effect/grouped/heldup
id = "heldup"
duration = -1
tick_interval = -1
@@ -123,11 +123,11 @@
desc = "Making any sudden moves would probably be a bad idea!"
icon_state = "aimed"
-/datum/status_effect/heldup/on_apply()
+/datum/status_effect/grouped/heldup/on_apply()
owner.apply_status_effect(STATUS_EFFECT_SURRENDER)
return ..()
-/datum/status_effect/heldup/on_remove()
+/datum/status_effect/grouped/heldup/on_remove()
owner.remove_status_effect(STATUS_EFFECT_SURRENDER)
return ..()
@@ -302,7 +302,7 @@
slap_item = null
//this effect gives the user an alert they can use to surrender quickly
-/datum/status_effect/surrender
+/datum/status_effect/grouped/surrender
id = "surrender"
duration = -1
tick_interval = -1
diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm
index edcc07eaec6..dd63c5350d2 100644
--- a/code/modules/projectiles/gun.dm
+++ b/code/modules/projectiles/gun.dm
@@ -197,6 +197,9 @@
if (user.GetComponent(/datum/component/gunpoint))
to_chat(user, "You are already holding someone up!")
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
+ if (user == victim)
+ to_chat(user,"You can't hold yourself up!")
+ return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
user.AddComponent(/datum/component/gunpoint, victim, src)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN