Skip to content

Commit

Permalink
"Fix" the check_monster_behavior_tree_locust placing a nonsense plant…
Browse files Browse the repository at this point in the history
… furniture
  • Loading branch information
Procyonae committed Dec 14, 2024
1 parent a197a65 commit 0635102
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions data/mods/TEST_DATA/behaviour_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"type": "mapgen",
"nested_mapgen_id": "test_seedling",
"method": "json",
"object": {
"mapgensize": [ 1, 1 ],
"sealed_item": { " ": { "items": { "item": "farming_seeds", "chance": 100 }, "furniture": "f_plant_seedling" } }
}
}
]
15 changes: 14 additions & 1 deletion tests/behavior_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ static const itype_id itype_sandwich_cheese_grilled( "sandwich_cheese_grilled" )
static const itype_id itype_sweater( "sweater" );
static const itype_id itype_water( "water" );

static const nested_mapgen_id nested_mapgen_test_seedling( "test_seedling" );

static const string_id<behavior::node_t> behavior_node_t_npc_needs( "npc_needs" );

namespace behavior
Expand Down Expand Up @@ -228,7 +230,18 @@ TEST_CASE( "check_monster_behavior_tree_locust", "[monster][behavior]" )
SECTION( "Special Attack EAT_CROP" ) {
test_monster.set_special( "EAT_CROP", 0 );
CHECK( monster_goals.tick( &oracle ) == "idle" );
here.furn_set( monster_location, furn_id( "f_plant_seedling" ) );

// Gross but I couldn't figure out how to place a sealed item without manual mapgen and the mapgen helper version doesn't let you specify rel_ms and adding that as a defaulted arg breaks the templated manual_mapgen()...
const tripoint_abs_ms abs_pos = here.getglobal( monster_location );
tripoint_abs_omt pos;
point_omt_ms pos_rel;
std::tie( pos, pos_rel ) = project_remain<coords::omt>( abs_pos );
tinymap tm;
tm.load( pos, true );
mapgendata md( pos, *tm.cast_to_map(), 0.0f, calendar::turn, nullptr );
const auto &ptr = nested_mapgens[nested_mapgen_test_seedling].funcs().pick();
( *ptr )->nest( md, tripoint_rel_ms( rebase_rel( pos_rel ), 0 ), "test" );

CHECK( monster_goals.tick( &oracle ) == "EAT_CROP" );
test_monster.set_special( "EAT_CROP", 1 );
CHECK( monster_goals.tick( &oracle ) == "idle" );
Expand Down

0 comments on commit 0635102

Please sign in to comment.