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

Implemented new property to block imps from taking objects #3541

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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 .vscode/compile_settings.cfg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DEBUG=0
DEBUG=1
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is an oversight?

5 changes: 5 additions & 0 deletions src/config_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const struct NamedCommand objects_properties_commands[] = {
{"BUOYANT", 5},
{"BEATING", 6},
{"HEART", 7},
{"IGNORED_BY_IMPS", 8},
{NULL, 0},
};

Expand Down Expand Up @@ -281,6 +282,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, blocknamelen, blockname, config_textname);
Expand Down
1 change: 1 addition & 0 deletions src/config_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};


Expand Down
21 changes: 9 additions & 12 deletions src/creature_states_spdig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Contributor

Choose a reason for hiding this comment

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

What about crates? If mapmaker gives the flag to crate, it will still be able to be dragged on right? Altho I can't imagine a scenario where mapmaker would want a not draggable crate. 🤔

Another thing, what about gold pot or gold pile? Not technically draggable but the name IGNORED_BY_IMPS makes me think it could work if I were to set this flag on those objects, but it doesn't of course, the flag name is confusing.

So maybe a name change to make sense? Like NOT_DRAGGABLE for example. 🤔

Let me know what you think about it.

Copy link
Member

Choose a reason for hiding this comment

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

I suppose the (thing_is_spellbook(thing) || thing_is_special_box(thing)) is unneeded as thing_can_be_picked_to_place_in_player_room_of_role should cover it

Copy link
Member

Choose a reason for hiding this comment

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

What about crates? If mapmaker gives the flag to crate, it will still be able to be dragged on right? Altho I can't imagine a scenario where mapmaker would want a not draggable crate. 🤔

check_out_unclaimed_traps already uses thing_can_be_picked_to_place_in_player_room_of_role so should be ok

Copy link
Member

Choose a reason for hiding this comment

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

Another thing, what about gold pot or gold pile? Not technically draggable but the name IGNORED_BY_IMPS makes me think it could work if I were to set this flag on those objects, but it doesn't of course, the flag name is confusing.

looks like get_next_unclaimed_gold_thing_pickable_by_digger has it as a TODO but indeed it could also make use of thing_can_be_picked_to_place_in_player_room_of_role

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as far as tested, this works with crates, spellbooks, and special boxes, also in possession mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks like get_next_unclaimed_gold_thing_pickable_by_digger has it as a TODO but indeed it could also make use of thing_can_be_picked_to_place_in_player_room_of_role

yes, I think mapmakers could appreciate having this option

{
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))
Expand Down Expand Up @@ -566,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;
}
}
}
Expand Down
19 changes: 7 additions & 12 deletions src/spdigger_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -1706,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
Expand Down
2 changes: 1 addition & 1 deletion src/thing_creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -6891,7 +6891,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)) ) &&
Expand Down
2 changes: 1 addition & 1 deletion src/thing_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down