Martian: Difference between revisions
Content deleted Content added
Piranhaplant (talk | contribs) No edit summary |
Piranhaplant (talk | contribs) No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
=== Normal martian === |
=== Normal martian === |
||
[[File:MartianAreas.png|thumb|256px|Normal martian behavior areas.<br />'''Red:''' |
[[File:MartianAreas.png|thumb|256px|Normal martian behavior areas.<br />'''Red:''' Move 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. |
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: | Line 19: | ||
** If none of the above is true and there is no player within 207 pixels on a single axis, then despawn. |
** 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. |
* Move in the current direction at a speed of 1.5 px/frame. |
||
⚫ | |||
=== Top of screen martian === |
=== Top of screen martian === |
||
Line 38: | Line 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 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. |
** 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. |
||
⚫ | |||
{{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:Respawning monster]] |
||
[[Category:Monster]] |
|||
[[Category:Entity]] |
Revision as of 18:07, 22 June 2024
Monster data | |
---|---|
HP | 1 |
Points | 200 |
Special | {{{special}}} |
Resists | {{{resists}}} |
Weak to | {{{weak_to}}} |
Entity data | |
---|---|
Entity pointer | $81:99DF (normal) $81:9A3E (top of screen) |
The martian is a respawning monster. There are two different types of martians: normal and top of screen.
Behavior
Normal martian
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.
- Every frame, attempt to shoot at a player or victim if there is one within 8 pixels of the martian on a single axis. Every 61 attempts, a shot will actually be fired.
- When a shot is fired, stand in place for 12 frames.
- Every 61 frames (about once per second) update the movement direction:
- If the nearest target is less than 60 pixels away, move away from the target.
- If the nearest target is between 60 and 79 pixels away, move in the direction of the shortest distance to line up with the target on a single axis.
- If the nearest target is between 80 and 223 pixels away, move towards the target.
- 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.
Top of screen martian
Top of screen martians will move side to side above a target, trying to maintain about 108 pixels of space vertically. Upon spawning, they will set their Y position to 8 pixels below the top of the screen.
- If there is no player within 207 pixels on a single axis, despawn.
- If there is a player above the martian, convert into a normal martian.
- Every frame, attempt to shoot at a player or victim if there is one within 8 pixels of the martian on a single axis. Every 61 attempts, a shot will actually be fired.
- If a shot was not attempted in this way, randomly attempt to shoot down with probability 30/256 (about 11.72%).
- When a shot is fired, stand in place for 12 frames.
- Every 33 frames, update horizontal movement direction:
- If the nearest target is less than 20 pixels away, move away from the target.
- If the nearest target is 20 pixels or more away, move towards the target.
- Move based on the current horizontal movement direction:
- If the nearest target is less than 96 pixels below the martian, move up-left or up-right at a speed of 3 px/frame.
- 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 will not attempt to shoot at them.
Bugs
- Freezing or 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
Address | Length | Type | Description |
---|---|---|---|
$00 | 2 | int16 | X position |
$02 | 2 | int16 | Y position |
Entity memory
Address | Length | 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) |
$7E | 2 | unused | Value is set but not used |