Skip to content
Snippets Groups Projects
Commit 1484daa6 authored by dg's avatar dg
Browse files

blindness

git-svn-id: http://svn.net-core.org/repos/t-engine4@175 51575b47-30f0-44d4-a5cc-537603b46e54
parent d842ac9d
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ require "engine.interface.ActorTalents"
require "engine.interface.ActorResource"
require "engine.interface.BloodyDeath"
require "mod.class.interface.Combat"
local Map = require "engine.Map"
module(..., package.seeall, class.inherit(
-- a ToME actor is a complex beast it uses may inetrfaces
......@@ -56,8 +57,8 @@ function _M:init(t, no_default)
-- Default regen
t.mana_regen = t.mana_regen or 0.5
t.stamina_regen = t.stamina_renge or 0.5
t.life_regen = t.life_regen or 0.1
t.stamina_regen = t.stamina_regen or 0.2 -- Stamina regens slower than mana
t.life_regen = t.life_regen or 0.1 -- Life regen real slow
-- Default melee barehanded damage
self.combat = { dam=1, atk=1, apr=0, dammod={str=1} }
......@@ -284,6 +285,9 @@ end
-- This does not check LOS or such, only the actual ability to see it.<br/>
-- Check for telepathy, invisibility, stealth, ...
function _M:canSee(actor)
-- Blindness means can't see anything
if self:attr("blind") then return false, 0 end
-- Check for invisibility. This is a "simple" checkHit between invisible and see_invisible attrs
if actor:attr("invisible") then
-- Special case, 0 see invisible, can NEVER see invisible things
......@@ -299,6 +303,7 @@ end
--- Can the target be applied some effects
-- @param what a string describing what is being tried
function _M:canBe(what)
if what == "blind" and self:attr("blind_immune") then return false end
if what == "stun" and self:attr("stun_immune") then return false end
if what == "knockback" and self:attr("knockback_immune") then return false end
return true
......
......@@ -98,6 +98,7 @@ end
function _M:save()
return class.save(self, {w=true, h=true, zone=true, player=true, level=true, entities=true,
energy_to_act=true, energy_per_tick=true, turn=true, paused=true, save_name=true,
always_target=true,
}, true)
end
......@@ -193,7 +194,7 @@ end
function _M:targetMode(v, msg, co, typ)
if not v then
Map:setViewerFaction(nil)
Map:setViewerFaction(self.always_target and "players" or nil)
if msg then self.log(type(msg) == "string" and msg or "Tactical display disabled. Press 't' or right mouse click to enable.") end
self.level.map.changed = true
self.target:setActive(false)
......@@ -415,7 +416,9 @@ function _M:setupCommands()
[{"_t","shift"}] = function()
if Map.view_faction then
self:targetMode(false, true)
self.always_target = nil
else
self.always_target = true
self:targetMode(true, true)
-- Find nearest target
self.target:scan(5)
......
......@@ -15,7 +15,9 @@ function _M:act()
-- Let the AI think .... beware of Shub !
-- If AI did nothing, use energy anyway
if not self:doAI() then self:useEnergy() end
local old = self.energy.value
self:doAI()
if old == self.energy.value then self:useEnergy() end
end
--- Called by ActorLife interface
......
......@@ -55,6 +55,21 @@ newDamageType{
end,
}
-- Blinds
newDamageType{
name = "blindness", type = "BLIND",
projector = function(src, x, y, type, dam)
local target = game.level.map(x, y, Map.ACTOR)
if target then
if target:checkHit(src:combatSpellpower(), target:combatSpellResist(), 0, 95, 15) and target:canBe("blind") then
target:setEffect(target.EFF_BLINDED, math.ceil(dam), {})
else
game.logSeen(target, "%s resists the blinding light!", target.name:capitalize())
end
end
end,
}
-- Fire damage + DOT
newDamageType{
name = "fireburn", type = "FIREBURN",
......
......@@ -36,7 +36,7 @@ newTalent{
newTalent{
name = "Death Blow",
type = {"physical/2hweapon", 2},
cooldown = 8,
cooldown = 30,
stamina = 15,
require = { stat = { str=22 }, },
action = function(self, t)
......@@ -55,6 +55,7 @@ newTalent{
if self:knowTalent(Talents.T_MIGHTY_BLOWS) then
self.combat_dam = self.combat_dam + inc
end
self.combat_physcrit = self.combat_physcrit + 100
local speed, hit = self:attackTargetWith(target, weapon.combat, nil, 1)
......@@ -62,6 +63,7 @@ newTalent{
self.combat_dam = self.combat_dam - inc
self.stamina = 0
end
self.combat_physcrit = self.combat_physcrit - 100
-- Try to insta-kill
if hit then
......
......@@ -9,8 +9,8 @@ newTalent{
action = function(self, t)
local t = {type="ball", range=0, friendlyfire=false, radius=5 + self:combatSpellpower(0.2)}
self:project(t, self.x, self.y, DamageType.LIGHT, 1)
if self:knowTalent(Talents.T_GLOBE_OF_LIGHT) then
self:project(t, self.x, self.y, DamageType.BLIND, 1)
if self:knowTalent(Talents.T_BLINDING_LIGHT) then
self:project(t, self.x, self.y, DamageType.BLIND, 4 + self:combatSpellpower(0.03))
end
return true
end,
......
......@@ -166,3 +166,19 @@ newEffect{
self:removeTemporaryValue("see_invisible", eff.tmpid)
end,
}
newEffect{
name = "BLINDED",
desc = "Blinded",
type = "magical",
status = "detrimental",
parameters = {},
on_gain = function(self, err) return "#Target# loses sight!.", "+Blind" end,
on_lose = function(self, err) return "#Target# recovers sight.", "-Blind" end,
activate = function(self, eff)
eff.tmpid = self:addTemporaryValue("blind", 1)
end,
deactivate = function(self, eff)
self:removeTemporaryValue("blind", eff.tmpid)
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