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

Mouse running will try very hard to avoid traps but if there is no way out but...

Mouse running will try very hard to avoid traps but if there is no way out but a trap it will walk through it


git-svn-id: http://svn.net-core.org/repos/t-engine4@3518 51575b47-30f0-44d4-a5cc-537603b46e54
parent d3d13b13
No related branches found
No related tags found
No related merge requests found
...@@ -59,20 +59,23 @@ function _M:mouseMove(tmx, tmy, spotHostiles, astar_check, force_move) ...@@ -59,20 +59,23 @@ function _M:mouseMove(tmx, tmy, spotHostiles, astar_check, force_move)
if config.settings.mouse_move or force_move then if config.settings.mouse_move or force_move then
local a = Astar.new(game.level.map, self) local a = Astar.new(game.level.map, self)
local recheck = false
if type(astar_check) == "table" then recheck = astar_check.recheck astar_check = astar_check.astar_check end
local path = a:calc(self.x, self.y, tmx, tmy, true, nil, astar_check) local path = a:calc(self.x, self.y, tmx, tmy, true, nil, astar_check)
if recheck and not path then path = a:calc(self.x, self.y, tmx, tmy, true, nil, nil) end
-- No Astar path ? just be dumb and try direct line -- No Astar path ? just be dumb and try direct line
if not path then if not path then
local d = DirectPath.new(game.level.map, self) local d = DirectPath.new(game.level.map, self)
path = d:calc(self.x, self.y, tmx, tmy, true) path = d:calc(self.x, self.y, tmx, tmy, true)
end end
if path then if path then
-- Should we just try to move in the direction, aka: attack! -- Should we just try to move in the direction, aka: attack!
if path[1] and game.level.map:checkAllEntities(path[1].x, path[1].y, "block_move", self) then self:move(path[1].x, path[1].y) return end if path[1] and game.level.map:checkAllEntities(path[1].x, path[1].y, "block_move", self) then self:move(path[1].x, path[1].y) return end
-- Insert the player coords, running needs to find the player -- Insert the player coords, running needs to find the player
table.insert(path, 1, {x=self.x, y=self.y}) table.insert(path, 1, {x=self.x, y=self.y})
-- Move along the projected A* path -- Move along the projected A* path
self:runFollow(path) self:runFollow(path)
end end
......
...@@ -579,7 +579,7 @@ function _M:mouseMove(tmx, tmy, force_move) ...@@ -579,7 +579,7 @@ function _M:mouseMove(tmx, tmy, force_move)
if trap and trap:knownBy(self) and trap:canTrigger(x, y, self, true) then return false end if trap and trap:knownBy(self) and trap:canTrigger(x, y, self, true) then return false end
return true return true
end end
return engine.interface.PlayerMouse.mouseMove(self, tmx, tmy, spotHostiles, astar_check, force_move) return engine.interface.PlayerMouse.mouseMove(self, tmx, tmy, spotHostiles, {recheck=true, astar_check=astar_check}, force_move)
end end
--- Called after running a step --- Called after running a step
......
...@@ -187,9 +187,9 @@ But meanwhile, this is your place! Welcome to paradise, @playerdescriptor.race@! ...@@ -187,9 +187,9 @@ But meanwhile, this is your place! Welcome to paradise, @playerdescriptor.race@!
#YELLOW#Next time you play, you shall battle this new champion instead! #YELLOW#Next time you play, you shall battle this new champion instead!
]], ]],
answers = { answers = {
{"WEALTH!! AND!! GLORYYYYY!!"}, {"WEALTH!! AND!! GLORYYYYY!!", action=function(npc, player) player:hasQuest("arena"):win() end},
{"I won't need to save chicks from cults anymore!", cond=function(npc, player) if player.female == true then return false else return true end end }, {"I won't need to save chicks from cults anymore!", cond=function(npc, player) if player.female == true then return false else return true end end, action=function(npc, player) player:hasQuest("arena"):win() end},
{"I hereby stand victorious, awaiting future challenges!"}, {"I hereby stand victorious, awaiting future challenges!", action=function(npc, player) player:hasQuest("arena"):win() end},
{"#LIGHT_GREEN#*dance*"}, {"#LIGHT_GREEN#*dance*", action=function(npc, player) player:hasQuest("arena"):win() end},
} }
} }
...@@ -24,3 +24,20 @@ desc = function(self, who) ...@@ -24,3 +24,20 @@ desc = function(self, who)
desc[#desc+1] = "Can you defeat your foes and become Master of Arena?" desc[#desc+1] = "Can you defeat your foes and become Master of Arena?"
return table.concat(desc, "\n") return table.concat(desc, "\n")
end end
function win(self)
game:playMusic("Lords of the Sky.ogg")
game.player.winner = "arena"
game:registerDialog(require("engine.dialogs.ShowText").new("Winner", "win", {playername=game.player.name, how="arena"}, game.w * 0.6))
end
function onWin(self, who)
local desc = {}
desc[#desc+1] = "#GOLD#Well done! You have won the Arena: Challenge of the Master#WHITE#"
desc[#desc+1] = ""
desc[#desc+1] = "You valiantly fought every creature the arena could throw on you and you emerged victorious!"
desc[#desc+1] = "Glory to you, you are now the new master and your future characters will challenge you."
return 0, desc
end
...@@ -203,7 +203,7 @@ return { ...@@ -203,7 +203,7 @@ return {
game.player:setQuestStatus("arena", engine.Quest.COMPLETED) game.player:setQuestStatus("arena", engine.Quest.COMPLETED)
local master = game.player:cloneFull() local master = game.player:cloneFull()
game.level.arena.rank = -1 game.level.arena.rank = -1
game.player:die(game.player) -- game.player:die(game.player)
master.version = game.__mod_info.version master.version = game.__mod_info.version
master.no_drops = true master.no_drops = true
master.energy.value = 0 master.energy.value = 0
...@@ -234,7 +234,7 @@ return { ...@@ -234,7 +234,7 @@ return {
end, end,
printRankings = function (val) printRankings = function (val)
local scores = world.arena.scores local scores = world.arena.scores
if not scores[1].name then return "#LIGHT_GREEN#...but it's been wiped out recently." if not scores or not scores[1] or not scores[1].name then return "#LIGHT_GREEN#...but it's been wiped out recently."
else else
local text = "" local text = ""
local tmp = "" local tmp = ""
......
...@@ -102,6 +102,7 @@ It should automatically create a portal back, but it might not be near your arri ...@@ -102,6 +102,7 @@ It should automatically create a portal back, but it might not be near your arri
boss.on_die = function(self, ...) boss.on_die = function(self, ...)
local x, y = self.x or game.player.x, self.y or game.player.y local x, y = self.x or game.player.x, self.y or game.player.y
local g = game.zone:makeEntityByName(game.level, "terrain", game.zone.basic_floor) local g = game.zone:makeEntityByName(game.level, "terrain", game.zone.basic_floor)
g.nice_tiler = nil
g.show_tooltip = true g.show_tooltip = true
g.name = "Exploratory Farportal exit" g.name = "Exploratory Farportal exit"
g.display = '&' g.color_r = colors.VIOLET.r g.color_g = colors.VIOLET.g g.color_b = colors.VIOLET.b g.display = '&' g.color_r = colors.VIOLET.r g.color_g = colors.VIOLET.g g.color_b = colors.VIOLET.b
......
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