Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lisa Greene
Tales of MajEyal
Commits
a464527c
Commit
a464527c
authored
5 years ago
by
Chris Davidson
Browse files
Options
Downloads
Patches
Plain Diff
NPCs only pass aggro if they have had their target in their actual FOV at least once
parent
4b43bb08
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game/engines/default/engine/interface/ActorAI.lua
+9
-0
9 additions, 0 deletions
game/engines/default/engine/interface/ActorAI.lua
game/modules/tome/class/NPC.lua
+3
-1
3 additions, 1 deletion
game/modules/tome/class/NPC.lua
with
12 additions
and
1 deletion
game/engines/default/engine/interface/ActorAI.lua
+
9
−
0
View file @
a464527c
...
...
@@ -61,12 +61,16 @@ end
function
_M
:
init
(
t
)
self
.
ai_state
=
self
.
ai_state
or
{}
self
.
ai_target
=
self
.
ai_target
or
{}
self
.
ai_actors_seen
=
self
.
ai_actors_seen
or
{}
-- List of actors the AI has had LOS of at least once (regardless of target)
self
:
autoLoadedAI
()
end
function
_M
:
autoLoadedAI
()
-- Make the table with weak values, so that threat list does not prevent garbage collection
setmetatable
(
self
.
ai_target
,
{
__mode
=
'v'
})
self
.
ai_actors_seen
=
self
.
ai_actors_seen
or
{}
setmetatable
(
self
.
ai_actors_seen
,
{
__mode
=
'v'
})
end
function
_M
:
aiCanPass
(
x
,
y
)
...
...
@@ -131,6 +135,11 @@ function _M:doAI()
-- we forget it
self
:
clearAITarget
()
-- Keep track of actors we've actually seen at least once in our own FOV, NPC calls doFOV right before doAI
for
i
,
v
in
ipairs
(
self
.
fov
.
actors_dist
)
do
self
.
ai_actors_seen
[
v
]
=
v
end
-- Update the ai_target table
local
target_pos
=
self
.
ai_target
.
actor
and
self
.
fov
and
self
.
fov
.
actors
and
self
.
fov
.
actors
[
self
.
ai_target
.
actor
]
if
target_pos
then
...
...
This diff is collapsed.
Click to expand it.
game/modules/tome/class/NPC.lua
+
3
−
1
View file @
a464527c
...
...
@@ -200,8 +200,10 @@ function _M:seen_by(who)
if
self
.
dont_pass_target
then
return
end
-- This means that ghosts can alert other NPC's but not vice versa ;)
local
who_target
=
who
.
ai_target
and
who
.
ai_target
.
actor
if
not
(
who_target
and
who_target
.
x
)
then
return
end
if
not
(
who
and
who
.
ai_actors_seen
[
who_target
])
then
return
end
-- Only pass target if we've seen them via FOV at least once, this limits chain aggro
if
self
.
ai_target
and
self
.
ai_target
.
actor
==
who_target
then
return
end
if
not
rng
.
percent
(
who
:
getRankTalkativeAdjust
())
then
return
end
-- Only receive (usually) hostile targets from allies
if
self
:
reactionToward
(
who
)
<=
0
or
not
who
.
ai_state
.
_pass_friendly_target
and
who
:
reactionToward
(
who_target
)
>
0
then
return
end
...
...
@@ -210,7 +212,7 @@ function _M:seen_by(who)
-- Check if it's actually a being of cold machinery and not of blood and flesh
if
not
who
.
aiSeeTargetPos
then
return
end
if
self
.
ai_target
.
actor
and
not
who_target
:
attr
(
"stealthed_prevents_targetting"
)
then
-- Pass last seen coordinates
-- Pass last seen coordinates
if we already have the same target
if
self
.
ai_target
.
actor
==
who_target
then
-- Adding some type-safety checks, but this isn't fixing the source of the errors
local
last_seen
=
{
turn
=
0
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment