[spell] Telekinesis (video)
Posted: Tue Dec 11, 2012 11:53 pm
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
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.
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
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.