Page 1 of 1

Hook Actor:move - working as intended?

Posted: Tue Nov 05, 2013 2:55 pm
by MisiuPysiu
Hey,

I was using the the hook

Code: Select all

self:triggerHook{"Actor:move", moved=moved, force=force, ox=ox, oy=oy}
to check if the player is still in a zone of an effect:

Code: Select all

class:bindHook("Actor:move", function(self, data)
	if data.moved and  self:hasEffect(self.EFF_CRIMSON_FOG) then				
			local isInCrimsonFog = 0
			game.logPlayer(self, "data.x: %s, data.y: %s",data.ox,data.oy)
   			for i, e in ipairs(game.level.map.effects) do


      			if e.damtype == DamageType.CRIMSON_FOG and e.grids[data.ox] and e.grids[data.ox][data.oy]  
      			then isInCrimsonFog = 1 end
      		end
      		game.logPlayer(self, "isInCrimsonFog: %s",isInCrimsonFog)
      		if isInCrimsonFog == 0 then	
      			self:removeEffect(self.EFF_CRIMSON_FOG)
      			game.logPlayer(self, "EFF_CRIMSON_FOG removed")
      		end
   	end
end)	
data.ox and data.oy are the coordinates from where the char starts his movement and not the ones where he finally arrives, am I right? If so, does it work as intended?
I assumed, the hook is used to do stuff after the movement so the new position coordinates would be more helpful.

Cheers:)

Re: Hook Actor:move - working as intended?

Posted: Tue Nov 05, 2013 3:41 pm
by darkgod
After move coords are the current coords so self.x / self.y is fine ;)

Re: Hook Actor:move - working as intended?

Posted: Tue Nov 05, 2013 6:08 pm
by MisiuPysiu
Yeah...

Silly me. With the hook you have access to both the source and the target coordinates.

Cheers:)