Skip to content
Snippets Groups Projects
Commit 14bb43c7 authored by Hachem_Muche's avatar Hachem_Muche
Browse files

Merge branch 'master' into Randart_Randboss_Updates

parents 84d46920 62b4637b
No related branches found
No related tags found
No related merge requests found
......@@ -381,6 +381,11 @@ function _M:unregisterDialog(d)
if last.on_recover_focus then last:on_recover_focus() end
end
--- Do we have a specific dialog
function _M:hasDialog(d)
return self.dialogs[d] and true or false
end
--- Do we have a dialog running
function _M:hasDialogUp(nb)
nb = nb or 0
......
......@@ -859,4 +859,36 @@ function _M:talentCallbackOn(on, ...)
self:callTalent(tid, on, ...)
end
end
end
\ No newline at end of file
end
local dialog_returns_list = setmetatable({}, {__mode="v"})
local dialog_returns = setmetatable({}, {__mode="k"})
--- Set the result for a talent dialog
function _M:talentDialogReturn(...)
local d = dialog_returns_list[#dialog_returns_list]
if not d then return end
dialog_returns[d] = {...}
end
--- Get the dialog
function _M:talentDialogGet()
return dialog_returns_list[#dialog_returns_list]
end
--- Show a dialog and wait for it to end in a talent
function _M:talentDialog(d)
if not game:hasDialog(d) then game:registerDialog(d) end
dialog_returns_list[#dialog_returns_list+1] = d
local co = coroutine.running()
d.unload = function(self) coroutine.resume(co, dialog_returns[d]) end
local ret = coroutine.yield()
dialog_returns[d] = nil
table.removeFromList(dialog_returns_list, d)
return unpack(ret)
end
......@@ -1549,7 +1549,7 @@ end
function _M:displayParty(scale, bx, by)
if game.player.changed and next(self.party) then
for a, d in pairs(self.party) do if not game.party:hasMember(a) then game.mouse:unregisterZone(d[2]) print("==UNREG part ", d[1].name, d[2]) end end
for a, d in pairs(self.party) do if not game.party:hasMember(a) then game.mouse:unregisterZone(d[2]) end end
self.party = {}
end
......
......@@ -124,13 +124,9 @@ newTalent{
return tostring(math.ceil(val)), fnt
end,
activate = function(self, t)
local d = require("mod.dialogs.talents.ChronomancyContingency").new(self)
game:registerDialog(d)
local co = coroutine.running()
d.unload = function() coroutine.resume(co, d.contingecy_talent) end
if not coroutine.yield() then return nil end
local talent = d.contingecy_talent
local talent = self:talentDialog(require("mod.dialogs.talents.ChronomancyContingency").new(self))
if not talent then return nil end
return {
talent = talent, rest_count = 0
}
......
......@@ -378,22 +378,10 @@ newTalent{
if game.level.map(x, y, Map.ACTOR) or game.level.map:checkEntity(x, y, game.level.map.TERRAIN, "block_move") then return nil end
-- select the item
local d = self:showInventory("Which weapon will be your sentry?", inven,
function(o)
return o.type == "weapon"
end, nil)
d.action = function(o, item)
d.used_talent = true
d.selected_object = o
d.selected_item = item
return false
end
local co = coroutine.running()
d.unload = function(self) coroutine.resume(co, self.used_talent, self.selected_object, d.selected_item) end
local used_talent, o, item = coroutine.yield()
if not used_talent then return nil end
local d = self:showInventory("Which weapon will be your sentry?", inven, function(o) return o.type == "weapon" end, nil)
d.action = function(o, item) self:talentDialogReturn(true, o, item) return false end
local ret, o, item = self:talentDialog(d)
if not ret then return nil end
local result = self:removeObject(inven, item)
......
......@@ -101,7 +101,7 @@ newTalent{
return math.floor(self:combatTalentMindDamage(t, 2, 10))
end,
action = function(self, t)
local d d = self:showInventory("Reshape which weapon or armor?", self:getInven("INVEN"),
local ret = self:talentDialog(self:showInventory("Reshape which weapon or armor?", self:getInven("INVEN"),
function(o)
return not o.quest and (o.type == "weapon" and o.subtype ~= "mindstar") or (o.type == "armor" and (o.slot == "BODY" or o.slot == "OFFHAND" )) and not o.fully_reshaped --Exclude fully reshaped?
end
......@@ -125,7 +125,7 @@ newTalent{
game.logPlayer(self, "You reshape your %s.", o:getName{do_colour=true, no_count=true})
o.special = true
o.been_reshaped = "reshaped("..tostring(atk_boost)..","..tostring(dam_boost)..") "
d.used_talent = true
self:talentDialogReturn(true)
else
game.logPlayer(self, "You cannot reshape your %s any further.", o:getName{do_colour=true, no_count=true})
end
......@@ -152,15 +152,13 @@ newTalent{
o.special = true
if o.orig_name then o.name = o.orig_name end --Fix name for items affected by older versions of this talent
o.been_reshaped = "reshaped["..tostring(armour)..","..tostring(o.wielder.fatigue-o.orig_fat).."%] "
d.used_talent = true
self:talentDialogReturn(true)
else
game.logPlayer(self, "You cannot reshape your %s any further.", o:getName{do_colour=true, no_count=true})
end
end
end)
local co = coroutine.running()
d.unload = function(self) coroutine.resume(co, self.used_talent) end
if not coroutine.yield() then return nil end
end))
if not ret then return nil end
return true
end,
info = function(self, t)
......@@ -186,18 +184,15 @@ newTalent{
return self:combatTalentMindDamage(t, 10, 40)
end,
action = function(self, t)
local d d = self:showInventory("Use which gem?", self:getInven("INVEN"), function(gem) return gem.type == "gem" and gem.material_level and not gem.unique end, function(gem, gem_item)
local ret = self:talentDialog(self:showInventory("Use which gem?", self:getInven("INVEN"), function(gem) return gem.type == "gem" and gem.material_level and not gem.unique end, function(gem, gem_item)
self:removeObject(self:getInven("INVEN"), gem_item)
local amt = t.energy_per_turn(self, t)
local dur = 3 + 2*(gem.material_level or 0)
self:setEffect(self.EFF_PSI_REGEN, dur, {power=amt})
self.changed = true
d.used_talent = true
self:setEffect(self.EFF_CRYSTAL_BUFF, dur, {name=gem.name, effects=gem.wielder})
end)
local co = coroutine.running()
d.unload = function(self) coroutine.resume(co, self.used_talent) end
if not coroutine.yield() then return nil end
self:setEffect(self.EFF_CRYSTAL_BUFF, dur, {name=gem.name, gem=gem.define_as, effects=gem.wielder})
self:talentDialogReturn(true)
end))
if not ret then return nil end
return true
end,
info = function(self, t)
......
......@@ -28,7 +28,7 @@ newTalent{
no_npc_use = true,
action = function(self, t)
local inven = self:getInven("INVEN")
local d d = self:showInventory("Telekinetically grasp which item?", inven, function(o)
local ret = self:talentDialog(self:showInventory("Telekinetically grasp which item?", inven, function(o)
return (o.type == "weapon" or o.type == "gem") and o.subtype ~= "sling"
end, function(o, item)
local pf = self:getInven("PSIONIC_FOCUS")
......@@ -71,11 +71,9 @@ newTalent{
game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName{do_color=true})
self:sortInven()
d.used_talent = true
end)
local co = coroutine.running()
d.unload = function(self) coroutine.resume(co, self.used_talent) end
if not coroutine.yield() then return nil end
self:talentDialogReturn(true)
end))
if not ret then return nil end
return true
end,
info = function(self, t)
......
......@@ -40,7 +40,7 @@ newTalent{
return gem
end,
action = function(self, t)
local d d = self:showEquipInven("Use which gem?", function(o) return not o.unique and o.type == "gem" and not o.__tagged end, function(o, inven, item)
local ret = self:talentDialog(self:showEquipInven("Use which gem?", function(o) return not o.unique and o.type == "gem" and not o.__tagged end, function(o, inven, item)
if not o then return end
local gem = t.make_gem(self, t, o.define_as)
if not gem then return end
......@@ -48,12 +48,10 @@ newTalent{
self:removeObject(inven, item)
game.logPlayer(self, "You create: %s", gem:getName{do_color=true, do_count=true})
self:sortInven()
d.used_talent = true
self:talentDialogReturn(true)
return true
end)
local co = coroutine.running()
d.unload = function(self) coroutine.resume(co, self.used_talent) end
if not coroutine.yield() then return nil end
end))
if not ret then return nil end
game:playSoundNear(self, "talents/arcane")
return true
......@@ -95,15 +93,12 @@ newTalent{
self:addObject(self.INVEN_INVEN, gem)
game.logPlayer(self, "You extract %s from %s", gem:getName{do_color=true, do_count=true}, o:getName{do_color=true, do_count=true})
self:sortInven()
if d then d.used_talent = true end
self:talentDialogReturn(true)
end
return true
end,
action = function(self, t)
local d d = self:showEquipInven("Try to extract gems from which metallic item?", function(o) return t.filterGem(self, t, o) end, function(o, inven, item) return t.extractGem(self, t, o, inven, item, d) end)
local co = coroutine.running()
d.unload = function(self) coroutine.resume(co, self.used_talent) end
if not coroutine.yield() then return nil end
if not self:talentDialog(self:showEquipInven("Try to extract gems from which metallic item?", function(o) return t.filterGem(self, t, o) end, function(o, inven, item) return t.extractGem(self, t, o, inven, item, d) end)) then return nil end
return true
end,
info = function(self, t)
......@@ -128,7 +123,7 @@ newTalent{
no_npc_use = true,
no_unlearn_last = true,
action = function(self, t)
local d d = self:showInventory("Use which gem?", self:getInven("INVEN"), function(gem) return gem.type == "gem" and gem.imbue_powers and gem.material_level and gem.material_level <= self:getTalentLevelRaw(t) end, function(gem, gem_item)
local ret = self:talentDialog(self:showInventory("Use which gem?", self:getInven("INVEN"), function(gem) return gem.type == "gem" and gem.imbue_powers and gem.material_level and gem.material_level <= self:getTalentLevelRaw(t) end, function(gem, gem_item)
local nd = self:showInventory("Imbue which armour?", self:getInven("INVEN"), function(o) return o.type == "armor" and (o.slot == "BODY" or (self:knowTalent(self.T_CRAFTY_HANDS) and (o.slot == "HEAD" or o.slot == "BELT"))) and not o.been_imbued end, function(o, item)
self:removeObject(self:getInven("INVEN"), gem_item)
o.wielder = o.wielder or {}
......@@ -140,15 +135,13 @@ newTalent{
o.been_imbued = " <"..gem.name..">"
game.logPlayer(self, "You imbue your %s with %s.", o:getName{do_colour=true, no_count=true}, gem:getName{do_colour=true, no_count=true})
o.special = true
d.used_talent = true
game:unregisterDialog(d)
self:talentDialogReturn(true)
game:unregisterDialog(self:talentDialogGet())
end)
nd.unload = function(self) game:unregisterDialog(d) end
nd.unload = function(_) game:unregisterDialog(self:talentDialogGet()) end
return true
end)
local co = coroutine.running()
d.unload = function(self) coroutine.resume(co, self.used_talent) end
if not coroutine.yield() then return nil end
end))
if not ret then return nil end
return true
end,
info = function(self, t)
......
......@@ -83,7 +83,7 @@ end
function _M:use(item)
if not item or not item.talent then return end
self.contingecy_talent = item.talent
self.actor:talentDialogReturn(item.talent)
game:unregisterDialog(self)
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