11use super :: { game_lib, hook} ;
22use crate :: pnp;
3+ use core:: num:: { NonZeroU32 , NonZeroU8 } ;
34use pkm_rs:: { Pk7 , PokeCrypto } ;
45
56struct Gen7Addresses {
@@ -21,6 +22,7 @@ struct Gen7Addresses {
2122 id : u32 ,
2223 box_cursor : u32 ,
2324 npc_list : u32 ,
25+ npc_head_blinking_offset : u32 ,
2426}
2527
2628const SM_ADDRESSES : Gen7Addresses = Gen7Addresses {
@@ -41,7 +43,8 @@ const SM_ADDRESSES: Gen7Addresses = Gen7Addresses {
4143 shiny_charm : 0x330d5930 ,
4244 id : 0x330d67d0 ,
4345 box_cursor : 0x30000298 ,
44- npc_list : 0x341977b8 ,
46+ npc_list : 0x341977c4 ,
47+ npc_head_blinking_offset : 0x2f4 ,
4548} ;
4649
4750const USUM_ADDRESSES : Gen7Addresses = Gen7Addresses {
@@ -63,6 +66,7 @@ const USUM_ADDRESSES: Gen7Addresses = Gen7Addresses {
6366 id : 0x33012818 ,
6467 box_cursor : 0x30000298 ,
6568 npc_list : 0x33f81438 ,
69+ npc_head_blinking_offset : 0x2fc ,
6670} ;
6771
6872pub struct Gen7Reader {
@@ -197,7 +201,20 @@ impl Gen7Reader {
197201 let can_blink = pnp:: read :: < u32 > ( npc + 0xe8 ) == 0 ;
198202
199203 if is_present && can_blink {
200- npc_count += 1 ;
204+ let blink_type =
205+ NonZeroU32 :: new ( pnp:: read :: < u32 > ( npc + self . addrs . npc_head_blinking_offset ) )
206+ . and_then ( |struct_ptr| {
207+ NonZeroU32 :: new ( pnp:: read :: < u32 > ( struct_ptr. get ( ) + 0x114 ) )
208+ } )
209+ . and_then ( |struct_ptr| {
210+ NonZeroU8 :: new ( pnp:: read :: < u8 > ( struct_ptr. get ( ) + 0xde ) )
211+ } )
212+ . map ( |blink_setting| blink_setting. get ( ) )
213+ . unwrap_or_default ( ) ;
214+ let is_blinking = blink_type == 1 || blink_type == 2 ;
215+ if is_blinking {
216+ npc_count += 1 ;
217+ }
201218 }
202219 }
203220
0 commit comments