Advertisement
HR_Shaft

Custom Team and FFA Colors

Oct 27th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.26 KB | None | 0 0
  1. --[[ ###  Custom Team and FFA Colors ###]]--
  2. --[[ ###  by H® Shaft for Phasor v2+ ###]]--
  3.  
  4. -- Team Games: allows you to set custom colors for each team (see color table and selected team colors below)
  5. -- FFA games: each time a player spawns, they are given a new random color.
  6.  
  7. -- inspired by: AelitePrimes Colored Team Gametypes. Numerous rgb offsets published by Wizard,
  8. -- Correct rgb offsets found by 002 in his SAPP custom team color script: https://www.dropbox.com/s/91ksoqbsydi49nl/customteamcolors.lua
  9.  
  10. -- selected team colors - edit these
  11. red_color[1] = {1, 1, 0.003} --"Yellow"
  12. blue_color[1] = {0, 1, 0.003} --"Green"
  13.  
  14. -- team color tables - don't edit
  15. red_color = {}
  16. blue_color = {}
  17. team_play = false
  18. color_table = {}
  19. color_table[1] = {0, 0, 0} --"Black"
  20. color_table[2] = {0.996, 0, 0} --"Red"
  21. color_table[3] = {0.007, 0.003, 0.890} --"Blue"
  22. color_table[4] = {0.439, 0.494, 0.443} --"Gray"
  23. color_table[5] = {1, 1, 0.003} --"Yellow"
  24. color_table[6] = {0, 1, 0.003} --"Green"
  25. color_table[7] = {1, 0.337, 0.725} --"Pink"
  26. color_table[8] = {0.67, 0.062, 0.956} --"Purple"
  27. color_table[9] = {0.003, 1, 1} --"Cyan"
  28. color_table[10] = {0.392, 0.576, 0.929} --"Cobalt"
  29. color_table[11] = {1, 0.498, 0} --"Orange"
  30. color_table[12] = {0.117, 0.80, 0.568} --"Teal"
  31. color_table[13] = {0, 0.392, 0.003} --"Sage"
  32. color_table[14] = {0.376, 0.217, 0.078} --"Brown"
  33. color_table[15] = {0.776, 0.6117, 0.423} --"Tan"
  34. color_table[16] = {0.615, 0.043, 0.054} --"Maroon"
  35. color_table[17] = {0.960, 0.6, 0.619} --"Salmon"
  36. color_table[18] = {1, 1, 1} -- "White"
  37.  
  38. function GetRequiredVersion()
  39.     return 200
  40. end
  41.  
  42. function OnScriptLoad(process, game, persistent)
  43.     GAME = game
  44.     GetGameAddresses(game)
  45. end
  46.  
  47. function OnNewGame(map)
  48.     team_play = getteamplay()
  49. end
  50.  
  51. function OnPlayerSpawn(player, m_objectId)
  52.     if getplayer(player) then
  53.         local m_objectId = getplayerobjectid(player)
  54.         if m_objectId then
  55.             local m_object = getobject(m_objectId)
  56.             if m_object then
  57.                 local m_player = getplayer(player)
  58.                 if m_player then
  59.                     if team_play then
  60.                         writebyte(gametype_base + 0x34, 0) -- temporarily sets team game to ffa
  61.                         if getteam(player) == 0 then                   
  62.                             writefloat(m_object + 0x1A0, red_color[1][1])
  63.                             writefloat(m_object + 0x1A4, red_color[1][2])
  64.                             writefloat(m_object + 0x1A8, red_color[1][3])                          
  65.                         else
  66.                             writefloat(m_object + 0x1A0, blue_color[1][1])
  67.                             writefloat(m_object + 0x1A4, blue_color[1][2])
  68.                             writefloat(m_object + 0x1A8, blue_color[1][3])
  69.                         end
  70.                         toteamplay = registertimer(100, "ToTeamPlay") -- resets game to team game
  71.                     else
  72.                         local random_color = SelectRandomRGB()
  73.                         if random_color ~= nil then
  74.                             writefloat(m_object + 0x1A0, color_table[random_color][1])
  75.                             writefloat(m_object + 0x1A4, color_table[random_color][2])
  76.                             writefloat(m_object + 0x1A8, color_table[random_color][3])
  77.                         end    
  78.                         -- this works too - comment out lines 73-77, uncomment line 79 --
  79.                         --ChangeFFAColor(player)
  80.                     end
  81.                 end
  82.             end
  83.         end    
  84.     end
  85. end
  86.  
  87. function ToTeamPlay(id, count)
  88.     writebyte(gametype_base + 0x34, 1)
  89.     return false
  90. end
  91.  
  92. function SelectRandomRGB()
  93.     local colorcount = #color_table
  94.     if colorcount > 0 then
  95.         return getrandomnumber(1, colorcount+1)
  96.     end
  97.     return nil 
  98. end
  99.  
  100. function ChangeFFAColor(player)
  101.     if getplayer(player) then
  102.         local m_objectId = getplayerobjectid(player)
  103.         if m_objectId then
  104.             local m_object = getobject(m_objectId)
  105.             if m_object then
  106.                 local m_player = getplayer(player)
  107.                 local color = getrandomnumber(1, 18)
  108.                 writeword(m_player + 0x60, color)
  109.             end
  110.         end
  111.     end
  112. end
  113.  
  114. function GetGameAddresses(game)
  115.     if game == "PC" or GAME == "PC" then
  116.         map_name = readstring(0x698F21)
  117.         gametype_base = 0x671340       
  118.     else
  119.         map_name = readstring(0x61D151)
  120.         gametype_base = 0x5F5498   
  121.     end
  122. end
  123.  
  124. function getteamplay()
  125.     if readbyte(gametype_base + 0x34) == 1 then
  126.         return true
  127.     else
  128.         return false
  129.     end
  130. end
  131.  
  132. function OnGameEnd(stage)
  133.     if stage == 1 then
  134.         if toteamplay then
  135.             toteamplay = nil
  136.         end
  137.     end
  138. end
  139.  
  140. --[[ Created by H® Shaft.
  141. Thanks to Oxide, AelitePrime, Wizard -- and 002
  142. Visit http://halorace.org/forum/index.php?topic=514.0 or
  143. Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
  144. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement