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

Prevent color bleeding in talent requirements

Townfolk now can have random chatter when backup guardians are up


git-svn-id: http://svn.net-core.org/repos/t-engine4@3047 51575b47-30f0-44d4-a5cc-537603b46e54
parent a44d20ac
No related branches found
No related tags found
No related merge requests found
......@@ -367,7 +367,7 @@ function _M:getTalentReqDesc(t_id, levmod)
if t.type[2] and t.type[2] > 1 then
local known = self:numberKnownTalent(t.type[1], t.id)
local c = (known >= t.type[2] - 1) and {"color", 0x00,0xff,0x00} or {"color", 0xff,0x00,0x00}
str:add("- ", c, ("Talents of the same category: %d"):format(t.type[2] - 1), true)
str:add(c, ("- Talents of the same category: %d"):format(t.type[2] - 1), true)
end
-- Obviously this requires the ActorStats interface
......@@ -375,27 +375,27 @@ function _M:getTalentReqDesc(t_id, levmod)
for s, v in pairs(req.stat) do
v = util.getval(v, tlev)
local c = (self:getStat(s) >= v) and {"color", 0x00,0xff,0x00} or {"color", 0xff,0x00,0x00}
str:add("- ", c, ("%s %d"):format(self.stats_def[s].name, v), true)
str:add(c, ("- %s %d"):format(self.stats_def[s].name, v), true)
end
end
if req.level then
local v = util.getval(req.level, tlev)
local c = (self.level >= v) and {"color", 0x00,0xff,0x00} or {"color", 0xff,0x00,0x00}
str:add("- ", c, ("Level %d\n"):format(v), true)
str:add(c, ("- Level %d\n"):format(v), true)
end
if req.talent then
for _, tid in ipairs(req.talent) do
if type(tid) == "table" then
if type(tid[2]) == "boolean" and tid[2] == false then
local c = (not self:knowTalent(tid[1])) and {"color", 0x00,0xff,0x00} or {"color", 0xff,0x00,0x00}
str:add("- ", c, ("Talent %s (not known)\n"):format(self:getTalentFromId(tid[1]).name), true)
str:add(c, ("- Talent %s (not known)\n"):format(self:getTalentFromId(tid[1]).name), true)
else
local c = (self:getTalentLevelRaw(tid[1]) >= tid[2]) and {"color", 0x00,0xff,0x00} or {"color", 0xff,0x00,0x00}
str:add("- ", c, ("Talent %s (%d)\n"):format(self:getTalentFromId(tid[1]).name, tid[2]), true)
str:add(c, ("- Talent %s (%d)\n"):format(self:getTalentFromId(tid[1]).name, tid[2]), true)
end
else
local c = self:knowTalent(tid) and {"color", 0x00,0xff,0x00} or {"color", 0xff,0x00,0x00}
str:add("- ", c, ("Talent %s\n"):format(self:getTalentFromId(tid).name), true)
str:add(c, ("- Talent %s\n"):format(self:getTalentFromId(tid).name), true)
end
end
end
......
......@@ -85,6 +85,16 @@ function _M:activateBackupGuardian(guardian, on_level, zonelevel, rumor, action)
}
end
--- Get random emote for townpeople based on backup guardians
function _M:getBackupGuardianEmotes(t)
if not self.is_advanced then return t end
for zone, data in pairs(self.allow_backup_guardians) do
print("possible chatter", zone, data.rumor)
t[#t+1] = data.rumor
end
return t
end
--- Activate a backup guardian & settings, if available
function _M:zoneCheckBackupGuardian()
if not self.is_advanced then print("Not gone east, no backup guardian") return end
......
......@@ -46,8 +46,12 @@ function _M:act()
-- If AI did nothing, use energy anyway
self:doAI()
if self.emote_random and rng.percent(self.emote_random.chance) then
self:doEmote(rng.table(self.emote_random))
if self.emote_random and self.x and self.y and game.level.map.seens(self.x, self.y) and rng.range(0, 999) < self.emote_random.chance * 10 then
local e = util.getval(rng.table(self.emote_random))
if e then
local dur = util.bound(#e, 30, 90)
self:doEmote(e, dur)
end
end
if not self.energy.used then self:useEnergy() end
......
......@@ -107,6 +107,8 @@ newEntity{
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, },
energy = { mod=1 },
stats = { str=8, dex=8, mag=16, wil=18, con=10 },
emote_random = resolvers.emote_random{allow_backup_guardian=true},
}
newEntity{ base = "BASE_NPC_ANGOLWEN_TOWN",
......
......@@ -46,6 +46,8 @@ newEntity{
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, },
energy = { mod=1 },
stats = { str=12, dex=8, mag=6, con=10 },
emote_random = resolvers.emote_random{allow_backup_guardian=true},
}
newEntity{ base = "BASE_NPC_DERTH_TOWN",
......
......@@ -46,6 +46,8 @@ newEntity{
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, },
energy = { mod=1 },
stats = { str=12, dex=8, mag=6, con=10 },
emote_random = resolvers.emote_random{allow_backup_guardian=true},
}
newEntity{ base = "BASE_NPC_ELVALA_TOWN",
......
......@@ -47,6 +47,8 @@ newEntity{
ai = "dumb_talented_simple", ai_state = { ai_move="move_dmap", talent_in=3, },
energy = { mod=1 },
stats = { str=12, dex=8, mag=6, con=10 },
emote_random = resolvers.emote_random{allow_backup_guardian=true},
}
newEntity{ base = "BASE_NPC_ELVALA_TOWN",
......
......@@ -512,3 +512,19 @@ function resolvers.calc.racial(t, e)
e._levelup_talents = levelup_talents
return nil
end
function resolvers.emote_random(def)
return {__resolver="emote_random", def}
end
function resolvers.calc.emote_random(t, e)
local def = t[1]
def.chance = def.chance or 0.1
if def.allow_backup_guardian then
def[#def+1] = function()
local t = game.state:getBackupGuardianEmotes{}
return #t > 0 and rng.table(t) or nil
end
end
return def
end
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