From 8e85f70f694e3aa8f07dc99e2b82c3d3ff8c1c8a Mon Sep 17 00:00:00 2001
From: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>
Date: Mon, 25 Jul 2022 02:20:27 -0400
Subject: [PATCH] Fixes Issue with Wizarditis Teleportation (#18392)
* cleanup
* AA changes
* Apply suggestions from code review
Co-authored-by: Charlie <69320440+hal9000PR@users.noreply.github.com>
* implement requested changes
* oopsie
Co-authored-by: Charlie <69320440+hal9000PR@users.noreply.github.com>
---
code/datums/diseases/wizarditis.dm | 48 ++++++++++++++++--------------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/code/datums/diseases/wizarditis.dm b/code/datums/diseases/wizarditis.dm
index 9533fc33c0f..6daf9eccf8e 100644
--- a/code/datums/diseases/wizarditis.dm
+++ b/code/datums/diseases/wizarditis.dm
@@ -28,16 +28,16 @@ STI KALY - blind
switch(stage)
if(2)
- if(prob(1)&&prob(50))
+ if(prob(0.5))
affected_mob.say(pick("You shall not pass!", "Expeliarmus!", "By Merlins beard!", "Feel the power of the Dark Side!"))
- if(prob(1)&&prob(50))
+ if(prob(0.5))
to_chat(affected_mob, "You feel [pick("that you don't have enough mana", "that the winds of magic are gone", "an urge to summon familiar")].")
if(3)
- if(prob(1)&&prob(50))
+ if(prob(0.5))
affected_mob.say(pick("NEC CANTIO!","AULIE OXIN FIERA!", "STI KALY!", "TARCOL MINTI ZHERI!"))
- if(prob(1)&&prob(50))
+ if(prob(0.5))
to_chat(affected_mob, "You feel [pick("the magic bubbling in your veins","that this location gives you a +1 to INT","an urge to summon familiar")].")
if(4)
@@ -45,10 +45,10 @@ STI KALY - blind
if(prob(1))
affected_mob.say(pick("NEC CANTIO!","AULIE OXIN FIERA!","STI KALY!","EI NATH!"))
return
- if(prob(1)&&prob(50))
+ if(prob(0.5))
to_chat(affected_mob, "You feel [pick("the tidal wave of raw power building inside","that this location gives you a +2 to INT and +1 to WIS","an urge to teleport")].")
spawn_wizard_clothes(50)
- if(prob(1)&&prob(1))
+ if(prob(0.01))
teleport()
return
@@ -87,32 +87,34 @@ STI KALY - blind
/datum/disease/wizarditis/proc/teleport()
- var/list/theareas = get_areas_in_range(80, affected_mob)
- for(var/area/space/S in theareas)
- theareas -= S
-
- if(!theareas||!theareas.len)
+ if(!is_teleport_allowed(affected_mob.z))
return
- var/area/thearea = pick(theareas)
+ var/list/possible_areas = get_areas_in_range(80, affected_mob)
+ for(var/area/space/S in possible_areas)
+ possible_areas -= S
- var/list/L = list()
- for(var/turf/T in get_area_turfs(thearea.type))
- if(T.z != affected_mob.z) continue
- if(T.name == "space") continue
+ if(!length(possible_areas))
+ return
+
+ var/area/chosen_area = pick(possible_areas)
+
+ var/list/teleport_turfs = list()
+ for(var/turf/T in get_area_turfs(chosen_area.type))
+ if(isspaceturf(T))
+ continue
if(!T.density)
- var/clear = 1
+ var/clear = TRUE
for(var/obj/O in T)
if(O.density)
- clear = 0
+ clear = FALSE
break
if(clear)
- L+=T
+ teleport_turfs += T
- if(!L)
+ if(!length(teleport_turfs))
return
- affected_mob.say("SCYAR NILA [uppertext(thearea.name)]!")
- affected_mob.loc = pick(L)
+ affected_mob.say("SCYAR NILA [uppertext(chosen_area.name)]!")
+ affected_mob.forceMove(pick(teleport_turfs))
- return