Page 1 of 1

Summoning in a 'wall' formation

Posted: Wed May 14, 2014 3:01 pm
by Razakai
In my Necromancer addon I have a spell called Corpsewall, the intent of which is to summon an immobile line of necrotic walls segments, similar to Ice Wall but with NPCs. Currently they spawn at random, as I can't figure out how to get the 'wall' targeting type to work correctly. The current code is below (with the npc details stripped out for the sake of space), as you can see I've left the commented 'wall' code in. Attempting to use it with this target type causes it to fail due to no space found.

Code: Select all

newTalent{
	name = "Corpsewall",
	type = {"spell/corpse", 4},
	points = 5,
	require = spells_req_high4,
	mana = 50,
	cooldown = function(self, t) return math.ceil(self:combatTalentLimit(t, 18, 40, 24)) end,
--	getLength = function(self, t) return 1 + math.floor(self:combatTalentScale(t, 3, 7)/2)*2 end,
	getNb = function(self,t) return 2 + math.floor(self:combatTalentScale(t, 1, 3)) end,
	range = 5,
	action = function(self, t)
	--	local halflength = math.floor(t.getLength(self,t)/2)
	--	local block = function(_, lx, ly)
	--		return game.level.map:checkAllEntities(lx, ly, "block_move")
	--	end
	--	local tg = {type="wall", range=self:getTalentRange(t), halflength=halflength, talent=t, halfmax_spots=halflength+1}
	--	local x, y = self:getTarget(tg)
	--	if not x or not y then return nil end
	--	local _ _, _, _, x, y = self:canProject(tg, x, y)
	--	if game.level.map:checkEntity(x, y, Map.TERRAIN, "block_move") then return nil end
	
	  local tg = {type="bolt", nowarning=true, range=self:getTalentRange(t), nolock=true, talent=t}
		local tx, ty, target = self:getTarget(tg)
		if not tx or not ty then return nil end
		local _ _, _, _, tx, ty = self:canProject(tg, tx, ty)
		target = game.level.map(tx, ty, Map.ACTOR)
		if target == self then target = nil end
		
		local nb = t.getNb(self,t)

		-- Find space
		for i = 1, nb do
			local x, y = util.findFreeGrid(tx, ty, 5, true, {[Map.ACTOR]=true})
			if not x then
				game.logPlayer(self, "Not enough space to summon!")
				return
			end

			local NPC = require "mod.class.NPC"
			local m = NPC.new{
				<npc details go here>
			}
			setupSummon(self, m, x, y)
		end

		game:playSoundNear(self, "talents/spell_generic")
		return true
	end,
	info = function(self, t)
		return ([[Creates a towering wall of flesh and bone of %d length at the target location for 10 turns. The wall is so large that it blocks line of sight, and it will lash out nearby foes with bleeding attacks, diseases and Bone Grasp.]]):
		format(t.getNb(self, t))
	end,
}

Re: Summoning in a 'wall' formation

Posted: Wed May 14, 2014 3:33 pm
by darkgod
You seem to be missed an actual call to self:project no ?

Re: Summoning in a 'wall' formation

Posted: Wed May 14, 2014 3:55 pm
by Razakai
darkgod wrote:You seem to be missed an actual call to self:project no ?
The current code used the Wayist talent, which didn't have a self:project call. Do you mean that it needs to use this bit of the Ice Wall code:

Code: Select all

self:project(tg, x, y, function(px, py, tg, self) 
and whatever else comes after it, but with corpsewall substituted for the ice blocks? Sorry, I'm pretty unfamiliar with the summoning code, I just relied on how other spells worked.

Re: Summoning in a 'wall' formation

Posted: Wed May 14, 2014 4:17 pm
by darkgod
yup :)