library Cinema requires TimerUtils
globals //Privates
private integer FuncNum = 0
private integer ActNum = 1
endglobals
globals //"Globals"
location array ShapePoint
real Time
boolean IsInFade
string BlackFade = "ReplaceableTextures\\CameraMasks\\Black_mask.blp"
string WhiteFade = "ReplaceableTextures\\CameraMasks\\White_mask.blp"
string GroundFade = "ReplaceableTextures\\CameraMasks\\GroundFog_mask.blp"
string HazeFade = "ReplaceableTextures\\CameraMasks\\HazeFilter_mask.blp"
string HazeFogFade = "ReplaceableTextures\\CameraMasks\\HazeAndFogFilter_Mask.blp"
string DiagonalSlashFade = "ReplaceableTextures\\CameraMasks\\DiagonalSlash_mask.blp"
string DreamFade = "ReplaceableTextures\\CameraMasks\\DreamFilter_Mask.blp"
string ScopeFade = "ReplaceableTextures\\CameraMasks\\Scope_Mask.blp"
string PowFade = "ReplaceableTextures\\CameraMasks\\SpecialPowMask.blp"
string SplatFade = "ReplaceableTextures\\CameraMasks\\SpecialSplatMask.blp"
string PandaFade = "ReplaceableTextures\\CameraMasks\\Panda-n-Cub.blp"
endglobals
//! textmacro Func takes ActIndex, FuncIndex
function Act$ActIndex$F$FuncIndex$ takes nothing returns nothing
//! endtextmacro
//! textmacro EndFunc takes r
call Cinema.wait($r$)
endfunction
//! endtextmacro
//! textmacro cam takes n, d
call Cinema.cam(gg_cam_Camera_$n$, $d$)
//! endtextmacro
function Life takes nothing returns nothing
call BJDebugMsg("Life ran")
endfunction
struct Cinema //extends array yeaaaa structs
private unit SlideUnit
private real SlideReal
private static unit tempU
//implement Alloc
static method changeAct takes integer act returns nothing
set ActNum = act
set FuncNum = 0
endmethod
private static method waitEx takes nothing returns nothing
set FuncNum = FuncNum + 1
call ExecuteFunc("Act" + I2S(ActNum) + "F" + I2S(FuncNum))
call BJDebugMsg("Act" + I2S(ActNum) + "F" + I2S(FuncNum))
endmethod
static method wait takes real sec returns nothing
call BJDebugMsg("ran")
set Time = Time + sec
call TimerStart(CreateTimer(), 4, false, function Life)
call TimerStart(CreateTimer(), sec, false, function Cinema.waitEx)
call BJDebugMsg("ran complete")
endmethod
static method waitCus takes real sec, code func returns nothing
call TimerStart(CreateTimer(), sec, false, func)
endmethod
static method fade takes integer fadetype, real duration, string tex, real Red, real Green, real Blue, real Trans returns nothing
local integer red = R2I(Red)
local integer green = R2I(Green)
local integer blue = R2I(Blue)
local integer trans = R2I(Trans)
if (fadetype == 1) then
set IsInFade = true
if (bj_cineFadeContinueTimer != null) then
call DestroyTimer(bj_cineFadeContinueTimer)
endif
if (bj_cineFadeFinishTimer != null) then
call DestroyTimer(bj_cineFadeFinishTimer)
endif
call EnableUserUI(false)
call SetCineFilterTexture(tex)
call SetCineFilterBlendMode(BLEND_MODE_BLEND)
call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
call SetCineFilterStartUV(0, 0, 1, 1)
call SetCineFilterEndUV(0, 0, 1, 1)
call SetCineFilterStartColor(red, green, blue, 0)
call SetCineFilterEndColor(red, green, blue, 255-trans)
call SetCineFilterDuration(duration)
call DisplayCineFilter(true)
elseif (fadetype == 2) then
set IsInFade = false
if (bj_cineFadeContinueTimer != null) then
call DestroyTimer(bj_cineFadeContinueTimer)
endif
if (bj_cineFadeFinishTimer != null) then
call DestroyTimer(bj_cineFadeFinishTimer)
endif
call EnableUserUI(false)
call SetCineFilterTexture(tex)
call SetCineFilterBlendMode(BLEND_MODE_BLEND)
call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
call SetCineFilterStartUV(0, 0, 1, 1)
call SetCineFilterEndUV(0, 0, 1, 1)
call SetCineFilterStartColor(red, green, blue, 255-trans)
call SetCineFilterEndColor(red, green, blue, 0)
call SetCineFilterDuration(duration)
call DisplayCineFilter(true)
set bj_cineFadeFinishTimer = CreateTimer()
call TimerStart(bj_cineFadeFinishTimer, duration, false, function FinishCinematicFadeBJ)
endif
endmethod
static method talk takes string s, real dur, sound snd returns nothing
local real x = 1 - (I2R(StringLength(s)) * 0.004)
local real y = (R2I(I2R(StringLength(s)) / 70) + 1) * 0.1
call TimerStart(CreateTimer(), I2R(GetSoundDuration(snd)) * 0.001, false, function ClearTextMessages)
call DisplayTimedTextToPlayer(Player(0), x, y, I2R(GetSoundDuration(snd)) * 0.001, "\n\n\n\n\n\n" + s + "\n\n\n\n\n\n\n\n\n\n\n\n")
call StartSound(snd)
endmethod
private static method goDown takes nothing returns nothing
local timer t = GetExpiredTimer()
local Cinema cin = thistype(GetTimerData(t))
call SetUnitFlyHeight(cin.SlideUnit, 0, (GetUnitFlyHeight(cin.SlideUnit) / cin.SlideReal))
set cin.SlideUnit = null
set cin.SlideReal = 0
call cin.destroy()
call ReleaseTimer(t)
endmethod
static method slide takes unit u, real height, real dur, location where returns nothing
local location l = GetUnitLoc(u)
local real ddur = dur / 2
local real dx = GetLocationX(where) - GetLocationX(l)
local real dy = GetLocationY(where) - GetLocationY(l)
local Cinema cin = Cinema.create()
if height > 0 then
if height != 0 then
set cin.SlideUnit = u
set cin.SlideReal = ddur
call SetUnitFlyHeight(u, height, height / ddur)
call TimerStart(NewTimerEx(integer(cin)), ddur, false, function Cinema.goDown)
endif
set udg_Knockback2DAngle = bj_RADTODEG * Atan2(GetLocationY(where) - GetLocationY(l), GetLocationX(where) - GetLocationX(l))
set udg_Knockback2DTime = dur
set udg_Knockback2DDistance = SquareRoot(dx * dx + dy * dy)
set udg_Knockback2DUnit = u
set udg_Knockback2DCollision = -1.00
set udg_Knockback2DSimple = true
call TriggerExecute(gg_trg_Knockback_2D)
endif
call RemoveLocation(l)
endmethod
static method createEqualShape takes location center, real radius, integer points returns nothing
local real x
local real y
local integer i = 1
loop
exitwhen i > points
set x = GetLocationX(center) + radius * Cos(360 / points * i * bj_DEGTORAD)
set y = GetLocationY(center) + radius * Sin(360 / points * i * bj_DEGTORAD)
set ShapePoint[i] = Location(x, y)
set i = i + 1
endloop
endmethod
static method look takes unit u, real startx, real starty, real startz, real endx, real endy, real endz, real dur returns nothing
local location l = Location(startx, starty)
local unit dum = CreateUnitAtLoc(Player(15), 'n000', l, 270)
local real dx = endx - startx
local real dy = endy - starty
set udg_Knockback2DAngle = bj_RADTODEG * Atan2(dy, dx)
set udg_Knockback2DTime = dur
set udg_Knockback2DDistance = SquareRoot(dx * dx + dy * dy)
set udg_Knockback2DUnit = dum
set udg_Knockback2DCollision = -1.00
set udg_Knockback2DSimple = true
call TriggerExecute(gg_trg_Knockback_2D)
call SetUnitFlyHeight(dum, startz, 0)
if dur == 0 then
call SetUnitFlyHeight(dum, endz, 0)
else
call SetUnitFlyHeight(dum, endz, endz / dur)
endif
call SetUnitLookAt(u, "bone_head", dum, 0, 0, 0)
call RemoveLocation(l)
set l = null
set dum = null
endmethod
static method cam takes camerasetup c, real dur returns nothing
call CameraSetupApplyForceDuration(c, true, dur)
endmethod
static method startPreload takes nothing returns nothing
set Cinema.tempU = CreateUnit(Player(0), 'n000', 0, 0, 0)
endmethod
static method preloadEffect takes string path returns nothing
call AddSpecialEffect(path, 0, 0)
endmethod
static method preloadAbility takes integer abil returns nothing
call UnitAddAbility(Cinema.tempU, abil)
call UnitRemoveAbility(Cinema.tempU, abil)
endmethod
static method endPreload takes nothing returns nothing
call RemoveUnit(Cinema.tempU)
set Cinema.tempU = null
endmethod
endstruct
endlibrary
//WARNING: Touch if you know what you're doing.
//! inject config
call SetPlayers(1)
call DefineStartLocation(0, 704.0, - 832.0)
call InitCustomPlayerSlots()
call PlayMusic("Secrets.mp3")
//! endinject