Advertisement
HR_Shaft

Auto Vehicle Flip 1.1 for Phasor V2+

Nov 23rd, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.74 KB | None | 0 0
  1. -- Auto Vehicle Flip 1.1 for Phasor V2+
  2. -- by Giraffe, converted to phasor by H® Shaft
  3.  
  4. -- This script disables rider ejection (forcing players to exit vehicle when vehicle is upside down)
  5. -- and automatically flips upside down vehicles right-side up.
  6.  
  7. -- true or false, whether or not to only auto flip vehicles that players are in
  8. PLAYER_VEHICLES_ONLY = true
  9.  
  10. -- true or false, whether or not to wait until impact before auto flipping vehicle
  11. WAIT_FOR_IMPACT = true
  12.  
  13. -- don't edit below --
  14. object_table_ptr = nil
  15. riderejection = 1
  16.  
  17. function GetRequiredVersion()
  18.     return 200
  19. end
  20.  
  21. function OnScriptLoad(process, game, persistent)
  22.     if game == true or game == "PC" then
  23.         GAME = "PC"
  24.         riderejection = readbyte(0x6163EC)
  25.         writebyte(0x6163EC, 0) 
  26.         object_table_ptr = 0x744C34
  27.     else
  28.         GAME = "CE"
  29.         riderejection = readbyte(0x59A34C)
  30.         writebyte(0x59A34C, 0) 
  31.         object_table_ptr = 0x6C69F0
  32.     end
  33. end
  34.  
  35. function OnNewGame(map)
  36.     if GAME == "PC" then
  37.         riderejection = readbyte(0x6163EC)
  38.         writebyte(0x6163EC, 0) 
  39.     else
  40.         riderejection = readbyte(0x59A34C)
  41.         writebyte(0x59A34C, 0)
  42.     end
  43. end
  44.  
  45. function OnGameEnd(stage)
  46.     if GAME == "PC" then
  47.         writebyte(0x6163EC, 1)
  48.     else
  49.         writebyte(0x59A34C, 1)
  50.     end
  51. end
  52.  
  53. function OnClientUpdate(player)
  54.     if(PLAYER_VEHICLES_ONLY) then
  55.         for i=0,15 do
  56.             if getplayer(i) then
  57.                 local player_obj_id = getplayerobjectid(i)
  58.                 if player_obj_id then
  59.                     local player_object = getobject(player_obj_id)
  60.                     if player_object then
  61.                         local player_vehicle_id = readdword(player_object + 0x11C)               
  62.                         if player_vehicle_id then
  63.                             local vehicle_object = getobject(player_vehicle_id)
  64.                             flip_vehicle(vehicle_object)
  65.                         end
  66.                     end
  67.                 end
  68.             end
  69.         end    
  70.     else
  71.         local object_table = readdword(object_table_ptr)
  72.         local object_count = readword(object_table + 0x2E)
  73.         local first_object = readdword(object_table + 0x34)
  74.         for i=0,object_count-1 do
  75.             local object = readdword(first_object + i * 0xC + 0x8)
  76.             if(object ~= 0 and object ~= 0xFFFFFFFF) then
  77.                 if(readword(object + 0xB4) == 1) then
  78.                     flip_vehicle(object)
  79.                 end
  80.             end
  81.         end
  82.     end
  83. end
  84.  
  85. function flip_vehicle(vehicle_object)
  86.     if vehicle_object then
  87.         if readbit(vehicle_object + 0x8B, 7) then
  88.             if (WAIT_FOR_IMPACT and not readbit(vehicle_object + 0x10, 1)) then
  89.                 return
  90.             end
  91.             writefloat(vehicle_object + 0x80, 0)
  92.             writefloat(vehicle_object + 0x84, 0)
  93.             writefloat(vehicle_object + 0x88, 1)       
  94.         end
  95.     end
  96. end
  97.  
  98. function OnScriptUnload()
  99.     if GAME == "PC" then
  100.         writebyte(0x6163EC, riderejection)
  101.     else
  102.         writebyte(0x59A34C, riderejection)
  103.     end
  104. end
  105.  
  106. -- Created by H® Shaft
  107. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement