Advertisement
-wtvr-

test

Jun 24th, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.00 KB | None | 0 0
  1. //TESH.scrollpos=153
  2. //TESH.alwaysfold=0
  3. //hash keys
  4. // call SaveStr(udg_Hash, parentKey, 1, udg_HeroIcon[x]) // icon [key-1]
  5. // call SaveSoundHandle(udg_Hash, parentKey, 2, udg_Sounds[x]) // sound [key-2]
  6. // call SaveInteger(udg_Hash, h_id, 4, x) // remember hero number (1,2,3 or 4) [key-4]
  7. // call SaveInteger(udg_Hash, p_id, 6, 0) // player kills [key-6]
  8. // call SaveInteger(udg_Hash, p_id, 7, 0) // player deaths [key-7]
  9. // call SaveInteger(udg_Hash, p_id, 8, playerRow) // player Row in MB [key-8]
  10.  
  11. //------------------------------------------------------------------------------------
  12. function MB_SaveParameters takes nothing returns nothing
  13. local integer parentKey
  14. local integer x=1
  15. loop
  16. exitwhen x>udg_HRheroesQuantity
  17. set parentKey = udg_Heros[x]
  18. call SaveStr(udg_Hash, parentKey, 1, udg_HeroIcon[x]) // icon [key-1]
  19. call SaveSoundHandle(udg_Hash, parentKey, 2, udg_Sounds[x]) // sound [key-2]
  20. set x=x+1
  21. endloop
  22. endfunction
  23. //------------------------------------------------------------------------------------
  24.  
  25. //------------------------------------------------------------------------------------
  26. //--------------- MB --> Clock ------------------------------------------------------
  27. //------------------------------------------------------------------------------------
  28. function MB_UpdateClock takes nothing returns nothing
  29. set udg_clockS0 = udg_clockS0 + 1
  30. if udg_clockS0 == 10 then
  31. set udg_clockS0 = 0
  32. set udg_clockS1 = udg_clockS1 + 1
  33. endif
  34. if udg_clockS1 == 6 then
  35. set udg_clockS0 = 0
  36. set udg_clockS1 = 0
  37. set udg_clockM0 = udg_clockM0 + 1
  38. endif
  39. if udg_clockM0 == 10 then
  40. set udg_clockS0 = 0
  41. set udg_clockS1 = 0
  42. set udg_clockM0 = 0
  43. set udg_clockM1 = udg_clockM1 + 1
  44. endif
  45. if udg_clockM1 == 6 then
  46. set udg_clockS0 = 0
  47. set udg_clockS1 = 0
  48. set udg_clockM0 = 0
  49. set udg_clockM1 = 0
  50. set udg_clockH0 = udg_clockH0 + 1
  51. endif
  52. call MultiboardSetTitleText(udg_MB, "Scoreboard " + I2S(udg_clockH0) + ":" + I2S(udg_clockM1) + I2S(udg_clockM0) + ":" + I2S(udg_clockS1) + I2S(udg_clockS0))
  53. endfunction
  54. //---------------------------------------------------------------------------
  55. //---------------------------------------------------------------------------
  56. function MB_UpdatePlayerKD takes player pla returns nothing
  57. local integer playerId = GetPlayerId(pla)
  58. local integer p_id = GetHandleId(pla)
  59. local integer playerRow = LoadInteger(udg_Hash, p_id, 8)
  60. local integer kills = LoadInteger(udg_Hash, p_id, 6)
  61. local integer deaths = LoadInteger(udg_Hash, p_id, 7)
  62. call MultiboardSetItemValueBJ( udg_MB, 6, playerRow, I2S(kills)+" - "+I2S(deaths) ) // K-D
  63. endfunction
  64. //---------------------------------------------------------------------------
  65. //---------------------------------------------------------------------------
  66. //---------------------------------------------------------------------------
  67. function MB_GetColor takes player pla returns string
  68. local playercolor c = GetPlayerColor(pla)
  69. local integer x=0
  70. loop
  71. exitwhen x==bj_MAX_PLAYERS
  72. if ConvertPlayerColor(x)==c then
  73. return udg_pCol[x]
  74. endif
  75. set x=x+1
  76. endloop
  77. return " "
  78. endfunction
  79. //---------------------------------------------------------------------------
  80. function MB_UpdatePlayers takes nothing returns nothing
  81. local player pla
  82. local integer p_id
  83. local integer x=0
  84. local integer playerRow=2 // for 1st player
  85.  
  86. loop //find active players
  87. exitwhen x==bj_MAX_PLAYERS
  88.  
  89. set pla=Player(x)
  90. if GetPlayerSlotState(pla)==PLAYER_SLOT_STATE_PLAYING then
  91. set p_id = GetHandleId(pla)
  92. call SaveInteger(udg_Hash, p_id, 6, 0) // player kills [key-6]
  93. call SaveInteger(udg_Hash, p_id, 7, 0) // player deaths [key-7]
  94. call SaveInteger(udg_Hash, p_id, 8, playerRow) // player Row in MB [key-8]
  95. call MultiboardSetItemValueBJ( udg_MB, 5, playerRow, MB_GetColor(pla) + GetPlayerName(pla) + "|r")
  96. call MultiboardSetItemValueBJ( udg_MB, 6, playerRow, "0 - 0" ) // K-D
  97.  
  98. set playerRow=playerRow+1 // prepare RowNr for next active player
  99. endif
  100.  
  101. set x=x+1
  102. endloop
  103. endfunction
  104.  
  105.  
  106. //---------------------------------------------------------------------------
  107. //--------------TRIGGER RELATED-----------------------------------------
  108. //---------------------------------------------------------------------------
  109. function Trig_HeroOnEnter_Conditions takes nothing returns boolean
  110. return IsUnitType(udg_UDexUnits[udg_UDex], UNIT_TYPE_HERO)
  111. endfunction
  112. //-----------------------------------------------------------------------
  113. function Trig_HeroOnEnter_Actions takes nothing returns nothing
  114. local player pla = GetOwningPlayer(udg_UDexUnits[udg_UDex])
  115. local integer playerId = GetPlayerId(pla)
  116. local integer p_id = GetHandleId(pla)
  117. local integer playerRow = LoadInteger(udg_Hash, p_id, 8)
  118. local integer h_id = GetHandleId(udg_UDexUnits[udg_UDex])
  119. local integer x
  120. local string s
  121. set udg_MBhCount[playerId] = udg_MBhCount[playerId] + 1 // counts heroes for MB purposes
  122. set x = udg_MBhCount[playerId]
  123. call SaveInteger(udg_Hash, h_id, 4, x) // remember hero number (1,2,3 or 4) [key-4]
  124. //update MB (hero icon / hero level)
  125. call MultiboardSetItemStyleBJ( udg_MB, x, playerRow, true, true )//x=heroNumber
  126. //column size
  127. call MultiboardSetItemWidthBJ( udg_MB, x, 0, 4.00 ) //col x(2) allRows 4% for 2nd hero
  128. set s = LoadStr(udg_Hash, GetUnitTypeId(udg_UDexUnits[udg_UDex]), 1)
  129. if s != null then
  130. call MultiboardSetItemIconBJ( udg_MB, x, playerRow, s ) // icon
  131. endif
  132. call MultiboardSetItemValueBJ( udg_MB, x, playerRow, "1") // hero level "1"
  133. //play sound
  134. call PlaySoundOnUnitBJ(LoadSoundHandle(udg_Hash, GetUnitTypeId(udg_UDexUnits[udg_UDex]), 2), 100, udg_UDexUnits[udg_UDex])
  135.  
  136. endfunction
  137.  
  138. //---------------------------------------------------------------------------
  139. //-------------------------HERO LEVEL UP---------------------------------
  140. //---------------------------------------------------------------------------
  141. function Trig_HeroLevelUp_Cond takes nothing returns boolean
  142. local integer playerId = GetPlayerId(GetOwningPlayer(GetLevelingUnit()))
  143. local integer heroNr = LoadInteger(udg_Hash, GetHandleId(GetLevelingUnit()), 4)
  144. local integer playerRow = LoadInteger(udg_Hash, GetHandleId(Player(playerId)), 8)
  145. if IsUnitType(GetLevelingUnit(), UNIT_TYPE_HERO) and heroNr==1 or heroNr==2 or heroNr==3 or heroNr==4 then
  146. call MultiboardSetItemValueBJ( udg_MB, heroNr, playerRow, I2S(GetHeroLevel(GetLevelingUnit())) )
  147. endif
  148. return false
  149. endfunction
  150.  
  151. //---------------------------------------------------------------------------
  152. //-------------------------HERO DIES--------------------------------------
  153. //---------------------------------------------------------------------------
  154.  
  155. function Trig_HeroDies_Cond takes nothing returns boolean
  156. local unit u = GetDyingUnit()
  157. local integer heroNr = LoadInteger(udg_Hash, GetHandleId(u), 4) // dying
  158. local player pla = GetOwningPlayer(u) // dying
  159. local integer playerRow = LoadInteger(udg_Hash, GetHandleId(pla), 8)
  160. local integer deaths = LoadInteger(udg_Hash, GetHandleId(pla), 7) // dying
  161. local integer kills
  162. //victim:
  163. if IsUnitType(u, UNIT_TYPE_HERO) and heroNr==1 or heroNr==2 or heroNr==3 or heroNr==4 then
  164. call SaveInteger(udg_Hash, GetHandleId(pla), 7, deaths+1) // player deaths [7]
  165. call MB_UpdatePlayerKD(pla)
  166. call MultiboardSetItemColorBJ( udg_MB, heroNr, playerRow, 40.00, 40.00, 40.00, 25.00 )//col-heroNr
  167.  
  168. //killer?
  169. if GetKillingUnit() != null then
  170. set pla = GetOwningPlayer(GetKillingUnit()) //killer
  171. if GetPlayerId(pla)>=0 and GetPlayerId(pla)<=11 and IsUnitEnemy(u, pla) then
  172. //if (pla==Player(0) or pla==Player(1) or pla==Player(2) or pla==Player(3)) and IsUnitEnemy(u, pla) then
  173. set kills = LoadInteger(udg_Hash, GetHandleId(pla), 6)
  174. call SaveInteger(udg_Hash, GetHandleId(pla), 6, kills+1) // player kills [6]
  175. call MB_UpdatePlayerKD(pla)
  176. endif
  177. endif
  178. endif
  179. set u=null
  180. set pla=null
  181. return false
  182. endfunction
  183.  
  184. //-------------------------HERO REVIVE--------------------------------------
  185. function Trig_MB_HeroRevive takes nothing returns boolean
  186. local integer heroNr = LoadInteger(udg_Hash, GetHandleId(GetRevivingUnit()), 4)
  187. local player pla = GetOwningPlayer(GetRevivingUnit())
  188. local integer playerRow = LoadInteger(udg_Hash, GetHandleId(pla), 8)
  189. call MultiboardSetItemColorBJ( udg_MB, heroNr, playerRow, 100.00, 100.00, 100.00, 0.00 )
  190. return false
  191. endfunction
  192. //=================================================================
  193. //=================================================================
  194. function InitTrig_MBFunctions takes nothing returns nothing
  195. local trigger t = CreateTrigger()
  196. call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 1.00 )
  197. call TriggerAddCondition(t, Condition( function Trig_HeroOnEnter_Conditions ) )
  198. call TriggerAddAction(t, function Trig_HeroOnEnter_Actions )
  199.  
  200. set t=CreateTrigger()
  201. call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_LEVEL )
  202. call TriggerAddCondition(t, Condition( function Trig_HeroLevelUp_Cond ) )
  203.  
  204. set t=CreateTrigger()
  205. call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH )
  206. call TriggerAddCondition(t, Condition(function Trig_HeroDies_Cond ))
  207.  
  208. set t=CreateTrigger()
  209. call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_REVIVE_FINISH )
  210. call TriggerAddCondition(t, Condition( function Trig_MB_HeroRevive ) )
  211. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement