Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- newTalent{
- name = "Sandworm Lair",
- short_name = "SANDWORM_LAIR",
- type = {"race/Xorn_Infusions", 1},
- --type = {"race/Chrono_Xorn", 4},
- --require = corrs_req4,
- image = "talents/phase_door.png",
- anomaly_type = "major",
- mode = "sustained",
- points = 5,
- sustain_paradox = 90,
- drain_mana = 5,
- remove_on_zero = true,
- cooldown = 60,
- no_sustain_autoreset = true,
- --random_boss_rarity = 10,
- tactical = { DISABLE = function(self, t, target) if target and target.game_ender then return 3 else return 0 end end},
- range = 1,
- on_pre_use = function(self, t) return self:canBe("planechange") and self:getMana() >= 10 end,
- activate = function(self, t)
- if game.zone.is_sandworm_lair then
- game.logPlayer(self, "This spell cannot be used from within the Sandworm Lair.")
- return
- end
- if game.zone.is_demon_plane then
- game.logPlayer(self, "This spell cannot be used from within the Fearscape.")
- return
- end
- if game.zone.no_planechange then
- game.logPlayer(self, "This spell cannot be cast here.")
- return
- end
- local tg = {type="hit", range=self:getTalentRange(t), talent=t}
- local tx, ty, target = self:getTarget(tg)
- if not tx or not ty or not target then return nil end
- local _ _, tx, ty = self:canProject(tg, tx, ty)
- if not tx or not ty or not target then return nil end
- target = game.level.map(tx, ty, Map.ACTOR)
- if not tx or not ty or not target then return nil end
- if not (target.player and target.game_ender) and not (self.player and self.game_ender) then return nil end
- if target == self then return end
- if target:attr("negative_status_effect_immune") or target:attr("status_effect_immune") then return nil end
- if not self:canBe("planechange") or target.summon_time or target.summon then
- game.logPlayer(self, "The spell fizzles...")
- return
- end
- game:playSoundNear(self, "talents/flame")
- --local dam = self:combatTalentSpellDamage(t, 12, 140)
- game:onTickEnd(function()
- if self:attr("dead") then return end
- local oldzone = game.zone
- local oldlevel = game.level
- -- Remove them before making the new level, this way party members are not removed from the old
- if oldlevel:hasEntity(self) then oldlevel:removeEntity(self) end
- if oldlevel:hasEntity(target) then oldlevel:removeEntity(target) end
- oldlevel.no_remove_entities = true
- local zone = mod.class.Zone.new("sandworm_lair_spell")
- local level = zone:getLevel(game, 1, 0)
- oldlevel.no_remove_entities = nil
- --level.demonfire_dam = dam
- level.plane_owner = self
- level:addEntity(self)
- level:addEntity(target)
- level.source_zone = oldzone
- level.source_level = oldlevel
- game.zone = zone
- game.level = level
- game.zone_name_s = nil
- local x1, y1 = util.findFreeGrid(4, 6, 20, true, {[Map.ACTOR]=true})
- if x1 then
- self:move(x1, y1, true)
- game.level.map:particleEmitter(x1, y1, 1, "demon_teleport")
- end
- local x2, y2 = util.findFreeGrid(8, 6, 20, true, {[Map.ACTOR]=true})
- if x2 then
- target:move(x2, y2, true)
- game.level.map:particleEmitter(x2, y2, 1, "demon_teleport")
- end
- target:setTarget(self)
- target.sandworm_lair_trapper = self
- target.sandworm_lair_on_die = target.on_die
- target.on_die = function(self, ...)
- self.sandworm_lair_trapper:forceUseTalent(self.T_SANDWORM_LAIR, {ignore_energy=true})
- local args = {...}
- game:onTickEnd(function()
- if self.sandworm_lair_on_die then self:sandworm_lair_on_die(unpack(args)) end
- self.on_die, self.sandworm_lair_on_die = self.sandworm_lair_on_die, nil
- end)
- end
- self.sandworm_lair_on_die = self.on_die
- self.on_die = function(self, ...)
- self:forceUseTalent(self.T_SANDWORM_LAIR, {ignore_energy=true})
- local args = {...}
- game:onTickEnd(function()
- if self.sandworm_lair_on_die then self:sandworm_lair_on_die(unpack(args)) end
- self.on_die, self.sandworm_lair_on_die = self.sandworm_lair_on_die, nil
- --if not game.party:hasMember(self) then world:gainAchievement("FEARSCAPE", game:getPlayer(true)) end
- end)
- end
- game.logPlayer(game.player, "#LIGHT_RED#You are taken to a plane of sand!")
- --game.party:learnLore("fearscape-entry")
- --level.allow_demon_plane_damage = true
- end)
- local particle
- if core.shader.active(4) then
- local bx, by = self:attachementSpot("back", true)
- particle = self:addParticles(Particles.new("shader_wings", 1, {infinite=1, x=bx, y=by, img="bloodwings", flap=28, a=0.6}))
- end
- local ret = {
- target = target,
- x = self.x, y = self.y,
- particle = particle,
- }
- return ret
- end,
- deactivate = function(self, t, p)
- -- If we're a clone of the original sandscaper, just deactivate
- if not self.on_die then return true end
- if p.particle then self:removeParticles(p.particle) end
- game:onTickEnd(function()
- -- Collect objects
- local objs = {}
- for i = 0, game.level.map.w - 1 do for j = 0, game.level.map.h - 1 do
- for z = game.level.map:getObjectTotal(i, j), 1, -1 do
- objs[#objs+1] = game.level.map:getObject(i, j, z)
- game.level.map:removeObject(i, j, z)
- end
- end end
- local oldzone = game.zone
- local oldlevel = game.level
- local zone = game.level.source_zone
- local level = game.level.source_level
- if not self.dead then
- oldlevel:removeEntity(self, true)
- level:addEntity(self)
- end
- game.zone = zone
- game.level = level
- game.zone_name_s = nil
- local x1, y1 = util.findFreeGrid(p.x, p.y, 20, true, {[Map.ACTOR]=true})
- if x1 then
- if not self.dead then
- self:move(x1, y1, true)
- self.on_die, self.sandworm_lair_on_die = self.sandworm_lair_on_die, nil
- game.level.map:particleEmitter(x1, y1, 1, "demon_teleport")
- else
- self.x, self.y = x1, y1
- end
- end
- local x2, y2 = util.findFreeGrid(p.x, p.y, 20, true, {[Map.ACTOR]=true})
- if not p.target.dead then
- if x2 then
- p.target:move(x2, y2, true)
- p.target.on_die, p.target.sandworm_lair_on_die = p.target.sandworm_lair_on_die, nil
- game.level.map:particleEmitter(x2, y2, 1, "demon_teleport")
- end
- if oldlevel:hasEntity(p.target) then oldlevel:removeEntity(p.target, true) end
- level:addEntity(p.target)
- else
- p.target.x, p.target.y = x2, y2
- end
- -- Add objects back
- for i, o in ipairs(objs) do
- if self.dead then
- game.level.map:addObject(p.target.x, p.target.y, o)
- else
- game.level.map:addObject(self.x, self.y, o)
- end
- end
- -- Remove all npcs in the sandscape
- for uid, e in pairs(oldlevel.entities) do
- if e ~= self and e ~= p.target and e.die then e:die() end
- end
- -- Reload MOs
- game.level.map:redisplay()
- game.level.map:recreate()
- game.uiset:setupMinimap(game.level)
- game.nicer_tiles:postProcessLevelTilesOnLoad(game.level)
- game.logPlayer(game.player, "#LIGHT_RED#You are brought back from the plane of sand!")
- end)
- return true
- end,
- info = function(self, t)
- return ([[Summon a part of the earthen plane of sand to intersect with the current level.
- Your target and yourself are taken to the Sandscape, trapped there until you end the spell or until your target dies.
- While inside, both of you will have to find your own means of moving and not suffocating.
- And some denizens might target you for invading their realm.
- When the spell ends, only you and the target (if still alive) are taken back to your home plane; all summons are left in the Sandscape.
- Objects will be moved as well.
- This spell has no effect if cast when already inside the Sandscape.
- This powerful spell drains 5 mana per turn, ending when it reaches 0.]]):format()
- end,
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement