Advertisement
Altamurenza

Bully SE: Chaos Wand

Oct 4th, 2020
1,724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.38 KB | None | 0 0
  1. -- CHAOS WAND ( SOURCE CODE )
  2. -- AUTHOR   : ALTAMURENZA
  3.  
  4.  
  5. -- GLOBAL ENV
  6.  
  7. _G.ANIMATION = {}
  8. _G.ELECTROCUTION = {}
  9. _G.BURNT = {}
  10.  
  11. -- LOCAL ENV
  12.  
  13. local ANIM_SPEED_PER_FRAME = 1
  14. local ANIM_DELAY_PER_FRAME = 100
  15. local ANIM_RANGE = 5
  16.  
  17. local EFFECT_MIN_TIMER = 1
  18. local EFFECT_MAX_TIMER = 3
  19.  
  20. -- FRAMEWORK
  21.  
  22. function FRAMEWORK()
  23.     while true do
  24.         Wait(0)
  25.        
  26.         -- ANIMATION
  27.         for I, V in ipairs(ANIMATION) do
  28.             if EffectIsRunning(V[1]) then
  29.                 if V[5] < GetTimer() then
  30.                     EffectSetPosition(V[1], V[3][V[4]][1], V[3][V[4]][2], V[3][V[4]][3] + (V[2] == "ElectrocuteLRG" and 1 or 0.5))
  31.                    
  32.                     V[4], V[5] = V[4] + ANIM_SPEED_PER_FRAME, GetTimer() + ANIM_DELAY_PER_FRAME
  33.                 end
  34.                
  35.                 if V[4] < table.getn(V[3]) then
  36.                     for K, PED in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
  37.                         if PedIsValid(PED) and PED ~= V[6] and PedGetHealth(PED) > 0 and PedIsInAreaXYZ(PED, V[3][V[4]][1], V[3][V[4]][2], V[3][V[4]][3] + (V[2] == "ElectrocuteLRG" and 1 or 0.5), 1.5) then
  38.                             local M = {
  39.                                 ["ElectrocuteLRG"] = {"ELECTROCUTION", {GetTimer() + math.random(EFFECT_MIN_TIMER * 1000, EFFECT_MAX_TIMER * 1000), nil, GetTimer() + 0}},
  40.                                 ["GymFire"] = {"BURNT", {GetTimer() + math.random(EFFECT_MIN_TIMER * 1000, EFFECT_MAX_TIMER * 1000), "BarrelFire", nil}},
  41.                             }
  42.                            
  43.                             if M[V[2]] then
  44.                                 if not _G[M[V[2]][1]][PED] then
  45.                                     _G[M[V[2]][1]][PED] = M[V[2]][2]
  46.                                 end
  47.                             end
  48.                         end
  49.                     end
  50.                 else
  51.                     if EffectIsRunning(V[1]) then
  52.                         EffectSlowKill(V[1], 1, true)
  53.                     end
  54.                    
  55.                     table.remove(ANIMATION, I)
  56.                 end
  57.             else
  58.                 table.remove(ANIMATION, I)
  59.             end
  60.         end
  61.        
  62.         -- ELECTROCUTION
  63.         for PED, EFFECT in pairs(ELECTROCUTION) do
  64.             if PedIsValid(PED) then
  65.                 if PED ~= gPlayer then
  66.                     if not SoundSpeechPlaying(PED) and PedGetHealth(PED) > 0 then
  67.                         SoundPlayAmbientSpeechEvent(PED, math.random(1, 2) == 1 and "FIGHT_FLEE" or "FLEE")
  68.                     end
  69.                 end
  70.                
  71.                 local PX, PY, PZ = PedGetPosXYZ(PED)
  72.                 if EFFECT[1] == nil or EFFECT[1] > GetTimer() then
  73.                     if not EFFECT[2] then
  74.                         EFFECT[2] = EffectCreate("ElectrocuteLRG", PX, PY, PZ + 0.2)
  75.                     else
  76.                         EffectSetPosition(EFFECT[2], PX, PY, PZ + 0.2)
  77.                     end
  78.                    
  79.                     if EFFECT[3] < GetTimer() then
  80.                         PedSetActionNode(PED, "/Global/HitTree/Standing/PostHit/BellyDown/OnGroundBounce/BackBounceSmall", "Act/HitTree.act")
  81.                         PedApplyDamage(PED, 5)
  82.                        
  83.                         EFFECT[3] = GetTimer() + 400
  84.                     end
  85.                 end
  86.                
  87.                 for I, PED in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
  88.                     if PedIsValid(PED) and PedIsInAreaXYZ(PED, PX, PY, PZ, 1.5) and PedGetHealth(PED) > 0 and not ELECTROCUTION[PED] then
  89.                         ELECTROCUTION[PED] = {GetTimer() + math.random(EFFECT_MIN_TIMER * 1000, EFFECT_MAX_TIMER * 1000), nil, GetTimer() + 0}
  90.                     end
  91.                 end
  92.                
  93.                 if EFFECT[1] ~= nil and EFFECT[1] < GetTimer() then
  94.                     if EffectIsRunning(EFFECT[2]) then
  95.                         EffectSlowKill(EFFECT[2], 1, true)
  96.                     end
  97.                    
  98.                     ELECTROCUTION[PED] = nil
  99.                 end
  100.             else
  101.                 if EffectIsRunning(EFFECT[2]) then
  102.                     EffectKill(EFFECT[2])
  103.                 end
  104.                
  105.                 ELECTROCUTION[PED] = nil
  106.             end
  107.         end
  108.        
  109.         -- BURNT
  110.         for PED, EFFECT in pairs(BURNT) do
  111.             if PedIsValid(PED) then
  112.                 if PED ~= gPlayer then
  113.                     PedFlee(PED)
  114.                    
  115.                     if not SoundSpeechPlaying(PED) and PedGetHealth(PED) > 0 then
  116.                         SoundPlayAmbientSpeechEvent(PED, math.random(1, 2) == 1 and "FIGHT_FLEE" or "FLEE")
  117.                     end
  118.                 end
  119.                
  120.                 local PX, PY, PZ = PedGetPosXYZ(PED)
  121.                 if EFFECT[1] == nil or EFFECT[1] > GetTimer() then
  122.                     if not EFFECT[3] then
  123.                         local EXPLOSION = EffectCreate("BigExplosion", PX, PY, PZ + 1)
  124.                         SoundPlay3D(PX, PY, PZ + 0.5, "Chrybmb_Exp", "large")
  125.                        
  126.                         if not ELECTROCUTION[PED] then
  127.                             PedSetActionNode(PED, "/Global/HitTree/KnockOuts/Rear/Rear", "Act/HitTree.act")
  128.                         end
  129.                        
  130.                         EFFECT[3] = EffectCreate(EFFECT[2], PX, PY, PZ)
  131.                         EffectSlowKill(EXPLOSION, 3, true)
  132.                     end
  133.                    
  134.                     EffectSetPosition(EFFECT[3], PX, PY, PZ + ((PedGetHealth(PED) < 1 or PedMePlaying(PED, "BellyDown") or PedMePlaying(PED, "BellyUp") or PedMePlaying(PED, "SitOnWall")) and 0.1 or 1))
  135.                     if PedGetHealth(PED) > 0 then
  136.                         PedApplyDamage(PED, 0.3)
  137.                     end
  138.                 end
  139.                
  140.                 for I, PED in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
  141.                     if PedIsValid(PED) and PedIsInAreaXYZ(PED, PX, PY, PZ, 1) and PedGetHealth(PED) > 0 and not BURNT[PED] then
  142.                         BURNT[PED] = {GetTimer() + math.random(EFFECT_MIN_TIMER * 1000, EFFECT_MAX_TIMER * 1000), "BarrelFire", nil}
  143.                     end
  144.                 end
  145.                
  146.                 if EFFECT[1] ~= nil and EFFECT[1] < GetTimer() then
  147.                     if EffectIsRunning(EFFECT[3]) then
  148.                         EffectSlowKill(EFFECT[3], 1, true)
  149.                     end
  150.                    
  151.                     BURNT[PED] = nil
  152.                 end
  153.             else
  154.                 if EffectIsRunning(EFFECT[3]) then
  155.                     EffectKill(EFFECT[3])
  156.                 end
  157.                
  158.                 BURNT[PED] = nil
  159.             end
  160.         end
  161.     end
  162. end
  163.  
  164. -- PROCESS
  165.  
  166. function main()
  167.     while not SystemIsReady() or AreaIsLoading() do
  168.         Wait(0)
  169.     end
  170.    
  171.     -- SETUP
  172.     local STORYLINE = {
  173.         {QST = "6_B", 5, 0, 30, 5, 9},
  174.         {QST = "4_06", 4, 0, 20, 5, 7},
  175.         {QST = "3_B", 3, 0, 15, 4, 6},
  176.         {QST = "2_B", 2, 0, 12, 3, 5},
  177.         {QST = "1_B", 1, 0, 8, 2, 4},
  178.     }
  179.     for I, V in ipairs(STORYLINE) do
  180.         if IsMissionCompleated(V.QST) then
  181.             ANIM_SPEED_PER_FRAME, ANIM_DELAY_PER_FRAME, ANIM_RANGE, EFFECT_MIN_TIMER, EFFECT_MAX_TIMER = V[1], V[2], V[3], V[4], V[5]; break
  182.         end
  183.     end
  184.    
  185.     -- REQUIRED ANIMATION
  186.     local ANIM = {
  187.         "W_Stick", "Umbrella",
  188.     }
  189.     for I, V in ipairs(ANIM) do
  190.         if HasAnimGroupLoaded(V) == false then
  191.             LoadAnimationGroup(V)
  192.         end
  193.     end
  194.    
  195.     -- FRAMEWORK
  196.     CreateThread("FRAMEWORK")
  197.    
  198.     -- SWAP TO WAND
  199.     local TIMER = GetTimer()
  200.    
  201.     while true do
  202.         Wait(0)
  203.        
  204.         -- POSITION
  205.         local X, Y, Z = PlayerGetPosXYZ()
  206.        
  207.         -- DESTROY WAND
  208.         PickupDestroyTypeInAreaXYZ(X, Y, Z, 4, 410)
  209.        
  210.         -- TARGET
  211.         local TARGET = PedIsValid(PedGetTargetPed(gPlayer)) and PedGetTargetPed(gPlayer) or gPlayer
  212.        
  213.         -- REAL WAND
  214.         if IsButtonBeingPressed(6, 0) and not PlayerIsInAnyVehicle() then
  215.             local MEET_REQUIREMENTS = true
  216.             local NODE_LIST = {
  217.                 "BlockHits", "BellyDown", "BellyUp", "SitOnWall", "TreeCheck", "Dead", "Climb_ON_BOT",
  218.                 "HoistUp_Spawns", "Jump", "HitTree"
  219.             }
  220.            
  221.             for K, V in ipairs(NODE_LIST) do
  222.                 if PedMePlaying(gPlayer, V) then
  223.                     MEET_REQUIREMENTS = false; break
  224.                 end
  225.             end
  226.            
  227.             if MEET_REQUIREMENTS then
  228.                 if PedHasWeapon(gPlayer, 410) and not PedMePlaying(gPlayer, "Swing3") then
  229.                     local SPEECH = {
  230.                         "INFIRMARY",
  231.                         "MP_TAUNT_JIMMY",
  232.                         "PLAYER_TAUNT_VICTIM",
  233.                         "PLAYER_DEJECTED",
  234.                         "PLAYER_NEGATIVE",
  235.                         "PLAYER_TAUNT_HARASS",
  236.                         "PLAYER_TAUNT_BURN",
  237.                         "PLAYER_EXCUSE",
  238.                         "PLAYER_JEER",
  239.                         "PLAYER_TAUNT_HUMILIATE",
  240.                         "PLAYER_TAUNT_HUMILIATE_HIT",
  241.                         "PLAYER_TAUNT_KO",
  242.                     }
  243.                     if SoundSpeechPlaying(gPlayer) then
  244.                         SoundStopCurrentSpeechEvent(gPlayer)
  245.                     end
  246.                     SoundPlayAmbientSpeechEvent(gPlayer, math.random(1, 5) == 3 and "PLAYER_LAUGH_CRUEL" or SPEECH[math.random(1, table.getn(SPEECH))])
  247.                    
  248.                     PedSetActionNode(gPlayer, "/Global/umbrella/Actions/Attacks/HeavyAttacks/Swing1/Swing2/Swing3", "Act/Weapons/umbrella.act")
  249.                     Wait((600 / GameGetPedStat(gPlayer, 20)) * 100)
  250.                    
  251.                     local XYZ = {}
  252.                    
  253.                     for CURRENT_DIST = 1, ANIM_RANGE do
  254.                         for INTEGER = 1, 10 do
  255.                             local PX, PY, PZ = PedGetOffsetInWorldCoords(gPlayer, 0, CURRENT_DIST + INTEGER/10, 0)
  256.                             table.insert(XYZ, {PX, PY, PZ})
  257.                         end
  258.                     end
  259.                    
  260.                     local EFFECT_TYPE = IsButtonPressed(6, 0) and "ElectrocuteLRG" or "GymFire"
  261.                     local EFFECT = EffectCreate(EFFECT_TYPE, XYZ[1][1], XYZ[1][2], XYZ[1][3] + (EFFECT_TYPE == "ElectrocuteLRG" and 1 or 0.5))
  262.                    
  263.                     table.insert(ANIMATION, {EFFECT, EFFECT_TYPE, XYZ, 2, GetTimer() + ANIM_DELAY_PER_FRAME, gPlayer})
  264.                 end
  265.             end
  266.         end
  267.        
  268.         -- REPLACE FLASHLIGHT
  269.         if PedHasWeapon(gPlayer, 420) then
  270.            
  271.             if TIMER + 500 < GetTimer() and not PedHasWeapon(gPlayer, 410) then
  272.                 PlayerSetWeapon(410, 1, false)
  273.             end
  274.         else
  275.             TIMER = GetTimer()
  276.         end
  277.        
  278.         -- IF LOST
  279.         if ItemGetCurrentNum(420) == 0 then
  280.             GiveWeaponToPlayer(420, 1, true)
  281.         end
  282.        
  283.         -- LIMIT SPEED & DELAY
  284.         ANIM_SPEED_PER_FRAME = ANIM_SPEED_PER_FRAME > 5 and 5 or (ANIM_SPEED_PER_FRAME < 1 and 1 or math.floor(ANIM_SPEED_PER_FRAME))
  285.         ANIM_DELAY_PER_FRAME = ANIM_DELAY_PER_FRAME > 100 and 100 or (ANIM_DELAY_PER_FRAME < 0 and 0 or math.floor(ANIM_DELAY_PER_FRAME))
  286.     end
  287. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement