Skip to content
Snippets Groups Projects
Commit 4338b347 authored by Hachem_Muche's avatar Hachem_Muche
Browse files

Added support for actor-specific checks for object usability and ai test.

Object use talent IDs are remembered for previously equipped objects if possible. (facilitates hotkey settings)
Added support for automatic use of object use talents via the Talent Use menu.
Added support for ai_talents weights (remembered by reference to individual objects) via party-control interface.
parent 8bde8912
No related branches found
No related tags found
No related merge requests found
...@@ -139,6 +139,12 @@ function _M:canUseObject(who) ...@@ -139,6 +139,12 @@ function _M:canUseObject(who)
return true, "Object can be used." return true, "Object can be used."
end end
--- Does the actor have inadequate AI to use this object intelligently?
-- @param who = the potential object user
function _M:restrictAIUseObject(who)
return not (who.ai == "tactical" or who.ai_real == "tactical" or (who.ai_state and who.ai_state.ai_party) == "tactical")
end
function _M:useObject(who, ...) function _M:useObject(who, ...)
-- Make sure the object is registered with the game, if need be -- Make sure the object is registered with the game, if need be
if not game:hasEntity(self) then game:addEntity(self) end if not game:hasEntity(self) then game:addEntity(self) end
......
...@@ -857,7 +857,8 @@ function _M:automaticTalents() ...@@ -857,7 +857,8 @@ function _M:automaticTalents()
local t = self.talents_def[tid] local t = self.talents_def[tid]
local spotted = spotHostiles(self, true) local spotted = spotHostiles(self, true)
local cd = self:getTalentCooldown(t) or 0 local cd = self:getTalentCooldown(t) or 0
local turns_used = util.getval(t.no_energy, self, t) == true and 0 or 1 local turns_used = util.getval(t.no_energy, self, t) == true and 0 or 1
-- if cd <= turns_used and t.mode ~= "sustained" then
if cd <= turns_used and t.mode ~= "sustained" and not t.is_object_use then if cd <= turns_used and t.mode ~= "sustained" and not t.is_object_use then
game.logPlayer(self, "Automatic use of talent %s #DARK_RED#skipped#LAST#: cooldown too low (%d).", t.name, cd) game.logPlayer(self, "Automatic use of talent %s #DARK_RED#skipped#LAST#: cooldown too low (%d).", t.name, cd)
elseif (t.mode ~= "sustained" or not self.sustain_talents[tid]) and not self.talents_cd[tid] and self:preUseTalent(t, true, true) and (not t.auto_use_check or t.auto_use_check(self, t)) then elseif (t.mode ~= "sustained" or not self.sustain_talents[tid]) and not self.talents_cd[tid] and self:preUseTalent(t, true, true) and (not t.auto_use_check or t.auto_use_check(self, t)) then
......
This diff is collapsed.
...@@ -394,6 +394,7 @@ newEntity{ ...@@ -394,6 +394,7 @@ newEntity{
radius = function(self, who) return 1 + self.material_level end, radius = function(self, who) return 1 + self.material_level end,
target = function(self, who) return {type="ball", range=self.use_power.range, radius=self.use_power.radius(self, who), selffire=false} end, target = function(self, who) return {type="ball", range=self.use_power.range, radius=self.use_power.radius(self, who), selffire=false} end,
requires_target = true, requires_target = true,
no_npc_use = function(self, who) return not self:restrictAIUseObject(who) end, -- don't let dumb ai blow up friends
tactical = { ATTACKAREA = function(who, t, aitarget) tactical = { ATTACKAREA = function(who, t, aitarget)
local weapon = who:hasStaffWeapon() local weapon = who:hasStaffWeapon()
if not weapon or not weapon.combat then return 1 end if not weapon or not weapon.combat then return 1 end
...@@ -522,6 +523,7 @@ newEntity{ ...@@ -522,6 +523,7 @@ newEntity{
radius = function(self, who) return 2*self.material_level end, radius = function(self, who) return 2*self.material_level end,
requires_target = true, requires_target = true,
target = function(self, who) return {type="cone", range=self.use_power.range, radius=self.use_power.radius(self, who), selffire=false} end, target = function(self, who) return {type="cone", range=self.use_power.range, radius=self.use_power.radius(self, who), selffire=false} end,
no_npc_use = function(self, who) return not self:restrictAIUseObject(who) end, -- don't let dumb ai blow up friends
tactical = { ATTACKAREA = function(who, t, aitarget) tactical = { ATTACKAREA = function(who, t, aitarget)
local weapon = who:hasStaffWeapon() local weapon = who:hasStaffWeapon()
if not weapon or not weapon.combat then return 1 end if not weapon or not weapon.combat then return 1 end
......
...@@ -25,7 +25,6 @@ Totems ...@@ -25,7 +25,6 @@ Totems
*thorny skin *thorny skin
]] ]]
newEntity{ newEntity{
name = " of cure ailments", addon=true, instant_resolve=true, name = " of cure ailments", addon=true, instant_resolve=true,
keywords = {ailments=true}, keywords = {ailments=true},
......
...@@ -116,6 +116,7 @@ newEntity{ ...@@ -116,6 +116,7 @@ newEntity{
"T_GLOBAL_CD", "T_GLOBAL_CD",
{range = 5, {range = 5,
requires_target = true, requires_target = true,
no_npc_use = function(self, who) return not self:restrictAIUseObject(who) end, -- don't let dumb ai hurt friends
target = function(self, who) return {type="wall", range=self.use_power.range, halflength=3, halfmax_spots=3+1} end, target = function(self, who) return {type="wall", range=self.use_power.range, halflength=3, halfmax_spots=3+1} end,
tactical = {ATTACKAREA = {FIRE = 2}}, tactical = {ATTACKAREA = {FIRE = 2}},
damage = function(self, who) return self:getCharmPower(who) end damage = function(self, who) return self:getCharmPower(who) end
......
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