- Joined
- Nov 20, 2005
- Messages
- 1,156
Again, taken from Destiny's Wake, my transmission functions. Basically, you can have skippable and unskippable, voiced and not voiced, and stuff like that, with easy to use functions. The basic version requires you to press escape to move along, after you have read the text.
Easiest way to explain is to take a look at the map I used it in: http://www.hiveworkshop.com/resources_new/maps/6283/
If you wanted, you could put in timed versions whereby it was either after a time or after they escape, but personally I don't feel a need for that.
NB: This is single player ONLY. Will (almost) certainly desync on multiplayer.
Example usage:
This one is skippable with voice. You do an initial transmission, put the next one in the buffer, and then do WaitBuffer to display the next one when they skip.
Another example, this time unskippable:
Easiest way to explain is to take a look at the map I used it in: http://www.hiveworkshop.com/resources_new/maps/6283/
If you wanted, you could put in timed versions whereby it was either after a time or after they escape, but personally I don't feel a need for that.
NB: This is single player ONLY. Will (almost) certainly desync on multiplayer.
JASS:
library TransmissionFuncs initializer Init
globals
private unit bufferUnit
private string bufferName
private string bufferMessage = null
private string bufferSound = null
private sound currentSound = null
private string currentSoundString = null
private boolean EscapeInterrupt = false
boolean END_AFTER_VOICE = true // this controls whether or not the transmission is auto-skipped after the end of a voiced bit.
private timer soundTimer
private string soundTimerString
boolean InCinematic = false
private code interEx
endglobals
// InCinematic should be set properly to avoid problems with the interrupt.
function CinematicModeOn takes nothing returns nothing
set InCinematic = true
call CinematicModeBJ(true, bj_FORCE_ALL_PLAYERS)
endfunction
function CinematicModeOff takes nothing returns nothing
set InCinematic = false
call CinematicModeBJ(false, bj_FORCE_ALL_PLAYERS)
endfunction
private function Interruption takes nothing returns nothing
if InCinematic then
if bufferMessage != null then
call TimerStart(CreateTimer(), 0.00, false, interEx)
else
set EscapeInterrupt = true
endif
if currentSound != null and bufferSound != currentSoundString then
call StopSound(currentSound, true, false)
endif
endif
endfunction
private function SetupVoice takes string snd returns nothing
if currentSound != null then
call KillSoundWhenDone(currentSound)
endif
call Preload(snd)
set currentSound = CreateSound(snd, false, false, false, 10, 10, "")
call StartSound(currentSound)
set currentSoundString = snd
endfunction
private function SoundOver takes nothing returns nothing
if soundTimer == GetExpiredTimer() and soundTimerString == currentSoundString then
call Interruption.execute()
endif
call DestroyTimer(GetExpiredTimer())
endfunction
function DisplayText takes string data returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0., 0., data)
endfunction
function Transmission takes unit talker, string name, string message returns nothing
call TransmissionFromUnitWithNameBJ( bj_FORCE_ALL_PLAYERS, talker, name, null, message, bj_TIMETYPE_ADD, 9999., false )
endfunction
function TransmissionSound takes unit talker, string name, string message, string snd returns nothing
local timer t
call SetupVoice(snd)
call TransmissionFromUnitWithNameBJ( bj_FORCE_ALL_PLAYERS, talker, name, null, message, bj_TIMETYPE_ADD, 9999., false )
if END_AFTER_VOICE then
set t = CreateTimer()
set soundTimer = t
set soundTimerString = snd
call TimerStart(t, I2R(GetSoundDuration(currentSound)) * 0.003 + 0.25, false, function SoundOver) // Why this is so, I have no idea. It just works.
endif
endfunction
function TransmissionAndBuffer takes unit talker, string name, string message returns nothing
call TransmissionFromUnitWithNameBJ( bj_FORCE_ALL_PLAYERS, talker, name, null, message, bj_TIMETYPE_ADD, 9999., false )
set bufferUnit = talker
set bufferName = name
set bufferMessage = message
endfunction
function TransmissionSoundAndBuffer takes unit talker, string name, string message, string snd returns nothing
call SetupVoice(snd)
call TransmissionFromUnitWithNameBJ( bj_FORCE_ALL_PLAYERS, talker, name, null, message, bj_TIMETYPE_ADD, 9999., false )
set bufferUnit = talker
set bufferName = name
set bufferMessage = message
set bufferSound = snd
endfunction
function TransmissionTimed takes unit talker, string name, string message, real time returns nothing
call TransmissionFromUnitWithNameBJ( bj_FORCE_ALL_PLAYERS, talker, name, null, message, bj_TIMETYPE_ADD, time-5., false )
endfunction
function TransmissionBufferDisplay takes nothing returns nothing
call TransmissionFromUnitWithNameBJ( bj_FORCE_ALL_PLAYERS, bufferUnit, bufferName, null, bufferMessage, bj_TIMETYPE_ADD, 9999., false )
endfunction
function TransmissionBuffer takes unit talker, string name, string message returns nothing
set bufferUnit = talker
set bufferName = name
set bufferMessage = message
endfunction
function TransmissionSoundBuffer takes unit talker, string name, string message, string snd returns nothing
set bufferUnit = talker
set bufferName = name
set bufferMessage = message
set bufferSound = snd
endfunction
function TransmissionClearBuffer takes nothing returns nothing
set bufferUnit = null
set bufferName = null
set bufferMessage = null
set bufferSound = null
endfunction
// This waits for escape, and does nothing else
function WaitEscape takes nothing returns nothing
set EscapeInterrupt = false
loop
exitwhen EscapeInterrupt == true
call TriggerSleepAction(0.)
endloop
set EscapeInterrupt = false
endfunction
// This waits for escape, and then displays the buffer, used to stop someone skipping it.
function WaitBuffer takes nothing returns nothing
set EscapeInterrupt = false
loop
exitwhen EscapeInterrupt == true
call TriggerSleepAction(0.)
endloop
call TransmissionBufferDisplay()
set EscapeInterrupt = false
endfunction
// This clears the buffer, and then waits for escape. Used at the end of a transmission sequence.
function WaitConclude takes nothing returns nothing
set EscapeInterrupt = false
call TransmissionClearBuffer()
loop
exitwhen EscapeInterrupt == true
call TriggerSleepAction(0.)
endloop
set EscapeInterrupt = false
endfunction
private function InterruptionEx takes nothing returns nothing
if bufferSound != null and bufferSound != currentSoundString then
call TransmissionSound(bufferUnit, bufferName, bufferMessage, bufferSound)
set bufferSound = null
else
call Transmission(bufferUnit, bufferName, bufferMessage)
endif
set EscapeInterrupt = true
call DestroyTimer(GetExpiredTimer())
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic( t, GetLocalPlayer() )
call TriggerAddAction( t, function Interruption )
set interEx = function InterruptionEx
endfunction
endlibrary
Example usage:
This one is skippable with voice. You do an initial transmission, put the next one in the buffer, and then do WaitBuffer to display the next one when they skip.
JASS:
call CinematicModeOn()
call IssueImmediateOrder(udg_PlayerUnit, "holdposition")
call TransmissionSound(udg_PlayerUnit, udg_PlayerName, "HAI! Take that you fatty!", "Hai!.mp3")
call TransmissionSoundBuffer(udg_PlayerUnit, udg_PlayerName, "...they'll be after me....", "They'll be after me.mp3")
call WaitBuffer()
call TransmissionSoundBuffer(udg_PlayerUnit, udg_PlayerName, "...in force, too...", "In force, too.mp3")
call WaitBuffer()
call TransmissionSoundBuffer(udg_PlayerUnit, udg_PlayerName, "Maybe I should go talk to the people in that house over there; find out who's in charge.", "Maybe i should go talk.mp3")
call WaitBuffer()
call WaitConclude()
call CinematicModeOff()
Another example, this time unskippable:
JASS:
call CinematicModeOn()
call TransmissionAndBuffer(udg_PlayerUnit, udg_PlayerName, "...new day, new worries.")
call PolledWait(4.)
call TransmissionClearBuffer()
call CinematicModeOff()
Last edited: