Skip to content

Commit

Permalink
Fixes & Updates cinematics (#495)
Browse files Browse the repository at this point in the history
* Fixes & Updates cinematics

* Reduces time cinematic is on the screen

From 30 seconds to 22.
  • Loading branch information
EgorDinamit authored Dec 29, 2023
1 parent 68767b0 commit 66c7b07
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions code/datums/cinematic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ GLOBAL_DATUM_INIT(cinematic, /datum/cinematic, new)
//station_explosion used to be a variable for every mob's hud. Which was a waste!
//Now we have a general cinematic centrally held within the gameticker....far more efficient!
var/obj/screen/cinematic_screen = null
/// List of clients currently watching a cinematic
var/list/watching_clients = list()

//Plus it provides an easy way to make cinematics for other events. Just use this as a template :)
/datum/cinematic/proc/station_explosion_cinematic(var/station_missed=0, var/datum/game_mode/override)
/datum/cinematic/proc/station_explosion_cinematic(station_missed = FALSE, datum/game_mode/override)
set waitfor = FALSE

if(cinematic_screen)
return //already a cinematic in progress!
if(cinematic_screen)
return //already a cinematic in progress!

if(!override)
override = SSticker.mode
Expand All @@ -20,30 +22,39 @@ GLOBAL_DATUM_INIT(cinematic, /datum/cinematic, new)
if(!override)
return

//initialise our cinematic screen object
watching_clients = list()

// Initialise our cinematic screen object
cinematic_screen = new(src)
cinematic_screen.icon = 'icons/effects/station_explosion.dmi'
cinematic_screen.icon_state = "station_intact"
cinematic_screen.plane = HUD_PLANE
cinematic_screen.layer = HUD_ABOVE_ITEM_LAYER
cinematic_screen.mouse_opacity = 0
cinematic_screen.screen_loc = "1,0"

//Let's not discuss how this worked previously.
var/list/viewers = list()
for(var/mob/living/M in GLOB.living_mob_list_)
if(M.client)
M.client.screen += cinematic_screen //show every client the cinematic
viewers[M.client] = M.stunned
M.stunned = 8000

override.nuke_act(cinematic_screen, station_missed) //cinematic happens here, as does mob death.
//If its actually the end of the round, wait for it to end.
//Otherwise if its a verb it will continue on afterwards.
sleep(30 SECONDS)

for(var/client/C in viewers)
cinematic_screen.screen_loc = "BOTTOM,LEFT+50%"
cinematic_screen.appearance_flags = APPEARANCE_UI | TILE_BOUND

for(var/client/C in GLOB.clients)
// Show every client the cinematic
C.screen += cinematic_screen
watching_clients += C
if(C.mob)
C.mob.stunned = viewers[C]
C.mob.stunned += 8000

// Cinematic happens here, as does mob death.
override.nuke_act(cinematic_screen, station_missed)
// If its actually the end of the round, wait for it to end.
// Otherwise if its a verb it will continue on afterwards.
sleep(20 SECONDS)

animate(cinematic_screen, alpha = 0, time = (2 SECONDS))

sleep(2 SECONDS)

for(var/client/C in watching_clients)
C.screen -= cinematic_screen
QDEL_NULL(cinematic_screen)
if(C.mob)
C.mob.stunned = max(0, C.mob.stunned - 8000)

watching_clients = list()
QDEL_NULL(cinematic_screen)

0 comments on commit 66c7b07

Please sign in to comment.