Skip to content
Snippets Groups Projects
Commit d2598c47 authored by dg's avatar dg
Browse files

When talents do not have enough resources to be used they will be greyed out in the hotkeys display

git-svn-id: http://svn.net-core.org/repos/t-engine4@2160 51575b47-30f0-44d4-a5cc-537603b46e54
parent 4bc3d8b2
No related branches found
No related tags found
No related merge requests found
......@@ -90,7 +90,11 @@ function _M:display()
if ts[3] == "talent" then
local tid = ts[1]
local t = a:getTalentFromId(tid)
if a:isTalentCoolingDown(t) then
local can_use = a:preUseTalent(t, true, true)
if not can_use then
txt = t.name
color = {190,190,190}
elseif a:isTalentCoolingDown(t) then
txt = ("%s (%d)"):format(t.name, a:isTalentCoolingDown(t))
color = {255,0,0}
elseif a:isTalentActive(t.id) then
......
......@@ -180,8 +180,10 @@ end
--- Called before an talent is used
-- Redefine as needed
-- @param ab the talent (not the id, the table)
-- @param silent no messages will be outputed
-- @param fake no actions are taken, only checks
-- @return true to continue, false to stop
function _M:preUseTalent(talent)
function _M:preUseTalent(talent, silent, fake)
return true
end
......
......@@ -85,11 +85,21 @@ function _M:onTakeHit(value, src)
-- if src and Faction:get(self.faction) and Faction:get(self.faction).hostile_on_attack then
-- Faction:setFactionReaction(self.faction, src.faction, Faction:factionReaction(self.faction, src.faction) - self.rank * 5, true)
-- end
if src.resolveSource then
-- Get angry if attacked by a friend
if src.resolveSource and src.faction and self:reactionToward(src) >= 0 then
local rsrc = src:resolveSource()
local rid = rsrc.unique or rsrc.name
if not self.reaction_actor then self.reaction_actor = {} end
self.reaction_actor[rid] = (self.reaction_actor[rid] or 0) - 50
self.reaction_actor[rid] = math.max(-200, (self.reaction_actor[rid] or 0) - 50)
-- Call for help if we become hostile
for i = 1, #self.fov.actors_dist do
local act = self.fov.actors_dist[i]
if act and self:reactionToward(act) > 0 and not act.dead then
if not act.reaction_actor then act.reaction_actor = {} end
act.reaction_actor[rid] = math.min(act.reaction_actor[rid] or 0, self.reaction_actor[rid])
end
end
end
return mod.class.Actor.onTakeHit(self, value, src)
......@@ -100,6 +110,21 @@ function _M:die(src)
Faction:setFactionReaction(self.faction, src.faction, Faction:factionReaction(self.faction, src.faction) - self.rank, true)
end
-- Get angry if attacked by a friend
if src.resolveSource and src.faction and self:reactionToward(src) >= 0 then
local rsrc = src:resolveSource()
local rid = rsrc.unique or rsrc.name
-- Call for help if we become hostile
for i = 1, #self.fov.actors_dist do
local act = self.fov.actors_dist[i]
if act and self:reactionToward(act) > 0 and not act.dead then
if not act.reaction_actor then act.reaction_actor = {} end
act.reaction_actor[rid] = math.min(act.reaction_actor[rid] or 0, -101)
end
end
end
-- Self resurrect, mouhaha!
if self:attr("self_resurrect") then
self:attr("self_resurrect", -1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment