Advertisement
Altamurenza

Bully SE: MP-360 Flamethrower

Feb 28th, 2021
1,381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.17 KB | None | 0 0
  1. -- MP-360 FLAMETHROWER ( SOURCE CODE )
  2. -- AUTHOR   : ALTAMURENZA
  3.  
  4. --[[
  5.    
  6.     ALREADY DONE:
  7.     [+] Moving fire particles
  8.     [+] Vertical directions by mouse/stick
  9.     [+] Burnable dynamic objects
  10.     [+] Explosion for any vehicle
  11.     [+] Purchase-able weapon from store
  12.     [+] Fuel gauge on the right screen
  13.     [+] Trouble meter effect on ped, object, and vehicle
  14.    
  15.     NEED TO BE DONE:
  16.     [+] A worthy opponent for this weapon
  17.    
  18. ]]
  19.  
  20.  
  21. -- GLOBAL ENV
  22.  
  23. _G.ANIMATION = {}
  24. _G.OBJ_EFF = {}
  25. _G.VEH_EFF = {}
  26.  
  27. -- LOCAL ENV
  28.  
  29. local ANIM_SPEED_PER_FRAME = 5
  30. local ANIM_DELAY_PER_FRAME = 0
  31. local ANIM_RANGE = 10
  32.  
  33. -- NEW GLOBAL FUNCTION
  34.  
  35. _G.SHOP_ADD = _G.ShopAddItem
  36. _G.ShopAddItem = function(ZERO, ID, POINT, STOCK, PRICE, FUNC, AMOUNT)
  37.     _G.SHOP_ADD(ZERO, ID, POINT, STOCK, PRICE, FUNC, AMOUNT)
  38.    
  39.     if ID == 309 then
  40.         _G.BUY_MP360_FT = function()
  41.             local POTATO = PedGetAmmoCount(gPlayer, 316)
  42.             GiveWeaponToPlayer(396, false)
  43.            
  44.             if PedGetAmmoCount(gPlayer, 305) == 1 then
  45.                 ItemSetCurrentNum(316, POTATO > 0 and POTATO or 1)
  46.             end
  47.            
  48.             PlayerSetScriptSavedData(90, 60)
  49.         end
  50.        
  51.         _G.SHOP_ADD(0, 396, POINTLIST._STORE_DT_COMIC_ITEM5, PlayerGetScriptSavedData(90) >= 1 and 0 or 1, 5000, BUY_MP360_FT, 12)
  52.     end
  53. end
  54.  
  55. _G.STAT_ADD = _G.StatAddToInt
  56. _G.StatAddToInt = function(STAT)
  57.     if STAT == 3 then
  58.         PlayerSetScriptSavedData(90, 0)
  59.     end
  60.    
  61.     _G.STAT_ADD(STAT)
  62. end
  63.  
  64. -- FRAMEWORK
  65.  
  66. function FRAMEWORK()
  67.     while true do
  68.         Wait(0)
  69.        
  70.         -- ANIMATION
  71.         for I, V in ipairs(ANIMATION) do
  72.             if EffectIsRunning(V[1]) then
  73.                 if V[4] < GetTimer() then
  74.                     EffectSetPosition(V[1], V[2][V[3]][1], V[2][V[3]][2], V[2][V[3]][3] + 0.5)
  75.                    
  76.                     V[3], V[4] = V[3] + ANIM_SPEED_PER_FRAME, GetTimer() + ANIM_DELAY_PER_FRAME
  77.                 end
  78.                
  79.                 if V[3] < table.getn(V[2]) then
  80.                     for K, PED in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
  81.                         if PedIsValid(PED) and PED ~= V[5] and PedGetHealth(PED) > 0 and PedIsInAreaXYZ(PED, V[2][V[3]][1], V[2][V[3]][2], V[2][V[3]][3] + 0.5, 1.5) then
  82.                             if not PedMePlaying(PED, "HitTree") and math.random(1, 10) == 5 then
  83.                                 PedPlayHitReaction(PED)
  84.                             end
  85.                            
  86.                             PedApplyDamage(PED, 1)
  87.                             if PedIsValid(PedGetTargetPed(V[5])) and PedGetTargetPed(V[5]) == PED then
  88.                                 PedCreateStimulus(V[5], PED, 4)
  89.                             end
  90.                         end
  91.                     end
  92.                    
  93.                     local OBJ_LIST = {ObjectFindInArea(V[2][V[3]][1], V[2][V[3]][2], V[2][V[3]][3] + 0.5, 0.3)}
  94.                     if OBJ_LIST[1] then
  95.                         for INDEX = 2, table.getn(OBJ_LIST) do
  96.                             local ALREADY_HAVE_ONE = false
  97.                            
  98.                             for OBJECT, TABLE in pairs(OBJ_EFF) do
  99.                                 if OBJECT and string.format("%.1f", TABLE[2]) == string.format("%.1f", V[2][V[3]][1]) and string.format("%.1f", TABLE[3]) == string.format("%.1f", V[2][V[3]][2]) and string.format("%.1f", TABLE[4]) == string.format("%.1f", V[2][V[3]][3] + 0.5) then
  100.                                     ALREADY_HAVE_ONE = true
  101.                                    
  102.                                     break
  103.                                 end
  104.                             end
  105.                            
  106.                             if not ALREADY_HAVE_ONE and not OBJ_EFF[OBJ_LIST[INDEX]] then
  107.                                 PedCreateStimulus(V[5], OBJ_LIST[INDEX], 2)
  108.                                 OBJ_EFF[OBJ_LIST[INDEX]] = {nil, V[2][V[3]][1], V[2][V[3]][2], V[2][V[3]][3] + 0.5, AreaGetVisible(), 15, GetTimer() + math.random(3000, 5000)}
  109.                             end
  110.                         end
  111.                     end
  112.                    
  113.                     local VEH_LIST = VehicleFindInAreaXYZ(V[2][V[3]][1], V[2][V[3]][2], V[2][V[3]][3] + 0.5, 1.5)
  114.                     if type(VEH_LIST) == "table" then
  115.                         for ID, VEH in ipairs(VEH_LIST) do
  116.                             if VehicleIsValid(VEH) and not VEH_EFF[VEH] then
  117.                                 local ALREADY_HAVE_ONE = false
  118.                                
  119.                                 for VEHICLE, TABLE in pairs(VEH_EFF) do
  120.                                     if VehicleIsValid(VEHICLE) and string.format("%.1f", TABLE[2]) == string.format("%.1f", V[2][V[3]][1]) and string.format("%.1f", TABLE[3]) == string.format("%.1f", V[2][V[3]][2]) and string.format("%.1f", TABLE[4]) == string.format("%.1f", V[2][V[3]][3] + 0.5) then
  121.                                         ALREADY_HAVE_ONE = true
  122.                                        
  123.                                         break
  124.                                     end
  125.                                 end
  126.                                
  127.                                 if not ALREADY_HAVE_ONE then
  128.                                     PedCreateStimulus(V[5], VEH, 2)
  129.                                     VEH_EFF[VEH] = {nil, V[2][V[3]][1], V[2][V[3]][2], V[2][V[3]][3] + 0.5, AreaGetVisible(), 15, GetTimer() + math.random(6000, 10000)}
  130.                                 end
  131.                             end
  132.                         end
  133.                     end
  134.                 else
  135.                     if EffectIsRunning(V[1]) then
  136.                         EffectSlowKill(V[1], 1, true)
  137.                     end
  138.                    
  139.                     table.remove(ANIMATION, I)
  140.                 end
  141.             else
  142.                 table.remove(ANIMATION, I)
  143.             end
  144.         end
  145.        
  146.         -- OBJECT EFFECT
  147.         for OBJ, TABLE in pairs(OBJ_EFF) do
  148.             if not TABLE[1] or not EffectIsRunning(TABLE[1]) then
  149.                 TABLE[1] = EffectCreate("GymFire", TABLE[2], TABLE[3], TABLE[4])
  150.             else
  151.                 if TABLE[7] < GetTimer() then
  152.                     EffectSlowKill(TABLE[1], 2, true)
  153.                     ObjectBreak(OBJ)
  154.                    
  155.                     OBJ_EFF[OBJ] = nil
  156.                 end
  157.                
  158.                 for I, PED in {PedFindInAreaXYZ(0, 0, 0, 999999)} do
  159.                     if PedIsValid(PED) and PedGetHealth(PED) > 0 and PedIsInAreaXYZ(PED, TABLE[2], TABLE[3], TABLE[4], 2) then
  160.                         PedApplyDamage(PED, 0.1)
  161.                     end
  162.                 end
  163.             end
  164.            
  165.             if AreaGetVisible() ~= TABLE[5] or not PedIsInAreaObject(gPlayer, OBJ, 0, TABLE[6], 0) or ObjectIsDestroyed(OBJ) then
  166.                 if EffectIsRunning(TABLE[1]) then
  167.                     EffectSlowKill(TABLE[1], 2, true)
  168.                 end
  169.                
  170.                 OBJ_EFF[OBJ] = nil
  171.             end
  172.         end
  173.        
  174.         -- VEHICLE EFFECT
  175.         for VEH, TABLE in pairs(VEH_EFF) do
  176.             if VehicleIsValid(VEH) then
  177.                 local VX, VY, VZ = VehicleGetPosXYZ(VEH)
  178.                
  179.                 if not TABLE[1] or not EffectIsRunning(TABLE[1]) then
  180.                     TABLE[1] = EffectCreate("GymFire", TABLE[2], TABLE[3], TABLE[4])
  181.                 else
  182.                     for I, PED in {PedFindInAreaXYZ(0, 0, 0, 999999)} do
  183.                         if PedIsValid(PED) then
  184.                             if PedIsInVehicle(PED, VEH) then
  185.                                 PedExitVehicle(PED)
  186.                             else
  187.                                 if PED ~= gPlayer and PedGetLastVehicle(PED) == VEH then
  188.                                     PedStop(PED)
  189.                                     PedClearObjectives(PED)
  190.                                     PedMakeAmbient(PED)
  191.                                     PedFlee(PED)
  192.                                 end
  193.                             end
  194.                            
  195.                             if PedIsInAreaXYZ(PED, VX, VY, VZ + 0.5, 3) then
  196.                                 if PedGetHealth(PED) > 0 then
  197.                                     PedApplyDamage(PED, 0.1)
  198.                                 end
  199.                                
  200.                                 if PED == gPlayer and PedMePlaying(gPlayer, "MoveToVehicle") then
  201.                                     PlayerStopAllActionControllers()
  202.                                 end
  203.                             end
  204.                         end
  205.                     end
  206.                    
  207.                     local BIKE = {
  208.                         [272] = true,
  209.                         [273] = true,
  210.                         [274] = true,
  211.                         [279] = true,
  212.                         [277] = true,
  213.                         [278] = true,
  214.                         [280] = true,
  215.                         [281] = true,
  216.                         [282] = true,
  217.                         [283] = true,
  218.                     }
  219.                     if BIKE[VehicleGetModelId(VEH)] then
  220.                         EffectSetPosition(TABLE[1], VX, VY, VZ + 0.5)
  221.                     else
  222.                         VehicleEnableEngine(VEH, false)
  223.                         VehicleSetAccelerationMult(VEH, 0)
  224.                     end
  225.                    
  226.                     if TABLE[7] < GetTimer() and not PedIsInVehicle(gPlayer, VEH) then
  227.                         EffectSlowKill(TABLE[1], 2, true)
  228.                        
  229.                         local EXPLOSION = EffectCreate("BigExplosion", VX, VY, VZ + 0.5)
  230.                         local DESTROYED = EffectCreate("CarDestroyed", VX, VY, VZ + 0.5)
  231.                        
  232.                         for I, PED in {PedFindInAreaXYZ(0, 0, 0, 999999)} do
  233.                             if PedIsValid(PED) and PedIsInAreaXYZ(PED, VX, VY, VZ + 0.5, BIKE[VehicleGetModelId(VEH)] and 2.25 or 4.25) then
  234.                                 PedApplyDamage(PED, PedGetHealth(PED) > PedGetMaxHealth(PED) and PedGetHealth(PED) + 1 or PedGetMaxHealth(PED) + 1)
  235.                                 PedPlayHitReaction(PED)
  236.                             end
  237.                         end
  238.                        
  239.                         if VehicleIsValid(VEH) then
  240.                             VehicleDelete(VEH)
  241.                         end
  242.                        
  243.                         VEH_EFF[VEH] = nil
  244.                     end
  245.                 end
  246.                
  247.                 if AreaGetVisible() ~= TABLE[5] or not PedIsInAreaXYZ(gPlayer, TABLE[2], TABLE[3], TABLE[4], TABLE[6]) then
  248.                     if EffectIsRunning(TABLE[1]) then
  249.                         EffectSlowKill(TABLE[1], 2, true)
  250.                     end
  251.                     if VehicleIsValid(VEH) then
  252.                         VehicleDelete(VEH)
  253.                     end
  254.                    
  255.                     VEH_EFF[VEH] = nil
  256.                 end
  257.             else
  258.                 if EffectIsRunning(TABLE[1]) then
  259.                     EffectKill(TABLE[1])
  260.                 end
  261.                
  262.                 VEH_EFF[VEH] = nil
  263.             end
  264.         end
  265.     end
  266. end
  267.  
  268. -- MAIN FUNCTION
  269.  
  270. function main()
  271.     while not SystemIsReady() or AreaIsLoading() do
  272.         Wait(0)
  273.     end
  274.    
  275.     -- REQUIRED THREAD
  276.     CreateThread("FRAMEWORK")
  277.    
  278.     -- FIRE TIMER
  279.     local TIMER = GetTimer()
  280.    
  281.     -- VERTICAL DIR
  282.     local VER_DIR = 0
  283.    
  284.     while true do
  285.         Wait(0)
  286.        
  287.         -- POSITION
  288.         local X, Y, Z = PlayerGetPosXYZ()
  289.        
  290.         -- CHECK CONDITION
  291.         local IS_POSSIBLE = true
  292.         local NODE_LIST = {
  293.             "Block", "Blocks", "BlockHits", "HitTree", "Vehicles", "Attacks",
  294.         }
  295.        
  296.         for K, V in ipairs(NODE_LIST) do
  297.             if PedMePlaying(gPlayer, V) or PedIsValid(PedGetGrappleTargetPed(gPlayer)) then
  298.                 IS_POSSIBLE = false
  299.                
  300.                 break
  301.             end
  302.         end
  303.        
  304.         -- FLAMETHROWER
  305.         if PlayerHasWeapon(396) then
  306.            
  307.             -- FUEL SCRIPT
  308.             if not PedIsValid(FUEL_PED) then
  309.                 FUEL_PED = PedCreateXYZ(136, X, Y, Z + 12)
  310.                
  311.                 PedSetEffectedByGravity(FUEL_PED, false)
  312.                 PedSetStationary(FUEL_PED, true)
  313.                 PedSetAsleep(FUEL_PED, true)
  314.                 PedSetInvulnerable(FUEL_PED, true)
  315.                 PedMakeTargetable(FUEL_PED, false)
  316.                 PedSetHealth(FUEL_PED, PlayerGetScriptSavedData(90))
  317.                 PedSetMaxHealth(FUEL_PED, 60)
  318.                 PedShowHealthBar(FUEL_PED, true, "N_FUEL", false)
  319.                
  320.                 FUEL_DECREASE_TIMER = GetTimer()
  321.             else
  322.                 PedSetPosXYZ(FUEL_PED, X, Y, Z + 12)
  323.                 PedSetHealth(FUEL_PED, PlayerGetScriptSavedData(90))
  324.             end
  325.            
  326.             -- FIRE SCRIPT
  327.             if IS_POSSIBLE then
  328.                 if IsButtonPressed(12, 0) then
  329.                     VER_DIR = VER_DIR + GetStickValue(19, 0)
  330.                     VER_DIR = VER_DIR > 0.3 and 0.3 or (VER_DIR < -0.1 and -0.1 or VER_DIR)
  331.                    
  332.                     if TIMER < GetTimer() then
  333.                         local XYZ = {}
  334.                        
  335.                         for CURRENT_DIST = 2, ANIM_RANGE do
  336.                             for INTEGER = 1, 10 do
  337.                                 local PX, PY, PZ = PedGetOffsetInWorldCoords(gPlayer, 0, CURRENT_DIST + INTEGER/10, 0)
  338.                                
  339.                                 HEIGHT = VER_DIR * (CURRENT_DIST + INTEGER/10)
  340.                                 PZ = PZ + HEIGHT
  341.                                
  342.                                 local TARGET = PedGetTargetPed(gPlayer)
  343.                                 if PedIsValid(TARGET) then
  344.                                     local TX, TY, TZ = PedGetPosXYZ(TARGET)
  345.                                    
  346.                                     GAP = (PZ - TZ) / (CURRENT_DIST + INTEGER/10)
  347.                                     PZ = PZ + GAP
  348.                                 end
  349.                                
  350.                                 table.insert(XYZ, {PX, PY, PZ})
  351.                             end
  352.                         end
  353.                        
  354.                         local EFFECT = EffectCreate("Gymfire", XYZ[1][1], XYZ[1][2], XYZ[1][3] + 0.5)
  355.                         table.insert(ANIMATION, {EFFECT, XYZ, 2, GetTimer() + ANIM_DELAY_PER_FRAME, gPlayer})
  356.                        
  357.                         TIMER = GetTimer() + 100
  358.                     end
  359.                    
  360.                     if FUEL_DECREASE_TIMER + 1000 < GetTimer() then
  361.                         PlayerSetScriptSavedData(90, PlayerGetScriptSavedData(90) - 1)
  362.                         FUEL_DECREASE_TIMER = GetTimer()
  363.                     end
  364.                    
  365.                     if CameraGetActive() == 13 then
  366.                         CameraSetActive(1, 0.5, false)
  367.                     end
  368.                 elseif IsButtonBeingReleased(12, 0) then
  369.                     PlayerStopAllActionControllers()
  370.                    
  371.                     TIMER = GetTimer() + 0
  372.                 end
  373.             end
  374.         else
  375.             if PedIsValid(FUEL_PED) then
  376.                 PedDelete(FUEL_PED)
  377.             end
  378.         end
  379.        
  380.         -- ETC
  381.         if PlayerGetScriptSavedData(90) >= 1 then
  382.             -- FIXED WILD EDITS ( MOSTLY FROM 100% SAVEGAME ON INTERNET, BEWARE!! )
  383.             if PlayerGetScriptSavedData(90) > 60 then
  384.                 PlayerSetScriptSavedData(90, 60)
  385.             end
  386.            
  387.             -- FIXED SPUD_GUN
  388.             if ItemGetCurrentNum(316) == 0 then
  389.                 GiveWeaponToPlayer(396, false)
  390.                 ItemSetCurrentNum(316, 1)
  391.                 PedDestroyWeapon(gPlayer, 305)
  392.             end
  393.         else
  394.             -- REMOVE FLAMETHROWER
  395.             if ItemGetCurrentNum(396) ~= 0 then
  396.                 PedDestroyWeapon(gPlayer, 396)
  397.             end
  398.         end
  399.     end
  400. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement