Skip to content
Snippets Groups Projects
Commit 9a3fc60c authored by DarkGod's avatar DarkGod
Browse files

fixed some staticmaps loading bugs

parent 14dd595d
No related branches found
No related tags found
No related merge requests found
...@@ -393,7 +393,7 @@ function _M:tmxLoad(file) ...@@ -393,7 +393,7 @@ function _M:tmxLoad(file)
--print("=== found attrs", k, v, "at", i, j, "with rotate:", rotate) --print("=== found attrs", k, v, "at", i, j, "with rotate:", rotate)
local i, j = rotate_coords(i + 1, j + 1) local i, j = rotate_coords(i + 1, j + 1)
i, j = i - 1, j - 1 i, j = i - 1, j - 1
self.add_attrs_later[#self.add_attrs_later+1] = {x=i, y=j, key=k, value=self:loadLuaInEnv(g, nil, "return "..v)} self.add_attrs_later[#self.add_attrs_later+1] = {x=self.data.__import_offset_x+i, y=self.data.__import_offset_y+j, key=k, value=self:loadLuaInEnv(g, nil, "return "..v)}
-- print("====", i, j, k) -- print("====", i, j, k)
end end end end
end end
...@@ -404,7 +404,7 @@ function _M:tmxLoad(file) ...@@ -404,7 +404,7 @@ function _M:tmxLoad(file)
for i = x, x + w do for j = y, y + h do for i = x, x + w do for j = y, y + h do
local i, j = rotate_coords(i, j) local i, j = rotate_coords(i, j)
t[fakeid] = props.id t[fakeid] = props.id
populate(i+1, j+1, {[layername] = fakeid}, fakeid) populate(self.data.__import_offset_x+i+1, self.data.__import_offset_y+j+1, {[layername] = fakeid}, fakeid)
fakeid = fakeid - 1 fakeid = fakeid - 1
end end end end
end end
......
...@@ -728,6 +728,30 @@ group_meta = { ...@@ -728,6 +728,30 @@ group_meta = {
if nb == what then if nb == what then
return jn return jn
end end
elseif mode == "most" then
local list, least = {}, nil
for j = 1, #group.list do
local jn = group.list[j]
if what == "north" then
if not least or jn.y < least then least = jn.y end
elseif what == "south" then
if not least or jn.y > least then least = jn.y end
elseif what == "west" then
if not least or jn.x < least then least = jn.x end
elseif what == "east" then
if not least or jn.x > least then least = jn.x end
end
end
for j = 1, #group.list do
local jn = group.list[j]
if what == "north" or what == "south" then
if jn.y == least then list[#list+1] = jn end
elseif what == "west" or what == "east" then
if jn.x == least then list[#list+1] = jn end
end
end
if #list == 0 then return nil end
return rng.table(list)
end end
end end
return nil return nil
......
...@@ -21,8 +21,9 @@ require "engine.class" ...@@ -21,8 +21,9 @@ require "engine.class"
require "mod.class.NPC" require "mod.class.NPC"
require "mod.class.interface.PartyDeath" require "mod.class.interface.PartyDeath"
require "engine.interface.PlayerHotkeys" require "engine.interface.PlayerHotkeys"
require "mod.class.interface.PlayerQuestPopup"
module(..., package.seeall, class.inherit(mod.class.NPC, mod.class.interface.PartyDeath, engine.interface.PlayerHotkeys)) module(..., package.seeall, class.inherit(mod.class.NPC, mod.class.interface.PartyDeath, engine.interface.PlayerHotkeys, mod.class.interface.PlayerQuestPopup))
function _M:init(t, no_default) function _M:init(t, no_default)
mod.class.NPC.init(self, t, no_default) mod.class.NPC.init(self, t, no_default)
......
...@@ -28,6 +28,7 @@ require "mod.class.interface.PlayerStats" ...@@ -28,6 +28,7 @@ require "mod.class.interface.PlayerStats"
require "mod.class.interface.PlayerDumpJSON" require "mod.class.interface.PlayerDumpJSON"
require "mod.class.interface.PlayerExplore" require "mod.class.interface.PlayerExplore"
require "mod.class.interface.PartyDeath" require "mod.class.interface.PartyDeath"
require "mod.class.interface.PlayerQuestPopup"
local Map = require "engine.Map" local Map = require "engine.Map"
local Dialog = require "engine.ui.Dialog" local Dialog = require "engine.ui.Dialog"
local ActorTalents = require "engine.interface.ActorTalents" local ActorTalents = require "engine.interface.ActorTalents"
...@@ -45,6 +46,7 @@ module(..., package.seeall, class.inherit( ...@@ -45,6 +46,7 @@ module(..., package.seeall, class.inherit(
mod.class.interface.PlayerStats, mod.class.interface.PlayerStats,
mod.class.interface.PlayerDumpJSON, mod.class.interface.PlayerDumpJSON,
mod.class.interface.PlayerExplore, mod.class.interface.PlayerExplore,
mod.class.interface.PlayerQuestPopup,
mod.class.interface.PartyDeath mod.class.interface.PartyDeath
)) ))
...@@ -1682,65 +1684,6 @@ function _M:on_targeted(act) ...@@ -1682,65 +1684,6 @@ function _M:on_targeted(act)
end end
end end
------ Quest Events
local quest_popups = {}
local function tick_end_quests()
local QuestPopup = require "mod.dialogs.QuestPopup"
local list = {}
for quest_id, status in pairs(quest_popups) do
list[#list+1] = { id=quest_id, status=status }
end
quest_popups = {}
table.sort(list, function(a, b) return a.status > b.status end)
local lastd = nil
for _, q in ipairs(list) do
local quest = game.player:hasQuest(q.id)
local d = QuestPopup.new(quest, q.status)
if lastd then
lastd.unload = function(self) game:registerDialog(d) end
else
game:registerDialog(d)
end
lastd = d
end
end
function _M:questPopup(quest, status)
if game and game.creating_player then return end
if not quest_popups[quest.id] or quest_popups[quest.id] < status then
quest_popups[quest.id] = status
if not game:onTickEndGet("quest_popups") then game:onTickEnd(tick_end_quests, "quest_popups") end
end
end
function _M:on_quest_grant(quest)
game.logPlayer(game.player, "#LIGHT_GREEN#Accepted quest '%s'! #WHITE#(Press 'j' to see the quest log)", quest.name)
if not config.settings.tome.quest_popup then game.bignews:saySimple(60, "#LIGHT_GREEN#Accepted quest '%s'!", quest.name)
else self:questPopup(quest, -1) end
end
function _M:on_quest_status(quest, status, sub)
if sub then
game.logPlayer(game.player, "#LIGHT_GREEN#Quest '%s' status updated! #WHITE#(Press 'j' to see the quest log)", quest.name)
if not config.settings.tome.quest_popup then game.bignews:saySimple(60, "#LIGHT_GREEN#Quest '%s' updated!", quest.name)
else self:questPopup(quest, engine.Quest.PENDING) end
elseif status == engine.Quest.COMPLETED then
game.logPlayer(game.player, "#LIGHT_GREEN#Quest '%s' completed! #WHITE#(Press 'j' to see the quest log)", quest.name)
if not config.settings.tome.quest_popup then game.bignews:saySimple(60, "#LIGHT_GREEN#Quest '%s' completed!", quest.name)
else self:questPopup(quest, status) end
elseif status == engine.Quest.DONE then
game.logPlayer(game.player, "#LIGHT_GREEN#Quest '%s' is done! #WHITE#(Press 'j' to see the quest log)", quest.name)
if not config.settings.tome.quest_popup then game.bignews:saySimple(60, "#LIGHT_GREEN#Quest '%s' done!", quest.name)
else self:questPopup(quest, status) end
elseif status == engine.Quest.FAILED then
game.logPlayer(game.player, "#LIGHT_RED#Quest '%s' is failed! #WHITE#(Press 'j' to see the quest log)", quest.name)
if not config.settings.tome.quest_popup then game.bignews:saySimple(60, "#LIGHT_RED#Quest '%s' failed!", quest.name)
else self:questPopup(quest, status) end
end
end
function _M:attackOrMoveDir(dir) function _M:attackOrMoveDir(dir)
local game_or_player = not config.settings.tome.actor_based_movement_mode and game or self local game_or_player = not config.settings.tome.actor_based_movement_mode and game or self
local tmp = game_or_player.bump_attack_disabled local tmp = game_or_player.bump_attack_disabled
......
-- TE4 - T-Engine 4
-- Copyright (C) 2009 - 2019 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
--- Handles actors quests
module(..., package.seeall, class.make)
------ Quest Events
local quest_popups = {}
local function tick_end_quests()
local QuestPopup = require "mod.dialogs.QuestPopup"
local list = {}
for quest_id, status in pairs(quest_popups) do
list[#list+1] = { id=quest_id, status=status }
end
quest_popups = {}
table.sort(list, function(a, b) return a.status > b.status end)
local lastd = nil
for _, q in ipairs(list) do
local quest = game.player:hasQuest(q.id)
local d = QuestPopup.new(quest, q.status)
if lastd then
lastd.unload = function(self) game:registerDialog(d) end
else
game:registerDialog(d)
end
lastd = d
end
end
function _M:questPopup(quest, status)
if game and game.creating_player then return end
if not quest_popups[quest.id] or quest_popups[quest.id] < status then
quest_popups[quest.id] = status
if not game:onTickEndGet("quest_popups") then game:onTickEnd(tick_end_quests, "quest_popups") end
end
end
function _M:on_quest_grant(quest)
game.logPlayer(game.player, "#LIGHT_GREEN#Accepted quest '%s'! #WHITE#(Press 'j' to see the quest log)", quest.name)
if not config.settings.tome.quest_popup then game.bignews:saySimple(60, "#LIGHT_GREEN#Accepted quest '%s'!", quest.name)
else self:questPopup(quest, -1) end
end
function _M:on_quest_status(quest, status, sub)
if sub then
game.logPlayer(game.player, "#LIGHT_GREEN#Quest '%s' status updated! #WHITE#(Press 'j' to see the quest log)", quest.name)
if not config.settings.tome.quest_popup then game.bignews:saySimple(60, "#LIGHT_GREEN#Quest '%s' updated!", quest.name)
else self:questPopup(quest, engine.Quest.PENDING) end
elseif status == engine.Quest.COMPLETED then
game.logPlayer(game.player, "#LIGHT_GREEN#Quest '%s' completed! #WHITE#(Press 'j' to see the quest log)", quest.name)
if not config.settings.tome.quest_popup then game.bignews:saySimple(60, "#LIGHT_GREEN#Quest '%s' completed!", quest.name)
else self:questPopup(quest, status) end
elseif status == engine.Quest.DONE then
game.logPlayer(game.player, "#LIGHT_GREEN#Quest '%s' is done! #WHITE#(Press 'j' to see the quest log)", quest.name)
if not config.settings.tome.quest_popup then game.bignews:saySimple(60, "#LIGHT_GREEN#Quest '%s' done!", quest.name)
else self:questPopup(quest, status) end
elseif status == engine.Quest.FAILED then
game.logPlayer(game.player, "#LIGHT_RED#Quest '%s' is failed! #WHITE#(Press 'j' to see the quest log)", quest.name)
if not config.settings.tome.quest_popup then game.bignews:saySimple(60, "#LIGHT_RED#Quest '%s' failed!", quest.name)
else self:questPopup(quest, status) end
end
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