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
f29759a7
Commit
f29759a7
authored
15 years ago
by
dg
Browse files
Options
Downloads
Patches
Plain Diff
talents
git-svn-id:
http://svn.net-core.org/repos/t-engine4@66
51575b47-30f0-44d4-a5cc-537603b46e54
parent
f271282d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
game/engine/interface/ActorAbilities.lua
+32
-32
32 additions, 32 deletions
game/engine/interface/ActorAbilities.lua
with
32 additions
and
32 deletions
game/engine/interface/ActorAbilities.lua
+
32
−
32
View file @
f29759a7
...
...
@@ -3,82 +3,82 @@ require "engine.class"
--- Handles actors stats
module
(
...
,
package
.
seeall
,
class
.
make
)
_M
.
abilitie
s_def
=
{}
_M
.
abilitie
s_types_def
=
{}
_M
.
talent
s_def
=
{}
_M
.
talent
s_types_def
=
{}
--- Defines actor
abilitie
s
--- Defines actor
talent
s
-- Static!
function
_M
:
loadDefinition
(
file
)
local
f
=
loadfile
(
file
)
setfenv
(
f
,
setmetatable
({
DamageType
=
require
(
"engine.DamageType"
),
new
Ability
=
function
(
t
)
self
:
new
Ability
(
t
)
end
,
new
Ability
Type
=
function
(
t
)
self
:
new
Ability
Type
(
t
)
end
,
new
Talent
=
function
(
t
)
self
:
new
Talent
(
t
)
end
,
new
Talent
Type
=
function
(
t
)
self
:
new
Talent
Type
(
t
)
end
,
},
{
__index
=
_G
}))
f
()
end
--- Defines one
ability
type(group)
--- Defines one
talent
type(group)
-- Static!
function
_M
:
new
Ability
Type
(
t
)
assert
(
t
.
name
,
"no
ability
type name"
)
assert
(
t
.
type
,
"no
ability
type type"
)
function
_M
:
new
Talent
Type
(
t
)
assert
(
t
.
name
,
"no
talent
type name"
)
assert
(
t
.
type
,
"no
talent
type type"
)
table.insert
(
self
.
abilitie
s_types_def
,
t
)
table.insert
(
self
.
talent
s_types_def
,
t
)
end
--- Defines one
ability
--- Defines one
talent
-- Static!
function
_M
:
new
Ability
(
t
)
assert
(
t
.
name
,
"no
ability
name"
)
assert
(
t
.
type
,
"no or unknown
ability
type"
)
function
_M
:
new
Talent
(
t
)
assert
(
t
.
name
,
"no
talent
name"
)
assert
(
t
.
type
,
"no or unknown
talent
type"
)
t
.
short_name
=
t
.
short_name
or
t
.
name
t
.
short_name
=
t
.
short_name
:
upper
():
gsub
(
"
[
]
"
,
"_"
)
t
.
mana
=
t
.
mana
or
0
t
.
stamina
=
t
.
stamina
or
0
t
.
mode
=
t
.
mode
or
"activated"
assert
(
t
.
mode
==
"activated"
or
t
.
mode
==
"sustained"
,
"wrong
ability
mode, requires either 'activated' or 'sustained'"
)
assert
(
t
.
info
,
"no
ability
info"
)
assert
(
t
.
mode
==
"activated"
or
t
.
mode
==
"sustained"
,
"wrong
talent
mode, requires either 'activated' or 'sustained'"
)
assert
(
t
.
info
,
"no
talent
info"
)
table.insert
(
self
.
abilitie
s_def
,
t
)
self
[
"
AB
_"
..
t
.
short_name
]
=
#
self
.
abilitie
s_def
table.insert
(
self
.
talent
s_def
,
t
)
self
[
"
T
_"
..
t
.
short_name
]
=
#
self
.
talent
s_def
end
--- Initialises stats with default values if needed
function
_M
:
init
(
t
)
self
.
abilities
=
t
.
abilitie
s
or
{}
self
.
talents
=
t
.
talent
s
or
{}
end
--- Make the actor use the
ability
function
_M
:
use
Ability
(
id
)
local
ab
=
_M
.
abilitie
s_def
[
id
]
assert
(
ab
,
"trying to cast
ability
"
..
tostring
(
id
)
..
" but it is not defined"
)
--- Make the actor use the
talent
function
_M
:
use
Talent
(
id
)
local
ab
=
_M
.
talent
s_def
[
id
]
assert
(
ab
,
"trying to cast
talent
"
..
tostring
(
id
)
..
" but it is not defined"
)
if
ab
.
action
then
if
not
self
:
preUse
Ability
(
ab
)
then
return
end
if
not
self
:
preUse
Talent
(
ab
)
then
return
end
local
co
=
coroutine.create
(
function
()
local
ret
=
ab
.
action
(
self
)
if
not
self
:
postUse
Ability
(
ab
,
ret
)
then
return
end
if
not
self
:
postUse
Talent
(
ab
,
ret
)
then
return
end
end
)
local
ok
,
err
=
coroutine.resume
(
co
)
if
not
ok
and
err
then
error
(
err
)
end
end
end
--- Called before an
ability
is used
--- Called before an
talent
is used
-- Redefine as needed
-- @param ab the
ability
(not the id, the table)
-- @param ab the
talent
(not the id, the table)
-- @return true to continue, false to stop
function
_M
:
preUse
Ability
(
ab
)
function
_M
:
preUse
Talent
(
ab
)
return
true
end
--- Called before an
ability
is used
--- Called before an
talent
is used
-- Redefine as needed
-- @param ab the
ability
(not the id, the table)
-- @param ret the return of the
ability
action
-- @param ab the
talent
(not the id, the table)
-- @param ret the return of the
talent
action
-- @return true to continue, false to stop
function
_M
:
postUse
Ability
(
ab
,
ret
)
function
_M
:
postUse
Talent
(
ab
,
ret
)
return
true
end
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