Skip to content

Commit

Permalink
Improve bonus move
Browse files Browse the repository at this point in the history
Fixes #83
  • Loading branch information
alexbatalov committed Sep 16, 2023
1 parent 3b3642a commit 1db15fe
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/game/anim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/game/combat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/game/gmouse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
40 changes: 26 additions & 14 deletions src/game/intface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <stdio.h>
#include <string.h>

#include <algorithm>

#include "game/anim.h"
#include "game/art.h"
#include "game/combat.h"
Expand Down Expand Up @@ -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;

Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/game/intface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/game/inventry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/protinst.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1db15fe

Please sign in to comment.