Page 2 of 2

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 1:48 pm
by Neikun
I have no problem with the item jumping to the middle of the tile, but I would prefer if it ended in front of the player rather than under them so that they can pick it up without moving.

Fantastic idea though. Maybe the runes should be balance and physicality instead of death and earth.

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 1:50 pm
by Xanathar
Maybe (after checking there is no mouse item) it could end on the mouse cursor ?

Re: [spell] Telekinesis (video)

Posted: Wed Dec 12, 2012 2:12 pm
by JKos
@Neikun: Good idea and should be easy to implement. This version is not very polished yet, it's more like quick proof of concept. There is some problems still, so I don't recommend to use it in any dungeon yet, but I will improve it. Just wanted to show it this early because I knew that you guys would be excited :)

@Xanathar: That's a good idea too, I could implement that as an optional feature.

Thanks for the ideas/feedback.

Re: [spell] Telekinesis (video)

Posted: Thu Dec 13, 2012 12:10 am
by Merethif
Truly awesome! I'm totally agree that it may be even more awesome with Xanathar's suggestion implemented, but nevertheless it's fantastic even at this "unpolished proof of concept" stage :-)

Re: [spell] Telekinesis (video)

Posted: Thu Dec 13, 2012 9:45 pm
by JKos
Ok, here is the "final" version which should be safe to use (haven't tested it in game though). You can now cast telekinesis to container type items too and the contents will be preserved.
I also made the changes you suggested. New video:
https://docs.google.com/file/d/0B7cR7sc ... w4V1U/edit
(you can change the video quality from the bottom right corner)

This version requires the newest version of the framework, which includes Xanathars awesome GrimQ-library.
See this page for details: https://sites.google.com/site/jkosgrimr ... dule-grimq

Edit: forgot the script:

Code: Select all

function onCast(caster)
	local item = help.nextEntityAheadOf(party, 5,'item',true)
	if item then
		telekinesis.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-10,true) 
		self:activate()
	end
	
	timer.onDeactivate = function(self)
		local item = findEntity(self.item_id)
		if (getMouseItem()) then
			local x = item.x+self.dx*self.distance
			local y = item.y+self.dy*self.distance
			item = grimq.respawnItem(item,item.level,x,y,item.facing,item.id)
			item:setSubtileOffset(-self.dx * 1,self.dy * 1)
		else
			local copy = grimq.saveItem(item)
			item:destroy()
			setMouseItem(grimq.loadItem(copy))
		end
		
	end
	local dist = help.getDistance(party,item)
	timer:moveTo(help.getOppositeFacing(party),dist)

end
Edit2: Should have guessed, it didn't work in game, but I fixed it.

Re: [spell] Telekinesis (video)

Posted: Fri Dec 14, 2012 10:51 pm
by JKos
Even more final version :)

I added sound and particle effects, and a check if the party is not the same location as it was when the spell was cast, if not the item is not spawned as a mouseItem.

Video with effects: https://docs.google.com/file/d/0B7cR7sc ... NGVjQ/edit

Script (I will leave all versions to this thread so you can see how the code has evolved):

Code: Select all

function onCast(caster)
	local item = help.nextEntityAheadOf(party, 5,'item',true)
	if item then
		playSound('teleport')
		telekinesis.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) 
			
			local fx = findEntity(self.fx_id)
			fx:translate(self.dx * 0.10,0, -self.dy * 0.10)
		end
	)
	
	timer.moveTo = function(self,dir,distance)
		self.dir = dir
		self.distance = distance
		self.sub_x = 0
		self.sub_y = 0
		local item = findEntity(self.item_id)
		local fx = spawn('fx',item.level,item.x,item.y,item.facing)
		fx:setParticleSystem('glitter_silver')
		fx:translate(0,0,0)
		fx:setLight(1, 1, 1,15,7,200,false)
		self.fx_id = fx.id
		
		self.dx,self.dy = getForward(dir)
		self:setTickLimit(distance*30-10,true) 
		self:activate()
	end
	
	timer.onDeactivate = function(self)
		local item = findEntity(self.item_id)
		local partyMoved = false
		local dest_x = item.x+self.dx*self.distance
		local dest_y = item.y+self.dy*self.distance
		if (party.x ~= dest_x or party.y ~= dest_y) then
			partyMoved = true
		end
		
		if (getMouseItem() or partyMoved) then
			item = grimq.respawnItem(item,item.level,dest_x,dest_y,item.facing,item.id)
			item:setSubtileOffset(-self.dx * 1,self.dy * 1)
		else
			local copy = grimq.saveItem(item)
			item:destroy()
			setMouseItem(grimq.loadItem(copy))
		end
		local fx = findEntity(self.fx_id):destroy()
		
	end
	local dist = help.getDistance(party,item)
	timer:moveTo(help.getOppositeFacing(party),dist)

end

Re: [spell] Telekinesis (video)

Posted: Sat Dec 15, 2012 4:30 pm
by Merethif
Pure genius. Final effect is breathtaking.
It's probably require different way of thinking about some puzzle designs, but nevertheless it's awesome.

Re: [spell] Telekinesis (video)

Posted: Sat Dec 15, 2012 6:49 pm
by JKos
Thanks, I'm pretty satisfied with it too. There is one minor visual problem still though: When you cast telekinesis to a torch holder the torch will move towards the party but the flame effect stays in holder. I think it could be fixed by respawning the torch right after the spell is cast so the flame effect will be destroyed.

Re: [spell] Telekinesis (video)

Posted: Sun Dec 16, 2012 6:32 am
by Komag
very nice, so well done!