// Cinematic Fade For Player
// Written by Elil
//
// This is a conversion of the cinematic fade triggers in "Blizzard.j" to fade
// the screen only for a single player, even when there are multiple players in the game.
//
// There is no problem executing the fade effect only for a single player using GetLocalPlayer()
// The problem comes from the timers used for cleanly ending the fade
// (and the timer for the middle of "fade out and back in"). If you put the standard fade call
// inside an asynchronous block, the game will desync because of the timers.
//
// The solution here is for every player to know about every timer.
// The timers will be registered and fired for everyone, and only the actual fading will be asynchronous.
//
// I mimic the functions in "Blizzard.j" as closely as possible, CinematicFadeCommonBJ
// is used asynchronously to do the actual fading. If you use both "For Player" fades and standard fades
// at the same time, you will have slight problems, because the fades will not cancel each other properly.
// For example if you do a "fade out and back in" locally, then immediately do a fast global fade,
// the global fade will happen, then the "middle" of the local fade will happen for that player.
//===========================================================================
function CinematicFadeCommonForPlayer takes player fadePlayer, real red, real green, real blue, real duration, string tex, real startTrans, real endTrans returns nothing
if (GetLocalPlayer() == fadePlayer) then
call CinematicFadeCommonBJ(red, green, blue, duration, tex, startTrans, endTrans)
endif
endfunction
//===========================================================================
function FinishCinematicFadeForPlayer takes nothing returns nothing
local integer fadePlayerId = 1
// We don't know which player the expired timer belongs to,
// so we check each player's timer to see if it matches the one that just expired.
loop
exitwhen udg_cineFadeFinishTimer[fadePlayerId] == GetExpiredTimer()
set fadePlayerId = fadePlayerId + 1
endloop
call DestroyTimer(udg_cineFadeFinishTimer[fadePlayerId])
set udg_cineFadeFinishTimer[fadePlayerId] = null
if (GetConvertedPlayerId(GetLocalPlayer()) == fadePlayerId) then
call DisplayCineFilter(false)
call EnableUserUI(true)
endif
endfunction
//===========================================================================
function FinishCinematicFadeAfterForPlayer takes player fadePlayer, real duration returns nothing
local integer fadePlayerId = GetConvertedPlayerId(fadePlayer)
// Create a timer to end the cinematic fade.
set udg_cineFadeFinishTimer[fadePlayerId] = CreateTimer()
call TimerStart(udg_cineFadeFinishTimer[fadePlayerId], duration, false, function FinishCinematicFadeForPlayer)
endfunction
//===========================================================================
function ContinueCinematicFadeForPlayer takes nothing returns nothing
local integer fadePlayerId = 1
// We don't know which player the expired timer belongs to,
// so we check each player's timer to see if it matches the one that just expired.
loop
exitwhen udg_cineFadeContinueTimer[fadePlayerId] == GetExpiredTimer()
set fadePlayerId = fadePlayerId + 1
endloop
call DestroyTimer(udg_cineFadeContinueTimer[fadePlayerId])
set udg_cineFadeContinueTimer[fadePlayerId] = null
call CinematicFadeCommonForPlayer(ConvertedPlayer(fadePlayerId), udg_cineFadeContinueRed, udg_cineFadeContinueGreen, udg_cineFadeContinueBlue, udg_cineFadeContinueDuration, udg_cineFadeContinueTex, udg_cineFadeContinueTrans, 100)
endfunction
//===========================================================================
function ContinueCinematicFadeAfterForPlayer takes player fadePlayer, real duration, real red, real green, real blue, real trans, string tex returns nothing
local integer fadePlayerId = GetConvertedPlayerId(fadePlayer)
if (GetLocalPlayer() == fadePlayer) then
set udg_cineFadeContinueRed = red
set udg_cineFadeContinueGreen = green
set udg_cineFadeContinueBlue = blue
set udg_cineFadeContinueTrans = trans
set udg_cineFadeContinueDuration = duration
set udg_cineFadeContinueTex = tex
endif
// Create a timer to continue the cinematic fade.
set udg_cineFadeContinueTimer[fadePlayerId] = CreateTimer()
call TimerStart(udg_cineFadeContinueTimer[fadePlayerId], duration, false, function ContinueCinematicFadeForPlayer)
endfunction
//===========================================================================
function AbortCinematicFadeForPlayer takes player fadePlayer returns nothing
local integer fadePlayerId = GetConvertedPlayerId(fadePlayer)
if (udg_cineFadeContinueTimer[fadePlayerId] != null) then
call DestroyTimer(udg_cineFadeContinueTimer[fadePlayerId])
endif
if (udg_cineFadeFinishTimer[fadePlayerId] != null) then
call DestroyTimer(udg_cineFadeFinishTimer[fadePlayerId])
endif
endfunction
function CinematicFadeForPlayer takes player fadePlayer, integer fadetype, real duration, string tex, real red, real green, real blue, real trans returns nothing
if (fadetype == bj_CINEFADETYPE_FADEOUT) then
// Fade out to the requested color.
call AbortCinematicFadeForPlayer(fadePlayer)
call CinematicFadeCommonForPlayer(fadePlayer, red, green, blue, duration, tex, 100, trans)
elseif (fadetype == bj_CINEFADETYPE_FADEIN) then
// Fade in from the requested color.
call AbortCinematicFadeForPlayer(fadePlayer)
call CinematicFadeCommonForPlayer(fadePlayer, red, green, blue, duration, tex, trans, 100)
call FinishCinematicFadeAfterForPlayer(fadePlayer, duration)
elseif (fadetype == bj_CINEFADETYPE_FADEOUTIN) then
// Fade out to the requested color, and then fade back in from it.
if (duration > 0) then
call AbortCinematicFadeForPlayer(fadePlayer)
call CinematicFadeCommonForPlayer(fadePlayer, red, green, blue, duration * 0.5, tex, 100, trans)
call ContinueCinematicFadeAfterForPlayer(fadePlayer, duration * 0.5, red, green, blue, trans, tex)
call FinishCinematicFadeAfterForPlayer(fadePlayer, duration)
endif
else
// Unrecognized fadetype - ignore the request.
endif
endfunction
Name | Type | is_array | initial_value |
ActivePlayers | force | No | |
AngleOffset | integer | No | 10 |
Backpack_Casting | boolean | Yes | |
Backpack_Unit | unit | Yes | |
BETA_TEST_HEROG_ROUP | group | No | |
Boss_Temp_Activated | boolean | Yes | |
Boss_Temp_Boss | unit | Yes | |
Boss_Temp_Boss_ScriptTrigger | trigger | Yes | |
Boss_Temp_Boss_UnitType | unitcode | Yes | |
Boss_Temp_Group | group | Yes | |
Boss_Temp_ID_Number | integer | No | |
Boss_Temp_ID_Quest_Complete | boolean | Yes | |
Boss_Temp_MAX_BOSS_2D_ARRAY | integer | No | |
Boss_Temp_MAX_SCRIPT_2D_ARRAY | integer | No | |
Boss_Temp_NPC | unit | Yes | |
Boss_Temp_Players | force | Yes | |
Boss_Temp_Position_Boss | location | Yes | |
Boss_Temp_Position_Player | location | Yes | |
Boss_Temp_Region | rect | Yes | |
Boss_Temp_RegionExit | rect | Yes | |
Boss_Temp_Script_Event_Number | boolean | Yes | |
Boss_Temp_Script_ID_Earth | integer | No | |
Boss_Temp_Script_ID_Final | integer | No | |
Boss_Temp_Script_ID_Fire | integer | No | |
Boss_Temp_Script_ID_Water | integer | No | |
Boss_Temp_Script_ID_Wind | integer | No | |
cineFadeContinueBlue | real | No | |
cineFadeContinueDuration | real | No | |
cineFadeContinueGreen | real | No | |
cineFadeContinueRed | real | No | |
cineFadeContinueTex | string | No | |
cineFadeContinueTimer | timer | Yes | |
cineFadeContinueTrans | real | No | |
cineFadeFinishTimer | timer | Yes | |
Color_Default_White | string | No | |r |
Color_Error_Msg | string | No | |
Color_NPC_Names | string | No | |
Color_NPC_Story | string | No | |
Creep_Count | integer | No | |
Creep_Dead | boolean | Yes | |
Creep_ItemDrop | itemcode | Yes | |
Creep_Level | integer | Yes | |
Creep_Owner | player | Yes | |
Creep_Pos | location | Yes | |
Creep_Timer | timer | Yes | |
Creep_Type | unitcode | Yes | |
Double_Click_Active | boolean | Yes | |
Exp_Gain | real | Yes | |
Faction_Allie | real | No | 700.00 |
Faction_Enemy | real | No | 300.00 |
Faction_MAX | real | No | 1000.00 |
Faction_MIN | real | No | 0.00 |
Faction_Starting_Allies | real | No | 600.00 |
Faction_Starting_Enemy | real | No | 600.00 |
FIX_Faction_Display | boolean | Yes | |
FIX_Rapid_Selection | boolean | Yes | |
Hero_Earth_Completion_Player | boolean | Yes | |
Hero_Final_Completion_Player | boolean | Yes | |
Hero_Fire_Completion_Player | boolean | Yes | |
Hero_Player | unit | Yes | |
Hero_Water_Completion_Player | boolean | Yes | |
Hero_Wind_Completion_Player | boolean | Yes | |
HeroEffect | effect | Yes | |
HeroSelected | unit | Yes | |
HeroSelectionOn | boolean | No | true |
Human_Faction_Timer | timer | Yes | |
Human_Faction_Value | real | Yes | 0.00 |
Human_Faction_Window | timerdialog | Yes | |
Human_Gate_Life | real | No | |
Human_Gate_Open | boolean | No | |
HumanResurectionStone | unit | No | |
MessageDelay | real | No | 3600.00 |
Multiboard_Faction | multiboard | No | |
Multiboard_Players | force | No | |
NightElf_Faction_Timer | timer | Yes | |
NightElf_Faction_Value | real | Yes | 0.00 |
NightElf_Faction_Window | timerdialog | Yes | |
NightElf_Gate_Life | real | No | |
NightElf_Gate_Open | boolean | No | |
NightElfResurectionStone | unit | No | |
NPC_CHAT_DISTANCE | integer | No | |
NPC_Human_Thanks_Msg | string | Yes | 0 |
NPC_NightElf_Thanks_Msg | string | Yes | 0 |
NPC_Orc_Thanks_Msg | string | Yes | 0 |
NPC_Status_Toward_Player | integer | Yes | |
NPC_Temp_Boss_Position_Boss | location | Yes | |
NPC_Temp_Boss_Position_Player | location | Yes | |
NPC_Temp_Boss_Region | rect | Yes | |
NPC_Temp_Boss_RegionExit | rect | Yes | |
NPC_Temp_Boss_ScriptTrigger | trigger | Yes | |
NPC_Temp_Boss_UnitType | unitcode | Yes | |
NPC_Temp_Building1_Created | unitcode | Yes | |
NPC_Temp_Building2_Created | unitcode | Yes | |
NPC_Temp_Building3_Created | unitcode | Yes | |
NPC_Temp_Building4_Created | unitcode | Yes | |
NPC_Temp_Building5_Created | unitcode | Yes | |
NPC_Temp_Building6_Created | unitcode | Yes | |
NPC_Temp_Change_Status_Quest | real | Yes | |
NPC_Temp_Completion_Msg | string | Yes | 0 |
NPC_Temp_Enemy1_Created | unitcode | Yes | |
NPC_Temp_Enemy1_CreatedByLevel | unitcode | Yes | |
NPC_Temp_Enemy2_Created | unitcode | Yes | |
NPC_Temp_Enemy2_CreatedByLevel | unitcode | Yes | |
NPC_Temp_Enemy3_Created | unitcode | Yes | |
NPC_Temp_Enemy3_CreatedByLevel | unitcode | Yes | |
NPC_Temp_Enemy_Type | player | Yes | |
NPC_Temp_Faction_Recieved_Huma | real | Yes | |
NPC_Temp_Faction_Recieved_Nigh | real | Yes | |
NPC_Temp_Faction_Recieved_Unde | real | Yes | |
NPC_Temp_Faction_Required | real | Yes | |
NPC_Temp_Gold_Recieved | integer | Yes | |
NPC_Temp_Gold_Required | integer | Yes | |
NPC_Temp_ID_Number | integer | Yes | |
NPC_Temp_Item1_Created | itemcode | Yes | |
NPC_Temp_Item1_Recieved | itemcode | Yes | |
NPC_Temp_Item1_Required | itemcode | Yes | |
NPC_Temp_Item2_Created | itemcode | Yes | |
NPC_Temp_Item2_Recieved | itemcode | Yes | |
NPC_Temp_Item2_Required | itemcode | Yes | |
NPC_Temp_Item3_Created | itemcode | Yes | |
NPC_Temp_Item3_Recieved | itemcode | Yes | |
NPC_Temp_Item3_Required | itemcode | Yes | |
NPC_Temp_Item4_Created | itemcode | Yes | |
NPC_Temp_Item4_Recieved | itemcode | Yes | |
NPC_Temp_Item4_Required | itemcode | Yes | |
NPC_Temp_Item5_Created | itemcode | Yes | |
NPC_Temp_Item5_Recieved | itemcode | Yes | |
NPC_Temp_Item5_Required | itemcode | Yes | |
NPC_Temp_Item6_Created | itemcode | Yes | |
NPC_Temp_Item6_Recieved | itemcode | Yes | |
NPC_Temp_Item6_Required | itemcode | Yes | |
NPC_Temp_Level_Required | integer | Yes | |
NPC_Temp_Loc_Number | integer | Yes | |
NPC_Temp_Location | rect | Yes | |
NPC_Temp_Quest_Msg | string | Yes | 0 |
NPC_Temp_QuestRepeat_Msg | string | Yes | 0 |
NPC_Temp_Race_Quest_Location | race | Yes | |
NPC_Temp_Unit1_Created | unitcode | Yes | |
NPC_Temp_Unit1_Required | unitcode | Yes | |
NPC_Temp_Unit2_Created | unitcode | Yes | |
NPC_Temp_Unit2_Required | unitcode | Yes | |
NPC_Temp_Unit3_Created | unitcode | Yes | |
NPC_Temp_Unit3_Required | unitcode | Yes | |
NPC_Temp_Unit4_Created | unitcode | Yes | |
NPC_Temp_Unit4_Required | unitcode | Yes | |
NPC_Temp_Unit5_Created | unitcode | Yes | |
NPC_Temp_Unit5_Required | unitcode | Yes | |
NPC_Temp_Unit6_Created | unitcode | Yes | |
NPC_Temp_Unit6_Required | unitcode | Yes | |
NPC_Temp_Welcome_Msg | string | Yes | 0 |
NPC_Undead_Thanks_Msg | string | Yes | 0 |
NPC_UnitSelected_Player | unit | Yes | |
NrOfPlayers | integer | No | 9 |
OrcResurectionStone | unit | No | |
Pass_alphabet | string | No | |
Pass_Base_Number_System | integer | No | |
Pass_Integer | integer | Yes | |
Pass_Integer2 | integer | Yes | |
Pass_Integer3 | integer | Yes | |
Pass_Integer_Remainer | integer | Yes | |
Pass_Integer_Total | integer | Yes | |
Pass_String_Player | string | Yes | |
Pass_TempInput_Player | string | Yes | |
Pass_TempInt | integer | No | |
Pass_TempInt2 | integer | No | |
Pass_TempOutput_Player | string | Yes | |
Pass_User_Name_Player | string | Yes | |
Password_Player | integer | Yes | |
PickedHeroes | group | No | |
Player_Color_Blue | real | Yes | |
Player_Color_Green | real | Yes | |
Player_Color_Red | real | Yes | |
PlayersCamera | camerasetup | Yes | |
PlayersLeft | force | No | |
Quest_Human_Total_Locations | integer | No | |
Quest_Location_Human | rect | Yes | |
Quest_Location_NightElf | rect | Yes | |
Quest_Location_Undead | rect | Yes | |
Quest_NightElf_Total_Locations | integer | No | |
Quest_Undead_Total_Locations | integer | No | |
Restricted_Regions | rect | Yes | |
ResurectionStone_Player | unit | Yes | |
SelectionScale | real | No | 160.00 |
Special_Blademaster_Avaliable | boolean | Yes | |
Special_FetalOrc_Avaliable | boolean | Yes | |
Special_Giant_Avaliable | boolean | Yes | |
Special_Shaman_Avaliable | boolean | Yes | |
Temp_Integer_Multiplication | integer | Yes | |
Temp_Local_Player | player | Yes | |
TempBool | boolean | No | |
TempInt | integer | No | |
TempInt_LowerHalf | integer | No | |
TempInt_Random | integer | No | |
TempInt_UpperHalf | integer | No | |
TempLocation | rect | No | |
TempPlayer | player | No | |
TempReal | real | No | |
TempString | string | No | |
TempUnit | unit | No | |
TempUnitGroup | group | No | |
TempUnitGroup_Array | group | Yes | |
Undead_Faction_Timer | timer | Yes | |
Undead_Faction_Value | real | Yes | 0.00 |
Undead_Faction_Window | timerdialog | Yes | |
Undead_Gate_Life | real | No | |
Undead_Gate_Open | boolean | No | |
UndeadResurectionStone | unit | No | |
Victory_Timer | timer | Yes | |
Weather_Current_Num | integer | No | |
WeatherArray | weathereffect | Yes |
function Trig_Local_Player_Actions takes nothing returns nothing
set udg_Temp_Local_Player[GetConvertedPlayerId(GetTriggerPlayer())] = GetLocalPlayer()
endfunction
//===========================================================================
function InitTrig_Local_Player takes nothing returns nothing
set gg_trg_Local_Player = CreateTrigger( )
call TriggerAddAction( gg_trg_Local_Player, function Trig_Local_Player_Actions )
endfunction
function Trig_Add_Locus_Ability_Actions takes nothing returns nothing
call UnitAddAbilityBJ( 'Aloc', GetEnumUnit() )
endfunction
//===========================================================================
function InitTrig_Add_Locus_Ability takes nothing returns nothing
set gg_trg_Add_Locus_Ability = CreateTrigger( )
call TriggerAddAction( gg_trg_Add_Locus_Ability, function Trig_Add_Locus_Ability_Actions )
endfunction
function Trig_Untitled_Trigger_003_Actions takes nothing returns nothing
call UnitApplyTimedLifeBJ( 60, 'BTLF', GetSpellTargetUnit() )
call UnitPauseTimedLifeBJ( true, GetTriggerUnit() )
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_003 takes nothing returns nothing
set gg_trg_Untitled_Trigger_003 = CreateTrigger( )
call TriggerAddAction( gg_trg_Untitled_Trigger_003, function Trig_Untitled_Trigger_003_Actions )
endfunction