library CIN initializer RegisterCinematicSystem
/* README ***************************************************************************************************************************************************************************************************************************
*** About:
This system can be used to create skippable cinematic transmissions.
Transmissions can be skipped by pressing the ESC button. This can be allowed for each player at map initialization.
The system can be used to display video transmissions or subtitle transmissions, which can be skipped for each player
independently.
IF YOU DO NOT HAVE AN EDITOR, THAT CAN HANDLE vJASS (e.g. JNGP), PLEASE CHECK OUT THE FOLDER "USE THIS IN NORMAL GUI"
***
***
*** How to use (a-c):
a) transmission styles
there are 5 transmission styles to control the system in single or multiple following transmissions.
these styles can be requested by using integer numbers from 1 to 5. For convenience, they can be used by named integer variables:
default variable string - integer system no. - what effect does it create?
--------------------------------------------------------------------------------------------------------------------------------
udg_CINE_SCENE_SUBTITLES - 1 - Creates text transmissions in subtitle style. UI won't be affected.
udg_CINE_SCENE_FADEOUTIN - 2 - Normal cinematic transmission style. Fade UI out before and in after video scene.
udg_CINE_SCENE_FADEOUT_KEEP_UI - 3 - Fade UI in for video transmission and keep the interface hidden for next transmission
udg_CINE_SCENE_KEEP_UI_FADEIN - 4 - Do not fade UI out, instead use interface from last transmission, and fade in UI to exit to game interface after this transmission
udg_CINE_SCENE_KEEP_UI - 5 - Intermediate transmission, do not fade out UI nor in.
b) using the system
- call the function:
PLAYER_CINEMATIK takes player p, integer interfaceMod, real fadeDuration1, real fadeDuration2, unit transmissionUnit, string title, string text, real wait, sound sounddat, boolean skippable returns nothing
player p: this is the player affected (locally)
interfaceMod: transmission style (see a))
fadeDuration1: time to fade out game interface
fadeDuration2: time to fade in game interface
transmissionUnit: unit, that transmitts the transmission
title: title of the transmission (e.g. unit name)
text: transmission text
wait: transmission time, this is the duration of the transmission
sounddat: sound for transmission
skippable: is transmission skippable or not?
- set the value skippable to TRUE, if you want the transmission to be skippable or to FALSE, if not.
c) placing the system call in your triggers:
- as the transmission system uses TriggerSleepAction() a.k.a trigger waits, it is important not to place code under the function call.
that is not "consistent" (e.g. event responses, global variables that may change, etc.)
***
***
*** How to make multiple transmissions:
- 1. transmission: udg_CINE_SCENE_FADEOUT_KEEP_UI (style 3)
- intermediate transmissions: udg_CINE_SCENE_KEEP_UI (style 5)
- last transmission: udg_CINE_SCENE_KEEP_UI_FADEIN (style 4)
*** How to use transmissions without sound:
- use udg_CINE_SOUND_NONE or the expression null for sounddat at system call, if you do not want to display sound in a transmission.
*** How to use udg_CINE_SOUND_FADEOUT:
- this value defines, whether a sound will be stopped after a transmission ends or not.
- FALSE means, it will be stopped.
- set this value to TRUE, if you want the sound to play to the end, if transmission ends
- NOTE: set it back to FALSE after the transmission to assure proper functioning of the system.
*** How many transmissions at one time point are possible?
- The system is fully MPI, but you can only display one transmission per player at the same time.
END README ***************************************************************************************************************************************************************************************************************************
*** System Array:
[Id+ 0*A] Transmission already on?
[Id+ 1*A] Transmission is allowed to be skipped for player
[Id+ 2*A] Transmission has been already skipped by player
(1 == true, 0 == false) */
globals
private integer array CINE_DATA // this is used as an internal array to store all system related info
private integer A = bj_MAX_PLAYERS // this is just to increase readability
endglobals
// ***************************************************************************************************************
// SKIP CINEMATIC TRANSMISSIONS
// **************************************************************************************************************
private function PLAYER_CINEMATIC_CONDITION takes nothing returns boolean
// only allow a player to skip a function, that is enabled to do so
return CINE_DATA[GetPlayerId( GetTriggerPlayer())+A] == 1
endfunction
private function PLAYER_CINEMATIC_SKIP takes nothing returns nothing
// if a player is allowed to skip a cinematic by pressing the ESC button, do so now
local player cinePlayer = GetTriggerPlayer()
local integer playerId = GetPlayerId( cinePlayer)
// End cinematic scene
if GetLocalPlayer() == cinePlayer then
call EndCinematicScene()
endif
// STORE "BEING SKIPPED"
set CINE_DATA[playerId+(2*A)] = 1
set cinePlayer = null
endfunction
// ***************************************************************************************************************
// TRANSMISSION MODULE
// **************************************************************************************************************
public function PLAYER_CINEMATIC takes player p, integer interfaceMod, real fadeDuration1, real fadeDuration2, unit transmissionUnit, string title, string text, real wait, sound sounddat, boolean skippable returns nothing
// Main function to call the system
local integer playerId = GetPlayerId( p)
local integer i = 0
local timer TRANSMISSION_WAITING
// Do not allow more than one transmission for the same player
if CINE_DATA[playerId] == 0 then
set CINE_DATA[playerId] = 1 // Lock Transmission status directly after starting to disable re-triggering.
set TRANSMISSION_WAITING = CreateTimer()
// Check for interfaceMod of requested transmission
if interfaceMod == 1 then
// interfaceMod == 1: Subtitle style
if GetLocalPlayer() == p then
call ForceCinematicSubtitles( TRUE)
endif
elseif ( interfaceMod == 2 ) or ( interfaceMod == 3 ) then
// interfaceMod == 2: Standard Transmissions
// interfaceMod == 3: First of Multitransmissions (Keep Interface later)
if GetLocalPlayer() == p then
call ShowInterface( FALSE, fadeDuration1)
endif
endif
// interfaceMod == 4: dont show interface, because its already on, but hide after this one!
// interfaceMod >= 5: do not change anything, because UI has to be kept during intermediate transmissions
// skippable means, transmission can be skipped entirely for this specific player!
if skippable then
set CINE_DATA[playerId+A] = 1 // skippable
else
set CINE_DATA[playerId+A] = 0 // not skippable
endif
// Blizzard Transmission Parameters
set bj_lastTransmissionDuration = wait
set bj_lastPlayedSound = sounddat
set bj_cineSceneLastSound = sounddat
// set up transmission sound and store transmission sound information
if sounddat != null and (GetLocalPlayer() == p) then
call StartSound( sounddat)
endif
// Set up the actual transmission
if GetLocalPlayer() == p then
call SetCinematicScene( GetUnitTypeId( transmissionUnit), GetPlayerColor( p), title, text, bj_lastTransmissionDuration + bj_TRANSMISSION_PORT_HANGTIME, bj_lastTransmissionDuration)
call PingMinimap( GetUnitX( transmissionUnit), GetUnitY( transmissionUnit), bj_TRANSMISSION_PING_TIME)
if not IsUnitHidden( transmissionUnit) then
call UnitAddIndicator( transmissionUnit, bj_TRANSMISSION_IND_RED, bj_TRANSMISSION_IND_BLUE, bj_TRANSMISSION_IND_GREEN, bj_TRANSMISSION_IND_ALPHA)
endif
endif
// wait for transmission time
call TimerStart( TRANSMISSION_WAITING, bj_lastTransmissionDuration, FALSE, null)
loop
exitwhen TimerGetRemaining( TRANSMISSION_WAITING) == 0.00 or (CINE_DATA[playerId+(2*A)] == 1)
call TriggerSleepAction(0.10)
endloop
// After end of transmission (if skipped or not), reset UI, if needed (true for 1,2,4)
// Do specific changes for each cinematic set up
if interfaceMod == 1 then
// Force subtitle transmissions to end
if GetLocalPlayer() == p then
call ForceCinematicSubtitles( FALSE)
call ClearTextMessages()
endif
elseif ( interfaceMod == 2 ) or ( interfaceMod == 4 ) then
// show interface after normal cinematic style (2) and if end of multi transmissions (4)
if GetLocalPlayer() == p then
call ShowInterface( TRUE, 0.10)
endif
endif
// End the cinematic Sound, if there is one
if sounddat != null and (GetLocalPlayer() == p) then
call StopSound( sounddat, FALSE, udg_CINE_SOUND_FADEOUT)
endif
// reset the system for Array Layer 1 and 3 (keep the other values for more transmissions)
set CINE_DATA[playerId] = 0 // Release Transmission to Off to allow new transmissions
set CINE_DATA[playerId+A] = 0 // Reset skippable transmissions
set CINE_DATA[playerId+2*A] = 0 // Release Cinematik Skippable
call DestroyTimer( TRANSMISSION_WAITING)
endif
set TRANSMISSION_WAITING = null
endfunction
function RegisterCinematicSystemExecute takes nothing returns nothing
// this trigger initializes the system and creates a trigger, to skip cinematic transimssions
local timer t = GetExpiredTimer()
local integer index = 0
local trigger cineTrig = CreateTrigger()
local player cinePlayer
loop
exitwhen index > A - 1
// register playing players, that are allowed to skip cinematic transmissions
if udg_CINE_ALLOWED_TO_SKIP[index] then
set cinePlayer = Player( index)
if GetPlayerSlotState( cinePlayer) == PLAYER_SLOT_STATE_PLAYING then
// Initialize the transmission ESC function
call TriggerRegisterPlayerEvent( cineTrig, cinePlayer, EVENT_PLAYER_END_CINEMATIC)
endif
endif
set index = index + 1
endloop
call TriggerAddCondition( cineTrig, function PLAYER_CINEMATIC_CONDITION)
call TriggerAddAction( cineTrig, function PLAYER_CINEMATIC_SKIP)
call DestroyTimer( t)
set t = null
set cineTrig = null
set cinePlayer = null
endfunction
function RegisterCinematicSystem takes nothing returns nothing
call TimerStart( CreateTimer(), 0., FALSE, function RegisterCinematicSystemExecute)
endfunction
endlibrary