forked from SilverGoLt/Standalone-Zombie-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zombies.lua
189 lines (154 loc) · 6.26 KB
/
zombies.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
-- Combined the base zombie and safezone code into standalone script package.
-- Fixed how zombies would be driving vehicles before getting out to wonder.
-- Fixed how zombies would run at a player even though they're in a vehicle.
-- Upgraded the efficiency by replacing vDist and combining zombie while loops.
local Shooting = false
local Running = false
local SafeZones = {
{x = 450.5966, y = -998.9636, z = 28.4284, radius = 80.0},-- Mission Row
{x = 1853.6666, y = 3688.0222, z = 33.2777, radius = 40.0},-- Sandy Shores
{x = -104.1444, y = 6469.3888, z = 30.6333, radius = 60.0}-- Paleto Bay
}
DecorRegister('RegisterZombie', 2)
AddRelationshipGroup('ZOMBIE')
SetRelationshipBetweenGroups(0, GetHashKey('ZOMBIE'), GetHashKey('PLAYER'))
SetRelationshipBetweenGroups(5, GetHashKey('PLAYER'), GetHashKey('ZOMBIE'))
function IsPlayerShooting()
return Shooting
end
function IsPlayerRunning()
return Running
end
Citizen.CreateThread(function()-- Will only work in it's own while loop
while true do
Citizen.Wait(0)
-- Peds
SetPedDensityMultiplierThisFrame(1.0)
SetScenarioPedDensityMultiplierThisFrame(1.0, 1.0)
-- Vehicles
SetRandomVehicleDensityMultiplierThisFrame(0.0)
SetParkedVehicleDensityMultiplierThisFrame(0.0)
SetVehicleDensityMultiplierThisFrame(0.0)
end
end)
Citizen.CreateThread(function()-- Will only work in it's own while loop
while true do
Citizen.Wait(0)
if IsPedShooting(PlayerPedId()) then
Shooting = true
Citizen.Wait(5000)
Shooting = false
end
if IsPedSprinting(PlayerPedId()) or IsPedRunning(PlayerPedId()) then
if Running == false then
Running = true
end
else
if Running == true then
Running = false
end
end
end
end)
Citizen.CreateThread(function()
for _, zone in pairs(SafeZones) do
local Blip = AddBlipForRadius(zone.x, zone.y, zone.z, zone.radius)
SetBlipHighDetail(Blip, true)
SetBlipColour(Blip, 2)
SetBlipAlpha(Blip, 128)
end
while true do
Citizen.Wait(0)
for _, zone in pairs(SafeZones) do
local Zombie = -1
local Success = false
local Handler, Zombie = FindFirstPed()
repeat
if IsPedHuman(Zombie) and not IsPedAPlayer(Zombie) and not IsPedDeadOrDying(Zombie, true) then
local pedcoords = GetEntityCoords(Zombie)
local zonecoords = vector3(zone.x, zone.y, zone.z)
local distance = #(zonecoords - pedcoords)
if distance <= zone.radius then
DeleteEntity(Zombie)
end
end
Success, Zombie = FindNextPed(Handler)
until not (Success)
EndFindPed(Handler)
end
local Zombie = -1
local Success = false
local Handler, Zombie = FindFirstPed()
repeat
Citizen.Wait(10)
if IsPedHuman(Zombie) and not IsPedAPlayer(Zombie) and not IsPedDeadOrDying(Zombie, true) then
if not DecorExistOn(Zombie, 'RegisterZombie') then
ClearPedTasks(Zombie)
ClearPedSecondaryTask(Zombie)
ClearPedTasksImmediately(Zombie)
TaskWanderStandard(Zombie, 10.0, 10)
SetPedRelationshipGroupHash(Zombie, 'ZOMBIE')
ApplyPedDamagePack(Zombie, 'BigHitByVehicle', 0.0, 1.0)
SetEntityHealth(Zombie, 200)
RequestAnimSet('move_m@drunk@verydrunk')
while not HasAnimSetLoaded('move_m@drunk@verydrunk') do
Citizen.Wait(0)
end
SetPedMovementClipset(Zombie, 'move_m@drunk@verydrunk', 1.0)
SetPedConfigFlag(Zombie, 100, false)
DecorSetBool(Zombie, 'RegisterZombie', true)
end
SetPedRagdollBlockingFlags(Zombie, 1)
SetPedCanRagdollFromPlayerImpact(Zombie, false)
SetPedSuffersCriticalHits(Zombie, true)
SetPedEnableWeaponBlocking(Zombie, true)
DisablePedPainAudio(Zombie, true)
StopPedSpeaking(Zombie, true)
SetPedDiesWhenInjured(Zombie, false)
StopPedRingtone(Zombie)
SetPedMute(Zombie)
SetPedIsDrunk(Zombie, true)
SetPedConfigFlag(Zombie, 166, false)
SetPedConfigFlag(Zombie, 170, false)
SetBlockingOfNonTemporaryEvents(Zombie, true)
SetPedCanEvasiveDive(Zombie, false)
RemoveAllPedWeapons(Zombie, true)
local PlayerCoords = GetEntityCoords(PlayerPedId())
local PedCoords = GetEntityCoords(Zombie)
local Distance = #(PedCoords - PlayerCoords)
local DistanceTarget
if IsPlayerShooting() then
DistanceTarget = 120.0
elseif IsPlayerRunning() then
DistanceTarget = 50.0
else
DistanceTarget = 20.0
end
if Distance <= DistanceTarget and not IsPedInAnyVehicle(PlayerPedId(), false) then
TaskGoStraightToCoord(Zombie, PlayerCoords.x, PlayerCoords.y, PlayerCoords.z, 2.0, -1, 0.0, 0.0)
end
if Distance <= 1.3 then
if not IsPedRagdoll(Zombie) and not IsPedGettingUp(Zombie) then
local health = GetEntityHealth(PlayerPedId())
if health == 0 then
ClearPedTasks(Zombie)
TaskWanderStandard(Zombie, 10.0, 10)
else
RequestAnimSet('melee@unarmed@streamed_core_fps')
while not HasAnimSetLoaded('melee@unarmed@streamed_core_fps') do
Citizen.Wait(10)
end
TaskPlayAnim(Zombie, 'melee@unarmed@streamed_core_fps', 'ground_attack_0_psycho', 8.0, 1.0, -1, 48, 0.001, false, false, false)
ApplyDamageToPed(PlayerPedId(), 5, false)
end
end
end
if not NetworkGetEntityIsNetworked(Zombie) then
DeleteEntity(Zombie)
end
end
Success, Zombie = FindNextPed(Handler)
until not (Success)
EndFindPed(Handler)
end
end)