Skip to content

Commit

Permalink
No Health Flower For Allied Unconscious (#3668)
Browse files Browse the repository at this point in the history
  • Loading branch information
walt253 authored Nov 13, 2024
1 parent 628de77 commit 476d8e1
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 72 deletions.
2 changes: 1 addition & 1 deletion config/creatrs/imp.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ GrowUp = 0 NULL 0
; It is enough if one slab of given type exists anywhere next to the room slab, and all creatures inside get the bonus.
; The formula is 256 for 1 experience point every game turns while sleeping. See terrain.cfg for a list of slab names.
SleepExperience = HARD 0
; Determines the multiplier for BaseExperienceGain defined in magic.cfg for shots.
; Sets the multiplier for BaseExperienceGain defined in magic.cfg for shots. This value is applied for other creatures when they attack this creature kind.
ExperienceForHitting = 1
; Level at which the creature gains the ability to resurrect, at one lower xp level.
; Setting this parameter to 1 makes the creature "immortal" as long as it has a lair. 0 disable this ability.
Expand Down
149 changes: 78 additions & 71 deletions src/engine_render.c
Original file line number Diff line number Diff line change
Expand Up @@ -5256,26 +5256,28 @@ void draw_status_sprites(long scrpos_x, long scrpos_y, struct Thing *thing)
{
struct PlayerInfo *player = get_my_player();
const struct Camera *cam = player->acamera;
if (cam == NULL) {
if (cam == NULL)
{
return;
}

float scale_by_zoom;
int base_size = creature_status_size*256;
switch (cam->view_mode) {
case PVM_IsoWibbleView:
case PVM_IsoStraightView:
// 1st argument: the scale when fully zoomed out. 2nd argument: the scale at base level zoom
scale_by_zoom = lerp(0.15, 1.00, hud_scale);
break;
case PVM_FrontView:
scale_by_zoom = lerp(0.15, 1.00, hud_scale);
break;
case PVM_ParchmentView:
scale_by_zoom = 1;
break;
default:
return; // Do not draw if camera is 1st person
int base_size = creature_status_size * 256;
switch (cam->view_mode)
{
case PVM_IsoWibbleView:
case PVM_IsoStraightView:
// 1st argument: the scale when fully zoomed out. 2nd argument: the scale at base level zoom.
scale_by_zoom = lerp(0.15, 1.00, hud_scale);
break;
case PVM_FrontView:
scale_by_zoom = lerp(0.15, 1.00, hud_scale);
break;
case PVM_ParchmentView:
scale_by_zoom = 1;
break;
default:
return; // Do not draw if camera is 1st person.
}

unsigned short flg_mem;
Expand All @@ -5287,7 +5289,7 @@ void draw_status_sprites(long scrpos_x, long scrpos_y, struct Thing *thing)
cctrl = creature_control_get_from_thing(thing);
if ((game.flags_cd & MFlg_NoHeroHealthFlower) != 0)
{
if ( player->thing_under_hand != thing->index )
if (player->thing_under_hand != thing->index)
{
cctrl->thought_bubble_last_turn_drawn = game.play_gameturn;
return;
Expand All @@ -5304,7 +5306,7 @@ void draw_status_sprites(long scrpos_x, long scrpos_y, struct Thing *thing)
state_spridx = 0;

CrtrExpLevel exp;
exp = min(cctrl->explevel,9);
exp = min(cctrl->explevel, 9);
if (cam->view_mode != PVM_ParchmentView)
{
fill_status_sprite_indexes(thing, cctrl, &health_spridx, &state_spridx, &anger_spridx);
Expand All @@ -5319,16 +5321,17 @@ void draw_status_sprites(long scrpos_x, long scrpos_y, struct Thing *thing)
spr = &button_sprite[GBS_creature_states_cloud];
bs_units_per_px = units_per_pixel_ui * 2 * scale_by_zoom;

if (cam->view_mode == PVM_FrontView) {
float flower_distance = 1280; // Higher number means flower is further away from creature
scrpos_y -= (int)( (flower_distance / spr->SHeight) * ((float)camera_zoom / FRONTVIEW_CAMERA_ZOOM_MAX) );
if (cam->view_mode == PVM_FrontView)
{
float flower_distance = 1280; // Higher number means flower is further away from creature.
scrpos_y -= (int)((flower_distance / spr->SHeight) * ((float)camera_zoom / FRONTVIEW_CAMERA_ZOOM_MAX));
}

if ( state_spridx || anger_spridx )
if (state_spridx || anger_spridx)
{
spr = &button_sprite[GBS_creature_states_cloud];
w = (base_size * spr->SWidth * bs_units_per_px/16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px/16) >> 13;
w = (base_size * spr->SWidth * bs_units_per_px / 16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px / 16) >> 13;
LbSpriteDrawScaled(scrpos_x - w / 2, scrpos_y - h, spr, w, h);
}

Expand All @@ -5337,78 +5340,82 @@ void draw_status_sprites(long scrpos_x, long scrpos_y, struct Thing *thing)
if (((game.play_gameturn & 4) == 0) && (anger_spridx > 0))
{
spr = &button_sprite[anger_spridx];
w = (base_size * spr->SWidth * bs_units_per_px/16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px/16) >> 13;
w = (base_size * spr->SWidth * bs_units_per_px / 16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px / 16) >> 13;
LbSpriteDrawScaled(scrpos_x - w / 2, scrpos_y - h, spr, w, h);
spr = get_button_sprite_for_player(state_spridx, thing->owner);
h_add += spr->SHeight * bs_units_per_px/16;
} else if ( state_spridx )
h_add += spr->SHeight * bs_units_per_px / 16;
}
else if (state_spridx)
{
spr = get_button_sprite_for_player(state_spridx, thing->owner);
w = (base_size * spr->SWidth * bs_units_per_px/16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px/16) >> 13;
w = (base_size * spr->SWidth * bs_units_per_px / 16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px / 16) >> 13;
LbSpriteDrawScaled(scrpos_x - w / 2, scrpos_y - h, spr, w, h);
h_add += h;
}

if ((thing->lair.spr_size > 0) && (health_spridx > 0) && ((game.play_gameturn & 1) != 0))
{
int flash_color = get_player_color_idx(thing->owner);
if (flash_color == PLAYER_NEUTRAL) {
if (flash_color == PLAYER_NEUTRAL)
{
flash_color = game.play_gameturn & 3;
}
spr = get_button_sprite_for_player(health_spridx, thing->owner);
w = (base_size * spr->SWidth * bs_units_per_px/16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px/16) >> 13;
w = (base_size * spr->SWidth * bs_units_per_px / 16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px / 16) >> 13;
LbSpriteDrawScaledOneColour(scrpos_x - w / 2, scrpos_y - h - h_add, spr, w, h, player_flash_colours[flash_color]);
}
else
{
// determine if the creature is under the player's hand (being hovered over)
TbBool is_thing_under_hand = (player->thing_under_hand == thing->index);
// check if the creature is an enemy and is visible
TbBool is_enemy_and_visible = players_are_enemies(player->id_number,thing->owner) && !creature_is_invisible(thing);
// check if the creature belongs to player and is hurt
TbBool is_allied_and_hurt = false;
TbBool should_drag_to_lair = false;
if (!is_enemy_and_visible)
{
is_allied_and_hurt = players_are_mutual_allies(player->id_number, thing->owner) && creature_would_benefit_from_healing(thing);
should_drag_to_lair = creature_is_being_unconscious(thing) && (player->id_number == thing->owner) && (
// check if the creature has a lair room or can heal in a lair
(game.conf.rules.workers.drag_to_lair == 1 && !room_is_invalid(get_creature_lair_room(thing))) ||
// or check if the creature can have lair and heal in it
(game.conf.rules.workers.drag_to_lair == 2 && creature_can_do_healing_sleep(thing)));
}

// check if the creature is in combat
TbBool is_in_combat = (cctrl->combat_flags != 0);
// check if the creature has a lair
TbBool has_lair = (thing->lair.spr_size > 0);
// determine if the current view is the schematic top-down map view
TbBool is_parchment_map_view = (cam->view_mode == PVM_ParchmentView);

if ( (is_thing_under_hand)
// Determine if the creature is under the player's hand (being hovered over).
TbBool is_thing_under_hand = (player->thing_under_hand == thing->index);
// Check if the creature is an enemy and is visible.
TbBool is_enemy_and_visible = players_are_enemies(player->id_number, thing->owner) && !creature_is_invisible(thing);
// Check if the creature belongs to the player, is hurt but not unconscious.
TbBool is_owned_and_hurt = false;

Check warning on line 5377 in src/engine_render.c

View workflow job for this annotation

GitHub Actions / build

variable ‘is_owned_and_hurt’ set but not used

Check warning on line 5377 in src/engine_render.c

View workflow job for this annotation

GitHub Actions / build

variable ‘is_owned_and_hurt’ set but not used
// Check if the creature belongs to an ally and is hurt.
TbBool is_allied_and_hurt = false;
TbBool should_drag_to_lair = false;
if (!is_enemy_and_visible)
{
is_owned_and_hurt = (player->id_number == thing->owner) && creature_would_benefit_from_healing(thing) && !creature_is_being_unconscious(thing);
is_allied_and_hurt = (player->id_number != thing->owner) && creature_would_benefit_from_healing(thing) && players_are_mutual_allies(player->id_number, thing->owner);
should_drag_to_lair = creature_is_being_unconscious(thing) && (player->id_number == thing->owner)
// Check if the creature has a lair room or can heal in a lair.
&& ((game.conf.rules.workers.drag_to_lair == 1 && !room_is_invalid(get_creature_lair_room(thing)))
// Or check if the creature can have lair and heal in it.
|| (game.conf.rules.workers.drag_to_lair == 2 && creature_can_do_healing_sleep(thing)));
}
// Check if the creature is in combat.
TbBool is_in_combat = (cctrl->combat_flags != 0);
// Check if the creature has a lair.
TbBool has_lair = (thing->lair.spr_size > 0);
// Determine if the current view is the schematic top-down map view.
TbBool is_parchment_map_view = (cam->view_mode == PVM_ParchmentView);
if ((is_thing_under_hand)
|| (is_enemy_and_visible)
|| (is_allied_and_hurt)
|| (thing->owner == PLAYER_NEUTRAL)
// if drag_to_lair rule is active
// If drag_to_lair rule is active.
|| (should_drag_to_lair)
|| (is_in_combat)
|| (has_lair)
|| (is_parchment_map_view))
{
if (health_spridx > 0) {
spr = get_button_sprite_for_player(health_spridx, thing->owner);
w = (base_size * spr->SWidth * bs_units_per_px/16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px/16) >> 13;
LbSpriteDrawScaled(scrpos_x - w / 2, scrpos_y - h - h_add, spr, w, h);
}
spr = &button_sprite[GBS_creature_flower_level_01 + exp];
w = (base_size * spr->SWidth * bs_units_per_px/16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px/16) >> 13;
LbSpriteDrawScaled(scrpos_x - w / 2, scrpos_y - h - h_add, spr, w, h);
}
{
if (health_spridx > 0)
{
spr = get_button_sprite_for_player(health_spridx, thing->owner);
w = (base_size * spr->SWidth * bs_units_per_px / 16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px / 16) >> 13;
LbSpriteDrawScaled(scrpos_x - w / 2, scrpos_y - h - h_add, spr, w, h);
}
spr = &button_sprite[GBS_creature_flower_level_01 + exp];
w = (base_size * spr->SWidth * bs_units_per_px / 16) >> 13;
h = (base_size * spr->SHeight * bs_units_per_px / 16) >> 13;
LbSpriteDrawScaled(scrpos_x - w / 2, scrpos_y - h - h_add, spr, w, h);
}
}
lbDisplay.DrawFlags = flg_mem;
}
Expand Down

0 comments on commit 476d8e1

Please sign in to comment.