Help with Party.lua modding
Posted: Sat Jan 31, 2015 9:22 am
I havent played this game in ages, but one of the things I did in my own addon was to modify the party.lua file in the mod/ai folder.
It was basically to make all party member warp to the party leader (ie your character) when they were outside of their "leash" (i think its 10 by default) this worked for necromancers minions and alchemists golem etc. But it does not work anymore. I used the thought-forms warping code with minor alterations and had came up with this:
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
newAI("party_member", function(self)
local anchor = self.ai_state.tactic_leash_anchor
-- Stay close to the leash anchor
if anchor and self.ai_state.tactic_leash and anchor.x and anchor.y then
local leash_dist = core.fov.distance(self.x, self.y, anchor.x, anchor.y)
if self.ai_state.tactic_leash < leash_dist then
--was not here below
local Map = require "engine.Map"
local x, y = util.findFreeGrid(anchor.x, anchor.y, 5, true, {[engine.Map.ACTOR]=true})
if not x then
return
end
-- Clear it's targeting on teleport
self:setTarget(nil)
self:move(x, y, true)
game.level.map:particleEmitter(x, y, 1, "generic_teleport", {rm=225, rM=255, gm=225, gM=255, bm=225, bM=255, am=35, aM=90}) --was not here to above
-- print("[PARTY AI] leashing to anchor", self.name)
--was here -> return self:runAI("move_anchor")
end
end
-- Unselect friendly targets
if self.ai_target.actor and self:reactionToward(self.ai_target.actor) >= 0 then self:setTarget(nil) end
-- Run normal AI
local ret = self:runAI(self.ai_state.ai_party)
if not ret and anchor and not self.energy.used then
-- print("[PARTY AI] moving towards anchor", self.name)
return self:runAI("move_anchor")
else
return ret
end
end)
newAI("move_anchor", function(self)
local anchor = self.ai_state.tactic_leash_anchor
if anchor and anchor.x and anchor.y then
local a = engine.Astar.new(game.level.map, self)
local path = a:calc(self.x, self.y, anchor.x, anchor.y)
if not path then
return self:moveDirection(anchor.x, anchor.y)
else
local moved = self:move(path[1].x, path[1].y)
if not moved then return self:moveDirection(anchor.x, anchor.y) end
end
end
end)
As I said it does not seem to work anymore, is there something im missing?
Help much appreciated.
It was basically to make all party member warp to the party leader (ie your character) when they were outside of their "leash" (i think its 10 by default) this worked for necromancers minions and alchemists golem etc. But it does not work anymore. I used the thought-forms warping code with minor alterations and had came up with this:
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
newAI("party_member", function(self)
local anchor = self.ai_state.tactic_leash_anchor
-- Stay close to the leash anchor
if anchor and self.ai_state.tactic_leash and anchor.x and anchor.y then
local leash_dist = core.fov.distance(self.x, self.y, anchor.x, anchor.y)
if self.ai_state.tactic_leash < leash_dist then
--was not here below
local Map = require "engine.Map"
local x, y = util.findFreeGrid(anchor.x, anchor.y, 5, true, {[engine.Map.ACTOR]=true})
if not x then
return
end
-- Clear it's targeting on teleport
self:setTarget(nil)
self:move(x, y, true)
game.level.map:particleEmitter(x, y, 1, "generic_teleport", {rm=225, rM=255, gm=225, gM=255, bm=225, bM=255, am=35, aM=90}) --was not here to above
-- print("[PARTY AI] leashing to anchor", self.name)
--was here -> return self:runAI("move_anchor")
end
end
-- Unselect friendly targets
if self.ai_target.actor and self:reactionToward(self.ai_target.actor) >= 0 then self:setTarget(nil) end
-- Run normal AI
local ret = self:runAI(self.ai_state.ai_party)
if not ret and anchor and not self.energy.used then
-- print("[PARTY AI] moving towards anchor", self.name)
return self:runAI("move_anchor")
else
return ret
end
end)
newAI("move_anchor", function(self)
local anchor = self.ai_state.tactic_leash_anchor
if anchor and anchor.x and anchor.y then
local a = engine.Astar.new(game.level.map, self)
local path = a:calc(self.x, self.y, anchor.x, anchor.y)
if not path then
return self:moveDirection(anchor.x, anchor.y)
else
local moved = self:move(path[1].x, path[1].y)
if not moved then return self:moveDirection(anchor.x, anchor.y) end
end
end
end)
As I said it does not seem to work anymore, is there something im missing?
Help much appreciated.