unit: Refactored act def macros to allow for more future stats
authorLukas Krickl <lukas@krickl.dev>
Sun, 25 May 2025 06:22:24 +0000 (08:22 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 25 May 2025 06:22:24 +0000 (08:22 +0200)
src/defs.s
src/macros.inc
src/unit.s

index 64567873aaf5414b9423788f0b77345b46e8379b..e146d1a126b700ae06dab38ce4f8baf7b3027aa1 100644 (file)
 
   ; actor struct 
   ; actor structs are basically just states
+  ; to define an actor the following macros must be used in order
+  ; st_def
+  ; act_def
+  ; act_stat_def
+  ; act_st_def
+  ; act_def_draw
 .se 0
   ; copy of current state
 .de act_state, st_size
 .de act_type, 1
 .de act_flags, 1
+
+.de act_pos_y, 1 ; y/x tile position
+.de act_pos_x, 1
+  ; custom parameter
+.de act_p0, 1
+
+
   ; stats
 .de act_hp, stat_size
 .de act_atk, stat_size
 .de act_moves, stat_size ; moves for each turn
 .de act_init, 1 ; initiative value
 
-.de act_pos_y, 1 ; y/x tile position
-.de act_pos_x, 1
-  ; custom parameter
-.de act_p0, 1
-
   ; actor states 
   ; used for state switching
   ; set to 0000 to disable the state
index d3be0a3a33815abf334ebe428d1bb1fd587ac7f6..296612f36b766a80e64c8c1d25ef7d4bb669506d 100644 (file)
   ; inputs:
   ;   $1 type
   ;   $2 flags
-  ;   $3 hp
-  ;   $4 atk
-  ;   $5 shiled
-  ;   $6 moves
-  ;   $7 initiative
-  ;   $8 y pos
-  ;   $9 x pos
-  ;   $10 custom p0 value
+  ;   $3 y pos
+  ;   $4 x pos
+  ;   $5 custom p0 value
 #macro act_def
   .db $1 ; type
   .db $2 ; flags
-  .db $3, $3 ; hp hp max
-  .db $4, $4 ; atk atk max
-  .db $5, $5 ; shiled shield max
-  .db $6, $6 ; moves moves max
-  .db $7 ; initiative
-  .db $8 ; y pos
-  .db $9 ; x pos
-  .db $10 ; p0
+  .db $3 ; y pos
+  .db $4 ; x pos
+  .db $5 ; p0
+#endmacro
+  
+  ; defines an actor's stats
+  ;   $1 hp
+  ;   $2 atk
+  ;   $3 shiled
+  ;   $4 moves
+  ;   $5 initiative
+#macro act_stat_def
+  .db $1, $1 ; hp hp max
+  .db $2, $2 ; atk atk max
+  .db $3, $3 ; shiled shield max
+  .db $4, $4 ; moves moves max
+  .db $5 ; initiative
 #endmacro
 
   ; defines actor state callbacks
index 195d5269eed0762a2253e78bab662d8500bd2e7c..551c6c06371a9327146bad8a1f5af63e9f66d7dc 100644 (file)
@@ -623,20 +623,23 @@ unit_resume_objs:
 
 unit_demo_1:
   st_def 0x00, unit_demo_1_init, st_unit_idle
-  act_def ACT_T_DEMO_1, 0, 1, 2, 3, 4, 6, 2, 2, 0 
+  act_def ACT_T_DEMO_1, 0, 2, 2, 0
+  act_stat_def 1, 2, 3, 4, 6 
   act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_idle
   act_def_draw unit_draw, 0x84, 0
 
 
 unit_demo_2:
   st_def 0x00, unit_demo_1_init, st_unit_idle
-  act_def ACT_T_DEMO_1, 0, 1, 2, 3, 1, 5, 3, 3, 0 
+  act_def ACT_T_DEMO_1, 0, 3, 3, 0 
+  act_stat_def 1, 2, 3, 1, 5  
   act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_idle
   act_def_draw unit_draw, 0x84, 0
 
 unit_demo_3:
   st_def 0x00, unit_demo_1_init, st_unit_idle
-  act_def ACT_T_DEMO_1, 0, 1, 2, 3, 0, 5, 4, 4, 0 
+  act_def ACT_T_DEMO_1, 0, 4, 4, 0 
+  act_stat_def 1, 2, 3, 0, 5 
   act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_idle
   act_def_draw unit_draw, 0x84, 0