From 1db15fe6b5d65cbf7aaa3e5f543e3291b6eb547d Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 16 Sep 2023 11:06:21 +0300 Subject: [PATCH] Improve bonus move Fixes #83 --- src/game/anim.cc | 2 +- src/game/combat.cc | 14 +++++++------- src/game/gmouse.cc | 2 +- src/game/intface.cc | 40 ++++++++++++++++++++++++++-------------- src/game/intface.h | 2 +- src/game/inventry.cc | 2 +- src/game/protinst.cc | 2 +- 7 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/game/anim.cc b/src/game/anim.cc index 2360063..08fc4ac 100644 --- a/src/game/anim.cc +++ b/src/game/anim.cc @@ -2652,7 +2652,7 @@ static void object_move(int index) } if (object == obj_dude) { - intface_update_move_points(obj_dude->data.critter.combat.ap); + intface_update_move_points(obj_dude->data.critter.combat.ap, combat_free_move); } v17 = (object->data.critter.combat.ap + combat_free_move) <= 0; diff --git a/src/game/combat.cc b/src/game/combat.cc index e6d250b..8a24868 100644 --- a/src/game/combat.cc +++ b/src/game/combat.cc @@ -1825,7 +1825,7 @@ static void combat_over() obj_dude->data.critter.combat.ap = stat_level(obj_dude, STAT_MAXIMUM_ACTION_POINTS); - intface_update_move_points(0); + intface_update_move_points(0, 0); if (game_user_wants_to_quit == 0) { combat_give_exps(combat_exps); @@ -2155,7 +2155,7 @@ static int combat_input() break; } - if (obj_dude->data.critter.combat.ap <= 0) { + if (obj_dude->data.critter.combat.ap <= 0 && combat_free_move <= 0) { break; } @@ -2235,7 +2235,7 @@ static int combat_turn(Object* a1, bool a2) kb_clear(); intface_update_ac(true); combat_free_move = 2 * perk_level(PERK_BONUS_MOVE); - intface_update_move_points(obj_dude->data.critter.combat.ap); + intface_update_move_points(obj_dude->data.critter.combat.ap, combat_free_move); } else { soundUpdate(); } @@ -2285,7 +2285,7 @@ static int combat_turn(Object* a1, bool a2) a1->data.critter.combat.damageLastTurn = 0; intface_end_buttons_disable(); combat_outline_off(); - intface_update_move_points(-1); + intface_update_move_points(-1, -1); intface_update_ac(true); combat_free_move = 0; return -1; @@ -2307,7 +2307,7 @@ static int combat_turn(Object* a1, bool a2) gmouse_set_cursor(MOUSE_CURSOR_WAIT_WATCH); intface_end_buttons_disable(); combat_outline_off(); - intface_update_move_points(-1); + intface_update_move_points(-1, -1); combat_turn_obj = NULL; intface_update_ac(true); combat_turn_obj = obj_dude; @@ -2537,7 +2537,7 @@ int combat_attack(Object* attacker, Object* defender, int hitMode, int hitLocati } if (attacker == obj_dude) { - intface_update_move_points(attacker->data.critter.combat.ap); + intface_update_move_points(attacker->data.critter.combat.ap, combat_free_move); critter_set_who_hit_me(attacker, defender); } @@ -4141,7 +4141,7 @@ static void combat_standup(Object* critter) } if (critter == obj_dude) { - intface_update_move_points(obj_dude->data.critter.combat.ap); + intface_update_move_points(obj_dude->data.critter.combat.ap, combat_free_move); } dude_standup(critter); diff --git a/src/game/gmouse.cc b/src/game/gmouse.cc index 87341b1..be6841a 100644 --- a/src/game/gmouse.cc +++ b/src/game/gmouse.cc @@ -975,7 +975,7 @@ void gmouse_handle_event(int mouseX, int mouseY, int mouseState) } else { obj_dude->data.critter.combat.ap -= actionPointsRequired; } - intface_update_move_points(obj_dude->data.critter.combat.ap); + intface_update_move_points(obj_dude->data.critter.combat.ap, combat_free_move); } } } else { diff --git a/src/game/intface.cc b/src/game/intface.cc index a772a9c..9a726db 100644 --- a/src/game/intface.cc +++ b/src/game/intface.cc @@ -3,6 +3,8 @@ #include #include +#include + #include "game/anim.h" #include "game/art.h" #include "game/combat.h" @@ -1177,7 +1179,7 @@ void intface_update_ac(bool animate) } // 0x4547D4 -void intface_update_move_points(int actionPointsLeft) +void intface_update_move_points(int actionPoints, int bonusMove) { unsigned char* frmData; @@ -1187,24 +1189,34 @@ void intface_update_move_points(int actionPointsLeft) buf_to_buf(movePointBackground, 90, 5, 90, interfaceBuffer + 14 * 640 + 316, 640); - if (actionPointsLeft == -1) { + if (actionPoints == -1) { frmData = moveLightRed; - actionPointsLeft = 10; + actionPoints = 10; + bonusMove = 0; } else { frmData = moveLightGreen; + } - if (actionPointsLeft < 0) { - actionPointsLeft = 0; - } + int circle = 0; - if (actionPointsLeft > 10) { - actionPointsLeft = 10; - } + for (int index = 0; index < actionPoints && circle < 10; index++) { + buf_to_buf(frmData, + 5, + 5, + 5, + interfaceBuffer + 14 * 640 + 316 + circle * 9, + 640); + circle++; } - int index; - for (index = 0; index < actionPointsLeft; index++) { - buf_to_buf(frmData, 5, 5, 5, interfaceBuffer + 14 * 640 + 316 + index * 9, 640); + for (int index = 0; index < bonusMove && circle < 10; index++) { + buf_to_buf(moveLightYellow, + 5, + 5, + 5, + interfaceBuffer + 14 * 640 + 316 + circle * 9, + 640); + circle++; } if (!insideInit) { @@ -1439,7 +1451,7 @@ void intface_use_item() } else { obj_dude->data.critter.combat.ap -= actionPointsRequired; } - intface_update_move_points(obj_dude->data.critter.combat.ap); + intface_update_move_points(obj_dude->data.critter.combat.ap, combat_free_move); } } } else { @@ -1467,7 +1479,7 @@ void intface_use_item() obj_dude->data.critter.combat.ap -= actionPointsRequired; } - intface_update_move_points(obj_dude->data.critter.combat.ap); + intface_update_move_points(obj_dude->data.critter.combat.ap, combat_free_move); } } else { obj_use_item(obj_dude, ptr->item); diff --git a/src/game/intface.h b/src/game/intface.h index fbede0d..069f17d 100644 --- a/src/game/intface.h +++ b/src/game/intface.h @@ -45,7 +45,7 @@ bool intface_is_enabled(); void intface_redraw(); void intface_update_hit_points(bool animate); void intface_update_ac(bool animate); -void intface_update_move_points(int actionPointsLeft); +void intface_update_move_points(int actionPoints, int bonusMove); int intface_get_attack(int* hitMode, bool* aiming); int intface_update_items(bool animated); int intface_toggle_items(bool animated); diff --git a/src/game/inventry.cc b/src/game/inventry.cc index 932ccbb..b3c6be7 100644 --- a/src/game/inventry.cc +++ b/src/game/inventry.cc @@ -415,7 +415,7 @@ void handle_inventory() } obj_dude->data.critter.combat.ap -= actionPointsRequired; - intface_update_move_points(obj_dude->data.critter.combat.ap); + intface_update_move_points(obj_dude->data.critter.combat.ap, combat_free_move); } } diff --git a/src/game/protinst.cc b/src/game/protinst.cc index 38a3a4f..6737e4b 100644 --- a/src/game/protinst.cc +++ b/src/game/protinst.cc @@ -1108,7 +1108,7 @@ int check_scenery_ap_cost(Object* obj, Object* a2) obj->data.critter.combat.ap = actionPoints - 3; if (obj == obj_dude) { - intface_update_move_points(obj_dude->data.critter.combat.ap); + intface_update_move_points(obj_dude->data.critter.combat.ap, combat_free_move); } return 0;