DaBOSS54320

Bully LUA: PedCreateSheldonator

Sep 25th, 2016
894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.79 KB | None | 0 0
  1. function PedCreateSheldonator(x,y,z,ambient)
  2.     -- Usage example: sheldonator = PedCreateSheldonator(270,-110,6,true)
  3.     -- Note: This function creates a table called gSheldonators and it should never be overwritten or the function may not work properly.
  4.     -- Note: If gForceSlowSheldonator is true, all created Sheldonators will be slower.
  5.     -- Note: Set the 4th argument to true to make it so the Sheldonator will not be made ambient until he has killed the player.
  6.     --[[ When using this function, make sure all the animation groups for the Sheldonator are loaded:
  7.     LoadAnimationGroup("4_04_FunhouseFun")
  8.     LoadAnimationGroup("Straf_Dout")
  9.     LoadAnimationGroup("Straf_Male")
  10.     LoadAnimationGroup("Straf_Prep")
  11.     LoadAnimationGroup("Straf_Savage")
  12.     LoadAnimationGroup("Straf_Wrest")
  13.     LoadAnimationGroup("F_BULLY")
  14.     LoadAnimationGroup("F_Douts")
  15.     LoadAnimationGroup("F_Greas")
  16.     LoadAnimationGroup("F_Jocks")
  17.     LoadAnimationGroup("F_Pref")
  18.     LoadAnimationGroup("F_Preps")
  19.     LoadAnimationGroup("DO_Striker")
  20.     LoadAnimationGroup("DO_StrikeCombo")
  21.     LoadAnimationGroup("B_Striker")
  22.     LoadAnimationGroup("G_Striker")
  23.     LoadAnimationGroup("G_Grappler")
  24.     LoadAnimationGroup("J_Striker")
  25.     LoadAnimationGroup("P_Striker")
  26.     LoadAnimationGroup("Authority")
  27.     LoadAnimationGroup("Boxing")
  28.     LoadAnimationGroup("Nemesis")
  29.     LoadAnimationGroup("Russell")
  30.     ]]
  31.    
  32.     -- Create thread and table:
  33.     if not gSheldonators then
  34.         gSheldonators = {}
  35.         gSheldonatorThread = function()
  36.             local px,py,pz,near,nearBefore,notWanted
  37.             local processSheldonator = function(v)
  38.                 local x,y,z = PedGetPosXYZ(v[1])
  39.                 local dist = math.sqrt((px-x)*(px-x) + (py-y)*(py-y) + (pz-z)*(pz-z))
  40.                 if v[3] then
  41.                     if GetTimer() >= v[3] + 1100/(v[2]/100) then
  42.                         if PedGetGrappleTargetPed(v[1]) == gPlayer then
  43.                             PlayerSetControl(0)
  44.                             repeat
  45.                                 PedSetActionNode(v[1],"/Global/Actions/Grapples/GrappleReversals/MountReversals/MountReversalPunches","Act/Globals.act")
  46.                                 for hit = 1,2 do
  47.                                     Wait(325/(v[2]/100))
  48.                                     if not PedIsValid(v[1]) then
  49.                                         return false
  50.                                     end
  51.                                     PlayerSetHealth(PlayerGetHealth()-7)
  52.                                 end
  53.                                 Wait(0)
  54.                                 if not PedIsValid(v[1]) then
  55.                                     return false
  56.                                 end
  57.                             until PedGetGrappleTargetPed(v[1]) ~= gPlayer or PlayerGetHealth() <= 0
  58.                             while PedIsPlaying(v[1],"/Global/Actions/Grapples/GrappleReversals/MountReversals/MountReversalPunches",true) do
  59.                                 Wait(0)
  60.                                 if not PedIsValid(v[1]) then
  61.                                     return false
  62.                                 end
  63.                             end
  64.                             if PlayerGetHealth() <= 0 then
  65.                                 PedSetActionNode(v[1],"/Global/404Conv/Nerds/Dance1","Act/Conv/4_04.act")
  66.                                 if v[5] then
  67.                                     PedMakeAmbient(v[1])
  68.                                     v[5] = nil
  69.                                 end
  70.                             end
  71.                             PlayerSetControl(1)
  72.                         end
  73.                         v[3] = nil
  74.                     elseif PedGetGrappleTargetPed(v[1]) == gPlayer and IsButtonBeingPressed(9,0) then
  75.                         local original = GameGetPedStat(v[1],39)
  76.                         GameSetPedStat(v[1],39,0)
  77.                         PedSetActionNode(gPlayer,"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/DirectionalPush","Act/Globals.act")
  78.                         PedSetActionNode(v[1],"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/DirectionalPush/RCV","Act/Globals.act")
  79.                         repeat
  80.                             Wait(0)
  81.                             if not PedIsValid(v[1]) then
  82.                                 return false
  83.                             end
  84.                         until PedGetGrappleTargetPed(v[1]) ~= gPlayer
  85.                         GameSetPedStat(v[1],39,original)
  86.                         v[3] = nil
  87.                     end
  88.                 elseif PedMePlaying(v[1],"Default_KEY") and not PedIsDead(gPlayer) then
  89.                     if GetTimer() >= v[4] then
  90.                         if dist < 2.6 then
  91.                             PedFaceXYZ(v[1],px,py,pz)
  92.                             PedSetActionNode(v[1],"/Global/J_Damon/Offense/Medium/Grapples/GrapplesAttempt","Act/Anim/J_Damon.act")
  93.                             v[3] = GetTimer()
  94.                             v[4] = GetTimer() + math.random(2000,12500)
  95.                         end
  96.                     elseif GetTimer() >= v[6] then
  97.                         if dist < 1.2 then
  98.                             local reversed = false
  99.                             PedFaceXYZ(v[1],px,py,pz)
  100.                             PedSetActionNode(v[1],"/Global/Actions/Grapples/Front/Grapples/GrappleAttempt","Act/Globals.act")
  101.                             while PedIsPlaying(v[1],"/Global/Actions/Grapples/Front/Grapples/GrappleAttempt",true) do
  102.                                 Wait(0)
  103.                                 if not PedIsValid(v[1]) then
  104.                                     return false
  105.                                 elseif PedGetGrappleTargetPed(v[1]) == gPlayer and IsButtonBeingPressed(9,0) then
  106.                                     PedSetActionNode(gPlayer,"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/DirectionalPush","Act/Globals.act")
  107.                                     reversed = true
  108.                                 end
  109.                             end
  110.                             if not reversed and PedGetGrappleTargetPed(v[1]) == gPlayer and PedIsPlaying(v[1],"/Global/Actions/Grapples/Front/Grapples/Hold_Idle",true) then
  111.                                 local moves = {"GrappleStrikes/HitA/Charge","GrappleStrikes/HitB/Charge","GrappleStrikes/HitC/Charge","DirectionalPush","HeadButt","BodySlam"}
  112.                                 local move = "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/"..moves[math.random(1,table.getn(moves))]
  113.                                 PedSetActionNode(v[1],move,"Act/Globals.act")
  114.                                 while PedIsPlaying(v[1],move,true) do
  115.                                     Wait(0)
  116.                                     if not PedIsValid(v[1]) then
  117.                                         return false
  118.                                     end
  119.                                 end
  120.                             end
  121.                             v[6] = GetTimer() + math.random(3000,9500)
  122.                         end
  123.                     elseif GetTimer() >= v[7] then
  124.                         if dist < 1.4 then
  125.                             PedFaceXYZ(v[1],px,py,pz)
  126.                             PedSetActionNode(v[1],"/Global/BOSS_Darby/Offense/Short/Grapples/HeavyAttacks/Catch_Throw","Act/Anim/BOSS_Darby.act")
  127.                         end
  128.                         v[7] = GetTimer() + math.random(6000,14500)
  129.                     end
  130.                 end
  131.                 if not near then
  132.                     near = (dist < 10 or (dist < 50 and PedIsOnScreen(v[1]))) and not PedIsDead(v[1])
  133.                 end
  134.                 return true
  135.             end
  136.             while true do
  137.                 px,py,pz = PlayerGetPosXYZ()
  138.                 near = false
  139.                 for i,v in ipairs(gSheldonators) do
  140.                     if not PedIsValid(v[1]) or not processSheldonator(v) then
  141.                         table.remove(gSheldonators,i)
  142.                         i = i - 1
  143.                     end
  144.                 end
  145.                 if near then
  146.                     if not nearBefore then
  147.                         notWanted = PlayerGetPunishmentPoints() <= 200
  148.                     end
  149.                     if notWanted then
  150.                         if PlayerGetPunishmentPoints() > 200 then
  151.                             PlayerSetPunishmentPoints(200)
  152.                         end
  153.                     elseif nearBefore then
  154.                         notWanted = PlayerGetPunishmentPoints() <= 200
  155.                     end
  156.                 end
  157.                 nearBefore = near
  158.                 Wait(0)
  159.             end
  160.         end
  161.         gSheldonatorThread = CreateThread("gSheldonatorThread")
  162.     end
  163.    
  164.     -- Get spawn position:
  165.     if not x or not y or not z then
  166.         x,y,z = PedFindRandomSpawnPosition()
  167.         if x == 9999 then
  168.             return nil
  169.         end
  170.     end
  171.    
  172.     -- Spawn ped:
  173.     local ped = PedCreateXYZ(66,x,y,z)
  174.     --PED_SetMissionPed(ped,true)
  175.    
  176.     -- Set stats:
  177.     local health = math.random(150,400)
  178.     local speed = gForceSlowSheldonator and 50 or math.random(145,265)
  179.     PedSetHealth(ped,health)
  180.     PedSetMaxHealth(ped,health)
  181.     PedSetInfiniteSprint(ped,true)
  182.     GameSetPedStat(ped,0,math.random(1,100) <= 10 and 363 or 358)
  183.     GameSetPedStat(ped,1,10)
  184.     GameSetPedStat(ped,2,360)
  185.     GameSetPedStat(ped,3,500)
  186.     GameSetPedStat(ped,6,0)
  187.     GameSetPedStat(ped,7,0)
  188.     GameSetPedStat(ped,8,100)
  189.     GameSetPedStat(ped,12,math.random(40,65))
  190.     GameSetPedStat(ped,14,100)
  191.     GameSetPedStat(ped,20,speed)
  192.     GameSetPedStat(ped,39,math.random(20,60))
  193.     GameSetPedStat(ped,61,math.random(50,75))
  194.     GameSetPedStat(ped,62,math.random(0,1))
  195.     GameSetPedStat(ped,63,10)
  196.    
  197.     -- Set style:
  198.     local styles = {
  199.         "Authority",
  200.         "DO_Striker_A",
  201.         "G_Grappler_A",
  202.         "G_Striker_A",
  203.         "J_Striker_A",
  204.         "Nemesis",
  205.         "P_Striker_A",
  206.         "Russell_102",
  207.     }
  208.     local style = styles[math.random(1,table.getn(styles))]
  209.     PedSetActionTree(ped,"/Global/"..style,"Act/Anim/"..style..".act")
  210.    
  211.     -- Clear weapons:
  212.     PedClearAllWeapons(ped)
  213.    
  214.     -- Attack player:
  215.     for f = 0,11 do
  216.         PedSetPedToTypeAttitude(ped,f,2)
  217.     end
  218.     PedSetPedToTypeAttitude(ped,13,0)
  219.     PedAttackPlayer(ped,3)
  220.    
  221.     -- Add to sheldonators:
  222.     table.insert(gSheldonators,{ped,speed,[4] = 0,[5] = ambient,[6] = 4000,[7] = 7000})
  223.    
  224.     -- Return handle:
  225.     return ped
  226. end
Advertisement
Add Comment
Please, Sign In to add comment