Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //TESH.scrollpos=153
- //TESH.alwaysfold=0
- //hash keys
- // call SaveStr(udg_Hash, parentKey, 1, udg_HeroIcon[x]) // icon [key-1]
- // call SaveSoundHandle(udg_Hash, parentKey, 2, udg_Sounds[x]) // sound [key-2]
- // call SaveInteger(udg_Hash, h_id, 4, x) // remember hero number (1,2,3 or 4) [key-4]
- // call SaveInteger(udg_Hash, p_id, 6, 0) // player kills [key-6]
- // call SaveInteger(udg_Hash, p_id, 7, 0) // player deaths [key-7]
- // call SaveInteger(udg_Hash, p_id, 8, playerRow) // player Row in MB [key-8]
- //------------------------------------------------------------------------------------
- function MB_SaveParameters takes nothing returns nothing
- local integer parentKey
- local integer x=1
- loop
- exitwhen x>udg_HRheroesQuantity
- set parentKey = udg_Heros[x]
- call SaveStr(udg_Hash, parentKey, 1, udg_HeroIcon[x]) // icon [key-1]
- call SaveSoundHandle(udg_Hash, parentKey, 2, udg_Sounds[x]) // sound [key-2]
- set x=x+1
- endloop
- endfunction
- //------------------------------------------------------------------------------------
- //------------------------------------------------------------------------------------
- //--------------- MB --> Clock ------------------------------------------------------
- //------------------------------------------------------------------------------------
- function MB_UpdateClock takes nothing returns nothing
- set udg_clockS0 = udg_clockS0 + 1
- if udg_clockS0 == 10 then
- set udg_clockS0 = 0
- set udg_clockS1 = udg_clockS1 + 1
- endif
- if udg_clockS1 == 6 then
- set udg_clockS0 = 0
- set udg_clockS1 = 0
- set udg_clockM0 = udg_clockM0 + 1
- endif
- if udg_clockM0 == 10 then
- set udg_clockS0 = 0
- set udg_clockS1 = 0
- set udg_clockM0 = 0
- set udg_clockM1 = udg_clockM1 + 1
- endif
- if udg_clockM1 == 6 then
- set udg_clockS0 = 0
- set udg_clockS1 = 0
- set udg_clockM0 = 0
- set udg_clockM1 = 0
- set udg_clockH0 = udg_clockH0 + 1
- endif
- call MultiboardSetTitleText(udg_MB, "Scoreboard " + I2S(udg_clockH0) + ":" + I2S(udg_clockM1) + I2S(udg_clockM0) + ":" + I2S(udg_clockS1) + I2S(udg_clockS0))
- endfunction
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- function MB_UpdatePlayerKD takes player pla returns nothing
- local integer playerId = GetPlayerId(pla)
- local integer p_id = GetHandleId(pla)
- local integer playerRow = LoadInteger(udg_Hash, p_id, 8)
- local integer kills = LoadInteger(udg_Hash, p_id, 6)
- local integer deaths = LoadInteger(udg_Hash, p_id, 7)
- call MultiboardSetItemValueBJ( udg_MB, 6, playerRow, I2S(kills)+" - "+I2S(deaths) ) // K-D
- endfunction
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- function MB_GetColor takes player pla returns string
- local playercolor c = GetPlayerColor(pla)
- local integer x=0
- loop
- exitwhen x==bj_MAX_PLAYERS
- if ConvertPlayerColor(x)==c then
- return udg_pCol[x]
- endif
- set x=x+1
- endloop
- return " "
- endfunction
- //---------------------------------------------------------------------------
- function MB_UpdatePlayers takes nothing returns nothing
- local player pla
- local integer p_id
- local integer x=0
- local integer playerRow=2 // for 1st player
- loop //find active players
- exitwhen x==bj_MAX_PLAYERS
- set pla=Player(x)
- if GetPlayerSlotState(pla)==PLAYER_SLOT_STATE_PLAYING then
- set p_id = GetHandleId(pla)
- call SaveInteger(udg_Hash, p_id, 6, 0) // player kills [key-6]
- call SaveInteger(udg_Hash, p_id, 7, 0) // player deaths [key-7]
- call SaveInteger(udg_Hash, p_id, 8, playerRow) // player Row in MB [key-8]
- call MultiboardSetItemValueBJ( udg_MB, 5, playerRow, MB_GetColor(pla) + GetPlayerName(pla) + "|r")
- call MultiboardSetItemValueBJ( udg_MB, 6, playerRow, "0 - 0" ) // K-D
- set playerRow=playerRow+1 // prepare RowNr for next active player
- endif
- set x=x+1
- endloop
- endfunction
- //---------------------------------------------------------------------------
- //--------------TRIGGER RELATED-----------------------------------------
- //---------------------------------------------------------------------------
- function Trig_HeroOnEnter_Conditions takes nothing returns boolean
- return IsUnitType(udg_UDexUnits[udg_UDex], UNIT_TYPE_HERO)
- endfunction
- //-----------------------------------------------------------------------
- function Trig_HeroOnEnter_Actions takes nothing returns nothing
- local player pla = GetOwningPlayer(udg_UDexUnits[udg_UDex])
- local integer playerId = GetPlayerId(pla)
- local integer p_id = GetHandleId(pla)
- local integer playerRow = LoadInteger(udg_Hash, p_id, 8)
- local integer h_id = GetHandleId(udg_UDexUnits[udg_UDex])
- local integer x
- local string s
- set udg_MBhCount[playerId] = udg_MBhCount[playerId] + 1 // counts heroes for MB purposes
- set x = udg_MBhCount[playerId]
- call SaveInteger(udg_Hash, h_id, 4, x) // remember hero number (1,2,3 or 4) [key-4]
- //update MB (hero icon / hero level)
- call MultiboardSetItemStyleBJ( udg_MB, x, playerRow, true, true )//x=heroNumber
- //column size
- call MultiboardSetItemWidthBJ( udg_MB, x, 0, 4.00 ) //col x(2) allRows 4% for 2nd hero
- set s = LoadStr(udg_Hash, GetUnitTypeId(udg_UDexUnits[udg_UDex]), 1)
- if s != null then
- call MultiboardSetItemIconBJ( udg_MB, x, playerRow, s ) // icon
- endif
- call MultiboardSetItemValueBJ( udg_MB, x, playerRow, "1") // hero level "1"
- //play sound
- call PlaySoundOnUnitBJ(LoadSoundHandle(udg_Hash, GetUnitTypeId(udg_UDexUnits[udg_UDex]), 2), 100, udg_UDexUnits[udg_UDex])
- endfunction
- //---------------------------------------------------------------------------
- //-------------------------HERO LEVEL UP---------------------------------
- //---------------------------------------------------------------------------
- function Trig_HeroLevelUp_Cond takes nothing returns boolean
- local integer playerId = GetPlayerId(GetOwningPlayer(GetLevelingUnit()))
- local integer heroNr = LoadInteger(udg_Hash, GetHandleId(GetLevelingUnit()), 4)
- local integer playerRow = LoadInteger(udg_Hash, GetHandleId(Player(playerId)), 8)
- if IsUnitType(GetLevelingUnit(), UNIT_TYPE_HERO) and heroNr==1 or heroNr==2 or heroNr==3 or heroNr==4 then
- call MultiboardSetItemValueBJ( udg_MB, heroNr, playerRow, I2S(GetHeroLevel(GetLevelingUnit())) )
- endif
- return false
- endfunction
- //---------------------------------------------------------------------------
- //-------------------------HERO DIES--------------------------------------
- //---------------------------------------------------------------------------
- function Trig_HeroDies_Cond takes nothing returns boolean
- local unit u = GetDyingUnit()
- local integer heroNr = LoadInteger(udg_Hash, GetHandleId(u), 4) // dying
- local player pla = GetOwningPlayer(u) // dying
- local integer playerRow = LoadInteger(udg_Hash, GetHandleId(pla), 8)
- local integer deaths = LoadInteger(udg_Hash, GetHandleId(pla), 7) // dying
- local integer kills
- //victim:
- if IsUnitType(u, UNIT_TYPE_HERO) and heroNr==1 or heroNr==2 or heroNr==3 or heroNr==4 then
- call SaveInteger(udg_Hash, GetHandleId(pla), 7, deaths+1) // player deaths [7]
- call MB_UpdatePlayerKD(pla)
- call MultiboardSetItemColorBJ( udg_MB, heroNr, playerRow, 40.00, 40.00, 40.00, 25.00 )//col-heroNr
- //killer?
- if GetKillingUnit() != null then
- set pla = GetOwningPlayer(GetKillingUnit()) //killer
- if GetPlayerId(pla)>=0 and GetPlayerId(pla)<=11 and IsUnitEnemy(u, pla) then
- //if (pla==Player(0) or pla==Player(1) or pla==Player(2) or pla==Player(3)) and IsUnitEnemy(u, pla) then
- set kills = LoadInteger(udg_Hash, GetHandleId(pla), 6)
- call SaveInteger(udg_Hash, GetHandleId(pla), 6, kills+1) // player kills [6]
- call MB_UpdatePlayerKD(pla)
- endif
- endif
- endif
- set u=null
- set pla=null
- return false
- endfunction
- //-------------------------HERO REVIVE--------------------------------------
- function Trig_MB_HeroRevive takes nothing returns boolean
- local integer heroNr = LoadInteger(udg_Hash, GetHandleId(GetRevivingUnit()), 4)
- local player pla = GetOwningPlayer(GetRevivingUnit())
- local integer playerRow = LoadInteger(udg_Hash, GetHandleId(pla), 8)
- call MultiboardSetItemColorBJ( udg_MB, heroNr, playerRow, 100.00, 100.00, 100.00, 0.00 )
- return false
- endfunction
- //=================================================================
- //=================================================================
- function InitTrig_MBFunctions takes nothing returns nothing
- local trigger t = CreateTrigger()
- call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 1.00 )
- call TriggerAddCondition(t, Condition( function Trig_HeroOnEnter_Conditions ) )
- call TriggerAddAction(t, function Trig_HeroOnEnter_Actions )
- set t=CreateTrigger()
- call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_LEVEL )
- call TriggerAddCondition(t, Condition( function Trig_HeroLevelUp_Cond ) )
- set t=CreateTrigger()
- call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH )
- call TriggerAddCondition(t, Condition(function Trig_HeroDies_Cond ))
- set t=CreateTrigger()
- call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_REVIVE_FINISH )
- call TriggerAddCondition(t, Condition( function Trig_MB_HeroRevive ) )
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement