diff --git a/game/engine/Target.lua b/game/engine/Target.lua index 9292542d1d33607db6d0c6c196f3ad9d06459dc1..b059fa4b272cdae2e5fc60d71c03bd69382e36de 100644 --- a/game/engine/Target.lua +++ b/game/engine/Target.lua @@ -76,16 +76,17 @@ end function _M:getType(t) if not t or not t.type then return {} end t.range = t.range or 20 + if t.friendlyfire == nil then t.friendlyfire = true end if t.type == "hit" then - return {range=t.range} + return {range=t.range, friendlyfire=t.friendlyfire} elseif t.type == "beam" then - return {range=t.range, line=true} + return {range=t.range, friendlyfire=t.friendlyfire, line=true} elseif t.type == "bolt" then - return {range=t.range, stop_block=true} + return {range=t.range, friendlyfire=t.friendlyfire, stop_block=true} elseif t.type == "ball" then - return {range=t.range, ball=t.radius} + return {range=t.range, friendlyfire=t.friendlyfire, ball=t.radius} elseif t.type == "cone" then - return {range=t.range, cone=t.radius} + return {range=t.range, friendlyfire=t.friendlyfire, cone=t.radius} else return {} end diff --git a/game/engine/interface/ActorLife.lua b/game/engine/interface/ActorLife.lua index 2819328c283c9e0dd8e42de6350ecf4dc869bdf4..063dd7a1a64dffba80086d9de098c64bd8be51c7 100644 --- a/game/engine/interface/ActorLife.lua +++ b/game/engine/interface/ActorLife.lua @@ -90,7 +90,14 @@ function _M:project(t, x, y, damtype, dam) -- Now project on each grid, one type for px, ys in pairs(grids) do for py, _ in pairs(ys) do - DamageType:get(damtype).projector(self, px, py, damtype, dam) + -- Friendly fire ? + if px == self.x and py == self.y then + if t.friendlyfire then + DamageType:get(damtype).projector(self, px, py, damtype, dam) + end + else + DamageType:get(damtype).projector(self, px, py, damtype, dam) + end end end end diff --git a/game/engine/interface/ActorStats.lua b/game/engine/interface/ActorStats.lua index a708260dc38078fce86c805f4d07fd0f0d7d6be8..a0d06bc761b5f45b4c44e6cb7d460aa59e49d799 100644 --- a/game/engine/interface/ActorStats.lua +++ b/game/engine/interface/ActorStats.lua @@ -47,7 +47,11 @@ end -- @param stat the stat id to change -- @param val the increment to add/substract function _M:incStat(stat, val) + local old = self.stats[stat] self.stats[stat] = math.max(math.min(self.stats[stat] + val, _M.stats_def[stat].max), _M.stats_def[stat].min) + if self.stats[stat] - old ~= 0 then + self:onStatChange(stat, self.stats[stat] - old) + end return self.stats[stat] end @@ -58,3 +62,7 @@ end function _M:getStat(stat) return self.stats[stat] end + +--- Notifies a change of stat value +function _M:onStatChange(stat, v) +end diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index c6bf5691d2c2a64dec9eb003656038bd6ffa7778..e357a31962aff2b907ac5c753482d14f7ffe6d0e 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -72,7 +72,15 @@ end function _M:levelup() self.unused_stats = self.unused_stats + 3 self.unused_abilities = self.unused_abilities + 1 +end +--- Notifies a change of stat value +function _M:onStatChange(stat, v) + if stat == self.STAT_CON then + self.max_life = self.max_life + 5 * v + elseif stat == self.STAT_MAG then + self.max_mana = self.max_mana + 5 * v + end end function _M:attack(target) diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index aee1caddf4075818dfa58e6626b2307011a7b3bc..89c63a621bc08743531204d1a48da21397664164 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -24,7 +24,7 @@ local Tooltip = require "engine.Tooltip" local Calendar = require "engine.Calendar" local QuitDialog = require "mod.dialogs.Quit" -local LevelupDialog = require "mod.dialogs.LevelupDialog" +local LevelupStatsDialog = require "mod.dialogs.LevelupStatsDialog" module(..., package.seeall, class.inherit(engine.GameTurnBased)) @@ -248,8 +248,8 @@ function _M:setupCommands() end, [{"_g","shift"}] = function() - local levelup_dialog = LevelupDialog.new(self.player) - self:registerDialog(levelup_dialog) + local d = LevelupStatsDialog.new(self.player) + self:registerDialog(d) end, _LEFT = function() self.player:move(self.player.x - 1, self.player.y ) end, diff --git a/game/modules/tome/dialogs/LevelupDialog.lua b/game/modules/tome/dialogs/LevelupStatsDialog.lua similarity index 97% rename from game/modules/tome/dialogs/LevelupDialog.lua rename to game/modules/tome/dialogs/LevelupStatsDialog.lua index d5bc1c59722a0e7e89eb79d0417129c6f2b274a1..f6ea0d4e4f5ca13fd2893af4f0ab835a1ada6cfe 100644 --- a/game/modules/tome/dialogs/LevelupDialog.lua +++ b/game/modules/tome/dialogs/LevelupStatsDialog.lua @@ -6,7 +6,7 @@ module(..., package.seeall, class.inherit(engine.Dialog)) function _M:init(actor) self.actor = actor self.actor_dup = actor:clone() - engine.Dialog.init(self, "Levelup: "..actor.name, 600, 400) + engine.Dialog.init(self, "Stats Levelup: "..actor.name, 500, 300) -- self.statstpl = self:loadDisplayTemplate() self.statsel = 1