Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- INSANITY EDITION 3.0
- --[[ TO ADD:
- Shady/police jobs
- More errands
- ]]
- -- Debug settings:
- gForceNormalPeds = nil -- make all peds normal
- gForceWeaponChance = nil -- override chance of peds having weapons
- gForceMoreEvents = nil -- spawn events more frequently
- gForceMoreErrands = nil -- spawn errands more frequently
- gForceSlowSheldonator = nil -- lower the sheldonator's speed for testing
- gDebugTests = nil -- create test functions and spawn a debug blip in Jimmy's room
- gDebugSlingshot = nil -- debugger's slingshot, player's slingshot is twice as fast and 1000x as powerful
- -- Settings:
- gSettings = {
- peds = {
- normalChance = (gForceNormalPeds and 100) or 2, -- percent chance a ped will not be ignored by the peds thread
- stats = { -- stats that can get fucked up, how much, and how frequently
- -- [stat] = {chance,minMult,maxMult}
- -- [stat] = {chance,fixedValue}
- [6] = {50,0,0.5},
- [7] = {25,1,3},
- [8] = {10,1.5,10},
- [9] = {40,2,10},
- [10] = {20,1,10},
- [11] = {75,4,12},
- [12] = {7,2,20},
- [13] = {10,2,50},
- [14] = {20,2,10},
- [15] = {75,9999999},
- [20] = {6,0.05,3.4},
- [31] = {7,0,20},
- [33] = {10,100},
- [34] = {15,2,30},
- [35] = {50,2,5},
- [36] = {50,0.1,9},
- [37] = {50,0.2,10},
- [38] = {20,0.5,10},
- [39] = {10,0.5,9},
- [44] = {20,2,3},
- [61] = {10,0.5,7},
- [62] = {4,0},
- [63] = {20,0.1,9},
- },
- infiniteSprintChance = 13, -- chance of having infinite sprint
- healthMult = {6,0.01,17}, -- health multiplier ({chance,minMult,maxMult})
- weaponChance = gForceWeaponChance or 35, -- percent chance that a ped will get a random weapon
- weapons = {300,301,302,303,305,307,309,310,311,313,315,320,321,323,324,326,327,329,335,338,341,342,346,348,349,354,355,358,363,372,397,400,404,409,410,418}, -- weapons that can be randomly set on a ped
- pedEventTimeFromSpawn = {0,15000}, -- time it takes for a ped event to happen per ped from spawn ({minTime,maxTime})
- pedEventTimeAfterSpawn = {10000,50000}, -- time it takes for a ped event to happen per ped after one has already happened ({minTime,maxTime})
- },
- events = {
- initialTime = 5000, -- time it takes for first event to start
- timeRange = (gForceMoreEvents and {1000,5000}) or {30000,120000}, -- time it takes for an event to start after the first
- },
- errands = {
- timeRange = (gForceMoreErrands and {1000,5000}) or {60000,300000}, -- time it takes for an errand to start (reset after missions)
- },
- }
- --[[ T_Peds:
- Fucks up all NPC peds, randomizing stats as they spawn, and periodically making them do random shit.
- Peds can be flagged as mission peds by using PED_SetMissionPed(ped,true), this will make the T_Peds thread ignore them.
- ]]
- function T_Peds()
- -- Variables:
- local settings = gSettings.peds
- local peds = {}
- gIgnorePeds = {[gPlayer] = true}
- gPedEvents = {
- F_PE_Attack,
- F_PE_AttackPlayer,
- F_PE_Dance,
- F_PE_Headbutt,
- F_PE_LayDown,
- F_PE_Vomit,
- F_PE_PunchCombo,
- F_PE_HateEveryone,
- F_PE_JoinPlayer,
- F_PE_Workout,
- F_PE_Spin,
- F_PE_Complain,
- F_PE_Scream,
- F_PE_Flee,
- }
- -- Main loop:
- while true do
- -- Get all peds:
- gAllPeds = {PedFindInAreaXYZ(0,0,0,9999999)}
- table.remove(gAllPeds,1)
- -- Process peds:
- for i,ped in ipairs(gAllPeds) do
- if not PedIsValid(ped) or PedIsModel(ped,136) then
- table.remove(gAllPeds,i)
- i = i - 1
- elseif not gIgnorePeds[ped] then
- local t = peds[ped]
- if not t then
- -- At spawn (initialize ped):
- if chance(settings.normalChance) then
- -- Ignore ped (make normal):
- gIgnorePeds[ped] = true
- else
- -- Set stats:
- for i,v in pairs(settings.stats) do
- if chance(v[1]) then
- if v[3] then
- GameSetPedStat(ped,i,GameGetPedStat(ped,i)*(math.random(v[2]*100,v[3]*100)/100))
- else
- GameSetPedStat(ped,i,v[2])
- end
- end
- end
- -- Set infinite sprint:
- if chance(settings.infiniteSprintChance) then
- PedSetInfiniteSprint(ped,true)
- end
- -- Set health:
- if chance(settings.healthMult[1]) then
- PedSetMaxHealth(ped,PedGetMaxHealth(ped)*(math.random(settings.healthMult[2]*100,settings.healthMult[3]*100)/100))
- PedSetHealth(ped,PedGetMaxHealth(ped))
- end
- -- Set weapon:
- if chance(settings.weaponChance) then
- PedSetWeapon(ped,settings.weapons[math.random(1,table.getn(settings.weapons))],50)
- end
- -- Set crazy timer:
- peds[ped] = GetTimer() + math.random(0,15000)
- end
- elseif GetTimer() >= t then
- -- Do something crazy (periodic shit):
- if gPedEvents[math.random(1,table.getn(gPedEvents))](ped) ~= false then
- -- Reset crazy timer:
- peds[ped] = GetTimer() + math.random(10000,50000)
- end
- end
- end
- end
- -- Wait:
- Wait(0)
- end
- end
- function PED_SetMissionPed(ped,onOrOff)
- gIgnorePeds[ped] = onOrOff ~= false and true or nil
- end
- function F_PE_Attack(ped)
- local enemy = gAllPeds[math.random(1,table.getn(gAllPeds))]
- if ped ~= enemy and PedIsValid(enemy) then
- PedSetPedToTypeAttitude(ped,PedGetFaction(enemy),0)
- PedAttack(ped,enemy,1)
- else
- return false
- end
- end
- function F_PE_AttackPlayer(ped)
- if not chance(25) then
- return false
- end
- PedSetPedToTypeAttitude(ped,13,0)
- PedAttackPlayer(ped,1)
- end
- function F_PE_Dance(ped)
- if PedMePlaying(ped,"Default_KEY") then
- local dances = {
- {"/Global/404Conv/Nerds/Dance1","Act/Conv/4_04.act"},
- {"/Global/404Conv/Nerds/Dance2","Act/Conv/4_04.act"},
- {"/Global/Ambient/Scripted/Cheerleading","Act/Anim/Ambient.act"},
- }
- local dance = dances[math.random(1,table.getn(dances))]
- PedSetActionNode(ped,dance[1],dance[2])
- else
- return false
- end
- end
- function F_PE_Headbutt(ped)
- if PedMePlaying(ped,"Default_KEY") then
- PedStopLove(ped)
- PedSetActionNode(ped,"/Global/6_02/HeadButt/HeadButt_AnticStart","Act/Conv/6_02.act")
- PedFaceXYZ(ped,PlayerGetPosXYZ())
- else
- return false
- end
- end
- function F_PE_LayDown(ped)
- if PedMePlaying(ped,"Default_KEY") then
- PedSetActionNode(ped,"/Global/1_11X1/Animations/GaryIdleInBed","Act/Conv/1_11X1.act")
- else
- return false
- end
- end
- function F_PE_Vomit(ped)
- if PedMePlaying(ped,"Default_KEY") then
- PedSetActionNode(ped,"/Global/Ambient/Scripted/SpecialPuke","Act/Anim/Ambient.act")
- else
- return false
- end
- end
- function F_PE_PunchCombo(ped)
- if PedMePlaying(ped,"Default_KEY") then
- local closestPed,closestDist = nil,1.5
- local x,y,z = PedGetPosXYZ(ped)
- for i,ped2 in ipairs(gAllPeds) do
- if ped ~= ped2 and PedIsValid(ped2) then
- local x2,y2,z2 = PedGetPosXYZ(ped2)
- local dist = math.sqrt((x2-x)*(x2-x) + (y2-y)*(y2-y) + (z2-z)*(z2-z))
- if dist < closestDist then
- closestPed = ped2
- closestDist = dist
- end
- end
- end
- if closestPed then
- PedSetPedToTypeAttitude(ped,PedGetFaction(closestPed),0)
- PedFaceXYZ(ped,PedGetPosXYZ(closestPed))
- PedLockTarget(ped,closestPed)
- PedStopLove(ped)
- PedSetActionNode(ped,"/Global/BOSS_Darby/Offense/Short/Grapples/HeavyAttacks/Catch_Throw","Act/Anim/BOSS_Darby.act")
- end
- else
- return false
- end
- end
- function F_PE_HateEveryone(ped)
- local faction = PedGetFaction(ped)
- for f = 0,13 do
- if f ~= faction and f ~= 12 then
- PedSetPedToTypeAttitude(ped,f,0)
- end
- end
- end
- function F_PE_JoinPlayer(ped)
- if not chance(10) then
- return false
- else
- local leader = gPlayer
- while PedHasAllyFollower(leader) do
- leader = PedGetAllyFollower(leader)
- if leader == ped then
- return false
- end
- end
- PedRecruitAlly(leader,ped)
- end
- end
- function F_PE_Workout(ped)
- if PedMePlaying(ped,"Default_KEY") then
- PedSetActionNode(ped,"/Global/Ambient/Scripted/Workout","Act/Anim/Ambient.act")
- else
- return false
- end
- end
- function F_PE_Spin(ped)
- if not chance(20) or not PedMePlaying(ped,"Default_KEY") then
- return false
- end
- if not gSpinningPeds then
- gSpinningPeds = {}
- gSpinningPedsThread = function()
- while true do
- for i,v in ipairs(gSpinningPeds) do
- if PedIsValid(v[1]) and GetTimer() < v[2] + 2000 then
- local x,y,z = PedGetPosXYZ(v[1])
- local h = PedGetHeading(v[1])+(20-(math.abs(GetTimer()-(v[2]+1000))/1000))
- PedFaceXYZ(v[1],x-math.sin(h),y+math.cos(h),z)
- else
- table.remove(gSpinningPeds,i)
- i = i - 1
- end
- end
- Wait(0)
- end
- end
- gSpinningPedsThread = CreateThread("gSpinningPedsThread")
- end
- table.insert(gSpinningPeds,{ped,GetTimer()})
- end
- function F_PE_Complain(ped)
- SoundPlayAmbientSpeechEvent(ped,chance(50) and "COMPLAIN" or "SEE_SOMETHING_CRAP")
- end
- function F_PE_Scream(ped)
- SoundPlayAmbientSpeechEvent(ped,chance(50) and "SCARED" or "SCARED_CRY")
- end
- function F_PE_Flee(ped)
- if PedMePlaying(ped,"Default_KEY") then
- PedSetActionTree(ped,"/Global/N_Ranged_A","Act/Anim/N_Ranged_A.act")
- SoundPlayAmbientSpeechEvent(ped,"SCARED")
- PedFlee(ped)
- else
- return false
- end
- end
- --[[ T_Blips:
- There are a few blips around Bullworth that give the player some special shit.
- ]]
- function T_Blips()
- -- Setup stuff for blip functions:
- local F_GiveWeapon = function(weapon)
- PlayerSetWeapon(weapon,50,false)
- end
- local stuff = {
- {"Food",{
- {"Apple",F_GiveWeapon,{310}},
- {"Banana",F_GiveWeapon,{358}},
- {"Eggs",F_GiveWeapon,{312}},
- }},
- {"Guns",{
- {"Spud Gun",F_GiveWeapon,{305}},
- {"Rocket Launcher",F_GiveWeapon,{307}},
- }},
- {"Melee",{
- {"Baseball Bat",F_GiveWeapon,{300}},
- {"Two by Four",F_GiveWeapon,{323}},
- {"Sledge Hammer",F_GiveWeapon,{324}},
- {"Paddle",F_GiveWeapon,{357}},
- {"Devil Fork",F_GiveWeapon,{409}},
- {"Magic Wand",F_GiveWeapon,{410}},
- {"Gold Pipe",F_GiveWeapon,{418}},
- }},
- {"Projectiles",{
- {"Fire Crackers",F_GiveWeapon,{301}},
- {"Stink Bombs",F_GiveWeapon,{309}},
- {"Itching Powder",F_GiveWeapon,{394}},
- {"Bag o' Marbles",F_GiveWeapon,{349}},
- {"Volcano 4000",F_GiveWeapon,{397}},
- {"Rigged Ball",F_GiveWeapon,{400}},
- }},
- {"Sports",{
- {"Baseball",F_GiveWeapon,{302}},
- {"Basket Ball",F_GiveWeapon,{381}},
- {"Soccer Ball",F_GiveWeapon,{329}},
- {"Foot Ball",F_GiveWeapon,{331}},
- {"Frisbee",F_GiveWeapon,{335}},
- }},
- {"Books",{
- {"Book",F_GiveWeapon,{405}},
- {"Book",F_GiveWeapon,{413}},
- {"Book",F_GiveWeapon,{414}},
- {"Book",F_GiveWeapon,{415}},
- {"Book",F_GiveWeapon,{416}},
- {"Diary",F_GiveWeapon,{432}},
- }},
- {"Junk",{
- {"Brick",F_GiveWeapon,{311}},
- {"Newspapers",F_GiveWeapon,{320}},
- {"Pom Poms",F_GiveWeapon,{341}},
- {"Old Pet",F_GiveWeapon,{346}},
- {"Vase",F_GiveWeapon,{354}},
- {"Lunch Tray",F_GiveWeapon,{348}},
- {"Dinner Plate",F_GiveWeapon,{338}},
- {"Decorative Plate",F_GiveWeapon,{355}},
- {"Pussy Magnet",F_GiveWeapon,{363}},
- {"Kick Me Sign",F_GiveWeapon,{372}},
- {"Broom",F_GiveWeapon,{377}},
- {"Old Slingshot",F_GiveWeapon,{303}},
- {"Flashlight",F_GiveWeapon,{420}},
- {"Shields",{
- {"Shield 1",F_GiveWeapon,{360}},
- {"Shield 2",F_GiveWeapon,{387}},
- {"Damaged Shield 1",F_GiveWeapon,{388}},
- {"Damaged Shield 2",F_GiveWeapon,{389}},
- }},
- }},
- }
- local garage = {
- {"Bikes",{
- {"Crap BMX",F_SpawnGarageVehicle,{274}},
- {"Race BMX",F_SpawnGarageVehicle,{272}},
- {"Retro BMX",F_SpawnGarageVehicle,{273}},
- {"Aquaberry Bike",F_SpawnGarageVehicle,{283}},
- {"Shop Class Bike",F_SpawnGarageVehicle,{277}},
- {"Blue BMX",F_SpawnGarageVehicle,{278}},
- {"Mountain Bike",F_SpawnGarageVehicle,{280}},
- {"Old Lady Bike",F_SpawnGarageVehicle,{281}},
- {"Racer Bike",F_SpawnGarageVehicle,{282}},
- {"Bicycle",F_SpawnGarageVehicle,{279}},
- }},
- {"Cars",{
- {"Taxi",F_SpawnGarageVehicle,{286,1}},
- {"Limo",F_SpawnGarageVehicle,{290,1}},
- {"70 Wagon",F_SpawnGarageVehicle,{294,1}},
- {"Foreign Car",F_SpawnGarageVehicle,{292,1}},
- {"Regular Car",F_SpawnGarageVehicle,{293,1}},
- {"Domestic Car",F_SpawnGarageVehicle,{296,1}},
- }},
- {"Trucks",{
- {"Truck",F_SpawnGarageVehicle,{297,1}},
- {"Delivery Truck",F_SpawnGarageVehicle,{291,1}},
- }},
- {"Police",{
- {"Police Bike",F_SpawnGarageVehicle,{275,1}},
- {"Police Car",F_SpawnGarageVehicle,{295,1}},
- }},
- {"Arcade",{
- {"Arcade 1",F_SpawnGarageVehicle,{298,2}},
- {"Arcade 1",F_SpawnGarageVehicle,{287,2}},
- {"Arcade 2",F_SpawnGarageVehicle,{285,2}},
- }},
- {"Other",{
- {"Dozer",F_SpawnGarageVehicle,{288,1}},
- {"Scooter",F_SpawnGarageVehicle,{276}},
- {"Mower",F_SpawnGarageVehicle,{284}},
- {"Go Cart",F_SpawnGarageVehicle,{289}},
- }},
- }
- -- Setup default blips:
- gBlips = {
- -- {prompt,a,x,y,z,icon,color,func,args,blip*,type*}
- {"get stuff",14,-490.6,314.4,31.4,-1,1,MENU_BasicMenu,{"JIMMY'S STUFF",stuff,-492.24,311.63,33.4,-491.84,312.52,33.21}},
- {"get vehicle",0,161.7,-7.84,6.04,-1,1,MENU_BasicMenu,{"GARAGE",garage,164.77,-3.12,9.41,165.53,-3.75,9.26}},
- }
- -- Create debug blip:
- if gDebugTests then
- BLIP_Create("debug",14,-497.95,309.37,31.4,-1,12,MENU_BasicMenu,"DEBUG",gDebugMenu)
- end
- -- Main loop:
- while true do
- -- Process blips:
- for i,b in ipairs(gBlips) do
- -- Create/edit blip:
- if AreaGetVisible() == b[2] and PedIsInAreaXYZ(gPlayer,b[3],b[4],b[5],30) then
- if b[11] ~= 1 then
- if b[10] then
- BlipRemove(b[10])
- end
- b[10] = BlipAddXYZ(b[3],b[4],b[5],b[6],b[6] ~= -1 and 1 or 0,b[7])
- b[11] = 1
- end
- elseif b[11] ~= 2 then
- if b[10] then
- BlipRemove(b[10])
- end
- b[10] = BlipAddXYZ(b[3],b[4],b[5],b[6],b[6] ~= -1 and 1 or 0)
- b[11] = 2
- end
- -- Use blip:
- if PedIsInAreaXYZ(gPlayer,b[3],b[4],b[5],0.8) and PedMePlaying(gPlayer,"Default_KEY") then
- repeat
- TextPrintString("Press \b to "..b[1]..".",0,2)
- Wait(0)
- if IsButtonBeingPressed(9,0) then
- if b[8] then
- if b[9] then
- b[8](unpack(b[9]))
- else
- b[8]()
- end
- end
- b[12] = GetTimer()
- end
- until not b[11] or not PedIsInAreaXYZ(gPlayer,b[3],b[4],b[5],0.8) or not PedMePlaying(gPlayer,"Default_KEY")
- i = 1
- end
- end
- -- Wait:
- Wait(0)
- end
- end
- function BLIP_Create(prompt,a,x,y,z,icon,color,func,...)
- local blip = {prompt,a,x,y,z,icon,color,func,arg}
- table.insert(gBlips,blip)
- return blip
- end
- function BLIP_Delete(blip)
- for i,v in ipairs(gBlips) do
- if v == blip then
- if v[10] then
- BlipRemove(v[10])
- v[10] = nil
- v[11] = nil
- table.remove(gBlips,i)
- break
- end
- end
- end
- end
- function BLIP_Reset(blip)
- for i,v in ipairs(gBlips) do
- if v == blip then
- if v[10] then
- BlipRemove(v[10])
- v[10] = nil
- v[11] = nil
- break
- end
- end
- end
- end
- function BLIP_SetPrompt(blip,prompt)
- blip[1] = prompt
- end
- function BLIP_SetPosition(blip,x,y,z,a)
- blip[3],blip[4],blip[5] = x,y,z
- if a then
- blip[2] = a
- end
- BLIP_Reset(blip)
- end
- function BLIP_SetColor(blip,color)
- blip[7] = color
- BLIP_Reset(blip)
- end
- function BLIP_SetFunc(blip,func,...)
- blip[8] = func
- blip[9] = arg
- end
- function BLIP_GetLastUse(blip)
- return blip[12]
- end
- --[[ T_Events:
- Random events may randomly occur at random times doing random things.
- ]]
- function T_Events()
- -- Variables:
- local settings = gSettings.events
- local t = GetTimer() + settings.initialTime
- gEvents = {
- F_EV_Sheldonator,
- F_EV_Crabblesnitch,
- F_EV_Joyride,
- F_EV_GangAttack,
- F_EV_Talk,
- F_EV_Abduction,
- }
- -- Main loop:
- while true do
- if GetTimer() >= t and table.getn(gAllPeds) <= 18 then
- local x,y,z = PedFindRandomSpawnPosition()
- if x ~= 9999 then
- local vehicles = VehicleFindInAreaXYZ(0,0,0,9999999)
- if (not vehicles or table.getn(vehicles) <= 10) and gEvents[math.random(1,table.getn(gEvents))](x,y,z) ~= false then
- t = GetTimer() + math.random(settings.timeRange[1],settings.timeRange[2])
- end
- end
- end
- Wait(0)
- end
- end
- function F_EV_Sheldonator(x,y,z)
- local ped = PedCreateSheldonator(x,y,z)
- if ped then
- PedMakeAmbient(ped)
- else
- return false
- end
- end
- function F_EV_Crabblesnitch(x,y,z)
- local ped = PedCreateXYZ(65,x,y,z)
- PED_SetMissionPed(ped,true)
- PedSetActionTree(ped,"/Global/Authority","Act/Anim/Authority.act")
- for f = 0,13 do
- if f ~= PedGetFaction(ped) and f ~= 12 then
- PedSetPedToTypeAttitude(ped,f,0)
- end
- end
- GameSetPedStat(ped,8,100)
- GameSetPedStat(ped,12,70)
- GameSetPedStat(ped,20,GameGetPedStat(ped,20)*1.4)
- GameSetPedStat(ped,39,100)
- GameSetPedStat(ped,61,100)
- GameSetPedStat(ped,62,0)
- GameSetPedStat(ped,63,10)
- PedSetInfiniteSprint(ped,true)
- local enemy = gAllPeds[math.random(1,table.getn(gAllPeds))]
- if PedIsValid(enemy) then
- PedAttack(ped,enemy,3)
- end
- PedMakeAmbient(ped)
- end
- function F_EV_Joyride(x,y,z)
- local peds = {165,219,253,58,87,84}
- local ped = PedCreateXYZ(peds[math.random(1,table.getn(peds))],x+0.5,y,z)
- local veh = VehicleCreateXYZ(276,x-0.5,y,z)
- VehicleSetAccelerationMult(veh,100)
- PedEnterVehicle(ped,veh)
- PedMakeAmbient(ped)
- VehicleMakeAmbient(veh)
- end
- function F_EV_GangAttack(x,y,z)
- local victim = gAllPeds[math.random(1,table.getn(gAllPeds))]
- if not PedIsValid(victim) then
- return false
- end
- local allModels = {
- {83,97,234,238},
- {49,50,51,52},
- {4,4,4,155},
- {160,141,220},
- {230,229,75},
- {84,87},
- {88,88,88,88},
- {186,208,209,210},
- {math.random(2,97),math.random(2,97),math.random(99,258),math.random(99,258)},
- }
- local models = allModels[math.random(1,table.getn(allModels))]
- local weapons = {360,324,305,323,300,357}
- for i,model in ipairs(models) do
- local h = (i/table.getn(models))*(math.pi*2)
- local cop = PedCreateXYZ(model,x-math.sin(h)/2,y+math.cos(h)/2,z)
- PED_SetMissionPed(cop,true)
- PedSetHealth(cop,PedGetMaxHealth(cop)*math.random(1,60)/10)
- PedSetMaxHealth(cop,PedGetHealth(cop))
- GameSetPedStat(cop,8,100)
- GameSetPedStat(cop,12,80)
- GameSetPedStat(cop,20,GameGetPedStat(cop,20)*1.3)
- GameSetPedStat(cop,39,100)
- GameSetPedStat(cop,61,100)
- GameSetPedStat(cop,62,0)
- GameSetPedStat(cop,63,5)
- PedSetInfiniteSprint(cop,true)
- PedSetWeapon(cop,weapons[math.random(1,table.getn(weapons))],50)
- for f = 0,13 do
- if f ~= PedGetFaction(ped) and f ~= 12 then
- PedSetPedToTypeAttitude(ped,f,0)
- end
- end
- PedAttack(cop,victim,3)
- PedMakeAmbient(cop)
- end
- end
- function F_EV_Talk()
- local buyer = gAllPeds[math.random(1,table.getn(gAllPeds))]
- local seller = gAllPeds[math.random(1,table.getn(gAllPeds))]
- local arePedsDead = function()
- return not (PedIsValid(buyer) and not PedIsDead(buyer) and PedIsValid(seller) and not PedIsDead(seller))
- end
- if buyer == seller or gIgnorePeds[buyer] or gIgnorePeds[seller] or arePedsDead() then
- return false
- end
- PED_SetMissionPed(buyer,true)
- PED_SetMissionPed(seller,true)
- PedClearObjectives(buyer)
- PedClearObjectives(seller)
- PedSetStationary(seller,true)
- local x,y,z = PedGetPosXYZ(seller)
- PedMoveToXYZ(buyer,2,x,y,z)
- while not PedIsInAreaXYZ(buyer,x,y,z,0.8) do
- Wait(0)
- if arePedsDead() then
- return
- end
- end
- PedSetStationary(seller,false)
- PedStop(buyer)
- PedStop(seller)
- PedFaceXYZ(buyer,PedGetPosXYZ(seller))
- PedFaceXYZ(seller,PedGetPosXYZ(buyer))
- PedSetActionNode(buyer,"/Global/1_02/Talking/Talk","Act/Conv/1_02.act")
- PedSetActionNode(seller,"/Global/1_02/Talking/Talk","Act/Conv/1_02.act")
- local t = GetTimer()
- repeat
- Wait(0)
- if arePedsDead() then
- return
- end
- until GetTimer() >= t + 6450
- PedSetActionNode(buyer,"/Global","Act/Globals.act")
- PedSetActionNode(seller,"/Global","Act/Globals.act")
- PED_SetMissionPed(buyer,false)
- PED_SetMissionPed(seller,false)
- end
- function F_EV_Abduction()
- local ped = gAllPeds[math.random(1,table.getn(gAllPeds))]
- if not PedIsValid(ped) or gIgnorePeds[ped] or MissionActive() or GetCutsceneRunning() ~= 0 then
- return false
- end
- PED_SetMissionPed(ped,true)
- SoundPlayAmbientSpeechEvent(ped,"SCARED")
- local x,y,z = PedGetPosXYZ(ped)
- local t = GetTimer()
- repeat
- PedSetEffectedByGravity(ped,false)
- if not PedIsPlaying(ped,"/Global/1_06/HoboFly",true) then
- PedSetActionNode(ped,"/Global/1_06/HoboFly","Act/Conv/1_06.act")
- end
- PedSetPosXYZ(ped,x,y,z + ((GetTimer()-t)/10000)*20)
- Wait(0)
- until not PedIsValid(ped) or (not PedIsOnScreen(ped) and GetTimer() >= t + 10000)
- if PedIsValid(ped) then
- PedDelete(ped)
- end
- end
- --[[ T_Errands:
- Needy peds will on occassion ask Jimmy to do shit.
- Some errands are small simple things, while others are short missions.
- All errands can only start when the player is not on a mission.
- ]]
- function T_Errands()
- -- Variables:
- local settings = gSettings.errands
- local inMission = false
- local t = GetTimer() + math.random(settings.timeRange[1],settings.timeRange[2])
- -- Setup errands:
- gErrands = {
- {
- ped = 87,
- area = {0,426.6,-461.1,3,300},
- chapter = 2,
- main = F_ER_Crack,
- },
- {
- ped = 6,
- area = {0,160.24,-73.79,6.37,350},
- chapter = 3,
- main = F_ER_Melvin,
- },
- }
- -- Main loop:
- while true do
- if ERRAND_ShouldStop() then
- if not inMission then
- inMission = true
- end
- else
- if inMission then
- t = GetTimer() + math.random(settings.timeRange[1],settings.timeRange[2])
- inMission = false
- end
- if GetTimer() >= t and table.getn(gErrands) > 0 and table.getn(gAllPeds) <= 18 then
- local x,y,z = PedFindRandomSpawnPosition()
- if x ~= 9999 then
- local vehicles = VehicleFindInAreaXYZ(0,0,0,9999999)
- if not vehicles or table.getn(vehicles) <= 10 then
- local i = math.random(1,table.getn(gErrands))
- local s = ERRAND_Play(gErrands[i])
- if s then
- t = GetTimer() + math.random(settings.timeRange[1],settings.timeRange[2])
- if s == 2 then
- table.remove(gErrands,i)
- end
- end
- end
- end
- end
- end
- Wait(0)
- end
- end
- function ERRAND_Play(errand)
- -- Variables:
- local started,control,ped,blip,t = false,true
- -- Cleanup:
- local cleanup = function()
- if ped and PedIsValid(ped) then
- PedStop(ped)
- PedMakeAmbient(ped)
- PED_SetMissionPed(ped,false)
- end
- if blip then
- BlipRemove(blip)
- end
- if not control then
- PlayerSetControl(1)
- end
- end
- -- Should stop errand:
- local shouldStopErrand = function()
- if ERRAND_ShouldStop() or (ped and (not PedIsValid(ped) or PedIsDead(ped) or PedDislikesPlayer(ped) or (not started and PedGetDistanceFromPed(gPlayer,ped) > 50))) then
- return true
- end
- end
- -- Check that the errand can start:
- if shouldStopErrand() or errand.chapter and ChapterGet() < errand.chapter or gAuthority[errand.ped] and PlayerGetPunishmentPoints() > 0 then
- cleanup()
- return nil
- end
- -- Check that the player is in the correct area:
- if errand.area then
- if errand.area[1] ~= AreaGetVisible() then
- cleanup()
- return nil
- elseif errand.area[2] and not PedIsInAreaXYZ(gPlayer,errand.area[2],errand.area[3],errand.area[4],errand.area[5]) then
- cleanup()
- return nil
- end
- end
- -- Get spawn position:
- local x,y,z = PedFindRandomSpawnPosition()
- if x == 9999 then
- cleanup()
- return nil
- end
- -- Create and ped:
- ped = PedCreateXYZ(errand.ped,x,y,z)
- blip = AddBlipForChar(ped,0,1,4)
- PedMakeNeutral(ped)
- PED_SetMissionPed(ped,true)
- if errand.setup and (errand.setup(ped) == false or shouldStopErrand()) then
- cleanup()
- return nil
- end
- -- Wait for player to trigger errand:
- PedMoveToObject(ped,gPlayer,2,1,nil,2)
- t = GetTimer()
- repeat
- Wait(0)
- if GetTimer() >= t + 25000 or shouldStopErrand() then
- cleanup()
- return 1
- end
- until PedGetTargetPed(gPlayer) == ped and IsButtonBeingPressed(7,0) and PedMePlaying(gPlayer,"Default_KEY") and PedMePlaying(ped,"Default_KEY")
- PedStop(ped)
- BlipRemove(blip)
- blip = nil
- -- Setup talk:
- PlayerSetControl(0)
- control = false
- if PedGetDistanceFromPed(gPlayer,ped) > 1.5 then
- PedMoveToXYZ(ped,0,PlayerGetPosXYZ())
- t = GetTimer()
- repeat
- Wait(0)
- if GetTimer() >= t + 10000 or shouldStopErrand() then
- cleanup()
- return 1
- end
- until PedGetDistanceFromPed(gPlayer,ped) <= 1.5
- PedStop(ped)
- end
- -- Talk:
- PedFaceXYZ(gPlayer,PedGetPosXYZ(ped))
- PedFaceXYZ(ped,PlayerGetPosXYZ())
- PedSetActionNode(gPlayer,"/Global/1_02/Talking/Talk","Act/Conv/1_02.act")
- PedSetActionNode(ped,"/Global/1_02/Talking/Talk","Act/Conv/1_02.act")
- t = GetTimer()
- repeat
- Wait(0)
- if shouldStopErrand() then
- cleanup()
- return 1
- end
- until GetTimer() >= t + 5000
- -- Stop talk:
- PedSetActionNode(gPlayer,"/Global","Act/Globals.act")
- PedSetActionNode(ped,"/Global","Act/Globals.act")
- PlayerSetControl(1)
- control = true
- -- Do errand:
- started = true
- errand.main(ped)
- cleanup()
- return 2
- end
- function ERRAND_ShouldStop()
- return MissionActive() or GetCutsceneRunning() ~= 0 or PedIsDead(gPlayer)
- end
- function F_ER_Crack(ped)
- -- Variables:
- local blip1,blip2,blip3
- -- Cleanup:
- local cleanup = function()
- if blip1 then
- BLIP_Delete(blip1)
- end
- if blip2 then
- BlipRemove(blip2)
- end
- if blip3 then
- BlipRemove(blip3)
- end
- end
- -- Should stop errand:
- local shouldStopErrand = function()
- return ERRAND_ShouldStop() or PedDislikesPlayer(ped)
- end
- -- Go to destination:
- PedWander(ped)
- TextPrintString("Go get the crack",3,1)
- blip1 = BLIP_Create("steal crack",0,426.6,-461.1,3,0,1)
- while AreaGetVisible() ~= 0 or not PedIsInAreaXYZ(gPlayer,431.1,-456,2.6,6) do
- Wait(0)
- if shouldStopErrand() then
- cleanup()
- return
- end
- end
- -- Get the crack:
- TextPrintString("Steal the crack",3,1)
- while not BLIP_GetLastUse(blip1) do
- Wait(0)
- if shouldStopErrand() then
- cleanup()
- return
- end
- end
- -- Celebrate:
- PlayerSetControl(0)
- PedSetActionNode(gPlayer,"/Global","Act/Globals.act")
- CameraFade(1500,0)
- Wait(2500)
- BLIP_Delete(blip1)
- blip1 = nil
- PedFaceXYZ(gPlayer,435.4,-450.1,2.5)
- PedSetActionNode(gPlayer,"/Global/C31Strt/PlayerVictory","Act/Conv/C3_1.act")
- CameraSetXYZ(432,-456.8,5,429.7,-458.8,4.5)
- CameraFade(1500,1)
- local t = GetTimer()
- while GetTimer() < t + 3000 or PedIsPlaying(gPlayer,"/Global/C31Strt/PlayerVictory",true) do
- TextPrintString("You got the crack!",0,1)
- Wait(0)
- end
- -- Create enemy:
- local enemy = PedCreateXYZ(105,435.4,-450.1,2.5)
- PED_SetMissionPed(enemy,true)
- PedSetActionTree(enemy,"/Global/DO_Grappler_A","Act/Anim/DO_Grappler_A.act")
- GameSetPedStat(enemy,8,100)
- PedClearAllWeapons(enemy)
- PedFaceXYZ(enemy,PlayerGetPosXYZ())
- PedSetPedToTypeAttitude(enemy,13,0)
- PedAttackPlayer(enemy,3)
- blip2 = AddBlipForChar(enemy,0,26,1)
- PedSetActionNode(enemy,"/Global/6_02/HeadButt/HeadButt_AnticStart","Act/Conv/6_02.act")
- CameraSetXYZ(429.1,-460.7,5,430.5,-458,4.5)
- TextPrintString("The dealer saw you!",2,1)
- Wait(2000)
- CameraReset()
- CameraReturnToPlayer()
- PlayerSetControl(1)
- -- Fight or escape:
- PedMakeAmbient(enemy)
- PED_SetMissionPed(enemy,false)
- local givenWeapon = false
- while PedIsValid(enemy) and not PedIsDead(enemy) do
- if not givenWeapon and PedGetHealth(enemy) < PedGetMaxHealth(enemy)*0.4 and PedMePlaying(enemy,"Default_KEY") then
- PedSetWeapon(enemy,418)
- givenWeapon = true
- end
- Wait(0)
- if shouldStopErrand() then
- cleanup()
- return
- end
- end
- -- Deliver:
- TextPrintString("Deliver the crack",3,1)
- blip3 = AddBlipForChar(ped,0,0,1)
- repeat
- Wait(0)
- if shouldStopErrand() then
- cleanup()
- return
- end
- until PedGetTargetPed(gPlayer) == ped and IsButtonBeingPressed(7,0) and PedMePlaying(gPlayer,"Default_KEY") and PedMePlaying(ped,"Default_KEY")
- -- Final cutscene:
- PedLockTarget(gPlayer,ped)
- PedLockTarget(ped,gPlayer)
- PedSetActionNode(gPlayer,"/Global/Player/Gifts/Errand_IND_Package","Act/Player.act")
- while PedIsPlaying(gPlayer,"/Global/Player/Gifts/Errand_IND_Package","Act/Player.act") do
- Wait(0)
- if shouldStopErrand() then
- cleanup()
- return
- end
- end
- PedSetActionNode(gPlayer,"/Global/Player/Gifts/GetMoney","Act/Player.act")
- while PedIsPlaying(gPlayer,"/Global/Player/Gifts/GetMoney","Act/Player.act") do
- Wait(0)
- if shouldStopErrand() then
- cleanup()
- return
- end
- end
- PlayerAddMoney(math.random(2500,5000))
- PedLockTarget(gPlayer,-1)
- PedLockTarget(ped,-1)
- PlayerSetControl(1)
- cleanup()
- end
- function F_ER_Melvin(ped)
- -- Variables:
- local blip,c
- -- Cleanup:
- local cleanup = function()
- if blip then
- BlipRemove(blip)
- end
- if c then
- for i,ped in ipairs(c.peds) do
- if PedIsValid(ped) then
- PedDelete(ped)
- end
- end
- end
- end
- -- Should stop errand:
- local shouldStopErrand = function()
- return ERRAND_ShouldStop() or PedDislikesPlayer(ped)
- end
- -- Follow:
- TextPrintString("Follow Melvin",3,1)
- PedSetInvulnerable(ped,true)
- blip = AddBlipForChar(ped,0,0,1)
- PedClearAllWeapons(ped)
- PedMoveToXYZ(ped,2,30.5,-224.6,3.2)
- GameSetPedStat(ped,20,200)
- PedSetInfiniteSprint(ped,true)
- local warped = false
- while not PedIsInAreaXYZ(gPlayer,30.5,-224.6,3.2,15) or not PedIsInAreaXYZ(ped,30.5,-224.6,3.2,15) do
- if warped and not PedIsInAreaXYZ(ped,30.5,-224.6,3.2,1) then
- PedMoveToXYZ(ped,2,30.5,-224.6,3.2)
- elseif not PedIsOnScreen(ped) then
- PedSetPosXYZ(ped,30.6,-224.6,3.2)
- warped = true
- end
- Wait(0)
- if shouldStopErrand() then
- cleanup()
- return
- end
- end
- GameSetPedStat(ped,20,100)
- BlipRemove(blip)
- PlayerSetControl(0)
- PedStop(gPlayer)
- PedStop(ped)
- -- Setup:
- CameraSetXYZ(19.4,-214.7,9.3,30.6,-224.6,3.2)
- PedFaceXYZ(gPlayer,PedGetPosXYZ(ped))
- PedFaceXYZ(ped,PlayerGetPosXYZ())
- PlayerSetPosXYZ(37.9,-216.7,3)
- PedSetPosXYZ(ped,30.6,-224.6,3.2)
- Wait(2000)
- PedSetActionNode(ped,"/Global/1_06/HoboFly","Act/Conv/1_06.act")
- PedSetEffectedByGravity(ped,false)
- -- Initialize circle of Melvins:
- local x,y,z = PedGetPosXYZ(ped)
- c = {
- -- Position:
- cx = x, -- current position x
- cy = y, -- current position y
- cz = z, -- current position z
- -- Radius:
- cr = 0, -- current radius
- -- Speed:
- ch = 0, -- current heading
- s = 0, -- current speed (full rotations per second)
- st = GetTimer(), -- start time (last time "ch" set)
- -- Peds:
- peds = {ped}, -- spawned peds
- cc = 1, -- current count
- }
- -- Circle functions:
- local processCircle = function()
- -- Get time:
- local ct = GetTimer()
- -- Position:
- if c.tp then
- c.tx,c.ty,c.tz = PedGetPosXYZ(c.tp)
- end
- if c.tx and (c.cx ~= c.tx or c.cy ~= c.ty or c.cz ~= c.tz) then
- local t = c.pt ~= 0 and (ct-c.pst)/c.pt or 1
- if t > 1 then
- t = 1
- end
- c.cx = c.sx + (c.tx-c.sx)*t
- c.cy = c.sy + (c.ty-c.sy)*t
- c.cz = c.sz + (c.tz-c.sz)*t
- end
- -- Radius:
- if c.tr and c.cr ~= c.tr then
- local t = c.rt ~= 0 and (ct-c.rst)/c.rt or 1
- if t > 1 then
- t = 1
- end
- c.cr = c.sr + (c.tr-c.sr)*t
- end
- -- Count:
- if c.tc and c.cc ~= c.tc then
- if c.cc > c.tc then
- repeat
- if PedIsValid(c.peds[cc]) then
- PedDelete(c.peds[cc])
- end
- table.remove(c.peds,cc)
- until table.getn(c.peds) == c.tc
- else
- repeat
- local ped = PedCreateXYZ(6,c.cx,c.cy,c.cz)
- PED_SetMissionPed(ped,true)
- PedMakeNeutral(ped)
- PedSetInvulnerable(ped,true)
- PedSetActionNode(ped,"/Global/1_06/HoboFly","Act/Conv/1_06.act")
- PedSetEffectedByGravity(ped,false)
- table.insert(c.peds,ped)
- until table.getn(c.peds) == c.tc
- end
- c.cc = c.tc
- end
- -- Move peds:
- c.ch = math.mod(c.ch+((GetTimer()-c.st)/(1000/c.s))*math.pi*2,math.pi*2)
- c.st = GetTimer()
- for i,ped in ipairs(c.peds) do
- if PedIsValid(ped) then
- local h = c.ch + (i/table.getn(c.peds))*math.pi*2
- local x = c.cx - math.sin(h)*c.cr
- local y = c.cy + math.cos(h)*c.cr
- PedFaceXYZ(ped,c.cx,c.cy,c.cz)
- PedSetPosXYZ(ped,x,y,c.cz)
- end
- end
- end
- local setPosition = function(x,y,z,t)
- c.sx,c.sy,c.sz = c.cx,c.cy,c.cz
- c.tx,c.ty,c.tz = x,y,z
- c.pt = t or 0
- c.pst = GetTimer()
- end
- local setFollowPed = function(ped,t)
- c.sx,c.sy,c.sz = c.cx,c.cy,c.cz
- c.tp = ped
- c.pt = t or 0
- c.pst = GetTimer()
- end
- local setRadius = function(r,t)
- c.sr = c.cr
- c.tr = r
- c.rt = t or 0
- c.rst = GetTimer()
- end
- local setCount = function(n)
- c.tc = n
- end
- local setSpeed = function(s,i)
- if not i or s > c.s then
- c.s = s
- end
- end
- local F_Wait = function(ms)
- local t = GetTimer()
- repeat
- Wait(0)
- processCircle()
- until GetTimer() >= t + ms
- end
- -- Disable peds:
- StopPedProduction(true)
- -- Do shit:
- setPosition(30.6,-224.6,6.6,2000)
- F_Wait(3000)
- setCount(8)
- setRadius(3.5,3000)
- setSpeed(0.2)
- F_Wait(6000)
- -- Restore control for a bit:
- CameraReset()
- CameraReturnToPlayer()
- PlayerSetControl(1)
- F_Wait(10000)
- -- Follow player:
- setFollowPed(gPlayer,2000)
- setRadius(1.5,5000)
- local t = GetTimer()
- repeat
- setSpeed(0.2 + ((GetTimer()-t)/7500))
- F_Wait(0)
- until GetTimer() >= t + 10000
- -- To graveyard:
- CameraFade(500,0)
- F_Wait(2000)
- setPosition(614.3,166,47.5)
- setFollowPed(nil)
- PlayerSetPosXYZ(614.3,166,47.5)
- ClothingSetPlayerOutfit("Underwear")
- ClothingBuildPlayer()
- CameraFade(500,1)
- F_Wait(10000)
- -- Resume ped production:
- StopPedProduction(false)
- -- Finish:
- cleanup()
- end
- --[[ T_Weapons:
- Some weapons behave a little differently than usual.
- ]]
- function T_Weapons()
- -- Variables:
- local peds = {}
- local specialWeapons = {
- -- {conditionFunc,startFunc,endFunc,backupTable*}
- { -- sledgehammer
- function(ped) -- condition
- return PedHasWeapon(ped,324) and PedIsPlaying(ped,"/Global/SledgeHammer/Actions/Attacks/Player",true)
- end,
- function(ped,t) -- start
- t.speed = GameGetPedStat(ped,20)
- t.damage = GameGetPedStat(ped,31)
- GameSetPedStat(ped,20,t.speed*1.5)
- GameSetPedStat(ped,31,t.damage*3)
- end,
- function(ped,t) -- end
- GameSetPedStat(ped,20,t.speed)
- GameSetPedStat(ped,31,t.damage)
- end,
- },
- { -- eggs
- function(ped) -- condition
- return PedHasWeapon(ped,312) and (PedMePlaying(ped,"Default_KEY") or PedIsInAnyVehicle(ped))
- end,
- function(ped,t) -- start
- t.damage = GameGetPedStat(ped,31)
- GameSetPedStat(ped,31,t.damage*100)
- end,
- function(ped,t) -- end
- GameSetPedStat(ped,31,t.damage)
- end,
- },
- }
- -- Debug slingshot:
- if gDebugSlingshot then
- table.insert(specialWeapons,{
- function(ped)
- return ped == gPlayer and (PedHasWeapon(ped,303) or PedHasWeapon(ped,306)) and PedMePlaying(ped,"Default_KEY")
- end,
- function(ped,t) -- start
- t.speed = GameGetPedStat(ped,20)
- t.damage = GameGetPedStat(ped,31)
- GameSetPedStat(ped,20,t.speed*2)
- GameSetPedStat(ped,31,t.damage*1000)
- end,
- function(ped,t) -- end
- GameSetPedStat(ped,20,t.speed)
- GameSetPedStat(ped,31,t.damage)
- end,
- })
- end
- -- Setup default backup tables:
- for i,v in ipairs(specialWeapons) do
- if not v[4] then
- v[4] = {}
- end
- end
- -- Main loop:
- while true do
- -- Special weapons:
- for i,ped in ipairs(gAllPeds) do
- if PedIsValid(ped) then
- local w = peds[ped]
- if w then
- if not w[1](ped) then
- w[3](ped,w[4])
- peds[ped] = nil
- end
- else
- for i,w in ipairs(specialWeapons) do
- if w[1](ped) then
- w[2](ped,w[4])
- peds[ped] = w
- break
- end
- end
- end
- end
- end
- -- Wait:
- Wait(0)
- -- Clean:
- for ped,t in ipairs(peds) do
- if not PedIsValid(ped) then
- peds[ped] = nil
- end
- end
- end
- end
- --[[ T_Grapples:
- This thread simply makes sure grappling peds have matched speeds.
- ]]
- function T_Grapples()
- -- Variables:
- local peds = {}
- -- Main loop:
- while true do
- -- Process peds:
- for i,ped in ipairs(gAllPeds) do
- if PedIsValid(ped) then
- local s = peds[ped]
- local target = PedGetGrappleTargetPed(ped)
- if s then
- if target ~= s[1] then
- GameSetPedStat(ped,20,s[2])
- peds[ped] = nil
- elseif GameGetPedStat(ped,20) ~= GameGetPedStat(target,20) then
- GameSetPedStat(ped,20,GameGetPedStat(target,20))
- end
- elseif PedIsValid(target) and not PedIsDead(target) and GameGetPedStat(ped,20) ~= GameGetPedStat(target,20) then
- peds[ped] = {target,GameGetPedStat(ped,20)}
- GameSetPedStat(ped,20,GameGetPedStat(target,20))
- end
- end
- end
- -- Wait:
- Wait(0)
- -- Clean:
- for ped,s in ipairs(peds) do
- if not PedIsValid(ped) then
- peds[ped] = nil
- end
- end
- end
- end
- --[[ T_Areas:
- Special shit for each area/interior.
- ]]
- function T_Areas()
- -- Variables:
- local areas = {
- {8,function()
- local peds = {}
- local t = GetTimer() + math.random(1000,10000)
- local spawns = {
- {-772.09,123.02,7.37},
- {-766.47,-90.14,8.46},
- {-773.56,-59.9,12.38},
- {-764.24,-53.2,9.34},
- {-754.9,-83.97,8.72},
- {-745.71,-85.9,8.11},
- {-734.15,-61.26,8.72},
- {-732.3,-50.77,9.45},
- {-761.12,-154.69,7.42},
- }
- local spawnSheldonator = function()
- local t = {}
- local px,py,pz = PlayerGetPosXYZ()
- for i,v in ipairs(spawns) do
- local x,y,z = v[1]-px,v[2]-py,v[3]-pz
- local dist = math.sqrt(x*x + y*y + z*z)
- for i = 1,3 do
- if not t[i] or dist > t[i][1] then
- table.insert(t,i,{dist,v})
- break
- end
- end
- end
- local sx,sy,sz = unpack(t[math.random(1,3)][2])
- for i,v in ipairs(peds) do
- local px,py,pz = PedGetPosXYZ(v)
- local x,y,z = sx-px,sy-py,sz-pz
- local dist = math.sqrt(x*x + y*y + z*z)
- if dist < 0.1 then
- return nil
- end
- end
- return PedCreateSheldonator(sx,sy,sz)
- end
- repeat
- if GetTimer() >= t and table.getn(gAllPeds) < 20 then
- local ped = spawnSheldonator()
- if ped then
- table.insert(peds,ped)
- local count = table.getn(peds)
- if count == 1 then
- t = GetTimer() + math.random(10000,50000)
- elseif count == 2 then
- t = GetTimer() + math.random(10000,30000)
- elseif count <= 5 then
- t = GetTimer() + math.random(5000,20000)
- elseif count <= 10 then
- t = GetTimer() + math.random(5000,10000)
- elseif count <= 20 then
- t = GetTimer() + math.random(2000,8000)
- elseif count <= 30 then
- t = GetTimer() + math.random(1000,5000)
- elseif math.mod(count,40) == 0 then
- t = GetTimer() + math.random(30000,90000)
- else
- t = GetTimer() + math.random(0,10000)
- end
- end
- end
- Wait(0)
- until AreaGetVisible() ~= 8
- for i,v in ipairs(peds) do
- if PedIsValid(v) then
- PedMakeAmbient(v)
- end
- end
- end},
- }
- -- Main loop:
- local area
- while true do
- local a = AreaGetVisible()
- if a ~= area then
- area = a
- for i,v in ipairs(areas) do
- if v[1] == a then
- v[2]()
- break
- end
- end
- else
- Wait(0)
- end
- end
- end
- --[[ T_Garbage:
- Collects garbage every frame, last created thread so it can run after all other threads.
- ]]
- function T_Garbage()
- while true do
- collectgarbage()
- Wait(0)
- end
- end
- --[[ Main:
- Randomizes default peds and starts all the other threads.
- ]]
- function main()
- -- Fuck up the peds:
- if not gForceNormalPeds then
- F_FuckUpThePeds()
- collectgarbage()
- end
- -- Wait for the game to start up:
- while not SystemIsReady() or AreaIsLoading() do
- Wait(0)
- end
- -- Load animation groups:
- F_LoadAnimations()
- -- Create threads:
- CreateThread("T_Peds")
- CreateThread("T_Blips")
- CreateThread("T_Events")
- CreateThread("T_Errands")
- CreateThread("T_Weapons")
- CreateThread("T_Grapples")
- CreateThread("T_Areas")
- CreateThread("T_Garbage")
- -- Main loop:
- while true do
- Wait(0)
- end
- end
- function F_FuckUpThePeds()
- -- Setup authority tables:
- gAuthority = {}
- -- Setup peds table:
- local peds = {
- -- {Index, model, winter texture, size}
- --{0,"player","player","Medium"},
- --{1,"DEFAULTPED","DEFAULTPED","Medium"},
- {2,"DOgirl_Zoe_EG","DOgirl_Zoe_EG","Medium"},
- {3,"NDGirl_Beatrice","NDGirl_Beatrice_W","Medium"},
- {4,"NDH1a_Algernon","NDH1a_Algernon_W","Fat"},
- {5,"NDH1_Fatty","NDH1_Fatty_W","Fat"},
- {6,"ND2nd_Melvin","ND2nd_Melvin_W","Fat"},
- {7,"NDH2_Thad","NDH2_Thad_W","Large"},
- {8,"NDH3_Bucky","NDH3_Bucky_W","Medium"},
- {9,"NDH2a_Cornelius","NDH2a_Cornelius_W","Large"},
- {10,"NDLead_Earnest","NDlead_Earnest_W","Medium"},
- {11,"NDH3a_Donald","NDH3a_Donald_W","Medium"},
- {12,"JKH1_Damon","JKH1_Damon_W","Huge"},
- {13,"JKH1a_Kirby","JKH1a_KirbyWinter","Medium"},
- {14,"JKGirl_Mandy","JKGirl_Mandy_W","Medium"},
- {15,"JKH2_Dan","JKH2_DanWinter","Medium"},
- {16,"JKH2a_Luis","JKH2a_Luis_W","Huge"},
- {17,"JKH3_Casey","JKH3_Casey_W","Huge"},
- {18,"JKH3a_Bo","JKH3a_Bo_W","Large"},
- {19,"JKlead_Ted","JKlead_Ted_W","Large"},
- {20,"JK2nd_Juri","JK2nd_Juri_W","Huge"},
- {21,"GR2nd_Peanut","GR2nd_Peanut_W","Large"},
- {22,"GRH2A_Hal","GRH2A_Hal","Large"},
- {23,"GRlead_Johnny","GRlead_Johnny_W","Large"},
- {24,"GRH1_Lefty","GRH1_Lefty_W","Medium"},
- {25,"GRGirl_Lola","GRGirl_Lola_W","Medium"},
- {26,"GRH3_Lucky","GRH3_Lucky_W","Large"},
- {27,"GRH1a_Vance","GRH1a_Vance","Medium"},
- {28,"GRH3a_Ricky","GRH3a_Ricky_W","Large"},
- {29,"GRH2_Norton","GRH2_Norton","Huge"},
- {30,"PRH1_Gord","PRH1_Gord_W","Medium"},
- {31,"PRH1a_Tad","PRH1a_Tad_W","Medium"},
- {32,"PRH2a_Chad","PRH2_Chad_W","Large"},
- {33,"PR2nd_Bif","PR2nd_Bif_W","Huge"},
- {34,"PRH3_Justin","PRH3_Justin_W","Large"},
- {35,"PRH2_Bryce","PRH2_Bryce_W","Large"},
- {36,"PRH2_Bryce_OBOX","PRH2_Bryce_OBOX","Large"},
- {37,"PRlead_Darby","PRlead_Darby_W","Large"},
- {38,"PRGirl_Pinky","PRGirl_Pinky_W","Medium"},
- {39,"GN_Asiangirl","GN_Asiangirl_W","Medium"},
- {40,"PRH3a_Parker","PRH3a_Parker_W","Large"},
- {41,"DOH2_Jerry","DOH2_Jerry_W","Large"},
- {42,"DOH1a_Otto","DOH1a_Otto_W","Medium"},
- {43,"DOH2a_Leon","DOH2a_Leon","Huge"},
- {44,"DOH1_Duncan","DOH1_Duncan_W","Medium"},
- {45,"DOH3_Henry","DOH3_Henry_W","Large"},
- {46,"DOH3a_Gurney","DOH3a_Gurney_W","Huge"},
- {47,"DO2nd_Omar","DO2nd_Omar","Huge"},
- {48,"DOGirl_Zoe","DOGirl_Zoe_W","Medium"},
- {49,"PF2nd_Max","PF2nd_Max_W","Huge"},
- {50,"PFH1_Seth","PFH1_Seth_W","Huge"},
- {51,"PFH2_Edward","PFH2_Edward_W","Huge"},
- {52,"PFlead_Karl","PFlead_Karl_W","Large"},
- {53,"TO_Orderly","TO_Orderly_W","Huge"},
- {54,"TE_HallMonitor","TE_Hallmonitor_W","Large"},
- {55,"TE_GymTeacher","TE_GymTeacher_W","Huge"},
- {56,"TE_Janitor","TE_Janitor","Huge"},
- {57,"TE_English","TE_English_W","Huge"},
- {58,"TE_Cafeteria","TE_Cafeteria_W","Huge"},
- {59,"TE_Secretary","TE_Secretary","Large"},
- {60,"TE_Nurse","TE_Nurse_W","Large"},
- {61,"TE_MathTeacher","TE_MathTeacher_W","Fat"},
- {62,"TE_Librarian","TE_Librarian_W","Large"},
- {63,"TE_Art","TE_Art","Large"},
- {64,"TE_Biology","TE_Biology_W","Huge"},
- {65,"TE_Principal","TE_Principal_W","Huge"},
- {66,"GN_Littleblkboy","GN_Littleblkboy_W","Small"},
- {67,"GN_SexyGirl","GN_SexyGirl_W","Medium"},
- {68,"GN_Littleblkgirl","GN_Littleblkgirl_W","Small"},
- {69,"GN_Hispanicboy","GN_Hispanicboy_W","Small"},
- {70,"GN_Greekboy","GN_Greekboy_W","Medium"},
- {71,"GN_Fatboy","GN_Fatboy_W","Fat"},
- {72,"GN_Boy01","GN_Boy01_W","Medium"},
- {73,"GN_Boy02","GN_Boy02_W","Large"},
- {74,"GN_Fatgirl","GN_Fatgirl_W","Fat"},
- {75,"DOlead_Russell","DOlead_Russell_W","Huge"},
- {76,"TO_Business1","TO_Business_01_W","Large"},
- {77,"TO_Business2","TO_Business2_W","Large"},
- {78,"TO_BusinessW1","TO_BusinessW1_W","Large"},
- {79,"TO_BusinessW2","TO_BusinessW2_W","Large"},
- {80,"TO_RichW1","TO_RichW1_W","Large"},
- {81,"TO_RichW2","TO_RichW2_W","Large"},
- {82,"TO_Fireman","TO_Fireman","Large"},
- {83,"TO_Cop","TO_Cop","Huge"},
- {84,"TO_Comic","TO_Comic","Fat"},
- {85,"GN_Bully03","GN_Bully03_W","Large"},
- {86,"TO_Bikeowner","TO_Bikeowner","Huge"},
- {87,"TO_Hobo","TO_Hobo_W","Huge"},
- {88,"Player_Mascot","Player_Mascot_W","Medium"},
- {89,"TO_GroceryOwner","TO_GroceryOwner","Huge"},
- {90,"GN_Sexygirl_UW","GN_Sexygirl_UW","Medium"},
- {91,"DOLead_Edgar","DOLead_Edgar_W","Large"},
- {92,"JK_LuisWrestle","JK_LuisWrestle","Huge"},
- {93,"JKGirl_MandyUW","JKGirl_MandyUW","Medium"},
- {94,"PRGirl_PinkyUW","PRGirl_PinkyUW","Medium"},
- {95,"NDGirl_BeatriceUW","NDGirl_BeatriceUW","Medium"},
- {96,"GRGirl_LolaUW","GRGirl_LolaUW","Medium"},
- {97,"TO_Cop2","TO_Cop2","Huge"},
- --{98,"Player_OWres","Player_Owres","Medium"},
- {99,"GN_Bully02","GN_Bully02_W","Medium"},
- {100,"TO_RichM1","TO_RichM1_W","Large"},
- {101,"TO_RichM2","TO_RichM2_W","Large"},
- {102,"GN_Bully01","GN_Bully01_W","Large"},
- {103,"TO_FireOwner","TO_FireOwner","Huge"},
- {104,"TO_CSOwner_2","TO_CSOwner_2","Huge"},
- {105,"TO_CSOwner_3","TO_CSOwner_3","Huge"},
- {106,"TE_Chemistry","TE_Chemistry_W","Huge"},
- {107,"TO_Poorwoman","TO_Poorwoman_W","Large"},
- {108,"TO_MotelOwner","TO_Motelowner_W","Huge"},
- {109,"JKKirby_FB","JKKirby_FB","Medium"},
- {110,"JKTed_FB","JKTed_FB","Large"},
- {111,"JKDan_FB","JKDan_FB","Medium"},
- {112,"JKDamon_FB","JKDamon_FB","Huge"},
- {113,"TO_Carny02","TO_Carny02_W","Huge"},
- {114,"TO_Carny01","TO_Carny01","Huge"},
- {115,"TO_CarnyMidget","TO_CarnyMidget_W","Small"},
- {116,"TO_Poorman2","TO_Poorman2_W","Huge"},
- {117,"PRH2A_Chad_OBOX","PRH2A_Chad_OBOX","Large"},
- {118,"PRH3_Justin_OBOX","PRH3_Justin_OBOX","Large"},
- {119,"PRH3a_Parker_OBOX","PRH3a_Parker_OBOX","Large"},
- {120,"TO_BarberRich","TO_BarberRich","Huge"},
- {121,"GenericWrestler","GenericWrestler","Huge"},
- {122,"ND_FattyWrestle","ND_FattyWrestle","Fat"},
- {123,"TO_Industrial","TO_Industrial_W","Huge"},
- {124,"TO_Associate","TO_Associate","Huge"},
- {125,"TO_Asylumpatient","TO_Asylumpatient","Huge"},
- {126,"TE_Autoshop","TE_Autoshop_W","Huge"},
- {127,"TO_Mailman","TO_Mailman_W","Huge"},
- {128,"TO_Tattooist","TO_Tattooist","Huge"},
- {129,"TE_Assylum","TE_Assylum","Huge"},
- {130,"Nemesis_Gary","Nemesis_Gary_W","Medium"},
- {131,"TO_Oldman2","TO_Oldman2_W","Large"},
- {132,"TO_BarberPoor","TO_BarberPoor","Large"},
- {133,"PR2nd_Bif_OBOX","PR2nd_Bif_OBOX","Huge"},
- {134,"Peter","Peter_W","Medium"},
- {135,"TO_RichM3","TO_RichM3_W","Large"},
- --{136,"Rat_Ped","Rat_Ped","Small"},
- {137,"GN_LittleGirl_2","GN_LittleGirl_2_W","Small"},
- {138,"GN_LittleGirl_3","GN_LittleGirl_3_W","Small"},
- {139,"GN_WhiteBoy","GN_WhiteBoy_W","Medium"},
- {140,"TO_FMidget","TO_FMidget","Small"},
- {141,"Dog_Pitbull","Dog_Pitbull","Small"},
- {142,"GN_SkinnyBboy","GN_SkinnyBboy_W","Medium"},
- {143,"TO_Carnie_female","TO_Carnie_fem_W","Large"},
- {144,"TO_Business3","TO_Business_03_W","Huge"},
- {145,"GN_Bully04","GN_Bully04_W","Large"},
- {146,"GN_Bully05","GN_Bully05_W","Medium"},
- {147,"GN_Bully06","GN_Bully06_W","Large"},
- {148,"TO_Business4","TO_Business4_W","Huge"},
- {149,"TO_Business5","TO_Business5_W","Huge"},
- {150,"DO_Otto_asylum","DO_Otto_asylum","Medium"},
- {151,"TE_History","TE_History","Huge"},
- {152,"TO_Record","TO_Record_W","Huge"},
- {153,"DO_Leon_Assylum","DO_Leon_Assylum","Huge"},
- {154,"DO_Henry_Assylum","DO_Henry_Assylum","Large"},
- {155,"NDH1_FattyChocolate","NDH1_FattyChocolate","Fat"},
- {156,"TO_GroceryClerk","TO_GroceryClerk","Huge"},
- {157,"TO_Handy","TO_Handy_W","Huge"},
- {158,"TO_Orderly2","TO_Orderly2_W","Huge"},
- {159,"GN_Hboy_Ween","GN_Hboy_Ween","Small"},
- {160,"Nemesis_Ween","Nemesis_Ween","Medium"},
- {161,"GRH3_Lucky_Ween","GRH3_Lucky_Ween","Large"},
- {162,"NDH3a_Donald_ween","NDH3a_Donald_ween","Medium"},
- {163,"PRH3a_Parker_Ween","PRH3a_Parker_Ween","Large"},
- {164,"JKH3_Casey_Ween","JKH3_Casey_Ween","Huge"},
- {165,"Peter_Ween","Peter_Ween","Medium"},
- {166,"GN_AsianGirl_Ween","GN_AsianGirl_Ween","Medium"},
- {167,"PRGirl_Pinky_Ween","PRGirl_Pinky_Ween","Medium"},
- {168,"JKH1_Damon_ween","JKH1_Damon_ween","Huge"},
- {169,"GN_WhiteBoy_Ween","GN_WhiteBoy_Ween","Medium"},
- {170,"GN_Bully01_Ween","GN_Bully01_Ween","Large"},
- {171,"GN_Boy02_Ween","GN_Boy02_Ween","Medium"},
- {172,"PR2nd_Bif_OBOX_D1","PR2nd_Bif_OBOX_D1","Huge"},
- {173,"GRH1a_Vance_Ween","GRH1a_Vance_Ween","Medium"},
- {174,"NDH2_Thad_Ween","NDH2_Thad_Ween","Large"},
- {175,"PRGirl_Pinky_BW","PRGirl_Pinky_BW","Medium"},
- {176,"DOlead_Russell_BU","DOlead_Russell_BU","Huge"},
- {177,"PRH1a_Tad_BW","PRH1a_Tad_BW","Medium"},
- {178,"PRH2_Bryce_BW","PRH2_Bryce_BW","Large"},
- {179,"PRH3_Justin_BW","PRH3_Justin_BW","Large"},
- {180,"GN_Asiangirl_CH","GN_Asiangirl_CH","Medium"},
- {181,"GN_Sexygirl_CH","GN_Sexygirl_CH","Medium"},
- {182,"PRGirl_Pinky_CH","PRGirl_Pinky_CH","Medium"},
- {183,"TO_NH_Res_01","TO_NH_Res_01","Large"},
- {184,"TO_NH_Res_02","TO_NH_Res_02","Large"},
- {185,"TO_NH_Res_03","TO_NH_Res_03","Medium"},
- {186,"NDH1_Fatty_DM","NDH1_Fatty_DM","Fat"},
- {187,"TO_PunkBarber","TO_PunkBarber","Huge"},
- {188,"FightingMidget_01","FightingMidget_01","Small"},
- {189,"FightingMidget_02","FightingMidget_02","Small"},
- {190,"TO_Skeletonman","TO_Skeletonman","Huge"},
- {191,"TO_Beardedwoman","TO_Beardedwoman","Huge"},
- {192,"TO_CarnieMermaid","TO_CarnieMermaid","Medium"},
- {193,"TO_Siamesetwin2","TO_Siamesetwin2","Medium"},
- {194,"TO_Paintedman","TO_Paintedman","Huge"},
- {195,"TO_GN_Workman","TO_GN_Workman","Huge"},
- {196,"DOLead_Edgar_GS","DOLead_Edgar_GS","Large"},
- {197,"DOH3a_Gurney_GS","DOH3a_Gurney_GS","Huge"},
- {198,"DOH2_Jerry_GS","DOH2_Jerry_GS","Large"},
- {199,"DOH2a_Leon_GS","DOH2a_Leon_GS","Huge"},
- {200,"GRH2a_Hal_GS","GRH2a_Hal_GS","Large"},
- {201,"GRH2_Norton_GS","GRH2_Norton_GS","Huge"},
- {202,"GR2nd_Peanut_GS","GR2nd_Peanut_GS","Large"},
- {203,"GRH1a_Vance_GS","GRH1a_Vance_GS","Medium"},
- {204,"JKH3a_Bo_GS","JKH3a_Bo_GS","Large"},
- {205,"JKH1_Damon_GS","JKH1_Damon_GS","Huge"},
- {206,"JK2nd_Juri_GS","JK2nd_Juri_GS","Huge"},
- {207,"JKH1a_Kirby_GS","JKH1a_Kirby_GS","Medium"},
- {208,"NDH1a_Algernon_GS","NDH1a_Algernon_GS","Fat"},
- {209,"NDH3_Bucky_GS","NDH3_Bucky_GS","Large"},
- {210,"NDH2_Thad_GS","NDH2_Thad_GS","Large"},
- {211,"PRH3a_Parker_GS","PRH3a_Parker_GS","Large"},
- {212,"PRH3_Justin_GS","PRH3_Justin_GS","Large"},
- {213,"PRH1a_Tad_GS","PRH1a_Tad_GS","Medium"},
- {214,"PRH1_Gord_GS","PRH1_Gord_GS","Medium"},
- {215,"NDLead_Earnest_EG","NDLead_Earnest_EG","Medium"},
- {216,"JKlead_Ted_EG","JKlead_Ted_EG","Large"},
- {217,"GRlead_Johnny_EG","GRlead_Johnny_EG","Large"},
- {218,"PRlead_Darby_EG","PRlead_Darby_EG","Large"},
- {219,"Dog_Pitbull2","Dog_Pitbull2","Small"},
- {220,"Dog_Pitbull3","Dog_Pitbull3","Small"},
- {221,"TE_CafeMU_W","TE_CafeMU_W","Huge"},
- {222,"TO_Millworker","TO_Millworker","Huge"},
- {223,"TO_Dockworker","TO_Dockworker","Huge"},
- {224,"NDH2_Thad_PJ","NDH2_Thad_PJ","Large"},
- {225,"GN_Lblkboy_PJ","GN_Lblkboy_PJ","Small"},
- {226,"GN_Hboy_PJ","GN_Hboy_PJ","Small"},
- {227,"GN_Boy01_PJ","GN_Boy01_PJ","Medium"},
- {228,"GN_Boy02_PJ","GN_Boy02_PJ","Large"},
- {229,"TE_Gym_Incog","TE_Gym_Incog_W","Huge"},
- {230,"JK_Mandy_Towel","JK_Mandy_Towel","Medium"},
- {231,"JK_Bo_FB","JK_Bo_FB","Large"},
- {232,"JK_Casey_FB","JK_Casey_FB","Huge"},
- --{233,"PunchBag","PunchBag","Large"},
- {234,"TO_Cop3","TO_Cop3","Huge"},
- {235,"GN_GreekboyUW","GN_GreekboyUW","Medium"},
- {236,"TO_Construct01","TO_Construct01","Huge"},
- {237,"TO_Construct02","TO_Construct02","Huge"},
- {238,"TO_Cop4","TO_Cop4","Huge"},
- {239,"PRH2_Bryce_OBOX_D1","PRH2_Bryce_OBOX_D1","Large"},
- {240,"PRH2_Bryce_OBOX_D2","PRH2_Bryce_OBOX_D2","Large"},
- {241,"PRH2A_Chad_OBOX_D1","PRH2A_Chad_OBOX_D1","Large"},
- {242,"PRH2A_Chad_OBOX_D2","PRH2A_Chad_OBOX_D2","Large"},
- {243,"PR2nd_Bif_OBOX_D2","PR2nd_Bif_OBOX_D2","Huge"},
- {244,"PRH3_Justin_OBOX_D1","PRH3_Justin_OBOX_D1","Large"},
- {245,"PRH3_Justin_OBOX_D2","PRH3_Justin_OBOX_D2","Large"},
- {246,"PRH3a_Prkr_OBOX_D1","PRH3a_Prkr_OBOX_D1","Large"},
- {247,"PRH3a_Prkr_OBOX_D2","PRH3a_Prkr_OBOX_D2","Large"},
- {248,"TE_Geography","TE_Geography","Huge"},
- {249,"TE_Music","TE_Music","Huge"},
- {250,"TO_ElfF","TO_ElfF","Medium"},
- {251,"TO_ElfM","TO_ElfM","Medium"},
- {252,"TO_HoboSanta","TO_HoboSanta","Huge"},
- {253,"TO_Santa","TO_Santa","Huge"},
- {254,"TO_Santa_NB","TO_Santa_NB","Huge"},
- {255,"Peter_Nutcrack","Peter_Nutcrack","Medium"},
- {256,"GN_Fatgirl_Fairy","GN_Fatgirl_Fairy","Fat"},
- {257,"GN_Lgirl_2_Flower","GN_Lgirl_2_Flower","Small"},
- {258,"GN_Hboy_Flower","GN_Hboy_Flower","Small"},
- }
- -- Setup other tables:
- local factions = {
- -- {Chance, name}
- -- [8] and beyond are adult
- {100,"NERD"},
- {100,"JOCK"},
- {100,"DROPOUT"},
- {100,"GREASER"},
- {100,"PREPPY"},
- {100,"STUDENT"},
- {100,"BULLY"},
- {50,"TOWNPERSON"},
- {50,"SHOPKEEP"},
- {10,"PREFECT"},
- {10,"COP"},
- {10,"TEACHER"},
- }
- local stats = {
- -- {Chance, stat}
- {1,"STAT_AN_DOG_A"},
- {1,"STAT_AN_RAT_A"},
- {1,"STAT_B_RUSSELL_A"},
- {1,"STAT_B_STRIKER_A"},
- {1,"STAT_B_STRIKER_B"},
- {1,"STAT_B_STRIKER_S"},
- {1,"STAT_CV_FEMALE_A"},
- {1,"STAT_CV_FEMALE_OLD"},
- {1,"STAT_CV_MALE_A"},
- {1,"STAT_CV_MALE_OLD"},
- {1,"STAT_DEFAULT"},
- {1,"STAT_DO_EDGAR"},
- {1,"STAT_DO_GRAPPLER_A"},
- {1,"STAT_DO_STRIKER_A"},
- {1,"STAT_GS_FEMALE_A"},
- {1,"STAT_GS_FEMALE_S"},
- {1,"STAT_GS_FEMALE_SMKID"},
- {1,"STAT_GS_GARY"},
- {1,"STAT_GS_MALE_A"},
- {1,"STAT_GS_MALE_SMKID"},
- {1,"STAT_GS_MALE_TATTLER"},
- {1,"STAT_G_GRAPPLER_A"},
- {1,"STAT_G_JOHNNY"},
- {1,"STAT_G_MELEE_A"},
- {1,"STAT_G_PIRATE"},
- {1,"STAT_G_STRIKER_A"},
- {1,"STAT_HOBO"},
- {1,"STAT_J_DAMON"},
- {1,"STAT_J_GRAPPLER_A"},
- {1,"STAT_J_GRAPPLER_B"},
- {1,"STAT_J_MASCOT"},
- {1,"STAT_J_MELEE_A"},
- {1,"STAT_J_STRIKER_A"},
- {1,"STAT_J_TED"},
- {1,"STAT_LE_OFFICER_A"},
- {1,"STAT_LE_ORDERLY_A"},
- {1,"STAT_N_EARNEST"},
- {1,"STAT_N_MELEE_A"},
- {1,"STAT_N_RANGED_A"},
- {1,"STAT_N_RANGED_S"},
- {1,"STAT_N_STRIKER_A"},
- {1,"STAT_N_STRIKER_B"},
- {1,"STAT_PF_BASIC_A"},
- {1,"STAT_PF_BASIC_S"},
- {1,"STAT_PLAYER"},
- {1,"STAT_P_BOXING"},
- {1,"STAT_P_BOXING_Bif"},
- {1,"STAT_P_BOXING_Bryce"},
- {1,"STAT_P_BOXING_Chad"},
- {1,"STAT_P_BOXING_Justin"},
- {1,"STAT_P_BOXING_Parker"},
- {1,"STAT_P_GRAPPLER_A"},
- {1,"STAT_P_STRIKER_A"},
- {1,"STAT_P_STRIKER_B"},
- {1,"STAT_TE_FEMALE_A"},
- {1,"STAT_TE_JANITOR"},
- {1,"STAT_TE_MALE_A"},
- {1,"STAT_TO_SIAMESE"},
- {1,"STAT_WRESTLING_FAT"},
- {1,"STAT_WRESTLING_GEN"},
- {1,"STAT_WRESTLING_LUIS"},
- }
- local styles = {
- -- {Chance, name}
- {50,"AN_DOG"},
- {20,"Authority"},
- {100,"B_Striker_A"},
- {200,"CV_Female_A"},
- {50,"CV_Male_A"},
- {100,"CV_OLD"},
- {100,"DO_Grappler_A"},
- {100,"DO_Striker_A"},
- {100,"GS_Fat_A"},
- {200,"GS_Female_A"},
- {100,"GS_Male_A"},
- {100,"G_Grappler_A"},
- {100,"G_Johnny"},
- {100,"G_Melee_A"},
- {100,"G_Striker_A"},
- {100,"J_Grappler_A"},
- {100,"J_Mascot"},
- {100,"J_Melee_A"},
- {100,"J_Striker_A"},
- {50,"LE_Orderly_A"},
- {100,"N_Ranged_A"},
- {100,"N_Striker_A"},
- {100,"N_Striker_B"},
- {100,"P_Grappler_A"},
- {100,"P_Striker_A"},
- {100,"P_Striker_B"},
- {50,"TE_Female_A"},
- {50,"Crazy_Basic"},
- {50,"BOSS_Russell"},
- }
- -- Setup chance:
- for i,t in ipairs({factions,stats,styles}) do
- local total = 0
- for i,v in ipairs(t) do
- total = total + v[1]
- v[1] = total
- end
- end
- -- Setup chance function:
- local getRandomShit = function(t,m)
- if not m then
- m = t[table.getn(t)][1]
- end
- if m >= 1 then
- local r = math.random(1,m)
- for i = table.getn(t),1,-1 do
- local c = t[i-1]
- if not c then
- return t[i]
- elseif r > c[1] then
- return t[i]
- end
- end
- end
- return t[1]
- end
- -- Setup ped tables:
- local texture = ChapterGet() == 2 and 3 or 2
- for k,v in ipairs(peds) do
- -- Sex and faction:
- local sex,faction
- if v[1] == 66 then
- sex = 0
- faction = getRandomShit(factions,factions[7][1])[2]
- else
- sex = chance(25) and 1 or 0
- faction = getRandomShit(factions)[2]
- if faction == "PREFECT" or faction == "COP" or faction == "TEACHER" then
- gAuthority[v[1]] = true
- end
- end
- -- Style:
- local style = getRandomShit(styles)[2]
- -- Setup ped object:
- SetupPedObject(
- v[1], -- index
- v[2], -- model
- v[texture], -- texture (use model in every season but winter)
- sex, -- sex (1 = female)
- v[4], -- size (for animation)
- faction, -- faction
- getRandomShit(stats)[2], -- stat
- "null", -- animation group 1
- "null", -- animation group 2
- "null", -- animation group 3
- "null", -- animation group 4
- chance(10) and 2 or 1, -- unique model status (1 = one copy of this ped at a time, 2 = multiple)
- "/Global/"..style, -- style root
- "Act/Anim/"..style..".act", -- style file
- "/Global/AI", -- ai root
- "Act/AI/AI.act" -- ai file
- )
- end
- end
- function F_LoadAnimations()
- -- Setup animation groups:
- local anims = {
- -- Insanity animations:
- "4_04_FunhouseFun",
- "Boxing",
- "Hang_Talking",
- "MINI_React",
- "Russell",
- "Nemesis",
- "V_Bike",
- "bike",
- "F_Crazy",
- -- Default ped animations:
- "Authority",
- "B_Striker",
- "CV_Female",
- "CV_Male",
- "DO_Edgar",
- "DO_Grap",
- "DO_StrikeCombo",
- "DO_Striker",
- "F_Adult",
- "F_BULLY",
- "F_Douts",
- "F_Girls",
- "F_Greas",
- "F_Jocks",
- "F_Nerds",
- "F_OldPeds",
- "F_Pref",
- "F_Preps",
- "G_Grappler",
- "G_Johnny",
- "G_Striker",
- "Grap",
- "J_Damon",
- "J_Grappler",
- "J_Melee",
- "J_Ranged",
- "J_Striker",
- "LE_Orderly",
- "N_Ranged",
- "N_Striker",
- "N_Striker_A",
- "N_Striker_B",
- "P_Grappler",
- "P_Striker",
- "PunchBag",
- "Qped",
- "Rat_Ped",
- "Russell_Pbomb",
- "Straf_Dout",
- "Straf_Fat",
- "Straf_Female",
- "Straf_Male",
- "Straf_Nerd",
- "Straf_Prep",
- "Straf_Savage",
- "Straf_Wrest",
- "TE_Female",
- }
- -- Load animation groups:
- for i,v in ipairs(anims) do
- LoadAnimationGroup(v)
- end
- end
- -- General functions:
- function PedCreateSheldonator(x,y,z)
- -- 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")
- 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,chance(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:
- PedSetPedToTypeAttitude(ped,13,0)
- PedAttackPlayer(ped,3)
- -- Add to sheldonators:
- table.insert(gSheldonators,{ped,speed,[4] = 0,[6] = 4000,[7] = 7000})
- -- Return handle:
- return ped
- end
- function PedStopLove(ped)
- local faction = PedGetFaction(ped)
- for f = 0,13 do
- if f ~= 12 and f ~= faction and PedGetPedToTypeAttitude(ped,f) > 2 then
- PedSetPedToTypeAttitude(ped,f,2)
- end
- end
- end
- function PedMakeNeutral(ped)
- local faction = PedGetFaction(ped)
- for f = 0,13 do
- if f ~= 12 and f ~= faction and PedGetPedToTypeAttitude(ped,f) ~= 2 then
- PedSetPedToTypeAttitude(ped,f,2)
- end
- end
- end
- function PedDislikesPlayer(ped)
- local e = PedGetEmotionTowardsPed(ped,gPlayer)
- return e == 0 or e == 1 or e == 2 or e == 4 or e == 5 or e == 6 or PedGetPedToTypeAttitude(ped,13) < 2 or gAuthority[PedGetModel(ped)] and PlayerGetPunishmentPoints() > 0 or PedGetWhoHitMeLast(ped) == gPlayer
- end
- function PedGetDistanceFromPed(ped1,ped2)
- local x1,y1,z1 = PedGetPosXYZ(ped1)
- local x2,y2,z2 = PedGetPosXYZ(ped2)
- local x,y,z = x1-x2,y1-y2,z1-z1
- return math.sqrt(x*x + y*y + z*z)
- end
- function PedGetModel(ped)
- if not gPedModels then
- gPedModels = {}
- end
- if gPedModels[ped] then
- return gPedModels[ped]
- end
- for i = 0,258 do
- if PedIsModel(ped,i) then
- gPedModels[ped] = i
- return i
- end
- end
- return -1
- end
- function chance(p)
- return math.random(1,100) <= p
- end
- -- New PedCreateXYZ:
- pcxyz = PedCreateXYZ
- function PedCreateXYZ(m,x,y,z)
- local ped = pcxyz(m,x,y,z)
- table.insert(gAllPeds,ped)
- return ped
- end
- -- Menu functions:
- function MENU_BasicMenu(title,options,x,y,z,xl,yl,zl)
- gMenuActive = true
- title = title.."\n\n"
- PlayerSetControl(0)
- local s = 1
- local allStuff = {options}
- while true do
- local stuff = allStuff[table.getn(allStuff)]
- local str = title
- for i=s-3,s+3 do
- if i == s then
- str = str..">"
- end
- if stuff[i] then
- str = str..stuff[i][1]
- end
- if i < table.getn(stuff) then
- str = str.."\n"
- end
- end
- TextPrintString(str,0,1)
- if zl then
- CameraSetXYZ(x,y,z,xl,yl,zl)
- end
- Wait(0)
- if not PedMePlaying(gPlayer,"Default_KEY") and not PedIsPlaying(gPlayer,"/Global/Weapons/SelectActions",true) then
- break
- elseif IsButtonBeingPressed(2,0) then
- s = s - 1
- if s < 1 and table.getn(stuff) > 0 then
- s = table.getn(stuff)
- end
- elseif IsButtonBeingPressed(3,0) then
- s = s + 1
- if s > table.getn(stuff) then
- s = 1
- end
- elseif IsButtonBeingPressed(7,0) and stuff[s][2] then
- if type(stuff[s][2]) == "table" then
- table.insert(allStuff,stuff[s][2])
- s = 1
- elseif stuff[s][3] then
- stuff[s][2](unpack(stuff[s][3]))
- else
- stuff[s][2]()
- end
- elseif IsButtonBeingPressed(8,0) then
- table.remove(allStuff)
- if table.getn(allStuff) < 1 then
- break
- end
- s = 1
- end
- end
- if zl then
- CameraReset()
- CameraReturnToPlayer()
- end
- PlayerSetControl(1)
- gMenuActive = nil
- end
- -- Other functions:
- function F_SpawnGarageVehicle(vehicle,drive)
- -- Create driving thread:
- if not gDrivingThread and drive then
- gDrivingThread = function()
- local pressTime,stopped
- local initEngine = function()
- VehicleEnableEngine(gSpawnedVehicle,gSpawnedVehicleEngine)
- if gSpawnedVehicleEngine then
- VehicleSetAccelerationMult(gSpawnedVehicle,1)
- else
- VehicleSetAccelerationMult(gSpawnedVehicle,0)
- end
- end
- while true do
- Wait(0)
- if gSpawnedVehicleDrive and VehicleIsValid(gSpawnedVehicle) then
- local x,y,z = VehicleGetPosXYZ(gSpawnedVehicle)
- if IsButtonBeingReleased(9,0) then
- if PedIsInAreaXYZ(gPlayer,x,y,z,3) and PedMePlaying(gPlayer,"Default_KEY") then
- PedWarpIntoCar(gPlayer,gSpawnedVehicle)
- VehicleSetStatic(gSpawnedVehicle,false)
- initEngine()
- elseif gSpawnedVehicleDrive == 2 and PedIsInVehicle(gPlayer,gSpawnedVehicle) then
- PedWarpOutOfCar(gPlayer)
- VehicleDelete(gSpawnedVehicle)
- gSpawnedVehicle = nil
- end
- elseif IsButtonBeingPressed(8,0) and PedIsInVehicle(gPlayer,gSpawnedVehicle) and (VehicleIsModel(gSpawnedVehicle,275) or VehicleIsModel(gSpawnedVehicle,295)) then
- gSpawnedVehicleSiren = not gSpawnedVehicleSiren
- VehicleEnableSiren(gSpawnedVehicle,gSpawnedVehicleSiren)
- elseif gSpawnedVehicleDrive == 1 and PedIsInVehicle(gPlayer,gSpawnedVehicle) then
- if not pressTime then
- if IsButtonBeingPressed(3,0) then
- pressTime = GetTimer()
- end
- elseif gSpawnedVehicleEngine and (IsButtonPressed(6,0) or IsButtonPressed(7,0)) then
- pressTime = nil
- elseif IsButtonPressed(3,0) and GetTimer() >= pressTime + 500 then
- gSpawnedVehicleEngine = not gSpawnedVehicleEngine
- initEngine()
- pressTime = nil
- end
- end
- end
- end
- end
- gDrivingThread = CreateThread("gDrivingThread")
- end
- -- Delete old:
- if gSpawnedVehicle and VehicleIsValid(gSpawnedVehicle) then
- VehicleDelete(gSpawnedVehicle)
- end
- -- Create new:
- gSpawnedVehicle = VehicleCreateXYZ(vehicle,174.83,-10.37,5.76)
- if VehicleIsValid(gSpawnedVehicle) then
- VehicleSetColor(gSpawnedVehicle,math.random(0,99))
- VehicleFaceHeading(gSpawnedVehicle,math.pi/2)
- VehicleSetOwner(gSpawnedVehicle,gPlayer)
- gSpawnedVehicleDrive = drive
- gSpawnedVehicleSiren = false
- gSpawnedVehicleEngine = true
- else
- TextPrintString("Failed to retrieve vehicle!",1.5,1)
- Wait(1500)
- end
- end
- --[[ Debug tests:
- For testing shit. Set "gDebugTests" to true to spawn a debug blip in Jimmy's room.
- ]]
- if gDebugTests then
- function T_TestEvents()
- local s = 1
- while true do
- TextPrintString("Event #"..s.."\nPress ~ddown~ to start.",0,2)
- Wait(0)
- if IsButtonBeingPressed(0,0) then
- s = s - 1
- if s < 1 then
- s = table.getn(gEvents)
- end
- elseif IsButtonBeingPressed(1,0) then
- s = s + 1
- if s > table.getn(gEvents) then
- s = 1
- end
- elseif IsButtonBeingPressed(3,0) and not gMenuActive then
- local x,y,z = PlayerGetPosXYZ()
- while gEvents[s](x+1,y,z) == false do
- TextPrintString("Launching event...",0,2)
- Wait(0)
- end
- end
- end
- end
- function T_TestErrands()
- local s = 1
- while true do
- TextPrintString("Errand #"..s.."\nPress ~ddown~ to start.",0,2)
- Wait(0)
- if IsButtonBeingPressed(0,0) then
- s = s - 1
- if s < 1 then
- s = table.getn(gErrands)
- end
- elseif IsButtonBeingPressed(1,0) then
- s = s + 1
- if s > table.getn(gErrands) then
- s = 1
- end
- elseif IsButtonBeingPressed(3,0) and not gMenuActive and gErrands[s] then
- while ERRAND_Play(gErrands[s]) ~= 2 do
- TextPrintString("Launching errand...",0,2)
- Wait(0)
- end
- end
- end
- end
- function T_TestPedEvents()
- local ped
- local s = 1
- while true do
- TextPrintString("Ped Event #"..s.."\nPress ~ddown~ to start.",0,2)
- Wait(0)
- if IsButtonBeingPressed(0,0) then
- s = s - 1
- if s < 1 then
- s = table.getn(gPedEvents)
- end
- elseif IsButtonBeingPressed(1,0) then
- s = s + 1
- if s > table.getn(gPedEvents) then
- s = 1
- end
- elseif IsButtonBeingPressed(3,0) and not gMenuActive then
- if ped and PedIsValid(ped) then
- PedDelete(ped)
- end
- ped = PedCreateXYZ(math.random(2,48),270,-110,6)
- PED_SetMissionPed(ped,true)
- AddBlipForChar(ped,0,0,1)
- PedMakeAmbient(ped)
- while PedIsValid(ped) and gPedEvents[s](ped) == false do
- TextPrintString("Launching event...",0,2)
- Wait(0)
- end
- end
- end
- end
- function T_TestPedWeapons()
- local weapons = gSettings.peds.weapons
- local s = 1
- while true do
- TextPrintString("Weapon #"..s.."\nPress ~ddown~ to give.",0,2)
- Wait(0)
- if IsButtonBeingPressed(0,0) then
- s = s - 1
- if s < 1 then
- s = table.getn(weapons)
- end
- elseif IsButtonBeingPressed(1,0) then
- s = s + 1
- if s > table.getn(weapons) then
- s = 1
- end
- elseif IsButtonBeingPressed(3,0) and not gMenuActive then
- PedSetWeapon(gPlayer,weapons[s],50,false)
- end
- end
- end
- function T_TestPedCount()
- while true do
- TextPrintString("Peds: "..(table.getn({PedFindInAreaXYZ(0,0,0,9999999)})-1),0,2)
- Wait(0)
- end
- end
- function T_TestSheldonator()
- while true do
- TextPrintString("Press ~ddown~ to spawn.",0,2)
- Wait(0)
- if IsButtonBeingPressed(3,0) and not gMenuActive then
- local ped = PedCreateSheldonator(270,-110,6)
- AddBlipForChar(ped,0,26,1)
- PedMakeAmbient(ped)
- end
- end
- end
- function T_TestHealth()
- while true do
- local ped = PedGetTargetPed(gPlayer)
- if ped ~= -1 then
- local lastHealth,newTarget = PedGetHealth(ped)
- repeat
- local health = PedGetHealth(ped)
- if health ~= lastHealth then
- TextPrintString(PedGetName(ped)..": "..string.format("%.1f",health-lastHealth).."HP",3,1)
- lastHealth = health
- end
- Wait(0)
- newTarget = PedGetTargetPed(gPlayer)
- until not PedIsValid(ped) or (newTarget ~= -1 and newTarget ~= ped)
- end
- Wait(0)
- end
- end
- function T_TestBlips()
- local blip = BLIP_Create("test",0,270,-110,6,0,1,TextPrintString,"RAWR!",1,1)
- local status = 0
- while true do
- TextPrintString("Press ~dright~ to move.\nPress ~ddown~ to delete.",0,2)
- Wait(0)
- if IsButtonBeingPressed(3,0) and not gMenuActive and status < 2 then
- BLIP_Delete(blip)
- status = 2
- TextPrintString("Blip deleted.",1,2)
- Wait(1000)
- elseif IsButtonBeingPressed(1,0) and status < 1 then
- BLIP_SetPosition(blip,270,-105,6)
- status = 1
- TextPrintString("Blip moved.",1,2)
- Wait(1000)
- end
- end
- end
- function T_TestEggs()
- while true do
- TextPrintString("Press ~ddown~ to spawn.",0,2)
- Wait(0)
- if IsButtonBeingPressed(3,0) and not gMenuActive then
- local ped = PedCreateXYZ(165,270,-110,6)
- PED_SetMissionPed(ped,true)
- PedSetStationary(ped,true)
- PedSetWeapon(ped,312,50)
- PedAttackPlayer(ped,3)
- GameSetPedStat(ped,10,100)
- GameSetPedStat(ped,11,100)
- AddBlipForChar(ped,0,26,1)
- PedMakeAmbient(ped)
- local lastHealth = PedGetHealth(gPlayer)
- repeat
- local health = PedGetHealth(gPlayer)
- if health ~= lastHealth then
- TextPrintString(PedGetName(gPlayer)..": "..string.format("%.1f",health-lastHealth).."HP",3,1)
- lastHealth = health
- end
- Wait(0)
- until not PedIsValid(ped) or PedIsDead(ped) or IsButtonBeingPressed(3,0) and not gMenuActive
- if PedIsValid(ped) then
- PedDelete(ped)
- end
- end
- end
- end
- function T_TestAnims()
- while true do
- TextPrintString("Press ~ddown~ to play.",0,2)
- Wait(0)
- if IsButtonBeingPressed(3,0) and not gMenuActive then
- PedSetActionNode(gPlayer,"/Global/404Conv/Nerds/Dance2","Act/Conv/4_04.act")
- end
- end
- end
- function F_DeleteDebugThread()
- if gDebugThread then
- TerminateThread(gDebugThread)
- gDebugThread = nil
- end
- end
- function F_CreateDebugThread(thread)
- F_DeleteDebugThread()
- gDebugThread = CreateThread(thread)
- end
- gDebugMenu = {
- {"Tests",{
- {"Events",F_CreateDebugThread,{"T_TestEvents"}},
- {"Errands",F_CreateDebugThread,{"T_TestErrands"}},
- {"Ped Events",F_CreateDebugThread,{"T_TestPedEvents"}},
- {"Ped Weapons",F_CreateDebugThread,{"T_TestPedWeapons"}},
- {"Ped Count",F_CreateDebugThread,{"T_TestPedCount"}},
- {"Sheldonator",F_CreateDebugThread,{"T_TestSheldonator"}},
- {"Health",F_CreateDebugThread,{"T_TestHealth"}},
- {"Blips",F_CreateDebugThread,{"T_TestBlips"}},
- {"Eggs",F_CreateDebugThread,{"T_TestEggs"}},
- {"Animation",F_CreateDebugThread,{"T_TestAnims"}},
- {"Stop Test",F_DeleteDebugThread},
- }},
- {"Ped Spawns",{
- {"Stop Ped Spawns",StopPedProduction,{true}},
- {"Resume Ped Spawns",StopPedProduction,{false}},
- }},
- {"Punishment System",{
- {"Disable Punishment",DisablePunishmentSystem,{true}},
- {"Enable Punishment",DisablePunishmentSystem,{false}},
- }},
- }
- end
- -- STimeCycle functions:
- function F_AttendedClass()
- if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
- return
- end
- SetSkippedClass(false)
- PlayerSetPunishmentPoints(0)
- end
- function F_MissedClass()
- if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
- return
- end
- SetSkippedClass(true)
- StatAddToInt(166)
- end
- function F_AttendedCurfew()
- if not PedInConversation(gPlayer) and not MissionActive() then
- TextPrintString("You got home in time for curfew", 4)
- end
- end
- function F_MissedCurfew()
- if not PedInConversation(gPlayer) and not MissionActive() then
- TextPrint("TM_TIRED5", 4, 2)
- end
- end
- function F_StartClass()
- if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
- return
- end
- end
- function F_EndClass()
- if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
- return
- end
- end
- function F_StartMorning()
- F_UpdateTimeCycle()
- end
- function F_EndMorning()
- F_UpdateTimeCycle()
- end
- function F_StartLunch()
- if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
- F_UpdateTimeCycle()
- return
- end
- F_UpdateTimeCycle()
- end
- function F_EndLunch()
- F_UpdateTimeCycle()
- end
- function F_StartAfternoon()
- F_UpdateTimeCycle()
- end
- function F_EndAfternoon()
- F_UpdateTimeCycle()
- end
- function F_StartEvening()
- F_UpdateTimeCycle()
- end
- function F_EndEvening()
- F_UpdateTimeCycle()
- end
- function F_StartCurfew_SlightlyTired()
- F_UpdateTimeCycle()
- end
- function F_StartCurfew_Tired()
- F_UpdateTimeCycle()
- end
- function F_StartCurfew_MoreTired()
- F_UpdateTimeCycle()
- end
- function F_StartCurfew_TooTired()
- F_UpdateTimeCycle()
- end
- function F_EndCurfew_TooTired()
- F_UpdateTimeCycle()
- end
- function F_EndTired()
- F_UpdateTimeCycle()
- end
- function F_Nothing()
- end
- function F_ClassWarning()
- if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
- return
- end
- local l_23_0 = math.random(1, 2)
- end
- function F_UpdateTimeCycle()
- if not IsMissionCompleated("1_B") then
- local l_24_0 = GetCurrentDay(false)
- if l_24_0 < 0 or l_24_0 > 2 then
- SetCurrentDay(0)
- end
- end
- F_UpdateCurfew()
- end
- function F_UpdateCurfew()
- local l_25_0 = shared.gCurfewRules
- if not l_25_0 then
- l_25_0 = F_CurfewDefaultRules
- end
- l_25_0()
- end
- function F_CurfewDefaultRules()
- local l_26_0 = ClockGet()
- if l_26_0 >= 23 or l_26_0 < 7 then
- shared.gCurfew = true
- else
- shared.gCurfew = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment