Advertisement
Guest User

sandscape

a guest
May 13th, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.61 KB | None | 0 0
  1.  
  2. newTalent{
  3.     name = "Sandworm Lair",
  4.     short_name = "SANDWORM_LAIR",
  5.     type = {"race/Xorn_Infusions", 1},
  6.     --type = {"race/Chrono_Xorn", 4},
  7.     --require = corrs_req4,
  8.     image = "talents/phase_door.png",
  9.     anomaly_type = "major",
  10.     mode = "sustained",
  11.     points = 5,
  12.     sustain_paradox = 90,
  13.     drain_mana = 5,
  14.     remove_on_zero = true,
  15.     cooldown = 60,
  16.     no_sustain_autoreset = true,
  17.     --random_boss_rarity = 10,
  18.     tactical = { DISABLE = function(self, t, target) if target and target.game_ender then return 3 else return 0 end end},
  19.     range = 1,
  20.     on_pre_use = function(self, t) return self:canBe("planechange") and self:getMana() >= 10 end,
  21.     activate = function(self, t)
  22.         if game.zone.is_sandworm_lair then
  23.             game.logPlayer(self, "This spell cannot be used from within the Sandworm Lair.")
  24.             return
  25.         end
  26.         if game.zone.is_demon_plane then
  27.             game.logPlayer(self, "This spell cannot be used from within the Fearscape.")
  28.             return
  29.         end
  30.         if game.zone.no_planechange then
  31.             game.logPlayer(self, "This spell cannot be cast here.")
  32.             return
  33.         end
  34.  
  35.         local tg = {type="hit", range=self:getTalentRange(t), talent=t}
  36.         local tx, ty, target = self:getTarget(tg)
  37.         if not tx or not ty or not target then return nil end
  38.         local _ _, tx, ty = self:canProject(tg, tx, ty)
  39.         if not tx or not ty or not target then return nil end
  40.         target = game.level.map(tx, ty, Map.ACTOR)
  41.         if not tx or not ty or not target then return nil end
  42.         if not (target.player and target.game_ender) and not (self.player and self.game_ender) then return nil end
  43.         if target == self then return end
  44.         if target:attr("negative_status_effect_immune") or target:attr("status_effect_immune") then return nil end
  45.  
  46.         if not self:canBe("planechange") or target.summon_time or target.summon then
  47.             game.logPlayer(self, "The spell fizzles...")
  48.             return
  49.         end
  50.  
  51.         game:playSoundNear(self, "talents/flame")
  52.         --local dam = self:combatTalentSpellDamage(t, 12, 140)
  53.  
  54.         game:onTickEnd(function()
  55.             if self:attr("dead") then return end
  56.             local oldzone = game.zone
  57.             local oldlevel = game.level
  58.  
  59.             -- Remove them before making the new level, this way party members are not removed from the old
  60.             if oldlevel:hasEntity(self) then oldlevel:removeEntity(self) end
  61.             if oldlevel:hasEntity(target) then oldlevel:removeEntity(target) end
  62.  
  63.             oldlevel.no_remove_entities = true
  64.             local zone = mod.class.Zone.new("sandworm_lair_spell")
  65.             local level = zone:getLevel(game, 1, 0)
  66.             oldlevel.no_remove_entities = nil
  67.             --level.demonfire_dam = dam
  68.             level.plane_owner = self
  69.  
  70.             level:addEntity(self)
  71.             level:addEntity(target)
  72.  
  73.             level.source_zone = oldzone
  74.             level.source_level = oldlevel
  75.             game.zone = zone
  76.             game.level = level
  77.             game.zone_name_s = nil
  78.  
  79.             local x1, y1 = util.findFreeGrid(4, 6, 20, true, {[Map.ACTOR]=true})
  80.             if x1 then
  81.                 self:move(x1, y1, true)
  82.                 game.level.map:particleEmitter(x1, y1, 1, "demon_teleport")
  83.             end
  84.             local x2, y2 = util.findFreeGrid(8, 6, 20, true, {[Map.ACTOR]=true})
  85.             if x2 then
  86.                 target:move(x2, y2, true)
  87.                 game.level.map:particleEmitter(x2, y2, 1, "demon_teleport")
  88.             end
  89.  
  90.             target:setTarget(self)
  91.             target.sandworm_lair_trapper = self
  92.             target.sandworm_lair_on_die = target.on_die
  93.             target.on_die = function(self, ...)
  94.                 self.sandworm_lair_trapper:forceUseTalent(self.T_SANDWORM_LAIR, {ignore_energy=true})
  95.                 local args = {...}
  96.                 game:onTickEnd(function()
  97.                     if self.sandworm_lair_on_die then self:sandworm_lair_on_die(unpack(args)) end
  98.                     self.on_die, self.sandworm_lair_on_die = self.sandworm_lair_on_die, nil
  99.                 end)
  100.             end
  101.  
  102.             self.sandworm_lair_on_die = self.on_die
  103.             self.on_die = function(self, ...)
  104.                 self:forceUseTalent(self.T_SANDWORM_LAIR, {ignore_energy=true})
  105.                 local args = {...}
  106.                 game:onTickEnd(function()
  107.                     if self.sandworm_lair_on_die then self:sandworm_lair_on_die(unpack(args)) end
  108.                     self.on_die, self.sandworm_lair_on_die = self.sandworm_lair_on_die, nil
  109.                     --if not game.party:hasMember(self) then world:gainAchievement("FEARSCAPE", game:getPlayer(true)) end
  110.                 end)
  111.             end
  112.  
  113.             game.logPlayer(game.player, "#LIGHT_RED#You are taken to a plane of sand!")
  114.             --game.party:learnLore("fearscape-entry")
  115.             --level.allow_demon_plane_damage = true
  116.         end)
  117.  
  118.         local particle
  119.         if core.shader.active(4) then
  120.             local bx, by = self:attachementSpot("back", true)
  121.             particle = self:addParticles(Particles.new("shader_wings", 1, {infinite=1, x=bx, y=by, img="bloodwings", flap=28, a=0.6}))
  122.         end
  123.         local ret = {
  124.             target = target,
  125.             x = self.x, y = self.y,
  126.             particle = particle,
  127.         }
  128.         return ret
  129.     end,
  130.     deactivate = function(self, t, p)
  131.         -- If we're a clone of the original sandscaper, just deactivate
  132.         if not self.on_die then return true end
  133.        
  134.         if p.particle then self:removeParticles(p.particle) end
  135.  
  136.         game:onTickEnd(function()
  137.             -- Collect objects
  138.             local objs = {}
  139.             for i = 0, game.level.map.w - 1 do for j = 0, game.level.map.h - 1 do
  140.                 for z = game.level.map:getObjectTotal(i, j), 1, -1 do
  141.                     objs[#objs+1] = game.level.map:getObject(i, j, z)
  142.                     game.level.map:removeObject(i, j, z)
  143.                 end
  144.             end end
  145.  
  146.             local oldzone = game.zone
  147.             local oldlevel = game.level
  148.             local zone = game.level.source_zone
  149.             local level = game.level.source_level
  150.  
  151.             if not self.dead then
  152.                 oldlevel:removeEntity(self, true)
  153.                 level:addEntity(self)
  154.             end
  155.  
  156.             game.zone = zone
  157.             game.level = level
  158.             game.zone_name_s = nil
  159.  
  160.             local x1, y1 = util.findFreeGrid(p.x, p.y, 20, true, {[Map.ACTOR]=true})
  161.             if x1 then
  162.                 if not self.dead then
  163.                     self:move(x1, y1, true)
  164.                     self.on_die, self.sandworm_lair_on_die = self.sandworm_lair_on_die, nil
  165.                     game.level.map:particleEmitter(x1, y1, 1, "demon_teleport")
  166.                 else
  167.                     self.x, self.y = x1, y1
  168.                 end
  169.             end
  170.             local x2, y2 = util.findFreeGrid(p.x, p.y, 20, true, {[Map.ACTOR]=true})
  171.             if not p.target.dead then
  172.                 if x2 then
  173.                     p.target:move(x2, y2, true)
  174.                     p.target.on_die, p.target.sandworm_lair_on_die = p.target.sandworm_lair_on_die, nil
  175.                     game.level.map:particleEmitter(x2, y2, 1, "demon_teleport")
  176.                 end
  177.                 if oldlevel:hasEntity(p.target) then oldlevel:removeEntity(p.target, true) end
  178.                 level:addEntity(p.target)
  179.             else
  180.                 p.target.x, p.target.y = x2, y2
  181.             end
  182.  
  183.             -- Add objects back
  184.             for i, o in ipairs(objs) do
  185.                 if self.dead then
  186.                     game.level.map:addObject(p.target.x, p.target.y, o)
  187.                 else
  188.                     game.level.map:addObject(self.x, self.y, o)
  189.                 end
  190.             end
  191.  
  192.             -- Remove all npcs in the sandscape
  193.             for uid, e in pairs(oldlevel.entities) do
  194.                 if e ~= self and e ~= p.target and e.die then e:die() end
  195.             end
  196.  
  197.             -- Reload MOs
  198.             game.level.map:redisplay()
  199.             game.level.map:recreate()
  200.             game.uiset:setupMinimap(game.level)
  201.             game.nicer_tiles:postProcessLevelTilesOnLoad(game.level)
  202.  
  203.             game.logPlayer(game.player, "#LIGHT_RED#You are brought back from the plane of sand!")
  204.         end)
  205.  
  206.         return true
  207.     end,
  208.     info = function(self, t)
  209.         return ([[Summon a part of the earthen plane of sand to intersect with the current level.
  210.         Your target and yourself are taken to the Sandscape, trapped there until you end the spell or until your target dies.
  211.         While inside, both of you will have to find your own means of moving and not suffocating.
  212.         And some denizens might target you for invading their realm.
  213.         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.
  214.         Objects will be moved as well.
  215.         This spell has no effect if cast when already inside the Sandscape.
  216.         This powerful spell drains 5 mana per turn, ending when it reaches 0.]]):format()
  217.     end,
  218. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement