## Combat
-[ ] Unit is selected based on the unit initiative queue
+[x] Unit is selected based on the unit initiative queue
[ ] A unit may skip its turn (moved to end of queue)
[x] Units have a move counter
-[ ] Move counter should be 1 for most units
+[x] Move counter should be 1 for most units
[x] Display moves in UI for selected units
[x] Each action consumes moves
[x] Units are moved one tile at a time
[ ] When a unit moves away from an adjacent melee unit it can attack
[x] Units are selected in a queue of initiative
[x] Once the queue is empty it is reset
-[ ] Units use state machines to update
-[ ] Each unit's start state is a polling state
-[ ] The polling state can either be player input or CPU input
-[ ] Mark the current active unit with a cursor
-[ ] When starting an encounter the player can place all hero units and troops based on initiative
-[ ] The player can collect up to 5 initiative points
-[ ] Initiative can be spent on deployment or special moves
-[ ] Rework all max stats to be calculated (e.g. hp max is calculated based on endurance)
+[x] Units use state machines to update
+[x] Each unit's start state is a polling state
+[x] The polling state can either be player input or CPU input
+[x] Mark the current active unit with a cursor
+[x] When starting an encounter the player can place all hero units and troops based on initiative
+[x] Rework all max stats to be calculated (e.g. hp max is calculated based on endurance)
## Map
[x] A map may reduce the playfield by making out of bounds tiles walls
[x] The camera always centers on the current unit
[x] All units are always visible
-[ ] Tiles can be impassible, walls or walkable
+[x] Tiles can be impassible, walls or walkable
[ ] Tiles may cost extra movement to pass
## Units
[ ] Only center camera on player
### Dice display
-[ ] When a unit fails to take initiative display dice roll and focus on unit with camera
-[ ] Update dice display for n frames until timer is 0
-[ ] Then continue the game
-[ ] Rework dice display to be a per-unit runtime only flag
-[ ] Dice display per unit should update in draw if timer is not 0
+[x] Update dice display for n frames until timer is 0
+[x] Rework dice display to be a per-unit runtime only flag
+[x] Dice display per unit should update in draw if timer is not 0
## Randomness
; stats struct
- ; with current and max
- ; used for hp, mp, fatigue, moves
- ; all other stats only have a max value
- ; and their real value is calculated before use
+ ; this tracks the current value. most real values
+ ; are calculated
; e.g. stat_calc_str with actor as input
- ; used for stats that can change and reset
- ; regularly
-.se 0
-.de stat_cur, 1
-.de stat_max, 1
-.de stat_size, 0
-
- ; lite stat with max value only
- ; used for stats that are not intended to
- ; decrease regularly
- ; stat lite's real value is
- ; calculated using an actor
- ; and stat_calc_nnn calls
-#define stat_lite_size 1
+#define stat_size 1
; status effect
.se 0
.de act_hp, stat_size
.de act_mp, stat_size
.de act_fatigue, stat_size
-.de act_ac, stat_lite_size
+.de act_ac, stat_size
.de act_moves, stat_size ; moves for each turn
-.de act_init, stat_lite_size ; initiative value
; stats2
-.de act_str, stat_lite_size
-.de act_int, stat_lite_size
-.de act_dex, stat_lite_size
-.de act_luck, stat_lite_size
-.de act_will, stat_lite_size
-.de act_charisma, stat_lite_size
-.de act_endurance, stat_lite_size
-.de act_speed, stat_lite_size
+.de act_str, stat_size
+.de act_int, stat_size
+.de act_dex, stat_size
+.de act_luck, stat_size
+.de act_will, stat_size
+.de act_charisma, stat_size
+.de act_endurance, stat_size
+.de act_speed, stat_size
; attributes
; describes skills
; stores items, for all actors but player
; there are 4 inventory slots.
; if the actor is type player a special inventory
- ; used instead
+ ; used instead
+ ; call unit_get_inventory to get a ptr and length
; equipment
; stores all items equiped
; $4 fatigue points
; $5 armor
; $6 moves
- ; $7 initiative
#macro act_stat_def1
.db $1 ; level
- .db $2, $2 ; hp hp max
- .db $3, $3 ; mp mp max
- .db $4, $4 ; fatigue fatigue max
+ .db $2 ; hp hp max
+ .db $3 ; mp mp max
+ .db $4 ; fatigue fatigue max
.db $5 ; ac
- .db $6, $6 ; moves moves max
- .db $7 ; initiative
+ .db $6 ; moves moves max
#endmacro
; $1 str
; a: str value
stat_calc_str:
ret
+
+ ; calculates the current actor's initiative
+ ; inputs:
+ ; de: actor
+ ; returns:
+ ; a: init
+stat_calc_init:
+ ; TODO
+ ; for now we just hard-code
+ ld a, 1
+ ret
+
+ ; calculates the current actor's max moves
+ ; inputs:
+ ; de: actor
+ ; retrns:
+ ; a: moves max
+stat_calc_moves_max:
+ ; TODO
+ ; for now we just hard-code
+ ld a, 1
+ ret
push hl
; check if this actor is better
; than the previous actor
- ld de, act_init
- add hl, de
ld a, [unit_next_best_init]
cp a, 0 ; if prev best is 0 proceed anyway
ld d, a ; d = previous best init
- ld a, [hl] ; a = init of new actor
+
+ pop de ; de = actor
+ push de ; store again for later
+ call stat_calc_init ; a = init of new actor
jr z, @first_hit REL ; on first match
; check if this init value is better
pop hl
push hl
- ; this unit is better
- ; but it can fail an initiative roll
- push af
- call roll_d16
- ld d, a ; d = roll value
- pop af ; a = init value
- cp a, d
- call nc, unit_dice_display_set_hl
- jr nc, @skip REL ; d < a
-
ld [unit_next_best_init], a
ld a, l
ld b, UNITS_MAX
ld hl, p0_units
@loop:
- push hl
- ld de, act_moves+1
- add hl, de ; hl = act_moves_max
+ push hl
- ld a, [hl]
- dec hl ; hl = current moves
+ pop de
+ push de
+ call stat_calc_moves_max
+
+ ld de, act_moves
+ add hl, de ; hl = current moves
ld [hl], a ; moves are now reset
pop hl
unit_demo_1:
st_def 0x00, unit_demo_1_init, st_unit_idle
act_def ACT_T_DEMO_1, 0, 2, 2, 0
- act_stat_def1 1, 1, 1, 1, 1, 3, 3
+ act_stat_def1 1, 1, 1, 1, 1, 1
act_stat_def2 1, 1, 1, 1, 1, 1, 1, 1
act_attr_def_empty
act_inventory_empty
unit_demo_2:
st_def 0x00, unit_demo_1_init, st_unit_idle
act_def ACT_T_DEMO_1, 0, 3, 3, 0
- act_stat_def1 1, 1, 1, 1, 1, 0, 3
+ act_stat_def1 1, 1, 1, 1, 1, 1
act_stat_def2 1, 1, 1, 1, 1, 1, 1, 1
act_attr_def_empty
act_inventory_empty
unit_demo_3:
st_def 0x00, unit_demo_1_init, st_unit_idle
act_def ACT_T_DEMO_1, 0, 4, 4, 0
- act_stat_def1 1, 1, 1, 1, 1, 4, 5
+ act_stat_def1 1, 1, 1, 1, 1, 1
act_stat_def2 1, 1, 1, 1, 1, 1, 1, 1
act_attr_def_empty
act_inventory_empty