diff --git a/feely_pona.cpp b/feely_pona.cpp index fc15d1f..2145ea2 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -1322,8 +1322,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform case FP_GameDirection_Count: break; } - Dqn_Rect entity_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle); - Dqn_V2 projectile_pos = entity_hit_box.pos + entity->attack_box_offset; + Dqn_V2 projectile_pos = FP_Game_CalcEntityWorldPos(game, entity->handle); Dqn_V2 projectile_acceleration = FP_Game_MetersToPixelsV2(game->play, dir_vector * 0.25f); FP_Entity_CreatePhoneMessageProjectile(game, entity->handle, @@ -1913,8 +1912,10 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input // NOTE: Recover hp & stamina entity->stamina = DQN_MIN(entity->stamina + 1, entity->stamina_cap); - if (game->play.update_counter % 12 == 0) { - entity->hp = DQN_MIN(entity->hp + 1, entity->hp_cap); + if (entity->flags & FP_GameEntityFlag_RecoversHP) { + if (game->play.update_counter % 12 == 0) { + entity->hp = DQN_MIN(entity->hp + 1, entity->hp_cap); + } } // NOTE: Derive dynmamic bounding boxes ==================================================== @@ -1968,8 +1969,8 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input mob->waypoints = FP_SentinelList_Init(game->play.chunk_pool); mob->flags |= FP_GameEntityFlag_Aggros; mob->flags |= FP_GameEntityFlag_RespondsToBuildings; - mob->hp_cap += hp_adjustment; - mob->hp = entity->hp_cap; + mob->hp_cap += hp_adjustment; + mob->hp = mob->hp_cap; for (FP_GameEntity *waypoint_entity = entity->first_child; waypoint_entity; waypoint_entity = waypoint_entity->next) { if ((waypoint_entity->flags & FP_GameEntityFlag_MobSpawnerWaypoint) == 0) @@ -2268,6 +2269,21 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer, TELY_COLOUR_WHITE_V4); } + if (entity->handle != game->play.player && entity->hp != entity->hp_cap && entity->hp) { + Dqn_f32 bar_height = 12.f; + TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.icon_health); + Dqn_Rect icon_tex_rect = game->atlas_sprite_sheet.rects.data[anim->index]; + + Dqn_V2 draw_p = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0.f, -0.2f)); + Dqn_f32 health_t = entity->hp / DQN_CAST(Dqn_f32)entity->hp_cap; + Dqn_Rect health_rect = Dqn_Rect_InitNx4(draw_p.x, draw_p.y, DQN_CAST(Dqn_f32)entity->hp_cap, bar_height); + Dqn_Rect curr_health_rect = Dqn_Rect_InitNx4(draw_p.x, draw_p.y, DQN_CAST(Dqn_f32)entity->hp_cap * health_t, bar_height); + + TELY_Render_RectColourV4(renderer, curr_health_rect, TELY_RenderShapeMode_Fill, TELY_COLOUR_RED_TOMATO_V4); + TELY_RenderCommandRect *cmd = TELY_Render_RectColourV4(renderer, health_rect, TELY_RenderShapeMode_Line, TELY_COLOUR_BLACK_V4); + cmd->thickness = 1.f; + } + if (entity->type == FP_EntityType_ClubTerry || entity->type == FP_EntityType_AirportTerry || entity->type == FP_EntityType_ChurchTerry) { @@ -2986,9 +3002,9 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer, } // NOTE: UI ==================================================================================== - TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity()); - DQN_DEFER { TELY_Render_PopTransform(renderer); }; if (game->play.debug_ui) { + TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity()); + DQN_DEFER { TELY_Render_PopTransform(renderer); }; // NOTE: Info bar ========================================================================== { TELY_RFuiResult info_bar = TELY_RFui_Row(rfui, DQN_STRING8("Info Bar")); diff --git a/feely_pona_entity_create.cpp b/feely_pona_entity_create.cpp index 99279bb..f3e1854 100644 --- a/feely_pona_entity_create.cpp +++ b/feely_pona_entity_create.cpp @@ -464,6 +464,7 @@ static FP_GameEntityHandle FP_Entity_CreateTerry(FP_Game *game, Dqn_V2 pos, DQN_ entity->flags |= FP_GameEntityFlag_NonTraversable; entity->flags |= FP_GameEntityFlag_Attackable; entity->flags |= FP_GameEntityFlag_CameraTracking; + entity->flags |= FP_GameEntityFlag_RecoversHP; entity->terry_mobile_data_plan_cap = DQN_KILOBYTES(6); entity->terry_mobile_data_plan = entity->terry_mobile_data_plan_cap; entity->faction = FP_GameEntityFaction_Friendly; diff --git a/feely_pona_game.cpp b/feely_pona_game.cpp index 673bd08..5184a05 100644 --- a/feely_pona_game.cpp +++ b/feely_pona_game.cpp @@ -226,7 +226,7 @@ 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 = FP_DEFAULT_DAMAGE; + result->hp_cap = DQN_CAST(uint16_t)(FP_DEFAULT_DAMAGE * .8f); result->hp = result->hp_cap; result->inventory.airports_base_price = 100; diff --git a/feely_pona_game.h b/feely_pona_game.h index 56590b2..b3349fe 100644 --- a/feely_pona_game.h +++ b/feely_pona_game.h @@ -24,6 +24,7 @@ enum FP_GameEntityFlag FP_GameEntityFlag_Friendly = 1 << 16, FP_GameEntityFlag_Foe = 1 << 17, FP_GameEntityFlag_NoClip = 1 << 18, + FP_GameEntityFlag_RecoversHP = 1 << 19, }; enum FP_GameShapeType