You can now take damage to your head.
This commit is contained in:
parent
cbd4b858ac
commit
d22eaa554d
7 changed files with 64 additions and 49 deletions
|
|
@ -188,7 +188,7 @@ void System::death() {
|
|||
|
||||
world.query<Combat>([&](auto ent, auto &combat) {
|
||||
// bring out yer dead
|
||||
if(combat.hp <= 0 && !combat.dead) {
|
||||
if(combat.is_dead() && !combat.dead) {
|
||||
combat.dead = true;
|
||||
if(ent != player.entity) {
|
||||
// we won't change out the player's components later
|
||||
|
|
@ -196,7 +196,7 @@ void System::death() {
|
|||
}
|
||||
// we need to send this event for everything that dies
|
||||
world.send<game::Event>(game::Event::DEATH, ent, {});
|
||||
} else if(float(combat.hp) / float(combat.max_hp) < 0.5f) {
|
||||
} else if(combat.almost_dead()) {
|
||||
// if enemies are below 50% health they are marked with bad health
|
||||
if(world.has<ai::EntityAI>(ent)) {
|
||||
auto& enemy_ai = world.get<ai::EntityAI>(ent);
|
||||
|
|
@ -479,23 +479,14 @@ void System::use_item(const string& slot_name) {
|
|||
auto& inventory = world.get<inventory::Model>(level.player);
|
||||
auto& player_combat = world.get<Combat>(level.player);
|
||||
|
||||
if(player_combat.hp >= player_combat.max_hp) return;
|
||||
if(!player_combat.can_heal()) return;
|
||||
if(!inventory.has(slot_name)) return;
|
||||
|
||||
auto what = inventory.get(slot_name);
|
||||
|
||||
if(auto curative = world.get_if<Curative>(what)) {
|
||||
inventory.remove(what);
|
||||
|
||||
player_combat.hp += curative->hp;
|
||||
|
||||
if(player_combat.hp > player_combat.max_hp) {
|
||||
player_combat.hp = player_combat.max_hp;
|
||||
}
|
||||
|
||||
dbc::log($F("player health now {}",
|
||||
player_combat.hp));
|
||||
|
||||
player_combat.apply_healing(*curative);
|
||||
world.remove<Curative>(what);
|
||||
} else {
|
||||
dbc::log($F("no usable item at {}", what));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue