From 3900244db04ede2111a4d988e49eeee66d0f4d79 Mon Sep 17 00:00:00 2001
From: Tails2091 <40816748+Tails2091@users.noreply.github.com>
Date: Wed, 22 Aug 2018 20:10:42 -0400
Subject: [PATCH 1/5] Hallucination Refactor
---
code/modules/flufftext/Hallucination.dm | 45 +++++++++++++------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/code/modules/flufftext/Hallucination.dm b/code/modules/flufftext/Hallucination.dm
index d8a1f4f1526..e3d139696c8 100644
--- a/code/modules/flufftext/Hallucination.dm
+++ b/code/modules/flufftext/Hallucination.dm
@@ -36,7 +36,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
handling_hal = 1
while(hallucination > 20)
- sleep(rand(200, 500) / (hallucination / 25))
+ sleep(rand(200, 500) / (hallucination * 0.04))
if(prob(20))
continue
var/list/current = list()
@@ -253,7 +253,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
break
if(pump)
borer = new(pump.loc,target)
- for(var/i=0, i<11, i++)
+ for(var/i in 0 to 10)
walk_to(borer, get_step(borer, get_cardinal_dir(borer, T)))
if(borer.Adjacent(T))
to_chat(T, "You feel a creeping, horrible sense of dread come over you, freezing your limbs and setting your heart racing.")
@@ -331,10 +331,10 @@ Gunshots/explosions/opening doors/less rare audio (done)
target = T
var/turf/start = get_turf(T)
var/screen_border = pick(cardinal)
- for(var/i = 0,i<11,i++)
+ for(var/i in 0 to 10)
start = get_step(start, screen_border)
s = new(start,target)
- for(var/i = 0,i<11,i++)
+ for(var/i in 0 to 10)
sleep(5)
s.loc = get_step(get_turf(s), get_dir(s, target))
s.Show()
@@ -359,10 +359,10 @@ Gunshots/explosions/opening doors/less rare audio (done)
/obj/effect/hallucination/battle/New(loc, mob/living/carbon/T)
target = T
- var/hits = rand(3,6)
+ var/hits = rand(2,5)
switch(rand(1,5))
if(1) //Laser fight
- for(var/i=0,i0, i--)
+ for(var/i = rand(1,3), i>0, i--) //Can this be formatted?
playsound_local(null, 'sound/weapons/empty.ogg', 15, 1)
sleep(rand(10,30))
playsound_local(null, 'sound/machines/airlockforced.ogg', 15, 1)
From ab36512935be25a5869ce919262020f06d4df34a Mon Sep 17 00:00:00 2001
From: Tails2091 <40816748+Tails2091@users.noreply.github.com>
Date: Thu, 23 Aug 2018 14:46:29 -0400
Subject: [PATCH 2/5] Removed My Useless Comment
And formatted another loop...
---
code/modules/flufftext/Hallucination.dm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/modules/flufftext/Hallucination.dm b/code/modules/flufftext/Hallucination.dm
index e3d139696c8..00e8166e94e 100644
--- a/code/modules/flufftext/Hallucination.dm
+++ b/code/modules/flufftext/Hallucination.dm
@@ -866,7 +866,7 @@ var/list/non_fakeattack_weapons = list(/obj/item/gun/projectile, /obj/item/ammo_
if(16)
playsound_local(null, 'sound/items/Screwdriver.ogg', 15, 1)
sleep(rand(10,30))
- for(var/i = rand(1,3), i>0, i--) //Can this be formatted?
+ for(var/i in 0 to rand(1,3))
playsound_local(null, 'sound/weapons/empty.ogg', 15, 1)
sleep(rand(10,30))
playsound_local(null, 'sound/machines/airlockforced.ogg', 15, 1)
From ea49c4116772a70efd26b7546c24781bbd6d2ad3 Mon Sep 17 00:00:00 2001
From: Tails2091 <40816748+Tails2091@users.noreply.github.com>
Date: Fri, 24 Aug 2018 21:21:29 -0400
Subject: [PATCH 3/5] Replaced Some Hallucination Spawns
---
code/modules/flufftext/Hallucination.dm | 38 +++++++++++--------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/code/modules/flufftext/Hallucination.dm b/code/modules/flufftext/Hallucination.dm
index 00e8166e94e..f28e7cb2526 100644
--- a/code/modules/flufftext/Hallucination.dm
+++ b/code/modules/flufftext/Hallucination.dm
@@ -21,7 +21,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
var/image/halbody
var/obj/halitem
var/hal_screwyhud = SCREWYHUD_NONE
- var/handling_hal = 0
+ var/handling_hal = FALSE
/mob/living/carbon/proc/handle_hallucinations()
if(handling_hal)
@@ -34,7 +34,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
//AAAAHg
var/list/major = list("fake"=20,"death"=10,"xeno"=10,"singulo"=10,"borer"=10,"delusion"=20,"koolaid"=10)
- handling_hal = 1
+ handling_hal = TRUE
while(hallucination > 20)
sleep(rand(200, 500) / (hallucination * 0.04))
if(prob(20))
@@ -51,7 +51,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
var/halpick = pickweight(current)
hallucinate(halpick)
- handling_hal = 0
+ handling_hal = FALSE
/obj/effect/hallucination
@@ -70,7 +70,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
var/col_mod = null
var/image/current_image = null
var/image_layer = MOB_LAYER
- var/active = 1 //qdelery
+ var/active = TRUE //qdelery
/obj/effect/hallucination/simple/New(loc, mob/living/carbon/T)
..()
@@ -113,7 +113,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
/obj/effect/hallucination/simple/Destroy()
if(target.client)
target.client.images.Remove(current_image)
- active = 0
+ active = FALSE
return ..()
#define FAKE_FLOOD_EXPAND_TIME 20
@@ -198,7 +198,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
pump = U
break
if(!pump)
- return 0
+ return FALSE
xeno = new(pump.loc,target)
sleep(10)
if(!xeno)
@@ -605,11 +605,9 @@ Gunshots/explosions/opening doors/less rare audio (done)
/obj/effect/fake_attacker/New(loc, mob/living/carbon/T)
..()
my_target = T
- spawn(300)
- qdel(src)
+ addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, src), 300)
step_away(src,my_target,2)
- spawn(0)
- attack_loop()
+ addtimer(CALLBACK(src, .proc/attack_loop))
/obj/effect/fake_attacker/proc/updateimage()
@@ -673,8 +671,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
O.name = "blood"
var/image/I = image('icons/effects/blood.dmi',O,"floor[rand(1,7)]",O.dir,1)
target << I
- spawn(300)
- qdel(O)
+ addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, O), 300)
return
var/list/non_fakeattack_weapons = list(/obj/item/gun/projectile, /obj/item/ammo_box/a357,\
@@ -829,19 +826,17 @@ var/list/non_fakeattack_weapons = list(/obj/item/gun/projectile, /obj/item/ammo_
if(9)
//To make it more realistic, I added two gunshots (enough to kill)
playsound_local(null, 'sound/weapons/Gunshot.ogg', 25, 1)
- spawn(rand(10,30))
- playsound_local(null, 'sound/weapons/Gunshot.ogg', 25, 1)
- sleep(rand(5,10))
- playsound_local(null, sound(get_sfx("bodyfall"), 25), 25, 1)
+ var/timer_pause = rand(10,30)
+ addtimer(CALLBACK(GLOBAL_PROC, .proc/playsound_local, null, 'sound/weapons/Gunshot.ogg', 25, 1), timer_pause)
+ addtimer(CALLBACK(GLOBAL_PROC, .proc/playsound_local, null, sound(get_sfx("bodyfall"), 25), 25, 1), timer_pause+rand(5,10))
if(10)
playsound_local(null, 'sound/effects/pray_chaplain.ogg', 50)
if(11)
//Same as above, but with tasers.
playsound_local(null, 'sound/weapons/Taser.ogg', 25, 1)
- spawn(rand(10,30))
- playsound_local(null, 'sound/weapons/Taser.ogg', 25, 1)
- sleep(rand(5,10))
- playsound_local(null, sound(get_sfx("bodyfall"), 25), 25, 1)
+ var/timer_pause = rand(10,30)
+ addtimer(CALLBACK(GLOBAL_PROC, .proc/playsound_local, null, 'sound/weapons/Taser.ogg', 25, 1), timer_pause)
+ addtimer(CALLBACK(GLOBAL_PROC, .proc/playsound_local, null, sound(get_sfx("bodyfall"), 25), 25, 1), timer_pause+rand(5,10))
//Rare audio
if(12)
//These sounds are (mostly) taken from Hidden: Source
@@ -988,8 +983,7 @@ var/list/non_fakeattack_weapons = list(/obj/item/gun/projectile, /obj/item/ammo_
halitem.icon_state = "flashbang1"
halitem.name = "Flashbang"
if(client) client.screen += halitem
- spawn(rand(100,250))
- qdel(halitem)
+ addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, halitem), rand(100,250))
if("dangerflash")
//Flashes of danger
if(!halimage)
From 7bacfd2af144e00d52978f3dde9333b11e0a6e37 Mon Sep 17 00:00:00 2001
From: Tails2091
Date: Sun, 9 Sep 2018 21:15:28 -0400
Subject: [PATCH 4/5] More Consolidation
Used some loops instead of repeated code. (also removed a variable)
---
code/modules/flufftext/Hallucination.dm | 41 ++++++++++---------------
1 file changed, 16 insertions(+), 25 deletions(-)
diff --git a/code/modules/flufftext/Hallucination.dm b/code/modules/flufftext/Hallucination.dm
index f28e7cb2526..2e2c0695afd 100644
--- a/code/modules/flufftext/Hallucination.dm
+++ b/code/modules/flufftext/Hallucination.dm
@@ -48,9 +48,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
if(86 to 100)
current = major
- var/halpick = pickweight(current)
-
- hallucinate(halpick)
+ hallucinate(pickweight(current))
handling_hal = FALSE
@@ -198,21 +196,17 @@ Gunshots/explosions/opening doors/less rare audio (done)
pump = U
break
if(!pump)
- return FALSE
+ return
xeno = new(pump.loc,target)
sleep(10)
if(!xeno)
return
- xeno.update_icon("alienh_leap",'icons/mob/alienleap.dmi',-32,-32)
- xeno.throw_at(target,7,1, spin = 0, diagonals_first = 1)
- sleep(10)
- if(!xeno)
- return
- xeno.update_icon("alienh_leap",'icons/mob/alienleap.dmi',-32,-32)
- xeno.throw_at(pump,7,1, spin = 0, diagonals_first = 1)
- sleep(10)
- if(!xeno)
- return
+ for(var/i in 0 to 2)
+ xeno.update_icon("alienh_leap",'icons/mob/alienleap.dmi',-32,-32)
+ xeno.throw_at(target,7,1, spin = 0, diagonals_first = 1)
+ sleep(10)
+ if(!xeno)
+ return
var/xeno_name = xeno.name
to_chat(target, "[xeno_name] begins climbing into the ventilation system...")
sleep(10)
@@ -813,10 +807,9 @@ var/list/non_fakeattack_weapons = list(/obj/item/gun/projectile, /obj/item/ammo_
playsound_local(null, pick('sound/effects/Glassbr1.ogg','sound/effects/Glassbr2.ogg','sound/effects/Glassbr3.ogg'), 50, 1)
if(5)
playsound_local(null, 'sound/weapons/ring.ogg', 35)
- sleep(15)
- playsound_local(null, 'sound/weapons/ring.ogg', 35)
- sleep(15)
- playsound_local(null, 'sound/weapons/ring.ogg', 35)
+ for(var/i in 0 to 2)
+ sleep(15)
+ playsound_local(null, 'sound/weapons/ring.ogg', 35)
if(6)
playsound_local(null, 'sound/magic/Summon_guns.ogg', 50, 1)
if(7)
@@ -873,10 +866,9 @@ var/list/non_fakeattack_weapons = list(/obj/item/gun/projectile, /obj/item/ammo_
playsound_local(null, 'sound/AI/outbreak5.ogg')
if(19) //Tesla loose!
playsound_local(null, 'sound/magic/lightningbolt.ogg', 35, 1)
- sleep(20)
- playsound_local(null, 'sound/magic/lightningbolt.ogg', 65, 1)
- sleep(20)
- playsound_local(null, 'sound/magic/lightningbolt.ogg', 100, 1)
+ for(var/i in 0 to 2)
+ sleep(20)
+ playsound_local(null, 'sound/magic/lightningbolt.ogg', 65+(35*(i-1)), 1) //65%, then 100% volume.
if(20) //AI is doomsdaying!
to_chat(src, "Anomaly Alert
")
to_chat(src, "
Hostile runtimes detected in all station systems, please deactivate your AI to prevent possible damage to its morality core.
")
@@ -1002,8 +994,7 @@ var/list/non_fakeattack_weapons = list(/obj/item/gun/projectile, /obj/item/ammo_
halimage = image('icons/turf/floors/Chasms.dmi',target,"smooth",TURF_LAYER)
if(4)
halimage = image('icons/obj/assemblies.dmi',target,"plastic-explosive2",OBJ_LAYER+0.01)
-
-
+
if(client)
client.images += halimage
sleep(rand(40,60)) //Only seen for a brief moment.
@@ -1049,4 +1040,4 @@ var/list/non_fakeattack_weapons = list(/obj/item/gun/projectile, /obj/item/ammo_
spawn(rand(30,50)) //Only seen for a brief moment.
if(client)
client.images -= halbody
- halbody = null
+ halbody = null
\ No newline at end of file
From 42b73ad17650d254ee2a4b209328a1f27303c61c Mon Sep 17 00:00:00 2001
From: Tails2091
Date: Thu, 27 Sep 2018 12:02:52 -0400
Subject: [PATCH 5/5] Replaced addtimer() with INVOKE_ASYNC()
---
code/modules/flufftext/Hallucination.dm | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/code/modules/flufftext/Hallucination.dm b/code/modules/flufftext/Hallucination.dm
index 2e2c0695afd..74a0baf8cd5 100644
--- a/code/modules/flufftext/Hallucination.dm
+++ b/code/modules/flufftext/Hallucination.dm
@@ -601,8 +601,7 @@ Gunshots/explosions/opening doors/less rare audio (done)
my_target = T
addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, src), 300)
step_away(src,my_target,2)
- addtimer(CALLBACK(src, .proc/attack_loop))
-
+ INVOKE_ASYNC(src, .proc/attack_loop)
/obj/effect/fake_attacker/proc/updateimage()
// qdel(src.currentimage)