summary refs log tree commit diff stats
path: root/res/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'res/scripts')
-rw-r--r--res/scripts/common.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 2e95f26..35eec22 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua
@@ -579,6 +579,20 @@ function FaceTowardSpriteCardinally(spriteName, targetName)
579 SetDirection(spriteName, dir) 579 SetDirection(spriteName, dir)
580end 580end
581 581
582--- Checks whether the given sprite is facing another sprite.
583-- @param spriteName the name of the sprite whose facing direction is relevant
584-- @param targetName the name of the sprite that is or isn't being looked at
585function IsFacingTowardSprite(spriteName, targetName)
586 local spriteId = getSpriteByAlias(spriteName)
587 local targetId = getSpriteByAlias(targetName)
588 local sprite = getSprite(spriteId)
589 local target = getSprite(targetId)
590 local diff = vec2i.new(target.loc:x() - sprite.loc:x(), target.loc:y() - sprite.loc:y())
591 local dir = directionFacingPoint(diff)
592
593 return sprite.dir == dir
594end
595
582--- Detaches the sprite's followers and erases their following trails. 596--- Detaches the sprite's followers and erases their following trails.
583function BreakUpParty(spriteName) 597function BreakUpParty(spriteName)
584 local spriteId = getSpriteByAlias(spriteName) 598 local spriteId = getSpriteByAlias(spriteName)