Altamurenza

Bully SE/AE: Chaos Wand 2.0

Jul 23rd, 2022 (edited)
1,585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.04 KB | None | 0 0
  1. -- CHAOS WAND 2.0
  2. -- AUTHOR   : ALTAMURENZA
  3.  
  4.  
  5. --[[
  6.     ---------------
  7.     # GARAGES.LUA #
  8.     ---------------
  9. ]]
  10.  
  11. if type(F_InitGarages) ~= 'function' then
  12.     F_InitGarages = function()
  13.         DATLoad('Garages.DAT', 1)
  14.         GarageClearAll()
  15.         GarageAdd(TRIGGER._Garage_SchoolGrounds, POINTLIST._Garage_SchoolGrounds)
  16.         GarageAdd(TRIGGER._Garage_RichArea, POINTLIST._Garage_RichArea)
  17.         GarageAdd(TRIGGER._Garage_BusinessArea, POINTLIST._Garage_BusinessArea)
  18.         GarageAdd(TRIGGER._Garage_PoorArea, POINTLIST._Garage_PoorArea)
  19.     end
  20. end
  21.  
  22.  
  23. --[[
  24.     ---------------------
  25.     # CHAOS WAND SCRIPT #
  26.     ---------------------
  27. ]]
  28.  
  29. _G.CHAOS_WAND_MAIN = function()
  30.     while not SystemIsReady() or AreaIsLoading() do
  31.         Wait(0)
  32.     end
  33.    
  34.    
  35.     -----------------------
  36.     -- # SHARED VARIABLES #
  37.     -----------------------
  38.    
  39.     shared.gChaosWand = {}
  40.    
  41.     shared.gChaosWand.MinTimer = 0.5
  42.     shared.gChaosWand.MaxTimer = 1
  43.     shared.gChaosWand.Speed = 1
  44.     shared.gChaosWand.Delay = 0
  45.     shared.gChaosWand.Range = 3
  46.    
  47.    
  48.     -----------------------
  49.     -- # SHARED FRAMEWORK #
  50.     -----------------------
  51.    
  52.     shared.gChaosWand.Framework = {}
  53.     shared.gChaosWand.Framework.Animation = {}
  54.     shared.gChaosWand.Framework.Electrocute = {}
  55.     shared.gChaosWand.Framework.Burn = {}
  56.    
  57.     _G.CHAOS_WAND_FRAMEWORK = function()
  58.         local OPEN = {
  59.             [272] = true, [273] = true, [274] = true, [275] = true, [276] = true,
  60.             [277] = true, [278] = true, [279] = true, [280] = true, [281] = true,
  61.             [282] = true, [283] = true, [284] = true, [289] = true,
  62.         }
  63.        
  64.         while true do
  65.             Wait(0)
  66.            
  67.            
  68.             ----------------
  69.             -- # ANIMATION #
  70.             ----------------
  71.            
  72.             for INDEX, CONTENT in ipairs(shared.gChaosWand.Framework.Animation) do
  73.                 if EffectIsRunning(CONTENT.EFFECT) then
  74.                     if CONTENT.TIMER < GetTimer() then
  75.                         EffectSetPosition(CONTENT.EFFECT, CONTENT.XYZ[CONTENT.ID][1], CONTENT.XYZ[CONTENT.ID][2], CONTENT.XYZ[CONTENT.ID][3] + (CONTENT.TYPE == 'ElectrocuteLRG' and 1 or 0.5))
  76.                         CONTENT.ID, CONTENT.TIMER = CONTENT.ID + shared.gChaosWand.Speed, GetTimer() + shared.gChaosWand.Delay
  77.                     end
  78.                    
  79.                     if CONTENT.ID < table.getn(CONTENT.XYZ) then
  80.                         for _, PED in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
  81.                             if PedIsValid(PED) and PED ~= CONTENT.CASTER and PedGetHealth(PED) > 0 and PedIsInAreaXYZ(PED, CONTENT.XYZ[CONTENT.ID][1], CONTENT.XYZ[CONTENT.ID][2], CONTENT.XYZ[CONTENT.ID][3] + (CONTENT.TYPE == 'ElectrocuteLRG' and 1 or 0.5), 1.5) then
  82.                                 _G.MODE = (not PedIsInAnyVehicle(PED) or (PedIsInAnyVehicle(PED) and OPEN[VehicleGetModelId(VehicleFromDriver(PED))])) and {
  83.                                     ['ElectrocuteLRG'] = {'Electrocute', {TIMER = GetTimer() + math.random(shared.gChaosWand.MinTimer * 1000, shared.gChaosWand.MaxTimer * 1000), EFFECT = nil, SHAKE = GetTimer() + 0}},
  84.                                     ['GymFire'] = {'Burn', {TIMER = GetTimer() + math.random(shared.gChaosWand.MinTimer * 1000, shared.gChaosWand.MaxTimer * 1000), EFFECT = nil, TYPE = 'BarrelFire'}},
  85.                                 } or nil
  86.                                
  87.                                 if type(MODE) == 'table' and MODE[CONTENT.TYPE] then
  88.                                     if shared.gChaosWand.Framework[MODE[CONTENT.TYPE][1]][PED] then
  89.                                         if EffectIsRunning(shared.gChaosWand.Framework[MODE[CONTENT.TYPE][1]][PED].EFFECT) then
  90.                                             EffectKill(shared.gChaosWand.Framework[MODE[CONTENT.TYPE][1]][PED].EFFECT)
  91.                                         end
  92.                                        
  93.                                         shared.gChaosWand.Framework[MODE[CONTENT.TYPE][1]][PED] = nil
  94.                                     end
  95.                                    
  96.                                     shared.gChaosWand.Framework[MODE[CONTENT.TYPE][1]][PED] = MODE[CONTENT.TYPE][2]
  97.                                    
  98.                                     if EffectIsRunning(CONTENT.EFFECT) then
  99.                                         EffectSlowKill(CONTENT.EFFECT, 1, true)
  100.                                     end
  101.                                    
  102.                                     table.remove(shared.gChaosWand.Framework.Animation, INDEX)
  103.                                 end
  104.                             end
  105.                         end
  106.                     else
  107.                         if EffectIsRunning(CONTENT.EFFECT) then
  108.                             EffectSlowKill(CONTENT.EFFECT, 1, true)
  109.                         end
  110.                        
  111.                         table.remove(shared.gChaosWand.Framework.Animation, INDEX)
  112.                     end
  113.                 else
  114.                     table.remove(shared.gChaosWand.Framework.Animation, INDEX)
  115.                 end
  116.             end
  117.            
  118.            
  119.             ------------------
  120.             -- # ELECTROCUTE #
  121.             ------------------
  122.            
  123.             for PED, CONTENT in pairs(shared.gChaosWand.Framework.Electrocute) do
  124.                 if PedIsValid(PED) then
  125.                     if PED ~= gPlayer then
  126.                         if not SoundSpeechPlaying(PED) and PedGetHealth(PED) > 0 then
  127.                             SoundPlayAmbientSpeechEvent(PED, math.random(1, 2) == 1 and 'FIGHT_FLEE' or 'FLEE')
  128.                         end
  129.                     end
  130.                    
  131.                     local PX, PY, PZ = PedGetPosXYZ(PED)
  132.                     if CONTENT.TIMER == nil or CONTENT.TIMER > GetTimer() then
  133.                         if not CONTENT.EFFECT then
  134.                             CONTENT.EFFECT = EffectCreate('ElectrocuteLRG', PX, PY, PZ + 0.2)
  135.                         else
  136.                             EffectSetPosition(CONTENT.EFFECT, PX, PY, PZ + 0.2)
  137.                         end
  138.                        
  139.                         if CONTENT.SHAKE < GetTimer() then
  140.                             if PedIsInAnyVehicle(PED) then
  141.                                 PedSetActionNode(PED, '/Global/Vehicles/Bikes/ExecuteNodes/FallOffBase/base', 'Act/Vehicles.act')
  142.                             else
  143.                                 PedSetActionNode(PED, '/Global/HitTree/Standing/PostHit/BellyDown/OnGroundBounce/BackBounceSmall', 'Act/HitTree.act')
  144.                             end
  145.                             PedApplyDamage(PED, 5)
  146.                            
  147.                             CONTENT.SHAKE = GetTimer() + (PedMePlaying(PED, 'BellyDown') and 400 or 0)
  148.                         end
  149.                     end
  150.                    
  151.                     for _, PED in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
  152.                         if PedIsValid(PED) and PedIsInAreaXYZ(PED, PX, PY, PZ, 1.5) and PedGetHealth(PED) > 0 and not shared.gChaosWand.Framework.Electrocute[PED] then
  153.                             shared.gChaosWand.Framework.Electrocute[PED] = {TIMER = GetTimer() + math.random(shared.gChaosWand.MinTimer * 1000, shared.gChaosWand.MaxTimer * 1000), EFFECT = nil, SHAKE = GetTimer() + 0}
  154.                         end
  155.                     end
  156.                    
  157.                     if CONTENT.TIMER ~= nil and CONTENT.TIMER < GetTimer() then
  158.                         if EffectIsRunning(CONTENT.EFFECT) then
  159.                             EffectSlowKill(CONTENT.EFFECT, 1, true)
  160.                         end
  161.                        
  162.                         shared.gChaosWand.Framework.Electrocute[PED] = nil
  163.                     end
  164.                 else
  165.                     if EffectIsRunning(CONTENT.EFFECT) then
  166.                         EffectKill(CONTENT.EFFECT)
  167.                     end
  168.                    
  169.                     shared.gChaosWand.Framework.Electrocute[PED] = nil
  170.                 end
  171.             end
  172.            
  173.            
  174.             -----------
  175.             -- # BURN #
  176.             -----------
  177.            
  178.             for PED, CONTENT in pairs(shared.gChaosWand.Framework.Burn) do
  179.                 if PedIsValid(PED) then
  180.                     if PED ~= gPlayer then
  181.                         PedFlee(PED)
  182.                        
  183.                         if not SoundSpeechPlaying(PED) and PedGetHealth(PED) > 0 then
  184.                             SoundPlayAmbientSpeechEvent(PED, math.random(1, 2) == 1 and 'FIGHT_FLEE' or 'FLEE')
  185.                         end
  186.                     end
  187.                    
  188.                     local PX, PY, PZ = PedGetPosXYZ(PED)
  189.                     if CONTENT.TIMER == nil or CONTENT.TIMER > GetTimer() then
  190.                         if not CONTENT.EFFECT then
  191.                             EffectSlowKill(EffectCreate('BigExplosion', PX, PY, PZ + 1), 3, true)
  192.                             SoundPlay3D(PX, PY, PZ + 0.5, 'Chrybmb_Exp', 'large')
  193.                            
  194.                             CONTENT.EFFECT = EffectCreate(CONTENT.TYPE, PX, PY, PZ)
  195.                            
  196.                             if not shared.gChaosWand.Framework.Electrocute[PED] then
  197.                                 if PedIsInAnyVehicle(PED) then
  198.                                     PedSetActionNode(PED, '/Global/Vehicles/Bikes/HIT/FallOff/'..(PedIsFacingObject(PED, CONTENT.EFFECT, 3, 180) and 'CheckFrontHitCollision/HitHardFrontLong' or 'CheckBackHitCollision/HitHardBackLong'), 'Act/Vehicles.act')
  199.                                 else
  200.                                     PedSetActionNode(PED, '/Global/HitTree/KnockOuts/'..(PedIsFacingObject(PED, CONTENT.EFFECT, 3, 180) and 'Front/KD_DROP_Default' or 'Rear/Rear'), 'Act/HitTree.act')
  201.                                 end
  202.                             end
  203.                         end
  204.                        
  205.                         EffectSetPosition(CONTENT.EFFECT, PX, PY, PZ + ((PedGetHealth(PED) < 1 or PedMePlaying(PED, 'BellyDown') or PedMePlaying(PED, 'BellyUp') or PedMePlaying(PED, 'SitOnWall')) and 0.1 or 1))
  206.                         if PedGetHealth(PED) > 0 then
  207.                             PedApplyDamage(PED, 0.3)
  208.                         end
  209.                     end
  210.                    
  211.                     for _, PED in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
  212.                         if PedIsValid(PED) and PedIsInAreaXYZ(PED, PX, PY, PZ, 1) and PedGetHealth(PED) > 0 and not shared.gChaosWand.Framework.Burn[PED] then
  213.                             shared.gChaosWand.Framework.Burn[PED] = {TIMER = GetTimer() + math.random(shared.gChaosWand.MinTimer * 1000, shared.gChaosWand.MaxTimer * 1000), EFFECT = nil, TYPE = 'BarrelFire'}
  214.                         end
  215.                     end
  216.                    
  217.                     if CONTENT.TIMER ~= nil and CONTENT.TIMER < GetTimer() then
  218.                         if EffectIsRunning(CONTENT.EFFECT) then
  219.                             EffectSlowKill(CONTENT.EFFECT, 1, true)
  220.                         end
  221.                        
  222.                         shared.gChaosWand.Framework.Burn[PED] = nil
  223.                     end
  224.                 else
  225.                     if EffectIsRunning(CONTENT.EFFECT) then
  226.                         EffectKill(CONTENT.EFFECT)
  227.                     end
  228.                    
  229.                     shared.gChaosWand.Framework.Burn[PED] = nil
  230.                 end
  231.             end
  232.         end
  233.     end
  234.    
  235.     shared.gChaosWand_FrameworkThread = CreateThread('CHAOS_WAND_FRAMEWORK')
  236.    
  237.    
  238.     ------------
  239.     -- # SETUP #
  240.     ------------
  241.    
  242.     for _, STAT in ipairs({{REQ = '6_B', 2, 0, 15, 4, 6}, {REQ = '4_06', 1, 0, 15, 2, 5}, {REQ = '3_B', 1, 0, 12, 2, 4}, {REQ = '2_B', 1, 0, 9, 1, 3}, {REQ = '1_B', 1, 0, 6, 1, 2}}) do
  243.         if IsMissionCompleated(STAT.REQ) then
  244.             shared.gChaosWand.Speed, shared.gChaosWand.Delay, shared.gChaosWand.Range, shared.gChaosWand.MinTimer, shared.gChaosWand.MaxTimer = STAT[1], STAT[2], STAT[3], STAT[4], STAT[5]
  245.            
  246.             break
  247.         end
  248.     end
  249.    
  250.     for _, ANIM in ipairs({'W_Stick', 'Umbrella'}) do
  251.         if not HasAnimGroupLoaded(ANIM) then
  252.             LoadAnimationGroup(ANIM)
  253.         end
  254.     end
  255.    
  256.    
  257.     ----------------------
  258.     -- # LOCAL VARIABLES #
  259.     ----------------------
  260.    
  261.     local X, Y, Z, IS_POSSIBLE
  262.     local FLASHLIGHT = GetTimer()
  263.    
  264.     local GAME_EDITION = type(_G.ClassMusicSetPlayers) == 'function' and 'SE' or 'AE'
  265.    
  266.    
  267.     ----------------
  268.     -- # MAIN LOOP #
  269.     ----------------
  270.    
  271.     while true do
  272.         Wait(0)
  273.        
  274.         -- POSITION & CLEAN UP
  275.         X, Y, Z = PlayerGetPosXYZ()
  276.         PickupDestroyTypeInAreaXYZ(X, Y, Z, 4, 410)
  277.        
  278.         -- CONDITION CHECK
  279.         IS_POSSIBLE = true
  280.        
  281.         for _, NODE in ipairs({'BlockHits', 'BellyDown', 'BellyUp', 'SitOnWall', 'TreeCheck', 'Dead', 'Climb_ON_BOT', 'HoistUp_Spawns', 'Jump', 'HitTree', 'Vehicles', 'Swing3'}) do
  282.             if PedMePlaying(gPlayer, NODE) then
  283.                 IS_POSSIBLE = false
  284.                
  285.                 break
  286.             end
  287.         end
  288.        
  289.         -- LAUNCH MECHANISM
  290.         if PlayerHasWeapon(410) and IS_POSSIBLE and IsButtonBeingPressed(6, 0) then
  291.             if not shared.gChaosWand.Speech then
  292.                 shared.gChaosWand.Speech = {
  293.                     'INFIRMARY',
  294.                     'MP_TAUNT_JIMMY',
  295.                     'PLAYER_TAUNT_VICTIM',
  296.                     'PLAYER_DEJECTED',
  297.                     'PLAYER_NEGATIVE',
  298.                     'PLAYER_TAUNT_HARASS',
  299.                     'PLAYER_TAUNT_BURN',
  300.                     'PLAYER_EXCUSE',
  301.                     'PLAYER_JEER',
  302.                     'PLAYER_TAUNT_HUMILIATE',
  303.                     'PLAYER_TAUNT_HUMILIATE_HIT',
  304.                     'PLAYER_TAUNT_KO',
  305.                 }
  306.             end
  307.            
  308.             if SoundSpeechPlaying(gPlayer) then
  309.                 SoundStopCurrentSpeechEvent(gPlayer)
  310.             end
  311.             SoundPlayAmbientSpeechEvent(gPlayer, math.random(1, 5) == 3 and 'PLAYER_LAUGH_CRUEL' or shared.gChaosWand.Speech[math.random(1, table.getn(shared.gChaosWand.Speech))])
  312.            
  313.             PedSetActionNode(gPlayer, '/Global/umbrella/Actions/Attacks/HeavyAttacks/Swing1/Swing2/Swing3', 'Act/Weapons/umbrella.act')
  314.             Wait((600 / GameGetPedStat(gPlayer, 20)) * 100)
  315.            
  316.             local XYZ = {}
  317.            
  318.             for INT = 1, shared.gChaosWand.Range do
  319.                 for DEC = 1, 10 do
  320.                     local PX, PY, PZ = PedGetOffsetInWorldCoords(gPlayer, 0, INT + (DEC/10), 0)
  321.                     table.insert(XYZ, {PX, PY, PZ})
  322.                 end
  323.             end
  324.            
  325.             local TYPE = _G['IsButton'..(GAME_EDITION == 'SE' and 'Pressed' or 'Held')](6, 0) and 'ElectrocuteLRG' or 'GymFire'
  326.             table.insert(shared.gChaosWand.Framework.Animation, {EFFECT = EffectCreate(TYPE, XYZ[1][1], XYZ[1][2], XYZ[1][3] + (TYPE == 'ElectrocuteLRG' and 1 or 0.5)), TYPE = TYPE, XYZ = XYZ, ID = 2, TIMER = GetTimer() + shared.gChaosWand.Delay, CASTER = gPlayer})
  327.         end
  328.        
  329.         -- FLASHLIST REPLACEMENT
  330.         if PlayerHasWeapon(420) then
  331.             if FLASHLIGHT + 500 < GetTimer() and not PlayerHasWeapon(410) then
  332.                 PlayerSetWeapon(410, 1, false)
  333.             end
  334.         else
  335.             FLASHLIGHT = GetTimer()
  336.            
  337.             if ItemGetCurrentNum(420) == 0 then
  338.                 GiveWeaponToPlayer(420, 1, true)
  339.             end
  340.         end
  341.        
  342.         -- LIMIT
  343.         shared.gChaosWand.Speed = shared.gChaosWand.Speed > 5 and 5 or (shared.gChaosWand.Speed < 1 and 1 or math.floor(shared.gChaosWand.Speed))
  344.         shared.gChaosWand.Delay = shared.gChaosWand.Delay > 100 and 100 or (shared.gChaosWand.Delay < 0 and 0 or math.floor(shared.gChaosWand.Delay))
  345.     end
  346. end
  347.  
  348. shared.gChaosWand_MainThread = CreateThread('CHAOS_WAND_MAIN')
Advertisement
Add Comment
Please, Sign In to add comment