• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Unit Transmissions by one function

Level 14
Joined
Jul 1, 2008
Messages
1,314
Hi guys,

as i'm working on a Harvest moon Map, where you got tons of Cinematic Transmissions from several units for several players, i decided to make this thing more easy.
There is one main function, which lets you create a transmission to only one player, with and without the interface. Its much easier than do it manually.

Here is the result.

Please help me make it better.

There is an initialisation function, and two to handle the transmissions.

Please open the map, try it and read the ReadMe-File, if your interested.


[n]v0.30[/b]
- uses integer parameter interfaceMod instead of a boolean, you can perform several transmission from one unit like this
v0.20
- doesnt need gamecache anymore
- uses global integer array
- improved some critical lines with GetLocalPlayer and the init-function

JASS:
//*************************************************************************
//******      global integer array udg_CineInteger_DataArray[]     ********
//*************************************************************************
//
// [0] == MaxPlayers, its initialisized at init-function ( ej_Init_Cinemaic() )
// [Id+0*[0] + 1] == Transmission already on?
// [Id+1*[0] + 1] == Interface on/off ? keep Interface for next transmission = 2, keep Interface from last transmission = 3
// [Id+2*[0] + 1] == Transmission can be skipped entirely
// [Id+3*[0] + 1] == Transmission has been already skipped
// [Id+4*[0] + 1] == sounddat ID
// 1 == true, 0 == false
//*************************************************************************

function ej_I2S takes integer i returns sound
    return i
    return null
endfunction

function ej_S2I takes sound s returns integer
    return s
    return 0
endfunction

//*************************EMMAS TRANSMISSION FROM UNIT FUNCTIONS*******************************
function ej_Player_Skipp_Cin takes nothing returns nothing

     local player p = GetTriggerPlayer()
     local integer Id = GetPlayerId(p)
     local integer CineSkip = udg_CineInteger_DataArray[Id+2*udg_CineInteger_DataArray[0]+1]
     local integer InterfaceStatus = udg_CineInteger_DataArray[Id+udg_CineInteger_DataArray[0]+1]
     local sound ej_GetLastSoundForPlayer = ej_I2S(udg_CineInteger_DataArray[Id+4*udg_CineInteger_DataArray[0]+1])
     
     if GetLocalPlayer() == p then
     
        // End the Cinematic Scene
        if ej_GetLastSoundForPlayer != null then
           call StopSound(ej_GetLastSoundForPlayer,false,true)
        endif
        call EndCinematicScene()
     
        // if Cine can be skipped
        if CineSkip == 1 then
           if InterfaceStatus == 1 then // normal cinematic style
              // if Player doesnt want to keep the interface for next TM
              call ShowInterface(true, 0.00)
           elseif InterfaceStatus == 3 then // just end
              // Player wants to end multi transmissions
              call ShowInterface(true, 0.00) 
           elseif InterfaceStatus == 0 then // text message style
              call ClearTextMessages()
           endif
           // set new information, interface is already skipped
           set udg_CineInteger_DataArray[Id+3*udg_CineInteger_DataArray[0]+1] = 1
        else
           // set new information, Interface could not be skipped, wait untill the end
           set udg_CineInteger_DataArray[Id+3*udg_CineInteger_DataArray[0]+1] = 0
        endif
     
     endif
     set p = null
     set ej_GetLastSoundForPlayer = null  
endfunction

function ej_Init_Cinemaic takes nothing returns nothing
    
    local integer i = 0
    local trigger new = CreateTrigger()
    local player p
    
    // create Cinematic Skip function
    loop
        exitwhen i > bj_MAX_PLAYERS
        // if player is human and playing
        set p = Player(i)
        if GetPlayerController(p) == MAP_CONTROL_USER and GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING then        
           // increase Player Count udg_CineInteger_DataArray[0]
           set udg_CineInteger_DataArray[0] = udg_CineInteger_DataArray[0] + 1
           // Initialize the transmission ESC function 
           call TriggerRegisterPlayerEvent(new, p, EVENT_PLAYER_END_CINEMATIC)           
        endif
        set i = i + 1
    endloop
    call TriggerAddAction(new, function ej_Player_Skipp_Cin)
    
    // reset
    set new = null
    set p = null
endfunction
    
function ej_Player_Cinematic takes player p, integer interfaceMod, real fadeDuration1, real fadeDuration2, unit tu, string TMName, string text, real wait, sound sounddat, boolean skippable returns nothing
         
         local integer CineSkipped         
         local integer TransmissionOn
         local integer Id = GetPlayerId(p)
         local timer T_Wait = CreateTimer()
         
         if GetLocalPlayer() == p then
            
            // Other Transmission at the same time not possible
            set TransmissionOn = udg_CineInteger_DataArray[Id+1]
            if TransmissionOn == 0 then
               set udg_CineInteger_DataArray[Id+1] = 1
                
               // interfaceMod == 0 -> Sutitles, interfaceMod == 1 -> normal Transmission
               if interfaceMod == 0 then
                  // Subtitles
                  call ForceCinematicSubtitles(true)               
                  set udg_CineInteger_DataArray[Id+udg_CineInteger_DataArray[0]+1] = 0  
               elseif interfaceMod == 1 then
                  call ShowInterface(false, fadeDuration1)
                  set udg_CineInteger_DataArray[Id+udg_CineInteger_DataArray[0]+1] = 1
               elseif interfaceMod == 2 then
                  // interfaceMod == 2 -> Player wants to keep the interface after the end of the transmission
                  call ShowInterface(false, fadeDuration1)
                  set udg_CineInteger_DataArray[Id+udg_CineInteger_DataArray[0]+1] = 2
               elseif interfaceMod == 3 then
                  // interfaceMod == 3 -> dont show the interface, its already on, but hide after this one!
                  set udg_CineInteger_DataArray[Id+udg_CineInteger_DataArray[0]+1] = 3 
               endif
               
               // skippable means, transmission can be skipped entirely
               if skippable then
                  set udg_CineInteger_DataArray[Id+2*udg_CineInteger_DataArray[0]+1] = 1
               else
                  set udg_CineInteger_DataArray[Id+2*udg_CineInteger_DataArray[0]+1] = 0
               endif
               
                  // set the cinematic
                  set bj_lastTransmissionDuration = wait 
                  set bj_lastPlayedSound = sounddat
                  set udg_CineInteger_DataArray[Id+4*udg_CineInteger_DataArray[0]+1] = ej_S2I(sounddat)
                  set bj_cineSceneLastSound = sounddat
            
                  // action
                  if sounddat != null then
                     call StartSound(sounddat)
                  endif 
                  call SetCinematicScene(GetUnitTypeId(tu), GetPlayerColor(p), TMName, text, bj_lastTransmissionDuration+ bj_TRANSMISSION_PORT_HANGTIME, bj_lastTransmissionDuration)
                  call PingMinimap(GetUnitX(tu), GetUnitY(tu), bj_TRANSMISSION_PING_TIME)
                  if IsUnitHidden(tu) == false then
                     call UnitAddIndicator(tu, bj_TRANSMISSION_IND_RED, bj_TRANSMISSION_IND_BLUE, bj_TRANSMISSION_IND_GREEN, bj_TRANSMISSION_IND_ALPHA)
                  endif
            
                  // wait transmission time           
                  call TimerStart(T_Wait,bj_lastTransmissionDuration,false,null)
                  loop
                      set CineSkipped = udg_CineInteger_DataArray[Id+3*udg_CineInteger_DataArray[0]+1]
                      exitwhen TimerGetRemaining(T_Wait) == 0.00 or udg_CineInteger_DataArray[Id+3*udg_CineInteger_DataArray[0]+1] == 1
                      call TriggerSleepAction(0.10)
                  endloop 
            
               // handle interface Mods, and exit to game interface; dont exit if Mod == 2
               if CineSkipped == 0 then
                  if interfaceMod == 0 then // Subtitle end
                     call ClearTextMessages()
                     // Subtitles
                     call ForceCinematicSubtitles(false)
                  elseif interfaceMod == 1 then // normal end
                     call ShowInterface(true, fadeDuration2)
                  elseif interfaceMod == 3 then // just end 
                     call ShowInterface(true, fadeDuration2)
                  endif
               endif
               
            // reset the system
            set udg_CineInteger_DataArray[Id+1] = 0
            set udg_CineInteger_DataArray[Id+3*udg_CineInteger_DataArray[0]+1] = 0                 
            endif
         endif
         call DestroyTimer(T_Wait)
         set T_Wait = null        
endfunction


Here is the Version 0.3 of the example map.

Greetings
Emm-A-
 
Last edited:
Latest benchmarks have proved that Gamecaches have increased in speed ever since 1.22, so using them gives no problem. I also did some benchmarks of I2(Any Handle) vs H2I and the speed was the same.

Yet since he's Game caches refer to players, he could make an array instead and relate the playerId to an stored value in the array.

JASS:
globals
         boolean array B_Cin
endglobals

///blah blah
local integer i = GetPlayerId(GetTriggeringPlayer())
local boolean b = B_Cin[i]
local boolean g = B_Cin[i+12]
///blah blah
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
hey guys thanks for the comments, i followed BlinkBoys Hint and made a global integer array to handle the "system".

I also improved the code, because there were some critical lines.

Do you see any desyncs?

I linked the new example map.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
there is a new version. Download in the first post.

i changed the first parameter boolean into integer, so you can perform multi transmission from one unit now, without changing the interface.
To do this, there are 2 mods, one which doesnt fade in and one which doesn fade out.

I think, its really usefull.

Greetings
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
hm, the thing is im not good enough in vjass at the moment, to make something really better, but thanks for the suggestion :)

Could someone test it, if there are any desyncs, because i cant at the moment...
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
sorry for the double posting, but could someone try it in battlenet with another player, so that we (i) know, if it works without desyncs or not?

I cant test this unluckily, because im not able to host games...
 
Top