document bullet flags

This commit is contained in:
Alula 2022-01-08 15:20:14 +01:00
parent 3e6adbe3c1
commit 27b439f2cb
No known key found for this signature in database
GPG Key ID: 3E00485503A1D8BA
4 changed files with 63 additions and 58 deletions

View File

@ -2,9 +2,9 @@ use std::fmt;
use lazy_static::lazy_static;
use num_traits::{abs, Num};
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use serde::de::{SeqAccess, Visitor};
use serde::ser::SerializeTupleStruct;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use crate::bitfield;
use crate::texture_set::G_MAG;
@ -131,16 +131,21 @@ bitfield! {
bitfield! {
#[derive(Clone, Copy)]
#[repr(C)]
pub struct BulletFlag(u16);
pub struct BulletFlag(u8);
impl Debug;
pub flag_x01, set_flag_x01: 0; // 0x01
pub flag_x02, set_flag_x02: 1; // 0x02
pub no_collision_checks, set_no_collision_checks: 2; // 0x04
pub bounce_from_walls, set_bounce_from_walls: 3; // 0x08
pub flag_x10, set_flag_x10: 4; // 0x10
pub flag_x20, set_flag_x20: 5; // 0x20
pub can_destroy_snack, set_can_destroy_snack: 6; // 0x40
pub flag_x80, set_flag_x80: 7; // 0x80
pub flag_x01, set_flag_x01: 0; // 0x01, nowhere in code?
pub flag_x02, set_flag_x02: 1; // 0x02, nowhere in code?
/// Corresponds to flag & 0x04. If set, bullet will pass through blocks.
pub no_collision_checks, set_no_collision_checks: 2;
/// Corresponds to flag & 0x08. IF set, bullet will bounce off walls.
pub bounce_from_walls, set_bounce_from_walls: 3;
/// Corresponds to flag & 0x10. IF set, bullet will not produce projectile dissipation effect when it hits a NPC or boss.
pub no_proj_dissipation, set_no_proj_dissipation: 4;
/// Corresponds to flag & 0x20. If set, performs checks in block colission check procedure. Kills the bullet if flag 0x40 isn't set.
pub check_block_hit, set_check_block_hit: 5;
/// Corresponds to flag & 0x40. If set, bullet will destroy snack blocks on hit.
pub can_destroy_snack, set_can_destroy_snack: 6;
pub flag_x80, set_flag_x80: 7; // 0x80, nowhere in code?
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

View File

@ -501,7 +501,7 @@ impl EngineConstants {
damage: 4,
life: 1,
lifetime: 20,
flags: BulletFlag(36),
flags: BulletFlag(0x24),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 2,
@ -512,7 +512,7 @@ impl EngineConstants {
damage: 6,
life: 1,
lifetime: 23,
flags: BulletFlag(36),
flags: BulletFlag(0x24),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 2,
@ -523,7 +523,7 @@ impl EngineConstants {
damage: 8,
life: 1,
lifetime: 30,
flags: BulletFlag(36),
flags: BulletFlag(0x24),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 2,
@ -535,7 +535,7 @@ impl EngineConstants {
damage: 1,
life: 1,
lifetime: 8,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 6,
enemy_hit_height: 6,
block_hit_width: 2,
@ -546,7 +546,7 @@ impl EngineConstants {
damage: 2,
life: 1,
lifetime: 12,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 6,
enemy_hit_height: 6,
block_hit_width: 2,
@ -557,7 +557,7 @@ impl EngineConstants {
damage: 4,
life: 1,
lifetime: 16,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 6,
enemy_hit_height: 6,
block_hit_width: 2,
@ -569,7 +569,7 @@ impl EngineConstants {
damage: 2,
life: 2,
lifetime: 100,
flags: BulletFlag(8),
flags: BulletFlag(0x08),
enemy_hit_width: 8,
enemy_hit_height: 16,
block_hit_width: 4,
@ -580,7 +580,7 @@ impl EngineConstants {
damage: 3,
life: 2,
lifetime: 100,
flags: BulletFlag(8),
flags: BulletFlag(0x08),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 4,
@ -591,7 +591,7 @@ impl EngineConstants {
damage: 3,
life: 2,
lifetime: 100,
flags: BulletFlag(8),
flags: BulletFlag(0x08),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 4,
@ -603,7 +603,7 @@ impl EngineConstants {
damage: 2,
life: 1,
lifetime: 20,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 2,
enemy_hit_height: 2,
block_hit_width: 2,
@ -614,7 +614,7 @@ impl EngineConstants {
damage: 4,
life: 1,
lifetime: 20,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 2,
enemy_hit_height: 2,
block_hit_width: 2,
@ -625,7 +625,7 @@ impl EngineConstants {
damage: 6,
life: 1,
lifetime: 20,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 2,
enemy_hit_height: 2,
block_hit_width: 2,
@ -637,7 +637,7 @@ impl EngineConstants {
damage: 0,
life: 10,
lifetime: 50,
flags: BulletFlag(40),
flags: BulletFlag(0x28),
enemy_hit_width: 2,
enemy_hit_height: 2,
block_hit_width: 2,
@ -648,7 +648,7 @@ impl EngineConstants {
damage: 0,
life: 10,
lifetime: 70,
flags: BulletFlag(40),
flags: BulletFlag(0x28),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 4,
@ -659,7 +659,7 @@ impl EngineConstants {
damage: 0,
life: 10,
lifetime: 90,
flags: BulletFlag(40),
flags: BulletFlag(0x28),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 0,
@ -671,7 +671,7 @@ impl EngineConstants {
damage: 1,
life: 100,
lifetime: 100,
flags: BulletFlag(20),
flags: BulletFlag(0x14),
enemy_hit_width: 16,
enemy_hit_height: 16,
block_hit_width: 0,
@ -682,7 +682,7 @@ impl EngineConstants {
damage: 1,
life: 100,
lifetime: 100,
flags: BulletFlag(20),
flags: BulletFlag(0x14),
enemy_hit_width: 16,
enemy_hit_height: 16,
block_hit_width: 0,
@ -693,7 +693,7 @@ impl EngineConstants {
damage: 1,
life: 100,
lifetime: 100,
flags: BulletFlag(20),
flags: BulletFlag(0x14),
enemy_hit_width: 16,
enemy_hit_height: 16,
block_hit_width: 0,
@ -705,7 +705,7 @@ impl EngineConstants {
damage: 1,
life: 1,
lifetime: 20,
flags: BulletFlag(8),
flags: BulletFlag(0x08),
enemy_hit_width: 2,
enemy_hit_height: 2,
block_hit_width: 2,
@ -716,7 +716,7 @@ impl EngineConstants {
damage: 2,
life: 1,
lifetime: 20,
flags: BulletFlag(8),
flags: BulletFlag(0x08),
enemy_hit_width: 2,
enemy_hit_height: 2,
block_hit_width: 2,
@ -727,7 +727,7 @@ impl EngineConstants {
damage: 2,
life: 1,
lifetime: 20,
flags: BulletFlag(8),
flags: BulletFlag(0x08),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 4,
@ -739,7 +739,7 @@ impl EngineConstants {
damage: 3,
life: 1,
lifetime: 32,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 2,
enemy_hit_height: 2,
block_hit_width: 2,
@ -751,7 +751,7 @@ impl EngineConstants {
damage: 0,
life: 100,
lifetime: 0,
flags: BulletFlag(36),
flags: BulletFlag(0x24),
enemy_hit_width: 8,
enemy_hit_height: 8,
block_hit_width: 8,
@ -763,7 +763,7 @@ impl EngineConstants {
damage: 127,
life: 1,
lifetime: 2,
flags: BulletFlag(4),
flags: BulletFlag(0x04),
enemy_hit_width: 8,
enemy_hit_height: 4,
block_hit_width: 8,
@ -775,7 +775,7 @@ impl EngineConstants {
damage: 15,
life: 1,
lifetime: 30,
flags: BulletFlag(36),
flags: BulletFlag(0x24),
enemy_hit_width: 8,
enemy_hit_height: 8,
block_hit_width: 4,
@ -786,7 +786,7 @@ impl EngineConstants {
damage: 6,
life: 3,
lifetime: 18,
flags: BulletFlag(36),
flags: BulletFlag(0x24),
enemy_hit_width: 10,
enemy_hit_height: 10,
block_hit_width: 4,
@ -797,7 +797,7 @@ impl EngineConstants {
damage: 1,
life: 100,
lifetime: 30,
flags: BulletFlag(36),
flags: BulletFlag(0x24),
enemy_hit_width: 6,
enemy_hit_height: 6,
block_hit_width: 4,
@ -809,7 +809,7 @@ impl EngineConstants {
damage: 0,
life: 10,
lifetime: 30,
flags: BulletFlag(40),
flags: BulletFlag(0x28),
enemy_hit_width: 2,
enemy_hit_height: 2,
block_hit_width: 2,
@ -820,7 +820,7 @@ impl EngineConstants {
damage: 0,
life: 10,
lifetime: 40,
flags: BulletFlag(40),
flags: BulletFlag(0x28),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 4,
@ -831,7 +831,7 @@ impl EngineConstants {
damage: 0,
life: 10,
lifetime: 40,
flags: BulletFlag(40),
flags: BulletFlag(0x28),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 0,
@ -843,7 +843,7 @@ impl EngineConstants {
damage: 2,
life: 100,
lifetime: 100,
flags: BulletFlag(20),
flags: BulletFlag(0x14),
enemy_hit_width: 12,
enemy_hit_height: 12,
block_hit_width: 0,
@ -854,7 +854,7 @@ impl EngineConstants {
damage: 2,
life: 100,
lifetime: 100,
flags: BulletFlag(20),
flags: BulletFlag(0x14),
enemy_hit_width: 12,
enemy_hit_height: 12,
block_hit_width: 0,
@ -865,7 +865,7 @@ impl EngineConstants {
damage: 2,
life: 100,
lifetime: 100,
flags: BulletFlag(20),
flags: BulletFlag(0x14),
enemy_hit_width: 12,
enemy_hit_height: 12,
block_hit_width: 0,
@ -877,7 +877,7 @@ impl EngineConstants {
damage: 4,
life: 4,
lifetime: 20,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 3,
@ -888,7 +888,7 @@ impl EngineConstants {
damage: 4,
life: 2,
lifetime: 20,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 2,
enemy_hit_height: 2,
block_hit_width: 2,
@ -899,7 +899,7 @@ impl EngineConstants {
damage: 1,
life: 1,
lifetime: 20,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 2,
enemy_hit_height: 2,
block_hit_width: 2,
@ -911,7 +911,7 @@ impl EngineConstants {
damage: 4,
life: 4,
lifetime: 30,
flags: BulletFlag(64),
flags: BulletFlag(0x40),
enemy_hit_width: 6,
enemy_hit_height: 6,
block_hit_width: 3,
@ -922,7 +922,7 @@ impl EngineConstants {
damage: 8,
life: 8,
lifetime: 30,
flags: BulletFlag(64),
flags: BulletFlag(0x40),
enemy_hit_width: 6,
enemy_hit_height: 6,
block_hit_width: 3,
@ -933,7 +933,7 @@ impl EngineConstants {
damage: 12,
life: 12,
lifetime: 30,
flags: BulletFlag(64),
flags: BulletFlag(0x40),
enemy_hit_width: 6,
enemy_hit_height: 6,
block_hit_width: 3,
@ -945,7 +945,7 @@ impl EngineConstants {
damage: 3,
life: 100,
lifetime: 30,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 6,
enemy_hit_height: 6,
block_hit_width: 3,
@ -956,7 +956,7 @@ impl EngineConstants {
damage: 6,
life: 100,
lifetime: 30,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 6,
enemy_hit_height: 6,
block_hit_width: 3,
@ -967,7 +967,7 @@ impl EngineConstants {
damage: 11,
life: 100,
lifetime: 30,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 6,
enemy_hit_height: 6,
block_hit_width: 3,
@ -979,7 +979,7 @@ impl EngineConstants {
damage: 4,
life: 4,
lifetime: 20,
flags: BulletFlag(32),
flags: BulletFlag(0x20),
enemy_hit_width: 4,
enemy_hit_height: 4,
block_hit_width: 3,
@ -991,7 +991,7 @@ impl EngineConstants {
damage: 0,
life: 4,
lifetime: 4,
flags: BulletFlag(4),
flags: BulletFlag(0x04),
enemy_hit_width: 0,
enemy_hit_height: 0,
block_hit_width: 0,
@ -1003,7 +1003,7 @@ impl EngineConstants {
damage: 1,
life: 1,
lifetime: 1,
flags: BulletFlag(36),
flags: BulletFlag(0x24),
enemy_hit_width: 1,
enemy_hit_height: 1,
block_hit_width: 1,

View File

@ -1050,7 +1050,7 @@ impl GameScene {
npc.popup.add_value(-bullet.damage);
}
}
} else if !bullet.weapon_flags.flag_x10()
} else if !bullet.weapon_flags.no_proj_dissipation()
&& bullet.btype != 13
&& bullet.btype != 14
&& bullet.btype != 15
@ -1160,7 +1160,7 @@ impl GameScene {
}
} else if [13, 14, 15, 28, 29, 30].contains(&bullet.btype) {
bullet.life = bullet.life.saturating_sub(1);
} else if !bullet.weapon_flags.flag_x10() {
} else if !bullet.weapon_flags.no_proj_dissipation() {
state.create_caret(bullet.x, bullet.y, CaretType::ProjectileDissipation, Direction::Right);
state.sound_manager.play_sfx(31);
bullet.life = 0;

View File

@ -1942,7 +1942,7 @@ impl PhysicalEntity for Bullet {
self.test_block_hit(state, x + ox, y + oy);
if self.flags.weapon_hit_block()
&& (self.weapon_flags.flag_x20() || self.weapon_flags.can_destroy_snack())
&& (self.weapon_flags.check_block_hit() || self.weapon_flags.can_destroy_snack())
{
if !self.weapon_flags.can_destroy_snack() {
self.cond.set_alive(false);