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
Otowa Kotori
Tales of MajEyal
Commits
4e7f5a11
Commit
4e7f5a11
authored
10 years ago
by
Alex Ksandra
Browse files
Options
Downloads
Patches
Plain Diff
Moved some object-related stuff around.
parent
fb397b15
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game/engines/default/engine/interface/ObjectActivable.lua
+20
-25
20 additions, 25 deletions
game/engines/default/engine/interface/ObjectActivable.lua
game/modules/tome/class/Object.lua
+82
-0
82 additions, 0 deletions
game/modules/tome/class/Object.lua
with
102 additions
and
25 deletions
game/engines/default/engine/interface/ObjectActivable.lua
+
20
−
25
View file @
4e7f5a11
...
...
@@ -65,26 +65,17 @@ function _M:useObject(who, ...)
-- Make sure the object is registered with the game, if need be
if
not
game
:
hasEntity
(
self
)
then
game
:
addEntity
(
self
)
end
local
reduce
=
100
-
util
.
bound
(
who
:
attr
(
"use_object_cooldown_reduce"
)
or
0
,
0
,
100
)
local
usepower
=
function
(
power
)
return
math.ceil
(
power
*
reduce
/
100
)
end
if
self
.
use_power
then
if
(
self
.
talent_cooldown
and
not
who
:
isTalentCoolingDown
(
self
.
talent_cooldown
))
or
(
not
self
.
talent_cooldown
and
self
.
power
>=
usepower
(
self
.
use_power
.
power
))
then
if
self
.
power
>=
self
.
use_power
.
power
then
local
ret
=
self
.
use_power
.
use
(
self
,
who
,
...
)
or
{}
local
no_power
=
not
ret
.
used
or
ret
.
no_power
if
not
no_power
then
if
self
.
talent_cooldown
then
who
.
talents_cd
[
self
.
talent_cooldown
]
=
usepower
(
self
.
use_power
.
power
)
local
t
=
who
:
getTalentFromId
(
self
.
talent_cooldown
)
if
t
.
cooldownStart
then
t
.
cooldownStart
(
who
,
t
,
self
)
end
else
self
.
power
=
self
.
power
-
usepower
(
self
.
use_power
.
power
)
end
self
.
power
=
self
.
power
-
self
.
use_power
.
power
end
return
ret
else
if
self
.
talent_cooldown
or
(
self
.
power_regen
and
self
.
power_regen
~=
0
)
then
if
self
.
power_regen
and
self
.
power_regen
~=
0
then
game
.
logPlayer
(
who
,
"%s is still recharging."
,
self
:
getName
{
no_count
=
true
})
else
game
.
logPlayer
(
who
,
"%s can not be used anymore."
,
self
:
getName
{
no_count
=
true
})
...
...
@@ -94,7 +85,7 @@ function _M:useObject(who, ...)
elseif
self
.
use_simple
then
return
self
.
use_simple
.
use
(
self
,
who
,
...
)
or
{}
elseif
self
.
use_talent
then
if
(
self
.
talent_cooldown
and
not
who
:
isTalentCoolingDown
(
self
.
talent_cooldown
))
or
(
not
self
.
talent_cooldown
and
(
not
self
.
use_talent
.
power
or
self
.
power
>=
usepower
(
self
.
use_talent
.
power
)))
then
if
not
self
.
use_talent
.
power
or
self
.
power
>=
self
.
use_talent
.
power
then
local
id
=
self
.
use_talent
.
id
local
ab
=
self
:
getTalentFromId
(
id
)
...
...
@@ -103,23 +94,27 @@ function _M:useObject(who, ...)
who
.
talents
[
id
]
=
old_level
if
ret
then
if
self
.
talent_cooldown
then
who
.
talents_cd
[
self
.
talent_cooldown
]
=
usepower
(
self
.
use_talent
.
power
)
local
t
=
who
:
getTalentFromId
(
self
.
talent_cooldown
)
if
t
.
cooldownStart
then
t
.
cooldownStart
(
who
,
t
,
self
)
end
else
self
.
power
=
self
.
power
-
usepower
(
self
.
use_talent
.
power
)
end
self
.
power
=
self
.
power
-
self
.
use_talent
.
power
end
return
{
used
=
ret
}
else
if
self
.
talent_cooldown
or
(
self
.
power_regen
and
self
.
power_regen
~=
0
)
then
game
.
logPlayer
(
who
,
"%s is still recharging."
,
self
:
getName
{
no_count
=
true
})
else
game
.
logPlayer
(
who
,
"%s can not be used anymore."
,
self
:
getName
{
no_count
=
true
})
end
game
.
logPlayer
(
who
,
"%s can not be used anymore."
,
self
:
getName
{
no_count
=
true
})
return
{}
end
end
end
function
_M
:
getObjectCooldown
()
local
need
=
(
self
.
use_power
and
self
.
use_power
.
power
)
or
(
self
.
use_talent
and
self
.
use_talent
.
power
)
or
0
if
not
self
.
power
then
return
end
if
self
.
power
<
need
then
if
self
.
power_regen
and
self
.
power_regen
>
0
then
return
math.ceil
((
need
-
self
.
power
)
/
self
.
power_regen
)
else
return
nil
end
else
return
0
end
end
This diff is collapsed.
Click to expand it.
game/modules/tome/class/Object.lua
+
82
−
0
View file @
4e7f5a11
...
...
@@ -114,6 +114,88 @@ function _M:canUseObject()
return
engine
.
interface
.
ObjectActivable
.
canUseObject
(
self
)
end
function
_M
:
useObject
(
who
,
...
)
-- Make sure the object is registered with the game, if need be
if
not
game
:
hasEntity
(
self
)
then
game
:
addEntity
(
self
)
end
local
reduce
=
100
-
util
.
bound
(
who
:
attr
(
"use_object_cooldown_reduce"
)
or
0
,
0
,
100
)
local
usepower
=
function
(
power
)
return
math.ceil
(
power
*
reduce
/
100
)
end
if
self
.
use_power
then
if
(
self
.
talent_cooldown
and
not
who
:
isTalentCoolingDown
(
self
.
talent_cooldown
))
or
(
not
self
.
talent_cooldown
and
self
.
power
>=
usepower
(
self
.
use_power
.
power
))
then
local
ret
=
self
.
use_power
.
use
(
self
,
who
,
...
)
or
{}
local
no_power
=
not
ret
.
used
or
ret
.
no_power
if
not
no_power
then
if
self
.
talent_cooldown
then
who
.
talents_cd
[
self
.
talent_cooldown
]
=
usepower
(
self
.
use_power
.
power
)
local
t
=
who
:
getTalentFromId
(
self
.
talent_cooldown
)
if
t
.
cooldownStart
then
t
.
cooldownStart
(
who
,
t
,
self
)
end
else
self
.
power
=
self
.
power
-
usepower
(
self
.
use_power
.
power
)
end
end
return
ret
else
if
self
.
talent_cooldown
or
(
self
.
power_regen
and
self
.
power_regen
~=
0
)
then
game
.
logPlayer
(
who
,
"%s is still recharging."
,
self
:
getName
{
no_count
=
true
})
else
game
.
logPlayer
(
who
,
"%s can not be used anymore."
,
self
:
getName
{
no_count
=
true
})
end
return
{}
end
elseif
self
.
use_simple
then
return
self
.
use_simple
.
use
(
self
,
who
,
...
)
or
{}
elseif
self
.
use_talent
then
if
(
self
.
talent_cooldown
and
not
who
:
isTalentCoolingDown
(
self
.
talent_cooldown
))
or
(
not
self
.
talent_cooldown
and
(
not
self
.
use_talent
.
power
or
self
.
power
>=
usepower
(
self
.
use_talent
.
power
)))
then
local
id
=
self
.
use_talent
.
id
local
ab
=
self
:
getTalentFromId
(
id
)
local
old_level
=
who
.
talents
[
id
];
who
.
talents
[
id
]
=
self
.
use_talent
.
level
local
ret
=
ab
.
action
(
who
,
ab
)
who
.
talents
[
id
]
=
old_level
if
ret
then
if
self
.
talent_cooldown
then
who
.
talents_cd
[
self
.
talent_cooldown
]
=
usepower
(
self
.
use_talent
.
power
)
local
t
=
who
:
getTalentFromId
(
self
.
talent_cooldown
)
if
t
.
cooldownStart
then
t
.
cooldownStart
(
who
,
t
,
self
)
end
else
self
.
power
=
self
.
power
-
usepower
(
self
.
use_talent
.
power
)
end
end
return
{
used
=
ret
}
else
if
self
.
talent_cooldown
or
(
self
.
power_regen
and
self
.
power_regen
~=
0
)
then
game
.
logPlayer
(
who
,
"%s is still recharging."
,
self
:
getName
{
no_count
=
true
})
else
game
.
logPlayer
(
who
,
"%s can not be used anymore."
,
self
:
getName
{
no_count
=
true
})
end
return
{}
end
end
end
function
_M
:
getObjectCooldown
(
who
)
if
not
self
.
power
then
return
end
if
self
.
talent_cooldown
then
return
(
who
and
who
:
isTalentCoolingDown
(
self
.
talent_cooldown
))
or
0
end
local
reduce
=
100
-
util
.
bound
(
who
:
attr
(
"use_object_cooldown_reduce"
)
or
0
,
0
,
100
)
local
usepower
=
function
(
power
)
return
math.ceil
(
power
*
reduce
/
100
)
end
local
need
=
(
self
.
use_power
and
usepower
(
self
.
use_power
.
power
))
or
(
self
.
use_talent
and
usepower
(
self
.
use_talent
.
power
))
or
0
if
self
.
power
<
need
then
if
self
.
power_regen
and
self
.
power_regen
>
0
then
return
math.ceil
((
need
-
self
.
power
)
/
self
.
power_regen
)
else
return
nil
end
else
return
0
end
end
--- Use the object (quaff, read, ...)
function
_M
:
use
(
who
,
typ
,
inven
,
item
)
inven
=
who
:
getInven
(
inven
)
...
...
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