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

Merge branch 'Effigy/t-engine4-cloning_fixes'

parents fc172667 256342c4
No related branches found
No related tags found
No related merge requests found
......@@ -283,11 +283,11 @@ local function cloneCustomRecurs(clonetable, d, noclonecall, use_saveinstead, al
return n, nb
end
--- Clone the object, with custom logic
--- Clones the object, with custom logic
-- Based on cloneFull(), with added functionality to skip/replace specified nodes.
-- @param[type=table] self Object to be cloned.
-- @param[type=table] alt_nodes Optional, these nodes will use a specified key/value on the clone instead of copying from the target.
-- @ Table keys should be the nodes to skip/replace (field name or table reference).
-- @ Table keys should be the nodes to skip/replace (field name or object reference).
-- @ Each key should be set to false (to skip assignment entirely) or a table with up to two nodes:
-- @ k = a name/ref to substitute for instances of this field,
-- @ or nil to use the default name/ref as keys on the clone
......
......@@ -35,6 +35,28 @@ newTalent{
speed = 'archery',
getDamage = function(self, t) return self:combatTalentWeaponDamage(t, 0.4, 1.0) end,
getDamagePenalty = function(self, t) return 50 end,
cleanupClones = function(self, t, clones)
if not self or not clones then return false end
for clone, _ in pairs(clones) do
if not clone.dead then clone:die() end
end
for _, ent in pairs(game.level.entities) do
-- Replace clone references in timed effects so they don't prevent GC
if ent.tmp then
for _, eff in pairs(ent.tmp) do
if eff.src then
for clone, _ in pairs(clones) do
if eff.src == clone then
eff.src = self
break
end
end
end
end
end
end
return true
end,
target = function(self, t)
return {type="bolt", range=self:getTalentRange(t), talent=t, friendlyfire=false, friendlyblock=false}
end,
......@@ -57,8 +79,10 @@ newTalent{
-- Summon our clones
if not self.arrow_stitching_done then
local clones = {}
for i = 1, 2 do
local m = makeParadoxClone(self, self, 0)
clones[m] = true
m.arrow_stitched_target = target
m.generic_damage_penalty = m.generic_damage_penalty or 0 + t.getDamagePenalty(self, t)
m:attr("archery_pass_friendly", 1)
......@@ -88,6 +112,7 @@ newTalent{
x, y = pos[1], pos[2]
game.zone:addEntity(game.level, m, "actor", x, y)
end
t.cleanupClones(self, t, clones)
end
return true
......
......@@ -275,12 +275,12 @@ end
-- Spell functions
--- Create a temporal clone
--- Creates a temporal clone
-- @param[type=table] self Actor doing the cloning. Not currently used.
-- @param[type=table] target Actor to be cloned.
-- @param[type=int] duration How many turns the clone lasts. Zero is allowed.
-- @param[type=table] alt_nodes Optional, these nodes will use a specified key/value on the clone instead of copying from the target.
-- @ Table keys should be the nodes to skip/replace (field name or table reference).
-- @ Table keys should be the nodes to skip/replace (field name or object reference).
-- @ Each key should be set to false (to skip assignment entirely) or a table with up to two nodes:
-- @ k = a name/ref to substitute for instances of this field,
-- @ or nil to use the default name/ref as keys on the clone
......@@ -291,7 +291,7 @@ makeParadoxClone = function(self, target, duration, alt_nodes)
if not target or not duration then return nil end
if duration < 0 then duration = 0 end
-- Don't copy certain properties from the target
-- Don't copy certain fields from the target
alt_nodes = alt_nodes or {}
alt_nodes[target:getInven("INVEN")] = false -- Skip main inventory; equipped items are still copied
alt_nodes.quests = false
......@@ -310,8 +310,10 @@ makeParadoxClone = function(self, target, duration, alt_nodes)
alt_nodes._last_mo = false
alt_nodes.add_mos = false
alt_nodes.add_displays = false
alt_nodes.fov = false
alt_nodes.distance_map = false
-- Don't copy some additional properties for short-lived clones
-- Don't copy some additional fields for short-lived clones
if duration == 0 then
alt_nodes.__particles = {v = {} }
alt_nodes.hotkey = false
......@@ -345,6 +347,7 @@ makeParadoxClone = function(self, target, duration, alt_nodes)
m.game_ender = nil
mod.class.NPC.castAs(m)
engine.interface.ActorFOV.init(m)
engine.interface.ActorAI.init(m, m)
-- Change some values
......@@ -389,7 +392,7 @@ makeParadoxClone = function(self, target, duration, alt_nodes)
-- Remove timed effects
m:removeTimedEffectsOnClone()
-- Reset folds for our Warden clones
-- Reset folds for Temporal Warden clones
for tid, cd in pairs(m.talents_cd) do
local t = m:getTalentFromId(tid)
if t.type[1]:find("^chronomancy/manifold") and m:knowTalent(tid) then
......
......@@ -273,14 +273,15 @@ newTalent{
findTarget = function(self, t)
local tgts = {}
local grids = core.fov.circle_grids(self.x, self.y, 10, true)
for x, yy in pairs(grids) do for y, _ in pairs(grids[x]) do
local target_type = Map.ACTOR
local a = game.level.map(x, y, Map.ACTOR)
if a and not a.dead and self:reactionToward(a) < 0 and self:hasLOS(a.x, a.y) then
tgts[#tgts+1] = a
for x, yy in pairs(grids) do
for y, _ in pairs(grids[x]) do
local target_type = Map.ACTOR
local a = game.level.map(x, y, Map.ACTOR)
if a and not a.dead and self:reactionToward(a) < 0 and self:hasLOS(a.x, a.y) then
tgts[#tgts+1] = a
end
end
end end
end
return tgts
end,
cleanupClone = function(self, t, clone)
......
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