Fire: Difference between revisions
Piranhaplant (talk | contribs) No edit summary |
Piranhaplant (talk | contribs) No edit summary |
||
Line 15: | Line 15: | ||
{| class="wikitable" |
{| class="wikitable" |
||
|- |
|- |
||
! Address !! Length !! [[Data types|Type]] !! Description |
! Address !! Length !! [[Data types|Type]] !! Name !! Description |
||
|- |
|- |
||
| $00 || 2 || int16 || X position |
| $00 || 2 || int16 || x || X position |
||
|- |
|- |
||
| $02 || 2 || int16 || Y position |
| $02 || 2 || int16 || y || Y position |
||
|- |
|- |
||
| $04 || 2 || uint16 || Extra data (unused) |
| $04 || 2 || uint16 || extra || Extra data (unused) |
||
|- |
|- |
||
| $06 || 2 || uint16 || Victim/one-shot monster index |
| $06 || 2 || uint16 || index || Victim/one-shot monster index |
||
|} |
|} |
||
Line 30: | Line 30: | ||
{| class="wikitable" |
{| class="wikitable" |
||
|- |
|- |
||
! Address !! Length !! [[Data types|Type]] !! Description |
! Address !! Length !! [[Data types|Type]] !! Name !! Description |
||
|- |
|- |
||
| $08 || 2 || pointer16 || Pointer to sprite |
| $08 || 2 || pointer16 || sprite || Pointer to sprite |
||
|- |
|- |
||
| $0A || 2 || uint16 || Current animation frame |
| $0A || 2 || uint16 || animationFrame || Current animation frame |
||
|- |
|- |
||
| $0C || 2 || int16 0-based || Number of 2 frame cycles until next animation frame |
| $0C || 2 || int16 0-based || cyclesUntilAnimUpdate || Number of 2 frame cycles until next animation frame |
||
|- |
|- |
||
| $0E || 2 || unused || Unused |
| $0E || 2 || unused || || Unused |
||
|- |
|- |
||
| $10 || 2 || int16 0-based || Health |
| $10 || 2 || int16 0-based || health || Health |
||
|- |
|- |
||
| $12 || 2 || int16 || X position |
| $12 || 2 || int16 || x || X position |
||
|- |
|- |
||
| $14 || 2 || int16 || Y position |
| $14 || 2 || int16 || y || Y position |
||
|- |
|- |
||
| $16 || 2 || sprite type || Type of sprite collided with |
| $16 || 2 || sprite type || collidedSpriteType || Type of sprite collided with |
||
|} |
|} |
||
== Psuedocode == |
|||
main() { |
|||
{{RAM name|$7E:00DE}} += 8 |
|||
this.init() |
|||
this.health = 5 |
|||
{{ROM name|$80:8475}}(this.collisionHandler) |
|||
while (this.collidedSpriteType == 0 or (this.collidedSpriteType != OFF_SCREEN and this.health >= 0)) { |
|||
this.collidedSpriteType = 0 |
|||
{{ROM name|$80:8353}}(2) |
|||
this.cyclesUntilAnimUpdate -= 1 |
|||
if (this.cyclesUntilAnimUpdate < 0) { |
|||
this.cyclesUntilAnimUpdate = 2 |
|||
this.animationFrame = (animationFrame + 1) % 4 |
|||
this.sprite.tileData.lowBytes = this.animation[this.animationFrame] |
|||
this.sprite.tileData.bank = 0x8F |
|||
this.sprite.type = spriteTypes[this.animationFrame & 3] |
|||
} |
|||
} |
|||
if (this.collidedSpriteType != OFF_SCREEN && args.index != 0) { |
|||
{{ROM name|$81:8191}}(args.index) |
|||
} |
|||
{{RAM name|$7E:00DE}} -= 8 |
|||
while ({{RAM name|$7E:00DE}} < 0) { } |
|||
{{ROM name|$80:BE41}}(this.sprite) |
|||
} |
|||
animation = { 0xD526, 0xD537, 0xD548, 0xD559 } |
|||
spriteTypes = { 2, 3, 3, 3 } |
|||
init() { |
|||
this.sprite = {{ROM name|$80:BE0C}}() |
|||
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 = {{RAM name|$7E:0008}} |
|||
this.sprite.type = 3 |
|||
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 or |
|||
weaponType == SODA_POP_CANS or |
|||
weaponType == SQUIRT_GUN or |
|||
weaponType == 0x65) { |
|||
this.health -= 1 |
|||
return true |
|||
} |
|||
if (weaponType == OFF_SCREEN) { |
|||
return true |
|||
} |
|||
return false |
|||
} |
|||
[[Category:One-shot monster]] |
[[Category:One-shot monster]] |
Revision as of 22:53, 22 June 2024
Monster data | |
---|---|
![]() | |
HP | 6 |
Points | 0 |
Entity data | |
---|---|
Entity pointer | $82:F25D |
Fire is a one-shot monster.
Behavior
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
Entity arguments
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
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 |
Psuedocode
main() { $7E:00DE += 8 this.init() this.health = 5 setCollisionHandler(this.collisionHandler) while (this.collidedSpriteType == 0 or (this.collidedSpriteType != OFF_SCREEN and this.health >= 0)) { this.collidedSpriteType = 0 waitFrames(2) this.cyclesUntilAnimUpdate -= 1 if (this.cyclesUntilAnimUpdate < 0) { this.cyclesUntilAnimUpdate = 2 this.animationFrame = (animationFrame + 1) % 4 this.sprite.tileData.lowBytes = this.animation[this.animationFrame] this.sprite.tileData.bank = 0x8F this.sprite.type = spriteTypes[this.animationFrame & 3] } } 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 = { 2, 3, 3, 3 } 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 = 3 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 or weaponType == SODA_POP_CANS or weaponType == SQUIRT_GUN or weaponType == 0x65) { this.health -= 1 return true } if (weaponType == OFF_SCREEN) { return true } return false }