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

Merge branch 'MiscAIFixes' into 'master'

Some AI Fixes

Safety check in ActorAI:aiTalentTargets

Slam: requires a target and correctly checks for hitting adjacent friends

True Grit: stamina drain will be correctly considered by the AI

Adrenalin Surge: AI less likely to trigger it unless there is a hostile target within range


See merge request !495
parents 1949746d e435b877
No related branches found
No related tags found
1 merge request!495Some AI Fixes
Pipeline #
......@@ -316,13 +316,15 @@ function _M:aiTalentTargets(t, aitarget, tg, all_targets, ax, ay)
friendlyfire = typ.friendlyfire and (type(typ.friendlyfire) == "number" and typ.friendlyfire or 100) or 0
if all_targets then typ.selffire, typ.friendlyfire = 100, 100 end
targets = {}
self:project(typ, ax, ay, function(px, py)
local tgt = game.level.map(px, py, typ.scan_on or Map.ACTOR)
if tgt and not tgt.dead then
if log_detail > 2 then print("[aiTalentTargets]", t.id, "may affect", px, py, "actor:", tgt.uid, tgt.name) end
targets[#targets+1] = tgt
end
end)
if ax and ay then
self:project(typ, ax, ay, function(px, py)
local tgt = game.level.map(px, py, typ.scan_on or Map.ACTOR)
if tgt and not tgt.dead then
if log_detail > 2 then print("[aiTalentTargets]", t.id, "may affect", px, py, "actor:", tgt.uid, tgt.name) end
targets[#targets+1] = tgt
end
end)
end
end
end
return targets, selffire, friendlyfire, tg
......
......@@ -148,7 +148,7 @@ newTalent{
cooldown = 6,
hate = 3,
random_ego = "attack",
tactical = { ATTACKAREA = { weapon = 3 } },
tactical = { ATTACKAREA = { PHYSICAL = 1 }, DISABLE = {stun = 1} },
getHitCount = function(self, t)
return 2 + math.min(math.floor(self:getTalentLevel(t) * 0.5), 3)
end,
......@@ -158,6 +158,8 @@ newTalent{
getDamage = function(self, t)
return self:combatTalentPhysicalDamage(t, 10, 140)
end,
requires_target = true,
target = {type="ball", range=0, radius=1, friendlyfire=false}, -- for ai only
on_pre_use = function(self, t, silent)
if not self:hasEffect(self.EFF_RAMPAGE) then
if not silent then game.logPlayer(self, "You must be rampaging to use this talant.") end
......
......@@ -113,27 +113,27 @@ newTalent{
getCapApproach = function(self, t) return self:combatTalentLimit(t, 1, 0.15, 0.5) end,
getResist = function(self, t) return (1 - self.life / self.max_life)*t.resistCoeff(self, t) end,
getResistCap = function(self, t) return util.bound((100-(self.resists_cap.all or 100))*t.getCapApproach(self, t), 0, 100) end,
drain_stamina = function(self, t, turn)
local p = self:isTalentActive(t.id)
return 1 + (turn or (p and p.turns) or 0)*0.3
end,
callbackOnActBase = function(self, t) --called by mod.class.Actor:actBase
local p = self:isTalentActive(t.id)
if p.resid then self:removeTemporaryValue("resists", p.resid) end
if p.cresid then self:removeTemporaryValue("resists_cap", p.cresid) end
if p.stamina then self:removeTemporaryValue("stamina_regen", p.stamina) end
if p.turns then p.turns = p.turns + 1 end
p.stamina = self:addTemporaryValue("stamina_regen", t.getStaminaDrain(self, t) + -0.3 * p.turns)
p.stamina = self:addTemporaryValue("stamina_regen", -(t.drain_stamina(self, t, p.turns) - t.drain_stamina(self, t, 0)))
--This makes it impossible to get 100% resist all cap from this talent, and most npc's will get no cap increase
local resistbonus = t.getResist(self, t)
p.resid = self:addTemporaryValue("resists", {all=resistbonus})
local capbonus = t.getResistCap(self, t)
p.cresid = self:addTemporaryValue("resists_cap", {all=capbonus})
end,
getStaminaDrain = function(self, t)
return -1
end,
activate = function(self, t)
return {
turns = 0,
stamina = self:addTemporaryValue("stamina_regen", t.getStaminaDrain(self, t)),
resid = self:addTemporaryValue("resists", {all = t.getResist(self, t)}),
cresid = self:addTemporaryValue("resists_cap", {all = t.getResistCap(self, t)})
}
......@@ -145,13 +145,13 @@ newTalent{
return true
end,
info = function(self, t)
local drain = t.getStaminaDrain(self, t)
local drain = t.drain_stamina(self, t)
local resistC = t.resistCoeff(self, t)
return ([[Take a defensive stance to resist the onslaught of your foes.
While wounded, you gain all damage resistance equal to %d%% of your missing health.
(So if you have lost 70%% of your life, you gain %d%% all resistance.)
In addition, your all damage resistance cap increases %0.1f%% closer to 100%%.
This consumes stamina rapidly the longer it is sustained (%d stamina increasing by -0.3/turn).
This consumes stamina rapidly the longer it is sustained (%0.1f stamina/turn, increasing by 0.3/turn).
The effects are refreshed at the start of each turn.]]):
format(resistC, resistC*0.7, t.getCapApproach(self, t)*100, drain)
end,
......
......@@ -150,7 +150,11 @@ newTalent{
require = techs_con_req4,
points = 5,
cooldown = 24,
tactical = { STAMINA = 1, BUFF = 2 },
tactical = { STAMINA = 1, BUFF = 1 },
on_pre_use_ai = function(self, t) -- save it for combat
local tgt = self.ai_target.actor
if self.stamina/self.max_stamina < 0.5 or tgt and core.fov.distance(self.x, self.y, tgt.x, tgt.y) < 10 and self:hasLOS(tgt.x, tgt.y) then return true end
end,
getAttackPower = function(self, t) return self:combatTalentStatDamage(t, "con", 5, 25) end,
getDuration = function(self, t) return math.floor(self:combatTalentLimit(t, 24, 3, 7)) end, -- Limit < 24
no_energy = true,
......
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