Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PedCreateSheldonator(x,y,z,ambient)
- -- Usage example: sheldonator = PedCreateSheldonator(270,-110,6,true)
- -- Note: This function creates a table called gSheldonators and it should never be overwritten or the function may not work properly.
- -- Note: If gForceSlowSheldonator is true, all created Sheldonators will be slower.
- -- Note: Set the 4th argument to true to make it so the Sheldonator will not be made ambient until he has killed the player.
- --[[ When using this function, make sure all the animation groups for the Sheldonator are loaded:
- LoadAnimationGroup("4_04_FunhouseFun")
- LoadAnimationGroup("Straf_Dout")
- LoadAnimationGroup("Straf_Male")
- LoadAnimationGroup("Straf_Prep")
- LoadAnimationGroup("Straf_Savage")
- LoadAnimationGroup("Straf_Wrest")
- LoadAnimationGroup("F_BULLY")
- LoadAnimationGroup("F_Douts")
- LoadAnimationGroup("F_Greas")
- LoadAnimationGroup("F_Jocks")
- LoadAnimationGroup("F_Pref")
- LoadAnimationGroup("F_Preps")
- LoadAnimationGroup("DO_Striker")
- LoadAnimationGroup("DO_StrikeCombo")
- LoadAnimationGroup("B_Striker")
- LoadAnimationGroup("G_Striker")
- LoadAnimationGroup("G_Grappler")
- LoadAnimationGroup("J_Striker")
- LoadAnimationGroup("P_Striker")
- LoadAnimationGroup("Authority")
- LoadAnimationGroup("Boxing")
- LoadAnimationGroup("Nemesis")
- LoadAnimationGroup("Russell")
- ]]
- -- Create thread and table:
- if not gSheldonators then
- gSheldonators = {}
- gSheldonatorThread = function()
- local px,py,pz,near,nearBefore,notWanted
- local processSheldonator = function(v)
- local x,y,z = PedGetPosXYZ(v[1])
- local dist = math.sqrt((px-x)*(px-x) + (py-y)*(py-y) + (pz-z)*(pz-z))
- if v[3] then
- if GetTimer() >= v[3] + 1100/(v[2]/100) then
- if PedGetGrappleTargetPed(v[1]) == gPlayer then
- PlayerSetControl(0)
- repeat
- PedSetActionNode(v[1],"/Global/Actions/Grapples/GrappleReversals/MountReversals/MountReversalPunches","Act/Globals.act")
- for hit = 1,2 do
- Wait(325/(v[2]/100))
- if not PedIsValid(v[1]) then
- return false
- end
- PlayerSetHealth(PlayerGetHealth()-7)
- end
- Wait(0)
- if not PedIsValid(v[1]) then
- return false
- end
- until PedGetGrappleTargetPed(v[1]) ~= gPlayer or PlayerGetHealth() <= 0
- while PedIsPlaying(v[1],"/Global/Actions/Grapples/GrappleReversals/MountReversals/MountReversalPunches",true) do
- Wait(0)
- if not PedIsValid(v[1]) then
- return false
- end
- end
- if PlayerGetHealth() <= 0 then
- PedSetActionNode(v[1],"/Global/404Conv/Nerds/Dance1","Act/Conv/4_04.act")
- if v[5] then
- PedMakeAmbient(v[1])
- v[5] = nil
- end
- end
- PlayerSetControl(1)
- end
- v[3] = nil
- elseif PedGetGrappleTargetPed(v[1]) == gPlayer and IsButtonBeingPressed(9,0) then
- local original = GameGetPedStat(v[1],39)
- GameSetPedStat(v[1],39,0)
- PedSetActionNode(gPlayer,"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/DirectionalPush","Act/Globals.act")
- PedSetActionNode(v[1],"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/DirectionalPush/RCV","Act/Globals.act")
- repeat
- Wait(0)
- if not PedIsValid(v[1]) then
- return false
- end
- until PedGetGrappleTargetPed(v[1]) ~= gPlayer
- GameSetPedStat(v[1],39,original)
- v[3] = nil
- end
- elseif PedMePlaying(v[1],"Default_KEY") and not PedIsDead(gPlayer) then
- if GetTimer() >= v[4] then
- if dist < 2.6 then
- PedFaceXYZ(v[1],px,py,pz)
- PedSetActionNode(v[1],"/Global/J_Damon/Offense/Medium/Grapples/GrapplesAttempt","Act/Anim/J_Damon.act")
- v[3] = GetTimer()
- v[4] = GetTimer() + math.random(2000,12500)
- end
- elseif GetTimer() >= v[6] then
- if dist < 1.2 then
- local reversed = false
- PedFaceXYZ(v[1],px,py,pz)
- PedSetActionNode(v[1],"/Global/Actions/Grapples/Front/Grapples/GrappleAttempt","Act/Globals.act")
- while PedIsPlaying(v[1],"/Global/Actions/Grapples/Front/Grapples/GrappleAttempt",true) do
- Wait(0)
- if not PedIsValid(v[1]) then
- return false
- elseif PedGetGrappleTargetPed(v[1]) == gPlayer and IsButtonBeingPressed(9,0) then
- PedSetActionNode(gPlayer,"/Global/Actions/Grapples/Front/Grapples/GrappleMoves/DirectionalPush","Act/Globals.act")
- reversed = true
- end
- end
- if not reversed and PedGetGrappleTargetPed(v[1]) == gPlayer and PedIsPlaying(v[1],"/Global/Actions/Grapples/Front/Grapples/Hold_Idle",true) then
- local moves = {"GrappleStrikes/HitA/Charge","GrappleStrikes/HitB/Charge","GrappleStrikes/HitC/Charge","DirectionalPush","HeadButt","BodySlam"}
- local move = "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/"..moves[math.random(1,table.getn(moves))]
- PedSetActionNode(v[1],move,"Act/Globals.act")
- while PedIsPlaying(v[1],move,true) do
- Wait(0)
- if not PedIsValid(v[1]) then
- return false
- end
- end
- end
- v[6] = GetTimer() + math.random(3000,9500)
- end
- elseif GetTimer() >= v[7] then
- if dist < 1.4 then
- PedFaceXYZ(v[1],px,py,pz)
- PedSetActionNode(v[1],"/Global/BOSS_Darby/Offense/Short/Grapples/HeavyAttacks/Catch_Throw","Act/Anim/BOSS_Darby.act")
- end
- v[7] = GetTimer() + math.random(6000,14500)
- end
- end
- if not near then
- near = (dist < 10 or (dist < 50 and PedIsOnScreen(v[1]))) and not PedIsDead(v[1])
- end
- return true
- end
- while true do
- px,py,pz = PlayerGetPosXYZ()
- near = false
- for i,v in ipairs(gSheldonators) do
- if not PedIsValid(v[1]) or not processSheldonator(v) then
- table.remove(gSheldonators,i)
- i = i - 1
- end
- end
- if near then
- if not nearBefore then
- notWanted = PlayerGetPunishmentPoints() <= 200
- end
- if notWanted then
- if PlayerGetPunishmentPoints() > 200 then
- PlayerSetPunishmentPoints(200)
- end
- elseif nearBefore then
- notWanted = PlayerGetPunishmentPoints() <= 200
- end
- end
- nearBefore = near
- Wait(0)
- end
- end
- gSheldonatorThread = CreateThread("gSheldonatorThread")
- end
- -- Get spawn position:
- if not x or not y or not z then
- x,y,z = PedFindRandomSpawnPosition()
- if x == 9999 then
- return nil
- end
- end
- -- Spawn ped:
- local ped = PedCreateXYZ(66,x,y,z)
- --PED_SetMissionPed(ped,true)
- -- Set stats:
- local health = math.random(150,400)
- local speed = gForceSlowSheldonator and 50 or math.random(145,265)
- PedSetHealth(ped,health)
- PedSetMaxHealth(ped,health)
- PedSetInfiniteSprint(ped,true)
- GameSetPedStat(ped,0,math.random(1,100) <= 10 and 363 or 358)
- GameSetPedStat(ped,1,10)
- GameSetPedStat(ped,2,360)
- GameSetPedStat(ped,3,500)
- GameSetPedStat(ped,6,0)
- GameSetPedStat(ped,7,0)
- GameSetPedStat(ped,8,100)
- GameSetPedStat(ped,12,math.random(40,65))
- GameSetPedStat(ped,14,100)
- GameSetPedStat(ped,20,speed)
- GameSetPedStat(ped,39,math.random(20,60))
- GameSetPedStat(ped,61,math.random(50,75))
- GameSetPedStat(ped,62,math.random(0,1))
- GameSetPedStat(ped,63,10)
- -- Set style:
- local styles = {
- "Authority",
- "DO_Striker_A",
- "G_Grappler_A",
- "G_Striker_A",
- "J_Striker_A",
- "Nemesis",
- "P_Striker_A",
- "Russell_102",
- }
- local style = styles[math.random(1,table.getn(styles))]
- PedSetActionTree(ped,"/Global/"..style,"Act/Anim/"..style..".act")
- -- Clear weapons:
- PedClearAllWeapons(ped)
- -- Attack player:
- for f = 0,11 do
- PedSetPedToTypeAttitude(ped,f,2)
- end
- PedSetPedToTypeAttitude(ped,13,0)
- PedAttackPlayer(ped,3)
- -- Add to sheldonators:
- table.insert(gSheldonators,{ped,speed,[4] = 0,[5] = ambient,[6] = 4000,[7] = 7000})
- -- Return handle:
- return ped
- end
Advertisement
Add Comment
Please, Sign In to add comment