Skip to content

Commit 80329a6

Browse files
authored
Merge pull request #175 from Shark-vil/dev
v1.13.6
2 parents e27b1ed + e593df6 commit 80329a6

4 files changed

Lines changed: 44 additions & 23 deletions

File tree

lua/background_npcs_core/classes/actor/sh_actor_base.lua

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ local table_RemoveByValue = table.RemoveByValue
2525
local table_Copy = table.Copy
2626
local table_Add = table.Add
2727
local table_insert = table.insert
28+
local table_isArray = table.isArray
2829
local string_find = string.find
2930
local string_lower = string.lower
3031
local hook_Run = hook.Run
@@ -1032,36 +1033,46 @@ function BaseClass:GetRelationship(value, default)
10321033
end
10331034

10341035
function BaseClass:HasTeam(value)
1035-
local value = value
1036-
if self.data.team ~= nil and value ~= nil then
1037-
if isstring(value) then
1038-
return table_HasValueBySeq(self.data.team, value)
1036+
if self.data == nil or self.data.team == nil or value == nil then
1037+
return false
1038+
end
1039+
1040+
if isstring(value) then
1041+
return table_HasValueBySeq(self.data.team, value)
1042+
end
1043+
1044+
if isentity(value) then
1045+
if isfunction(value.IsPlayer) and value:IsPlayer() then
1046+
if table_HasValueBySeq(self.data.team, 'player') then
1047+
return true
1048+
else
1049+
return bgNPC:GetModule('team_parent'):HasParent(value, self)
1050+
end
1051+
elseif value.isBgnActor and ((isfunction(value.IsNPC) and value:IsNPC()) or (isfunction(value.IsNextBot) and value:IsNextBot())) then
1052+
local actor = bgNPC:GetActor(value)
1053+
if actor then value = actor end
10391054
end
1055+
end
10401056

1041-
if isentity(value) then
1042-
if value:IsPlayer() then
1043-
if table_HasValueBySeq(self.data.team, 'player') then
1044-
return true
1045-
else
1046-
return bgNPC:GetModule('team_parent'):HasParent(value, self)
1047-
end
1048-
elseif value.isBgnActor and (value:IsNPC() or value:IsNextBot()) then
1049-
local actor = bgNPC:GetActor(value)
1050-
if not actor then return false end
1051-
value = actor:GetData().team
1057+
if istable(value) then
1058+
if value.isBgnClass and isfunction(value.GetData) then
1059+
local data = value:GetData()
1060+
if istable(data) and istable(data.team) then
1061+
value = data.team
10521062
end
10531063
end
10541064

1055-
if istable(value) then
1056-
if value.isBgnClass then value = value:GetData().team end
1065+
if not table_isArray(value) then
1066+
return false
1067+
end
10571068

1058-
for i = 1, #self.data.team do
1059-
for k = 1, #value do
1060-
if self.data.team[i] == value[k] then return true end
1061-
end
1069+
for i = 1, #self.data.team do
1070+
for k = 1, #value do
1071+
if self.data.team[i] == value[k] then return true end
10621072
end
10631073
end
10641074
end
1075+
10651076
return false
10661077
end
10671078

lua/background_npcs_core/states/sv_walk.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ local function UpdateActorMovementType(actor, data)
6363
end
6464

6565
local function UpdateActorTargetPointAsync(actor, data)
66+
-- if not data.Dick or data.Dick > CurTime() then
67+
-- local actors = bgNPC:GetAllByRadius(actor:GetPos(), 300)
68+
-- if #actors >= 3 then
69+
-- data.updateTargetPointDelay = 0
70+
-- print(1)
71+
-- data.Dick = CurTime() + 10
72+
-- else
73+
-- data.Dick = CurTime() + 1
74+
-- end
75+
-- end
6676
if not data.updateTargetPointDelay or data.updateTargetPointDelay > CurTime() then
6777
return
6878
end

lua/slib_autoloader/sh_background_npcs.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if SERVER then
1414
end
1515

1616
bgNPC = {}
17-
bgNPC.VERSION = '1.13.5'
17+
bgNPC.VERSION = '1.13.6'
1818

1919
-- Do not change -------------
2020
bgNPC.LANGUAGES = {}

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.13.5
1+
1.13.6

0 commit comments

Comments
 (0)