From 065292c7ac66d1b610a1f94a439066ebd55dde89 Mon Sep 17 00:00:00 2001 From: doyle Date: Sun, 8 Oct 2023 17:35:57 +1100 Subject: [PATCH] fp: Add attack upgrade to merchant --- feely_pona.cpp | 16 +++++++++------- feely_pona_game.cpp | 3 ++- feely_pona_game.h | 9 +++++---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/feely_pona.cpp b/feely_pona.cpp index 2145ea2..be3ff9f 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -2032,14 +2032,15 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input continue; } - defender->hp = defender->hp >= FP_DEFAULT_DAMAGE ? defender->hp - FP_DEFAULT_DAMAGE : 0; + defender->hp = defender->hp >= attacker->base_attack ? defender->hp - attacker->base_attack : 0; if (defender->hp <= 0) { + if (!defender->is_dying) { + FP_GameEntity *coin_receiver = FP_Game_GetEntity(game, attacker->projectile_owner); + if (FP_Game_IsNilEntity(coin_receiver)) + coin_receiver = attacker; + coin_receiver->coins += 1; + } defender->is_dying = true; - - FP_GameEntity *coin_receiver = FP_Game_GetEntity(game, attacker->projectile_owner); - if (FP_Game_IsNilEntity(coin_receiver)) - coin_receiver = attacker; - coin_receiver->coins += 1; } // NOTE: Kickback ====================================================================== @@ -2610,8 +2611,9 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer, if (mapping.merchant == game->play.merchant_terry) { // TODO(doyle): Attack damage? Or increase attack range? + player->base_attack += DQN_CAST(uint32_t)(FP_DEFAULT_DAMAGE * .3f); } else if (mapping.merchant == game->play.merchant_graveyard) { - player->stamina_cap += DQN_CAST(uint16_t)(FP_TERRY_DASH_STAMINA_COST * .5f); + player->stamina_cap += DQN_CAST(uint32_t)(FP_TERRY_DASH_STAMINA_COST * .5f); } else if (mapping.merchant == game->play.merchant_gym) { player->hp_cap += FP_DEFAULT_DAMAGE; player->hp = player->hp_cap; diff --git a/feely_pona_game.cpp b/feely_pona_game.cpp index 5184a05..9337419 100644 --- a/feely_pona_game.cpp +++ b/feely_pona_game.cpp @@ -226,13 +226,14 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_STRING_ result->action.sprite_alpha = 1.f; result->stamina_cap = 93; - result->hp_cap = DQN_CAST(uint16_t)(FP_DEFAULT_DAMAGE * .8f); + result->hp_cap = DQN_CAST(uint32_t)(FP_DEFAULT_DAMAGE * .8f); result->hp = result->hp_cap; result->inventory.airports_base_price = 100; result->inventory.churchs_base_price = 50; result->inventory.kennels_base_price = 50; result->inventory.clubs_base_price = 50; + result->base_attack = FP_DEFAULT_DAMAGE; result->inventory.stamina_base_price = 10; result->inventory.health_base_price = 10; diff --git a/feely_pona_game.h b/feely_pona_game.h index b3349fe..78bcc90 100644 --- a/feely_pona_game.h +++ b/feely_pona_game.h @@ -224,10 +224,11 @@ struct FP_GameEntity Dqn_usize coins; FP_GameInventory inventory; - Dqn_f32 hp; - uint16_t hp_cap; - Dqn_f32 stamina; - uint16_t stamina_cap; + uint32_t hp; + uint32_t hp_cap; + uint32_t stamina; + uint32_t stamina_cap; + uint32_t base_attack; bool converted_faction; FP_GameEntityFaction faction;