Fire: Difference between revisions
Piranhaplant (talk | contribs) No edit summary |
Piranhaplant (talk | contribs) No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 49: | Line 49: | ||
|} |
|} |
||
{{Pseudocode header}} |
|||
main() { |
main() { |
||
{{RAM name|$7E:00DE}} += 8 |
{{RAM name|$7E:00DE}} += 8 |
||
init() |
|||
this.health = 5 |
this.health = 5 |
||
{{ROM name|$80:8475}}( |
{{ROM name|$80:8475}}(collisionHandler) |
||
while (this.collidedSpriteType == 0 |
while (this.collidedSpriteType == 0 || (this.collidedSpriteType != OFF_SCREEN && this.health >= 0)) { |
||
this.collidedSpriteType = 0 |
this.collidedSpriteType = 0 |
||
{{ROM name|$80:8353}}(2) |
{{ROM name|$80:8353}}(2) |
||
Line 64: | Line 63: | ||
if (this.cyclesUntilAnimUpdate < 0) { |
if (this.cyclesUntilAnimUpdate < 0) { |
||
this.cyclesUntilAnimUpdate = 2 |
this.cyclesUntilAnimUpdate = 2 |
||
this.animationFrame = (animationFrame + 1) % 4 |
this.animationFrame = (this.animationFrame + 1) % 4 |
||
this.sprite.tileData.lowBytes = |
this.sprite.tileData.lowBytes = animation[this.animationFrame] |
||
this.sprite.tileData.bank = 0x8F |
this.sprite.tileData.bank = 0x8F |
||
this.sprite.type = |
this.sprite.type = spriteTypes[this.animationFrame % 4] |
||
} |
} |
||
} |
} |
||
Line 104: | Line 103: | ||
weaponType = spriteType & 0x7FFF |
weaponType = spriteType & 0x7FFF |
||
if (weaponType == FIRE_EXTINGUISHER |
if (weaponType == FIRE_EXTINGUISHER || |
||
weaponType == SODA_POP_CANS |
weaponType == SODA_POP_CANS || |
||
weaponType == SQUIRT_GUN |
weaponType == SQUIRT_GUN || |
||
weaponType == 0x65) { |
weaponType == 0x65) { |
||
this.health -= 1 |
this.health -= 1 |
||
Line 116: | Line 115: | ||
return false |
return false |
||
} |
} |
||
{{Pseudocode footer}} |
|||
[[Category:One-shot monster]] |
[[Category:One-shot monster]] |
Latest revision as of 18:55, 17 August 2024
Monster data | |
---|---|
![]() | |
HP | 6 |
Points | 0 |
Special | {{{special}}} |
Resists | {{{resists}}} |
Weak to | {{{weak_to}}} |
Entity data | |
---|---|
Entity pointer | $82:F25D |
Fire is a one-shot monster.
Behavior[edit]
Fire does not move, and thus only damages players who walk into it. It starts with 6 HP and takes one damage from each of fire extinguisher, pop cans, and squirt gun. Ironically, it also takes damage from flamethrower, since it shares the same sprite type as pop cans. It will also take damage from the unused sprite type 0x65. If the fire goes off screen, then the entity is deleted and will be created again when it comes back on screen. This will reset the fire's HP since the entity is recreated.
Fire has 4 different animation frames, and there are 6 frames between each one. During the first animation frame of each cycle, the fire is set to sprite type 2, which will allow the player to walk through it and not be damaged. The rest of the time, it is set to sprite type 3.
RAM map[edit]
Entity arguments[edit]
Address | Length | Type | Name | Description |
---|---|---|---|---|
$00 | 2 | int16 | x | X position |
$02 | 2 | int16 | y | Y position |
$04 | 2 | uint16 | extra | Extra data (unused) |
$06 | 2 | uint16 | index | Victim/one-shot monster index |
Entity memory[edit]
Address | Length | Type | Name | Description |
---|---|---|---|---|
$08 | 2 | pointer16 | sprite | Pointer to sprite |
$0A | 2 | uint16 | animationFrame | Current animation frame |
$0C | 2 | int16 0-based | cyclesUntilAnimUpdate | Number of 2 frame cycles until next animation frame |
$0E | 2 | unused | Unused | |
$10 | 2 | int16 0-based | health | Health |
$12 | 2 | int16 | x | X position |
$14 | 2 | int16 | y | Y position |
$16 | 2 | sprite type | collidedSpriteType | Type of sprite collided with |
Pseudocode
main() { $7E:00DE += 8 init() this.health = 5 setCollisionHandler(collisionHandler) while (this.collidedSpriteType == 0 || (this.collidedSpriteType != OFF_SCREEN && this.health >= 0)) { this.collidedSpriteType = 0 waitFrames(2) this.cyclesUntilAnimUpdate -= 1 if (this.cyclesUntilAnimUpdate < 0) { this.cyclesUntilAnimUpdate = 2 this.animationFrame = (this.animationFrame + 1) % 4 this.sprite.tileData.lowBytes = animation[this.animationFrame] this.sprite.tileData.bank = 0x8F this.sprite.type = spriteTypes[this.animationFrame % 4] } } if (this.collidedSpriteType != OFF_SCREEN && args.index != 0) { removeOneShotEntity(args.index) } $7E:00DE -= 8 while ($7E:00DE < 0) { } deleteSprite(this.sprite) } animation = { 0xD526, 0xD537, 0xD548, 0xD559 } spriteTypes = { NO_DAMAGE_MONSTER, MONSTER, MONSTER, MONSTER } init() { this.sprite = createSprite() this.sprite.x = args.x this.x = args.x this.sprite.z = 0 this.sprite.y = args.y this.y = args.y this.sprite.tileData = $8F:D526 this.sprite.entity = currentEntity this.sprite.type = MONSTER this.sprite.visible = true this.animationFrame = 0 this.collidedSpriteType = 0 this.cyclesUntilAnimUpdate = 2 } collisionHandler(spriteType) { this.collidedSpriteType = spriteType weaponType = spriteType & 0x7FFF if (weaponType == FIRE_EXTINGUISHER || weaponType == SODA_POP_CANS || weaponType == SQUIRT_GUN || weaponType == 0x65) { this.health -= 1 return true } if (weaponType == OFF_SCREEN) { return true } return false }