forked from NotAShelf/rogged
Compare commits
3 commits
d01a54161d
...
0cb0ca17ff
| Author | SHA1 | Date | |
|---|---|---|---|
|
0cb0ca17ff |
|||
|
62a4442844 |
|||
|
5e2f752c7e |
3 changed files with 5 additions and 19 deletions
|
|
@ -446,8 +446,10 @@ static int handle_movement_input(GameState *gs) {
|
|||
MoveResult result =
|
||||
try_move_entity(&gs->player.position, direction, &gs->map, &gs->player, gs->enemies, gs->enemy_count, true);
|
||||
if (result == MOVE_RESULT_MOVED) {
|
||||
player_on_move(&gs->player);
|
||||
action = 1;
|
||||
if (target != NULL) {
|
||||
player_on_move(&gs->player);
|
||||
action = 1;
|
||||
}
|
||||
} else if (result == MOVE_RESULT_BLOCKED_ENEMY) {
|
||||
target = player_find_enemy_at(gs->enemies, gs->enemy_count, new_x, new_y);
|
||||
player_attack(&gs->player, target);
|
||||
|
|
|
|||
16
src/player.c
16
src/player.c
|
|
@ -2,7 +2,6 @@
|
|||
#include "combat.h"
|
||||
#include "common.h"
|
||||
#include "items.h"
|
||||
#include "movement.h"
|
||||
#include "settings.h"
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -47,21 +46,6 @@ Enemy *player_find_enemy_at(Enemy *enemies, int count, int x, int y) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int player_move(Player *p, Vec2 direction, Map *map, Enemy *enemies, int enemy_count) {
|
||||
MoveResult result = try_move_entity(&p->position, direction, map, p, enemies, enemy_count, true);
|
||||
if (result != MOVE_RESULT_MOVED)
|
||||
return 0;
|
||||
|
||||
p->step_count += 1;
|
||||
if (p->step_count % REGEN_STEP_INTERVAL == 0 && p->hp < p->max_hp &&
|
||||
!combat_has_effect(p->effects, p->effect_count, EFFECT_POISON) &&
|
||||
!combat_has_effect(p->effects, p->effect_count, EFFECT_BLEED) &&
|
||||
!combat_has_effect(p->effects, p->effect_count, EFFECT_BURN)) {
|
||||
p->hp += 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void player_on_move(Player *p) {
|
||||
p->step_count += 1;
|
||||
if (p->step_count % REGEN_STEP_INTERVAL == 0 && p->hp < p->max_hp &&
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
// Initialize player at position
|
||||
void player_init(Player *p, int x, int y);
|
||||
|
||||
// Apply status effect, healing ect
|
||||
// Apply status effects, healing, etc
|
||||
void player_on_move(Player *p);
|
||||
|
||||
// Find a living enemy at tile (x, y); returns NULL if none
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue