forgottenserver icon indicating copy to clipboard operation
forgottenserver copied to clipboard

Added Creature:onChangeZone event

Open reyaleman opened this issue 3 years ago • 3 comments

Pull Request Prelude

Changes Proposed

  • Added Creature.onChangeZone event for scripts where we need to check if a creature changes a zone...

for example:

function Creature:onChangeZone(fromZone, toZone)
	if toZone == ZONE_PROTECTION then
		self:say("I'm protected!")
	end
end
  • Added ZONE_NOLOGOUT return to Tile:getZone() method.

Issues addressed:

reyaleman avatar May 25 '22 04:05 reyaleman

Can this be achieved with a regular onWalk callback?

ranisalt avatar Jun 07 '22 14:06 ranisalt

Can this be achieved with a regular onWalk callback?

It can be done using onStepIn movement but you'd have to register every itemid, actionid or w/e u'll be using and check if a creature is changing zone... but it can be achieved.

reyaleman avatar Jun 12 '22 15:06 reyaleman

It can be done using onStepIn movement but you'd have to register every itemid, actionid or w/e u'll be using and check if a creature is changing zone... but it can be achieved.

I mean, create a more generic onMove callback and there check of previous tile zone is different from current tile zone. It's more robust than creating a callback for every small event that may happen

ranisalt avatar Jun 12 '22 21:06 ranisalt

I mean, create a more generic onMove callback and there check of previous tile zone is different from current tile zone. It's more robust than creating a callback for every small event that may happen

wasn't that idea initially rejected due to performance concerns?

Zbizu avatar May 05 '23 09:05 Zbizu

I mean, create a more generic onMove callback and there check of previous tile zone is different from current tile zone. It's more robust than creating a callback for every small event that may happen

wasn't that idea initially rejected due to performance concerns?

that is a good point

EPuncker avatar May 23 '23 11:05 EPuncker

needs rebase so we can merge it

EPuncker avatar Sep 06 '23 22:09 EPuncker