From 58224a6c8b241cfbb88f542065a544b3b3ddc9d2 Mon Sep 17 00:00:00 2001 From: Shinthoras0815 <71405803+Shinthoras0815@users.noreply.github.com> Date: Thu, 10 Oct 2024 04:17:27 +0200 Subject: [PATCH 1/2] Implemented new property to block imps from taking objects --- .vscode/compile_settings.cfg | 2 +- src/config_objects.c | 5 +++++ src/config_objects.h | 1 + src/creature_states_spdig.c | 3 ++- src/spdigger_stack.c | 6 +++++- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.vscode/compile_settings.cfg b/.vscode/compile_settings.cfg index cc986409f9..ab445cce70 100644 --- a/.vscode/compile_settings.cfg +++ b/.vscode/compile_settings.cfg @@ -1 +1 @@ -DEBUG=0 +DEBUG=1 diff --git a/src/config_objects.c b/src/config_objects.c index a888f7990b..ce70017894 100644 --- a/src/config_objects.c +++ b/src/config_objects.c @@ -95,6 +95,7 @@ const struct NamedCommand objects_properties_commands[] = { {"BUOYANT", 5}, {"BEATING", 6}, {"HEART", 7}, + {"IGNORED_BY_IMPS", 8}, {NULL, 0}, }; @@ -290,6 +291,10 @@ TbBool parse_objects_object_blocks(char *buf, long len, const char *config_textn objst->model_flags |= OMF_Heart; n++; break; + case 8: // IGNORED_BY_IMPS + objst->model_flags |= OMF_IgnoredByImps; + n++; + break; default: CONFWRNLOG("Incorrect value of \"%s\" parameter \"%s\" in [%s] block of %s file.", COMMAND_TEXT(cmd_num),word_buf,block_buf,config_textname); diff --git a/src/config_objects.h b/src/config_objects.h index 875948a6a0..21b3964493 100644 --- a/src/config_objects.h +++ b/src/config_objects.h @@ -56,6 +56,7 @@ enum ObjectModelFlags { OMF_Buoyant = 0x0010, // Some objects do not get their sprite cut off when on water/lava OMF_Beating = 0x0020, // If the object is a heart, do the flashing, beating, back and forth animation that imitates a heartbeat OMF_Heart = 0x0040, // Functions as the heart of the dungeon + OMF_IgnoredByImps = 0x0080, // Specialdiggers don't dragging this object }; diff --git a/src/creature_states_spdig.c b/src/creature_states_spdig.c index 4ee3e89828..45cabd5116 100644 --- a/src/creature_states_spdig.c +++ b/src/creature_states_spdig.c @@ -320,7 +320,8 @@ long check_out_unclaimed_spells(struct Thing *spdigtng, long range) break; i = thing->next_of_class; // Per-thing code - if (thing_is_spellbook(thing) || thing_is_special_box(thing)) + if ((thing_is_spellbook(thing) || thing_is_special_box(thing)) && + thing_can_be_picked_to_place_in_player_room_of_role(thing, spdigtng->owner, RoRoF_PowersStorage, TngFRPickF_Default)) { if ((thing->owner != spdigtng->owner) && !thing_is_dragged_or_pulled(thing) && (get_slab_owner_thing_is_on(thing) == spdigtng->owner) && thing_revealed(thing, spdigtng->owner)) diff --git a/src/spdigger_stack.c b/src/spdigger_stack.c index 9a0d1634dd..8110644dca 100644 --- a/src/spdigger_stack.c +++ b/src/spdigger_stack.c @@ -1647,6 +1647,10 @@ TbBool thing_can_be_picked_to_place_in_player_room_of_role(const struct Thing* t if (thing_is_dragged_or_pulled(thing)) { return false; } + struct ObjectConfigStats* objst = get_object_model_stats(thing->model); + if (objst->model_flags & OMF_IgnoredByImps) { + return false; + } struct SlabMap *slb; slb = get_slabmap_for_subtile(thing->mappos.x.stl.num, thing->mappos.y.stl.num); // Neutral things on either neutral or owned ground should be always pickable @@ -1687,7 +1691,7 @@ TbBool thing_can_be_picked_to_place_in_player_room_of_role(const struct Thing* t return true; } } - return false; +return false; } struct Thing *get_next_unclaimed_gold_thing_pickable_by_digger(PlayerNumber owner, int start_idx) From 7ae8ff390d1a6406843becb606e1c2ef7f3aca31 Mon Sep 17 00:00:00 2001 From: Shinthoras0815 <71405803+Shinthoras0815@users.noreply.github.com> Date: Sat, 12 Oct 2024 03:37:44 +0200 Subject: [PATCH 2/2] gold objects can also be blocked --- src/creature_states_spdig.c | 18 +++++++----------- src/spdigger_stack.c | 13 ++----------- src/thing_creature.c | 2 +- src/thing_objects.c | 2 +- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/creature_states_spdig.c b/src/creature_states_spdig.c index 45cabd5116..c58f136254 100644 --- a/src/creature_states_spdig.c +++ b/src/creature_states_spdig.c @@ -567,22 +567,18 @@ long check_out_unclaimed_gold(struct Thing *spdigtng, long range) break; i = thing->next_of_class; // Per-thing code - if (thing_is_object(thing) && !thing_is_picked_up(thing) && thing_revealed(thing, spdigtng->owner)) + if (!thing_is_picked_up(thing) && thing_can_be_picked_to_place_in_player_room_of_role(thing, thing->owner, RoRoF_GoldStorage, TngFRPickF_Default)) { if (object_is_gold_pile(thing)) { - struct SlabMap* slb = get_slabmap_thing_is_on(thing); - if ((slabmap_owner(slb) == spdigtng->owner) || (slabmap_owner(slb) == game.neutral_player_num)) + if ((range < 0) || get_chessboard_distance(&thing->mappos, &spdigtng->mappos) < range) { - if ((range < 0) || get_chessboard_distance(&thing->mappos, &spdigtng->mappos) < range) + if (!imp_will_soon_be_working_at_excluding(spdigtng, thing->mappos.x.stl.num, thing->mappos.y.stl.num)) { - if (!imp_will_soon_be_working_at_excluding(spdigtng, thing->mappos.x.stl.num, thing->mappos.y.stl.num)) - { - if (setup_person_move_to_coord(spdigtng, &thing->mappos, NavRtF_Default)) { - spdigtng->continue_state = CrSt_ImpPicksUpGoldPile; - //cctrl->pickup_object_id = thing->index; -- don't do that; picking up gold destroys the object - return 1; - } + if (setup_person_move_to_coord(spdigtng, &thing->mappos, NavRtF_Default)) { + spdigtng->continue_state = CrSt_ImpPicksUpGoldPile; + //cctrl->pickup_object_id = thing->index; -- don't do that; picking up gold destroys the object + return 1; } } } diff --git a/src/spdigger_stack.c b/src/spdigger_stack.c index 8110644dca..944633ef76 100644 --- a/src/spdigger_stack.c +++ b/src/spdigger_stack.c @@ -1710,22 +1710,13 @@ struct Thing *get_next_unclaimed_gold_thing_pickable_by_digger(PlayerNumber owne // Per-thing code if (thing_is_object(thing) && object_is_gold_pile(thing)) { - // TODO DIGGERS Use thing_can_be_picked_to_place_in_player_room_of_role() instead of single conditions - //if (thing_can_be_picked_to_place_in_player_room_of_role(thing, owner, RoRoF_GoldStorage, TngFRPickF_Default)) - if (!thing_is_picked_up(thing) && !thing_is_dragged_or_pulled(thing)) + if (!thing_is_picked_up(thing) && thing_can_be_picked_to_place_in_player_room_of_role(thing, owner, RoRoF_GoldStorage, TngFRPickF_Default)) { - if (thing_revealed(thing, owner)) - { - PlayerNumber slb_owner; - slb_owner = get_slab_owner_thing_is_on(thing); - if ((slb_owner == owner) || (slb_owner == game.neutral_player_num)) { struct Room *room; room = find_any_navigable_room_for_thing_closer_than(thing, owner, RoRoF_GoldStorage, NavRtF_Default, gameadd.map_subtiles_x/2 + gameadd.map_subtiles_y/2); if (!room_is_invalid(room)) { return thing; - } - } - } + } } } // Per-thing code ends diff --git a/src/thing_creature.c b/src/thing_creature.c index 2fa2fe2164..6263af0c83 100644 --- a/src/thing_creature.c +++ b/src/thing_creature.c @@ -6820,7 +6820,7 @@ TbBool thing_is_pickable_by_digger(struct Thing *picktng, struct Thing *creatng) return false; } struct SlabMap *slb = get_slabmap_thing_is_on(picktng); - if (object_is_gold_pile(picktng)) + if (object_is_gold_pile(picktng) && thing_can_be_picked_to_place_in_player_room_of_role(picktng, creatng->owner, RoRoF_GoldStorage, TngFRPickF_Default)) { struct CreatureStats* crstat = creature_stats_get_from_thing(creatng); return ( ( (slabmap_owner(slb) == creatng->owner) || (subtile_is_unclaimed_path(picktng->mappos.x.stl.num, picktng->mappos.y.stl.num)) || (subtile_is_liquid(picktng->mappos.x.stl.num, picktng->mappos.y.stl.num)) ) && diff --git a/src/thing_objects.c b/src/thing_objects.c index 67a4f68a3d..22ded527a6 100644 --- a/src/thing_objects.c +++ b/src/thing_objects.c @@ -579,7 +579,7 @@ TbBool object_is_room_equipment(const struct Thing *thing, RoomKind rkind) TbBool object_is_room_inventory(const struct Thing *thing, RoomRole rrole) { - if((rrole & RoRoF_GoldStorage) && object_is_gold_hoard(thing)) + if((rrole & RoRoF_GoldStorage) && object_is_gold(thing)) return true; if((rrole & RoRoF_PowersStorage) && (thing_is_spellbook(thing) || thing_is_special_box(thing))) return true;