Martian: Difference between revisions

2,419 bytes added ,  22 days ago
no edit summary
No edit summary
No edit summary
(4 intermediate revisions by the same user not shown)
Line 7:
=== Normal martian ===
 
[[File:MartianAreas.png|thumb|256px|Normal martian behavior areas.<br />'''Red:''' moveMove away<br />'''Yellow:''' Line up<br />'''Pink:''' Move towards<br />'''Blue:''' Keep previous direction<br />'''Outside all colors:''' Despawn<br />Light area in center is the size of the screen]]
 
Normal martians will try to stay about 70 pixels away from a target, while lining themselves up for a shot on the target. However, the relatively large amount of time between direction updates means that they generally just dart around diagonally in the vicinity of the target.
Line 19:
** If none of the above is true and there is no player within 207 pixels on a single axis, then despawn.
* Move in the current direction at a speed of 1.5 px/frame.
 
Note that martians will target [[decoys]], but they will not attempt to shoot at them.
 
=== Top of screen martian ===
Line 38 ⟶ 36:
** If the nearest target is between 96 and 119 pixels below the martian, move left or right at a speed of 1.5 px/frame.
** If the nearest target is 120 pixels or more below the martian, move down-left or down-right at a speed of 3 px/frame.
 
Note that both types of martians will target [[decoys]], but they will not attempt to shoot at them.
 
{{BPMN_embed|BPMN:Martian state diagram}}
 
== Bugs ==
 
* [[Fire extinguisher|Freezing]] or [[Bubble gun|bubbling]] a martian, then letting it despawn will count as killing it. This is because the logic that determines if a martian was killed or not checks if it was ever hit by a weapon, not if it lost all its HP.
* Top of screen martians check if their updated spawn location is solid, and immediately despawn if it is. However, this check only looks for tiles that are solid to players, not solid to monsters. So, if the martian starts on a tile that is solid to monsters, but not players, it will be allowed to spawn, but will be unable to move.
 
== RAM map ==
 
=== Entity arguments ===
 
{| class="wikitable"
|-
! Address !! Length !! [[Data types|Type]] !! Description
|-
| $00 || 2 || int16 || X position
|-
| $02 || 2 || int16 || Y position
|}
 
=== Entity memory ===
 
{| class="wikitable"
|-
! Address !! Length !! [[Data types|Type]] !! Description
|-
| $08 || 2 || pointer16 || Pointer to sprite
|-
| $0A || 2 || pointer16 || Current state subroutine pointer
|-
| $0C || 2 || int16 || X position
|-
| $0E || 2 || int16 || Y position
|-
| $10 || 2 || int16 || New X position
|-
| $12 || 2 || int16 || New Y position
|-
| $14 || 2 || pointer16 || Pointer to sprite table
|-
| $16 || 2 || pointer16 || Pointer to target sprite
|-
| $18 || 2 || uint16 || Distance to target
|-
| $1A || 2 || unused || Unused
|-
| $1C || 2 || int16 || Target sprite X offset from martian
|-
| $1E || 2 || int16 || Target sprite Y offset from martian
|-
| $20 || 2 || uint16 || Target sprite X distance from martian (absolute value of $1C)
|-
| $22 || 2 || optional pointer16 || 'Shoot' subroutine pointer
|-
| $24 || 2 || uint16 0-based || Number of shot attempts until shot will be fired
|-
| $26 || 2 || boolean || Dead
|-
| $28 || 2 || direction x2 || Current direction
|-
| $2A || 2 || int16 0-based || Number of frames until direction update (normal state only)
|-
| $2C || 2 || uint16 || Current animation frame
|-
| $2E || 2 || int16 0-based || Number of frames until next animation frame
|-
| $30 || 2 || sprite type || Type of weapon shot sprite collided with
|-
| $32 || 2 || int16 0-based || Health
|-
| $34 || 2 || int16 0-based || Number of frames until target side update (top of screen only)
|-
| $36 || 2 || direction x2 || Target side (left or right) (top of screen only)
|- class="breakrow"
| $7E || 2 || unused || Value is set but not used
|}
 
[[Category:Respawning monster]]
[[Category:Monster]]
[[Category:Entity]]