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

most talents now warn the player when self-targetting

git-svn-id: http://svn.net-core.org/repos/t-engine4@706 51575b47-30f0-44d4-a5cc-537603b46e54
parent 2210d4fa
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,8 @@ function _M:project(t, x, y, damtype, dam, particles)
return
end
if type(particles) ~= "table" then particles = nil end
if type(dam) == "number" and dam < 0 then return end
local typ = Target:getType(t)
......
......@@ -53,6 +53,7 @@ local FlyingText = require "engine.FlyingText"
local Tooltip = require "engine.Tooltip"
local Calendar = require "engine.Calendar"
local Dialog = require "engine.Dialog"
local QuitDialog = require "mod.dialogs.Quit"
module(..., package.seeall, class.inherit(engine.GameTurnBased, engine.interface.GameMusic, engine.interface.GameSound))
......@@ -425,13 +426,26 @@ function _M:targetMode(v, msg, co, typ)
self.target:setActive(false)
if tostring(old) == "exclusive" then
self.key = self.normal_key
self.key:setCurrent()
if self.target_co then
local co = self.target_co
self.target_co = nil
local ok, err = coroutine.resume(co, self.target.target.x, self.target.target.y, self.target.target.entity)
if not ok and err then print(debug.traceback(co)) error(err) end
local fct = function(ok)
if not ok then
self.target.target.entity = nil
self.target.target.x = nil
self.target.target.y = nil
end
self.key = self.normal_key
self.key:setCurrent()
if self.target_co then
local co = self.target_co
self.target_co = nil
local ok, err = coroutine.resume(co, self.target.target.x, self.target.target.y, self.target.target.entity)
if not ok and err then print(debug.traceback(co)) error(err) end
end
end
if self.target_warning and self.target.target.x == game.player.x and self.target.target.y == game.player.y then
Dialog:yesnoPopup("Target yourself?", "Are you sure you want to target yourself?", fct)
else
fct(true)
end
end
else
......@@ -440,6 +454,7 @@ function _M:targetMode(v, msg, co, typ)
self.level.map.changed = true
self.target:setActive(true, typ)
self.target_style = "lock"
self.target_warning = true
-- Exclusive mode means we disable the current key handler and use a specific one
-- that only allows targetting and resumes talent coroutine when done
......@@ -453,7 +468,9 @@ function _M:targetMode(v, msg, co, typ)
self.target:scan(5, nil, self.player.x, self.player.y)
end
end
self.tooltip_x, self.tooltip_y = self.level.map:getTileToScreen(self.target.target.x, self.target.target.y)
if self.target.target.x then
self.tooltip_x, self.tooltip_y = self.level.map:getTileToScreen(self.target.target.x, self.target.target.y)
end
end
end
......
......@@ -268,9 +268,8 @@ function _M:getTarget(typ)
msg = typ.msg
end
game:targetMode("exclusive", msg, coroutine.running(), typ)
if typ.nolock then
game.target_style = "free"
end
if typ.nolock then game.target_style = "free" end
if typ.nowarning then game.target_warning = false end
return coroutine.yield()
end
return game.target.target.x, game.target.target.y, game.target.target.entity
......
......@@ -127,7 +127,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......@@ -192,7 +192,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......@@ -259,7 +259,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......@@ -327,7 +327,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......
......@@ -28,7 +28,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......@@ -88,7 +88,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......@@ -151,7 +151,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......@@ -220,7 +220,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......
......@@ -133,7 +133,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......@@ -197,7 +197,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......@@ -262,7 +262,7 @@ newTalent{
range = 20,
action = function(self, t)
if checkMaxSummon(self) then return end
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
local tx, ty, target = self:getTarget(tg)
if not tx or not ty then return nil end
local _ _, tx, ty = self:canProject(tg, tx, ty)
......
......@@ -34,7 +34,7 @@ newTalent{
if self:getTalentLevel(t) >= 3 then tg.type = "beam" end
local x, y = self:getTarget(tg)
if not x or not y then return nil end
self:project(tg, x, y, DamageType.ARCANE, self:spellCrit(20 + self:combatSpellpower(0.5) * self:getTalentLevel(t)))
self:project(tg, x, y, DamageType.ARCANE, self:spellCrit(20 + self:combatSpellpower(0.5) * self:getTalentLevel(t)), nil)
local _ _, x, y = self:canProject(tg, x, y)
if tg.type == "beam" then
game.level.map:particleEmitter(self.x, self.y, math.max(math.abs(x-self.x), math.abs(y-self.y)), "mana_beam", {tx=x-self.x, ty=y-self.y})
......
......@@ -30,7 +30,7 @@ newTalent{
action = function(self, t)
local target = self
if self:getTalentLevel(t) >= 5 then
local tx, ty = self:getTarget{type="hit", range=10}
local tx, ty = self:getTarget{default_target=self, type="hit", nowarning=true, range=10}
if tx and ty then
target = game.level.map(tx, ty, Map.ACTOR) or self
end
......@@ -38,7 +38,7 @@ newTalent{
local x, y = self.x, self.y
if self:getTalentLevel(t) >= 4 then
local tg = {type="ball", nolock=true, no_restrict=true, range=10 + self:combatSpellpower(0.1), radius=7 - self:getTalentLevel(t)}
local tg = {type="ball", nolock=true, no_restrict=true, nowarning=true, range=10 + self:combatSpellpower(0.1), radius=7 - self:getTalentLevel(t)}
x, y = self:getTarget(tg)
if not x then return nil end
-- Target code doesnot restrict the target coordinates to the range, it lets the poject function do it
......@@ -77,7 +77,7 @@ newTalent{
local target = self
if self:getTalentLevel(t) >= 5 then
local tx, ty = self:getTarget{default_target=self, type="hit", range=10}
local tx, ty = self:getTarget{default_target=self, nowarning=true, type="hit", range=10}
if tx and ty then
target = game.level.map(tx, ty, Map.ACTOR) or self
end
......@@ -85,7 +85,7 @@ newTalent{
local x, y = self.x, self.y
if self:getTalentLevel(t) >= 4 then
local tg = {type="ball", nolock=true, no_restrict=true, range=100 + self:combatSpellpower(1), radius=20 - self:getTalentLevel(t)}
local tg = {type="ball", nolock=true, no_restrict=true, nowarning=true, range=100 + self:combatSpellpower(1), radius=20 - self:getTalentLevel(t)}
x, y = self:getTarget(tg)
if not x then return nil end
-- Target code doesnot restrict the target coordinates to the range, it lets the poject function do it
......
......@@ -110,7 +110,7 @@ newTalent{
action = function(self, t)
local x, y = self.x, self.y
if self:getTalentLevel(t) >= 4 then
local tg = {type="bolt", range=self:getTalentRange(t), nolock=true, talent=t}
local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
x, y = self:getTarget(tg)
if not x or not y then return nil end
end
......
No preview for this file type
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