Improve bonus move

Fixes #83
This commit is contained in:
Alexander Batalov 2023-09-16 11:06:21 +03:00
parent 3b3642ae3c
commit 1db15fe6b5
7 changed files with 40 additions and 28 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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 {

View File

@ -3,6 +3,8 @@
#include <stdio.h>
#include <string.h>
#include <algorithm>
#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;
}
if (actionPointsLeft > 10) {
actionPointsLeft = 10;
}
}
int index;
for (index = 0; index < actionPointsLeft; index++) {
buf_to_buf(frmData, 5, 5, 5, interfaceBuffer + 14 * 640 + 316 + index * 9, 640);
int circle = 0;
for (int index = 0; index < actionPoints && circle < 10; index++) {
buf_to_buf(frmData,
5,
5,
5,
interfaceBuffer + 14 * 640 + 316 + circle * 9,
640);
circle++;
}
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);

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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;