[spell] Telekinesis (video)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: [spell] Telekinesis (video)

Post 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.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: [spell] Telekinesis (video)

Post by Xanathar »

Maybe (after checking there is no mouse item) it could end on the mouse cursor ?
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: [spell] Telekinesis (video)

Post 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.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Merethif
Posts: 274
Joined: Tue Apr 24, 2012 1:58 pm
Location: Poland

Re: [spell] Telekinesis (video)

Post 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 :-)
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: [spell] Telekinesis (video)

Post 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.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: [spell] Telekinesis (video)

Post 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
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Merethif
Posts: 274
Joined: Tue Apr 24, 2012 1:58 pm
Location: Poland

Re: [spell] Telekinesis (video)

Post 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.
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: [spell] Telekinesis (video)

Post 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.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: [spell] Telekinesis (video)

Post by Komag »

very nice, so well done!
Finished Dungeons - complete mods to play
Post Reply