Advertisement
HR_Shaft

Auto Vehicle Flip for Phasor V2+

Sep 5th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.69 KB | None | 0 0
  1. -- Auto Vehicle Flip 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.     else
  27.         GAME = "CE"
  28.         riderejection = readbyte(0x59A34C)
  29.         writebyte(0x59A34C, 0)     
  30.     end
  31. end
  32.  
  33. function OnNewGame(map)
  34.     if GAME == "PC" then
  35.         riderejection = readbyte(0x6163EC)
  36.         writebyte(0x6163EC, 0) 
  37.     else
  38.         riderejection = readbyte(0x59A34C)
  39.         writebyte(0x59A34C, 0)
  40.     end
  41. end
  42.  
  43. function OnGameEnd(stage)
  44.     if GAME == "PC" then
  45.         writebyte(0x6163EC, 1)
  46.     else
  47.         writebyte(0x59A34C, 1)
  48.     end
  49. end
  50.  
  51. function OnClientUpdate(player)
  52.     if(PLAYER_VEHICLES_ONLY) then
  53.         for i=0,15 do
  54.             if getplayer(i) then
  55.                 local player_obj_id = getplayerobjectid(i)
  56.                 if player_obj_id then
  57.                     local player_object = getobject(player_obj_id)
  58.                     if player_object then
  59.                         local player_vehicle_id = readdword(player_object + 0x11C)               
  60.                         if player_vehicle_id then
  61.                             local vehicle_object = getobject(player_vehicle_id)
  62.                             flip_vehicle(vehicle_object)
  63.                         end
  64.                     end
  65.                 end
  66.             end
  67.         end    
  68.     else
  69.         local object_table = readdword(readdword(object_table_ptr + 2))
  70.         local object_count = readword(object_table + 0x2E)
  71.         local first_object = readdword(object_table + 0x34)
  72.         for i=0,object_count-1 do
  73.             local object = readdword(first_object + i * 0xC + 0x8)
  74.             if(object ~= 0 and object ~= 0xFFFFFFFF) then
  75.                 if(readword(object + 0xB4) == 1) then
  76.                     flip_vehicle(object)
  77.                 end
  78.             end
  79.         end
  80.     end
  81. end
  82.  
  83. function flip_vehicle(vehicle_object)
  84.     if vehicle_object then
  85.         if readbit(vehicle_object + 0x8B, 7) then
  86.             if (WAIT_FOR_IMPACT and not readbit(vehicle_object + 0x10, 1)) then
  87.                 return
  88.             end
  89.             writefloat(vehicle_object + 0x80, 0)
  90.             writefloat(vehicle_object + 0x84, 0)
  91.             writefloat(vehicle_object + 0x88, 1)       
  92.         end
  93.     end
  94. end
  95.  
  96. function OnScriptUnload()
  97.     if GAME == "PC" then
  98.         writebyte(0x6163EC, riderejection)
  99.     else
  100.         writebyte(0x59A34C, riderejection)
  101.     end
  102. end
  103.  
  104. -- Created by H® Shaft
  105. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement