Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
tome
Tales of MajEyal
Commits
a2e5e5fd
Commit
a2e5e5fd
authored
10 years ago
by
Alex Ksandra
Browse files
Options
Downloads
Patches
Plain Diff
Made Lua errors drain energy on NPCs to prevent infinite chains and allow
potential recoveries.
parent
cde22396
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!74
Infinite lua chain
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game/engines/default/engine/interface/ActorTalents.lua
+12
-1
12 additions, 1 deletion
game/engines/default/engine/interface/ActorTalents.lua
game/modules/tome/class/NPC.lua
+4
-0
4 additions, 0 deletions
game/modules/tome/class/NPC.lua
with
16 additions
and
1 deletion
game/engines/default/engine/interface/ActorTalents.lua
+
12
−
1
View file @
a2e5e5fd
...
...
@@ -174,7 +174,11 @@ function _M:useTalent(id, who, force_level, ignore_cd, force_target, silent, no_
-- cancel checked in coroutine
success
,
err
=
coroutine.resume
(
co
)
end
if
not
success
and
err
then
print
(
debug.traceback
(
co
))
error
(
err
)
end
if
not
success
and
err
then
print
(
debug.traceback
(
co
))
self
:
onTalentLuaError
(
err
)
error
(
err
)
end
elseif
ab
.
mode
==
"sustained"
and
ab
.
activate
and
ab
.
deactivate
then
if
self
:
isTalentCoolingDown
(
ab
)
and
not
ignore_cd
then
game
.
logPlayer
(
who
,
"%s is still on cooldown for %d turns."
,
ab
.
name
:
capitalize
(),
self
.
talents_cd
[
ab
.
id
])
...
...
@@ -280,6 +284,13 @@ function _M:postUseTalent(talent, ret, silent)
return
true
end
--- Called if a talent errors out
-- @param ab the talent
-- @param err the error
function
_M
:
onTalentLuaError
(
ab
,
err
)
return
end
--- Force a talent to activate without using energy or such
-- "def" can have a field "ignore_energy" to not consume energy; other parameters can be passed and handled by an overload of this method.
-- Object activation interface calls this method with an "ignore_ressources" parameter
...
...
This diff is collapsed.
Click to expand it.
game/modules/tome/class/NPC.lua
+
4
−
0
View file @
a2e5e5fd
...
...
@@ -108,6 +108,10 @@ local function spotHostiles(self)
return
seen
end
function
_M
:
onTalentLuaError
(
ab
,
err
)
self
:
useEnergy
()
-- prevent infinitely long erroring out turns
end
--- Try to auto use listed talents
-- This should be called in your actors "act()" method
function
_M
:
automaticTalents
()
...
...
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