Skip to content

Commit

Permalink
5.16.2
Browse files Browse the repository at this point in the history
shai upd

Co-Authored-By: Sebastian Gabl (aka Hoppip) <sebastian.gabl@gmx.at>
  • Loading branch information
nikitawastaken and segabl committed Aug 8, 2023
1 parent d86ea4f commit 6a0192f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 43 deletions.
18 changes: 8 additions & 10 deletions lua/copsound.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-- Make CopSound return accurate speaking times
function CopSound:speak_done_callback(instance, event_type, unit, sound_source, label, identifier, position)
if alive(unit) then
unit:sound()._speak_expire_t = 0
Hooks:PreHook(CopSound, "init", "sh_init", function (self)
self._speak_done_callback = function ()
self._speak_expire_t = 0
end
end
end)

function CopSound:say(sound_name, sync, skip_prefix, important, callback)
Hooks:OverrideFunction(CopSound, "say", function (self, sound_name, sync, skip_prefix)
if self._last_speech then
self._last_speech:stop()
end
Expand All @@ -22,8 +22,6 @@ function CopSound:say(sound_name, sync, skip_prefix, important, callback)
self._unit:network():send("say", event_id)
end

self._last_speech = self:_play(full_sound or event_id, nil, self.speak_done_callback)
if self._last_speech then
self._speak_expire_t = TimerManager:game():time() + 8
end
end
self._last_speech = self:_play(full_sound or event_id, nil, self._speak_done_callback)
self._speak_expire_t = self._last_speech and TimerManager:game():time() + 10 or 0
end)
75 changes: 44 additions & 31 deletions lua/groupaistatebase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,33 +133,6 @@ function GroupAIStateBase:_process_recurring_grp_SO(...)
end
end

-- Log time when criminals enter an area to use for the teargas check
Hooks:PreHook(GroupAIStateBase, "on_criminal_nav_seg_change", "sh_on_criminal_nav_seg_change", function(self, unit, nav_seg_id)
local u_sighting = self._criminals[unit:key()]
if not u_sighting or u_sighting.ai then
return
end

local prev_area = u_sighting.area
local area = self:get_area_from_nav_seg_id(nav_seg_id)
if prev_area and prev_area ~= area then
if table.count(prev_area.criminal.units, function(c_data)
return not c_data.ai
end) <= 1 then
prev_area.criminal_left_t = self._t
prev_area.old_criminal_entered_t = prev_area.criminal_entered_t
prev_area.criminal_entered_t = nil
end
if not area.criminal_entered_t then
if area.criminal_left_t and area.old_criminal_entered_t then
area.criminal_entered_t = math.lerp(area.old_criminal_entered_t, self._t, math.min((self._t - area.criminal_left_t) / 20, 1))
else
area.criminal_entered_t = self._t
end
end
end
end)

-- Delay spawn points when enemies die close to them
Hooks:PostHook(GroupAIStateBase, "on_enemy_unregistered", "sh_on_enemy_unregistered", function(self, unit)
if Network:is_client() or not unit:character_damage():dead() then
Expand Down Expand Up @@ -245,10 +218,50 @@ Hooks:PostHook(GroupAIStateBase, "criminal_spotted", "sh_criminal_spotted", func
mvector3.set(u_sighting.pos, u_sighting.m_det_pos)
end)

Hooks:PostHook(GroupAIStateBase, "on_criminal_nav_seg_change", "sh_on_criminal_nav_seg_change", function(self, unit)
local u_sighting = self._criminals[unit:key()]
if u_sighting then
mvector3.set(u_sighting.pos, u_sighting.m_det_pos)
-- Do not update detected position and time on nav segment change
-- Log time when criminals enter an area to use for the teargas check
Hooks:OverrideFunction(GroupAIStateBase, "on_criminal_nav_seg_change", function (self, unit, nav_seg_id)
local u_key = unit:key()
local u_sighting = self._criminals[u_key]
if not u_sighting then
return
end

u_sighting.seg = nav_seg_id

local prev_area = u_sighting.area
local area = self:get_area_from_nav_seg_id(nav_seg_id)
if prev_area ~= area then
if prev_area and not u_sighting.ai then
if table.count(prev_area.criminal.units, function (c_data) return not c_data.ai end) <= 1 then
prev_area.criminal_left_t = self._t
prev_area.old_criminal_entered_t = prev_area.criminal_entered_t
prev_area.criminal_entered_t = nil
end

if not area.criminal_entered_t then
if area.criminal_left_t and area.old_criminal_entered_t then
area.criminal_entered_t = math.lerp(area.old_criminal_entered_t, self._t, math.min((self._t - area.criminal_left_t) / 20, 1))
else
area.criminal_entered_t = self._t
end
end
end

if prev_area then
prev_area.criminal.units[u_key] = nil
end

u_sighting.area = area
area.criminal.units[u_key] = u_sighting
end

if area.is_safe then
area.is_safe = nil
self:_on_area_safety_status(area, {
reason = "criminal",
record = u_sighting
})
end
end)

Expand Down
2 changes: 1 addition & 1 deletion meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"ident": "eclipse_difficulty",
"version": "5.16.1",
"version": "5.16.2",
"patchnotes_url": "https://github.com/mrcreepysos/Eclipse-Difficulty/commits/main",
"download_url": "https://github.com/mrcreepysos/Eclipse-Difficulty/archive/refs/heads/main.zip"
}
Expand Down
2 changes: 1 addition & 1 deletion mod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"contact" : "nikita_was_taken on Discord",
"image" : "mod.png",
"blt_version" : 2,
"version" : "5.16.1",
"version" : "5.16.2",
"updates" : [{
"identifier" : "eclipse_difficulty",
"host" : { "meta" : "https://raw.githubusercontent.com/mrcreepysos/Eclipse-Difficulty/main/meta.json" }
Expand Down

0 comments on commit 6a0192f

Please sign in to comment.