Page 1 of 2

[spell] Telekinesis (video)

Posted: Tue Dec 11, 2012 11:53 pm
by JKos
Hi,

I made a telekinesis spell which can be used to pull items towards the party. Technically it's done with a timer which modifies the subtile offset of the item.
I think it works pretty nicely, but unfortunately we can't access the subtileoffset of the item, so the initial offset has to be set to 0,0 which makes the items "jump" to the center of the tile when the spell is cast.
https://docs.google.com/file/d/0B7cR7sc ... NWU3c/edit
(my mouse is broken so don't care about the extra clicks :) )



Script entity telekinesis

Code: Select all

function onCast(caster)
	local item = help.nextEntityAheadOf(party, 5,'item',true)
	if item then
		pullItem(item)
	end
end


function pullItem(item)
	local timer = timers:create('move_timer_'..item.id)
	timer:setTimerInterval(0.01)
	
	timer.item_id = item.id
	
	timer:addCallback(
		function(self) 	
			local item = findEntity(self.item_id)
			
			self.sub_x = self.sub_x + (self.dx * 0.10)
			self.sub_y = self.sub_y + (self.dy * 0.10)
			item:setSubtileOffset(self.sub_x, -self.sub_y) 			
		end
	)
	
	timer.moveTo = function(self,dir,distance)
		self.dir = dir
		self.distance = distance
		self.sub_x = 0
		self.sub_y = 0
		self.dx,self.dy = getForward(dir)
		self:setTickLimit(distance*30,true) 
		self:activate()
	end
	
	timer.onDeactivate = function(self)
		local item = findEntity(self.item_id)
		item = help.recreateItem(item,item.x+self.dx*self.distance,item.y+self.dy*self.distance)
		item:setSubtileOffset(0,0)
	end
	local dist = help.getDistance(party,item)
	timer:moveTo(help.getOppositeFacing(party),dist)

end
Just call the telekinesis.onCast from spell onCast hook.

Requires LoG Framework (link is in my signature)

This technique could be used to make moving rats, mouses and insects too, which could be picked up and eaten. But I can't do 3d modelling.

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 12:06 am
by Xanathar
Awesome!

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 12:43 am
by Komag
I love it, very cool! 8-)

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 1:11 am
by LordYig
Ho ! This is so nice !
It opens some opportunities for puzzles !

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 1:21 am
by flatline
Amazing job! Grimrock has evolved to the point where Portal is the less complicated puzzle game. :)

Moving items in this way creates a lot of other opportunities too. *a thousand ideas pops up at once*

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 1:28 am
by Rook
You're a wizard, Harry!

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 1:29 am
by Rook
flatline wrote:Amazing job! Grimrock has evolved to the point where Portal is the less complicated puzzle game. :)

Moving items in this way creates a lot of other opportunities too. *a thousand ideas pops up at once*
Moving Dragon statues around a room to place on pressure plates springs to mind.

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 3:25 am
by akroma222
Brilliant!!
I had thought about a telekinesis spell but don't have the know how to make it happen...
Nice work for sure!!

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 3:31 am
by pferguso
Nice work!

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 9:21 am
by Diarmuid
Really cool! It is your extended timers that made animation possible to implement.