Bat

From ZAMN Hacking
Revision as of 19:25, 14 July 2024 by Piranhaplant (talk | contribs)
Entity data
Entity pointer $82:F03E

The bat is an entity that is spawned by vampires.

Behavior

A bat starts out moving in a given direction specified in the entity arguments. The initial velocity of the bat is 6 px/frame in this direction. If the direction is diagonal, the velocity is 6 px/frame on both axes. Every frame, the bat will accelerate towards the nearest target at a rate of 1 px/frame2, but its speed will not exceed 6 px/frame. After the acceleration is applied, then the position is updated based on the current velocity.

Every 3 frames the bat will switch to the next animation frame. There are 2 different sprites that it alternates between.

A bat will die if any of the following conditions are met:

  • It contacts a tile that is solid to weapons
  • It touches a player, victim, or any weapon shot
  • It has been alive for 131 frames

Once the bat dies, it plays a 32 frame death animation, then the entity is destroyed.

RAM map

Entity arguments

Address Length Type Name Description
$00 2 int16 x X position
$02 2 int16 y Y position
$04 2 direction x2 direction Direction

Entity memory

Address Length Type Name Description
$08 2 pointer16 sprite Pointer to sprite
$0A 2 int16 x X position
$0C 2 int16 y Y position
$0E 2 int16 velocityX X velocity
$10 2 int16 velocityY Y velocity
$12 2 unused unused12 Value is set, but never used
$14 2 boolean dead Dead
$16 2 uint16 animationFrame Low bit is the current animation frame
$18 2 uint16 0-based framesUntilAnimUpdate Number of frames until the next animation frame
$1A 2 uint16 0-based framesUntilDeath Number of frames until death