Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special Diggers #3209

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/creatrs/tunneller.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DamageToBoulder = 20
; Creature thing size - XY and Z, one cube is 256x256.
ThingSize = 240 400
LairObject = LAIR_TUNLR
Properties = BLEEDS HUMANOID_SKELETON SPECIAL_DIGGER
Properties = BLEEDS HUMANOID_SKELETON DIGGING_CREATURE

[attraction]
EntranceRoom = NULL NULL NULL
Expand Down
11 changes: 8 additions & 3 deletions src/config_creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,11 @@ TbBool set_creature_available(PlayerNumber plyr_idx, ThingModel crtr_model, long

ThingModel get_players_special_digger_model(PlayerNumber plyr_idx)
{
struct PlayerInfo* player = get_player(plyr_idx);

if(player->special_digger != 0)
return player->special_digger;

ThingModel crmodel;

if (player_is_roaming(plyr_idx))
Expand Down Expand Up @@ -2020,9 +2025,9 @@ CreatureJob get_job_for_subtile(const struct Thing *creatng, MapSubtlCoord stl_x
}
if (creatng->owner == slabmap_owner(slb))
{
if (thing_is_creature_special_digger(creatng))
if (thing_is_creature_digger(creatng))
{
if (creatng->model == get_players_special_digger_model(creatng->owner))
if (creature_is_for_dungeon_diggers_list(creatng))
{
required_kind_flags |= JoKF_OwnedDiggers;
}
Expand All @@ -2045,7 +2050,7 @@ CreatureJob get_job_for_subtile(const struct Thing *creatng, MapSubtlCoord stl_x
}
} else
{
if (creatng->model == get_players_special_digger_model(creatng->owner)) {
if (creature_is_for_dungeon_diggers_list(creatng)) {
required_kind_flags |= JoKF_EnemyDiggers;
} else {
required_kind_flags |= JoKF_EnemyCreatures;
Expand Down
3 changes: 2 additions & 1 deletion src/config_creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extern "C" {
#define CREATURE_PROPERTY_INCREASE_ON_EXP 35
/******************************************************************************/
enum CreatureModelFlags {
CMF_IsSpecDigger = 0x000001, // Imp and Tunneller.
CMF_IsSpecDigger = 0x000001, // is a dedicated digger that doesn't do things normal units do (like imp)
CMF_IsArachnid = 0x000002, // Simply, Spider.
CMF_IsDiptera = 0x000004, // Simply, Fly.
CMF_IsLordOTLand = 0x000008, // Simply, Knight and Avatar.
Expand All @@ -61,6 +61,7 @@ enum CreatureModelFlags {
CMF_NoTransfer = 0x020000, // Creature cannot be transferred.
CMF_Fat = 0x040000, // Creature to fat too walk a full animation.
CMF_NoStealHero = 0x080000, // Prevent the creature from being stolen with the Steal Hero special.
CMF_IsDiggingCreature = 0x100000, // unit still counts as a regular creature but can also do digger tasks (like tunneler)
};

enum CreatureJobFlags {
Expand Down
9 changes: 7 additions & 2 deletions src/config_crtrmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const struct NamedCommand creatmodel_properties_commands[] = {
{"TREMBLING", 30},
{"FAT", 31},
{"NO_STEAL_HERO", 32},
{"DIGGING_CREATURE", 33},
{NULL, 0},
};

Expand Down Expand Up @@ -769,6 +770,10 @@ TbBool parse_creaturemodel_attributes_blocks(long crtr_model,char *buf,long len,
crconf->model_flags |= CMF_NoStealHero;
n++;
break;
case 33: // DIGGING_CREATURE
crconf->model_flags |= CMF_IsDiggingCreature;
n++;
break;
default:
CONFWRNLOG("Incorrect value of \"%s\" parameter \"%s\" in [%s] block of %s %s file.",
COMMAND_TEXT(cmd_num),word_buf,block_buf, creature_code_name(crtr_model), config_textname);
Expand Down Expand Up @@ -847,7 +852,7 @@ TbBool parse_creaturemodel_attributes_blocks(long crtr_model,char *buf,long len,
}
#undef COMMAND_TEXT
// If the creature is a special breed, then update an attribute in CreatureConfig struct
if ((crconf->model_flags & CMF_IsSpecDigger) != 0)
if ((crconf->model_flags & (CMF_IsSpecDigger|CMF_IsDiggingCreature)) != 0)
{
if ((crconf->model_flags & CMF_IsEvil) != 0) {
game.conf.crtr_conf.special_digger_evil = crtr_model;
Expand All @@ -860,7 +865,7 @@ TbBool parse_creaturemodel_attributes_blocks(long crtr_model,char *buf,long len,
game.conf.crtr_conf.spectator_breed = crtr_model;
}
// Set creature start states based on the flags
if ((crconf->model_flags & CMF_IsSpecDigger) != 0)
if ((crconf->model_flags & (CMF_IsSpecDigger|CMF_IsDiggingCreature)) != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the evil_start_state and good_start_state also need to be cleaned up here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how so? good in this context should technically be roaming but think it's fine as is

{
crstat->evil_start_state = CrSt_ImpDoingNothing;
crstat->good_start_state = CrSt_TunnellerDoingNothing;
Expand Down
4 changes: 2 additions & 2 deletions src/console_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1195,13 +1195,12 @@ TbBool cmd_exec(PlayerNumber plyr_idx, char *msg)
PlayerNumber id = get_player_number_for_command(pr2str);
player = get_player(plyr_idx);
thing = thing_get(player->influenced_thing_idx);
ThingModel model = get_players_special_digger_model(thing->owner);
player = get_player(id);
if (player_exists(player))
{
if (thing_is_creature(thing))
{
if (thing->model == model)
if (creature_is_for_dungeon_diggers_list(thing))
{
if (get_random_position_in_dungeon_for_creature(id, CrWaS_WithinDungeon, thing, &pos))
{
Expand All @@ -1210,6 +1209,7 @@ TbBool cmd_exec(PlayerNumber plyr_idx, char *msg)
}
}
}
//todo replace with any on digger_list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget this, or is this for a future PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just for cheats, so yeah could be tackled at some point but really not critical at all

thing = find_players_next_creature_of_breed_and_gui_job(get_players_special_digger_model(thing->owner), -1, plyr_idx, TPF_None);
if (!thing_is_invalid(thing))
{
Expand Down
4 changes: 2 additions & 2 deletions src/creature_groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ TbBool remove_creature_from_group_without_leader_consideration(struct Thing *cre
static short creature_could_be_lead_digger(struct Thing* creatng, struct CreatureControl* cctrl)
{
short potential_leader = 0;
if (thing_is_creature_special_digger(creatng))
if (thing_is_creature_digger(creatng))
{
if (cctrl->party_objective != CHeroTsk_DefendParty)
{
Expand Down Expand Up @@ -406,7 +406,7 @@ struct Thing* get_best_creature_to_lead_group(struct Thing* grptng)
TRACE_THING(ctng);
if (has_digger > 0)
{
is_digger = thing_is_creature_special_digger(ctng);
is_digger = thing_is_creature_digger(ctng);
}
cctrl = creature_control_get_from_thing(ctng);
struct CreatureControl* bcctrl = creature_control_get_from_thing(best_creatng);
Expand Down
8 changes: 4 additions & 4 deletions src/creature_jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ TbBool is_correct_owner_to_perform_job(const struct Thing *creatng, PlayerNumber
// We need to check for it later in upper function, because lack of related room may generate message for the player
if (creatng->owner == plyr_idx)
{
if (creatng->model == get_players_special_digger_model(creatng->owner)) {
if (creature_is_for_dungeon_diggers_list(creatng)) {
if ((get_flags_for_job(new_job) & JoKF_OwnedDiggers) == 0)
return false;
} else {
Expand All @@ -504,7 +504,7 @@ TbBool is_correct_owner_to_perform_job(const struct Thing *creatng, PlayerNumber
}
} else
{
if (creatng->model == get_players_special_digger_model(creatng->owner)) {
if (creature_is_for_dungeon_diggers_list(creatng)) {
if ((get_flags_for_job(new_job) & JoKF_EnemyDiggers) == 0)
return false;
} else {
Expand Down Expand Up @@ -992,7 +992,7 @@ TbBool attempt_job_work_in_room_near_pos(struct Thing *creatng, MapSubtlCoord st
}
creatng->continue_state = get_arrive_at_state_for_job(new_job);
cctrl->target_room_id = room->index;
if (thing_is_creature_special_digger(creatng))
if (thing_is_creature_digger(creatng))
{
cctrl->digger.task_repeats = 0;
cctrl->job_assigned = new_job;
Expand All @@ -1017,7 +1017,7 @@ TbBool attempt_job_work_in_room_and_cure_near_pos(struct Thing *creatng, MapSubt
creatng->continue_state = get_arrive_at_state_for_job(new_job);
cctrl->target_room_id = room->index;
process_temple_cure(creatng);
if (thing_is_creature_special_digger(creatng))
if (thing_is_creature_digger(creatng))
{
cctrl->digger.task_repeats = 0;
cctrl->job_assigned = new_job;
Expand Down
10 changes: 5 additions & 5 deletions src/creature_states.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ struct StateInfo states[CREATURE_STATES_COUNT] = {
* - 1: Working.
* - 2: Fighting.
*/
long const state_type_to_gui_state[] = {
0, 1, 0, 0, 0, 2, 0, 0, 1, 0, 0, 2, 2, 1, 1, 0,
long const state_type_to_gui_state[STATE_TYPES_COUNT] = {
0, 1, 0, 0, 0, 2, 0, 0, 1, 0, 0, 2, 2, 1, 1,
};

/******************************************************************************/
Expand Down Expand Up @@ -1508,7 +1508,7 @@ short creature_being_dropped(struct Thing *creatng)
if (!creature_affected_by_spell(creatng, SplK_Chicken))
{
// Special tasks for diggers
if ((get_creature_model_flags(creatng) & CMF_IsSpecDigger) != 0)
if (thing_is_creature_digger(creatng))
{
if ((slabmap_owner(slb) == creatng->owner) || (slabmap_owner(slb) == game.neutral_player_num))
{
Expand Down Expand Up @@ -3686,7 +3686,7 @@ CrCheckRet move_check_persuade(struct Thing *creatng)
!thing_is_invalid(i);
i = thing_get(i->next_on_mapblk) )
{
if (i->owner != creatng->owner || !thing_is_creature(i) || i == creatng || i->model == get_players_special_digger_model(creatng->owner))
if (i->owner != creatng->owner || !thing_is_creature(i) || i == creatng || creature_is_for_dungeon_diggers_list(i))
continue;
i_leader = get_group_leader(i);
if (i_leader)
Expand Down Expand Up @@ -4767,7 +4767,7 @@ short set_start_state_f(struct Thing *thing,const char *func_name)
if (player->victory_state == VicS_LostLevel)
{
// TODO: Correctly deal with possession of creatures not owned by the player
if (thing->model != get_players_special_digger_model(player->id_number))
if (!creature_is_for_dungeon_diggers_list(thing))
{
cleanup_current_thing_state(thing);
initialise_thing_state(thing, CrSt_LeavesBecauseOwnerLost);
Expand Down
2 changes: 1 addition & 1 deletion src/creature_states.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

#include "bflib_basics.h"
#include "globals.h"
#include "dungeon_data.h"

/** Count of creature states, originally 147. */
#define CREATURE_STATES_COUNT CrSt_ListEnd

#define FIGHT_FEAR_DELAY 160
#define STATE_TYPES_COUNT CrStTyp_ListEnd

#ifdef __cplusplus
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions src/creature_states_combt.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ TbBool creature_is_being_attacked_by_enemy_creature_not_digger(struct Thing *fig
for (oppn_idx = 0; oppn_idx < COMBAT_MELEE_OPPONENTS_LIMIT; oppn_idx++)
{
struct Thing* enmtng = thing_get(figctrl->opponents_melee[oppn_idx]);
if (!thing_is_invalid(enmtng) && !thing_is_creature_special_digger(enmtng))
if (!thing_is_invalid(enmtng) && !thing_is_creature_digger(enmtng))
{
if (players_are_enemies(fightng->owner,enmtng->owner)) {
return true;
Expand All @@ -141,7 +141,7 @@ TbBool creature_is_being_attacked_by_enemy_creature_not_digger(struct Thing *fig
for (oppn_idx = 0; oppn_idx < COMBAT_RANGED_OPPONENTS_LIMIT; oppn_idx++)
{
struct Thing* enmtng = thing_get(figctrl->opponents_ranged[oppn_idx]);
if (!thing_is_invalid(enmtng) && !thing_is_creature_special_digger(enmtng))
if (!thing_is_invalid(enmtng) && !thing_is_creature_digger(enmtng))
{
if (players_are_enemies(fightng->owner,enmtng->owner)) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/creature_states_spdig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ short imp_birth(struct Thing *thing)
{
// If the creature has flight ability, make sure it returns to flying state
restore_creature_flight_flag(thing);
if (thing_is_creature_special_digger(thing))
if (thing_is_creature_digger(thing))
{
if (!check_out_available_spdigger_drop_tasks(thing)) {
set_start_state(thing);
Expand Down Expand Up @@ -1201,7 +1201,7 @@ short imp_doing_nothing(struct Thing *spdigtng)
{
SYNCDBG(19,"Starting for %s index %d",thing_model_name(spdigtng),(int)spdigtng->index);
TRACE_THING(spdigtng);
if (!thing_is_creature_special_digger(spdigtng))
if (!thing_is_creature_digger(spdigtng))
{
ERRORLOG("Non digger thing %ld, %s, owner %ld - reset",(long)spdigtng->index,thing_model_name(spdigtng),(long)spdigtng->owner);
set_start_state(spdigtng);
Expand Down
4 changes: 3 additions & 1 deletion src/dungeon_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "thing_traps.h"
#include "roomspace.h"
#include "config_creature.h"
#include "creature_states.h"

#include "power_hand.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -154,7 +156,7 @@ struct Dungeon {
unsigned short num_summon;
ThingIndex things_in_hand[MAX_THINGS_IN_HAND];
unsigned char num_things_in_hand;
unsigned short field_64[CREATURE_TYPES_MAX][15];
unsigned short crmodel_state_type_count[CREATURE_TYPES_MAX][STATE_TYPES_COUNT];
unsigned short guijob_all_creatrs_count[CREATURE_TYPES_MAX][3];
unsigned short guijob_angry_creatrs_count[CREATURE_TYPES_MAX][3];
int sight_casted_gameturn;
Expand Down
24 changes: 12 additions & 12 deletions src/frontmenu_ingame_tabs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1759,29 +1759,29 @@ void gui_activity_background(struct GuiMenu *gmnu)
activity_list[4*i+0] = 0;
activity_list[4*i+1] = 0;
activity_list[4*i+2] = 0;
for (int n = 0; n < 15; n++)
for (int n = 0; n < STATE_TYPES_COUNT; n++)
{
int job_idx = state_type_to_gui_state[n];
switch (job_idx)
int gui_state_idx = state_type_to_gui_state[n];
switch (gui_state_idx)
{
case 0:
activity_list[4*i+0] += dungeon->field_64[crmodel][n];
case CrGUIJob_Wandering:
activity_list[4*i+0] += dungeon->crmodel_state_type_count[crmodel][n];
break;
case 1:
activity_list[4*i+1] += dungeon->field_64[crmodel][n];
case CrGUIJob_Working:
activity_list[4*i+1] += dungeon->crmodel_state_type_count[crmodel][n];
break;
case 2:
activity_list[4*i+2] += dungeon->field_64[crmodel][n];
case CrGUIJob_Fighting:
activity_list[4*i+2] += dungeon->crmodel_state_type_count[crmodel][n];
break;
default:
ERRORLOG("Outranged GUI state value %d",(int)job_idx);
ERRORLOG("Outranged GUI state value %d",(int)gui_state_idx);
break;
}
}
}
int mm_units_per_px = (gmnu->width * 16 + 140 / 2) / 140;
lbDisplay.DrawFlags |= Lb_SPRITE_TRANSPAR4;
LbDrawBox(gmnu->pos_x + scale_value_for_resolution_with_upp(2, mm_units_per_px), gmnu->pos_y + scale_value_for_resolution_with_upp(218, mm_units_per_px), scale_value_for_resolution_with_upp(134, mm_units_per_px), scale_value_for_resolution_with_upp(24, mm_units_per_px), colours[0][0][0]);
LbDrawBox(gmnu->pos_x + scale_ui_value(2),gmnu->pos_y + scale_ui_value(218),scale_ui_value(134),scale_ui_value(24),colours[0][0][0]);

lbDisplay.DrawFlags = flg_mem;
}

Expand Down
Loading