-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Replace add_spawn() calls in mapgen with place_spawn() #3951
Comments
It will take some time, but I'll get it. |
I think it also makes the monster blacklist mod function fail. Which means we can't remove certain monsters from the game in their entirety via a mod, because they are hard coded. |
Afraid there are quite a few of these left in mapgen.cpp and mission_start.cpp |
Yes, sorry. I've somehow searched for this function only in |
I won't replace void mission_start::place_zombie_mom( mission *miss )
{
const tripoint house = random_house_in_closest_city();
miss->target = house;
overmap_buffer.reveal( house, 6 );
tinymap zomhouse;
zomhouse.load( house.x * 2, house.y * 2, house.z, false );
zomhouse.add_spawn( mon_zombie, 1, SEEX, SEEY, false, -1, miss->uid,
Name::get( nameIsFemaleName | nameIsGivenName ) );
zomhouse.save();
} |
Step 2 is in #22852. When that will be merged only 85 |
Step 3 is in #22854. When that will be merged only 67 |
Hi, I'm looking to start contributing to Cataclysm. Could I finish this task, if any |
Beware, it can end bad. |
Ok, I read the issue you linked. Could that issue be solved by adding some flag to Then, spawns for monsters like zombies can stay as a group, and spawns intended for turrets or powerful monsters can have the flag set to true so that only one of them spawns. |
@ZhilkinSerg @kevingranade I've listed the relevant bits of the place_spawns() method with comments where I made changes.
|
On a related note, there are certain spawns of individual, specific monsters that don't have monster groups like hazmat bots and fungaloids (lines 3787, 3843 of mapgen.cpp respectively). I saw that in the old, rolled-back commits, special monster groups consisting of only those monsters existed. Should I adopt that approach or is there some other approach I'm overlooking? |
That could be some legacy code which was not refactored yet. Generally we want most of the things unhardcoded and jsonized. Starting replacing single monster spawn with monster groups would be a good start. |
Thanks for the input. I'll keep at it. |
Should this issue be closed now? I see no add_spawn() in current source code. |
There are still dozens of occurrences of |
My bad, I was using the search wrong
|
Since there are only about eight of these left, I'm going to make this a blocker. It should be trivial to finish and close this ancient issue |
I can take a stab at this once I have my local environment configured - or happy to help @aaronstevenson408 if they feel good about making the changes |
@cathalpern im willing to work on it with you. i'm in the discord , you can @ me or dm me so we can organize |
I would think that's the actual intended spot for it |
@I-am-Erk just to make sure I'm understanding correctly - leave the add_spawn calls within place_spawns, yes? |
Gonna put in a PR for L6185, L2370, L2363, L275 in mapgen, L332, L333, L970 in mapgen_functions tomorrow |
A list of all the replacements necessary
|
ones that are bolded are ones that are chosen , unbolded ones are up for grabs , im assuming that @nornagon is gonna take the ones in map extras, on confirm those will be bolded |
map_extras.cpp PRs:
with all these merged there will be no more references to |
@nornagon you are way too good , at this rate you are gonna finish this before anyone else, if you want you can take lead on this, i have to reset up my dev enviroment tomorrow so if you want to keep on at this clip take mine on |
So I rewrote most of the calls to add_spawn in mapgen.cpp and map.cpp, and have those pushed to a branch in my fork - but since that would be touching some pretty core, potentially majorly breaking game functionality, I wonder if they should be put off, and just focus on replacing the calls in other files for 0.G |
Enough progress has been made here that I am content to move this along out of blockers now. I just did not want to see it sitting here waiting another six years. |
I think with the zombie mom mission JSON-ized, this issue should be closed. I think all of the old add_spawn calls have been converted. |
#68752 added a new one. |
|
Making it private: diff --git a/src/map.h b/src/map.h
index 17dbf6727d..01f8086223 100644
--- a/src/map.h
+++ b/src/map.h
@@ -1719,13 +1719,7 @@ class map
// places an NPC, if static NPCs are enabled or if force is true
character_id place_npc( const point &p, const string_id<npc_template> &type );
void apply_faction_ownership( const point &p1, const point &p2, const faction_id &id );
- void add_spawn( const mtype_id &type, int count, const tripoint &p,
- bool friendly = false, int faction_id = -1, int mission_id = -1,
- const std::string &name = "NONE" );
- void add_spawn( const mtype_id &type, int count, const tripoint &p, bool friendly,
- int faction_id, int mission_id, const std::string &name,
- const spawn_data &data );
- void add_spawn( const MonsterGroupResult &spawn_details, const tripoint &p );
+
void do_vehicle_caching( int z );
// Note: in 3D mode, will actually build caches on ALL z-levels
void build_map_cache( int zlev, bool skip_lightmap = false );
@@ -1873,6 +1867,15 @@ class map
*/
void rotten_item_spawn( const item &item, const tripoint &p );
private:
+ // Use place_spawns or JSON mapgen instead
+ void add_spawn( const mtype_id &type, int count, const tripoint &p,
+ bool friendly = false, int faction_id = -1, int mission_id = -1,
+ const std::string &name = "NONE" );
+ void add_spawn( const mtype_id &type, int count, const tripoint &p, bool friendly,
+ int faction_id, int mission_id, const std::string &name,
+ const spawn_data &data );
+ void add_spawn( const MonsterGroupResult &spawn_details, const tripoint &p );
+
// Helper #1 - spawns monsters on one submap
void spawn_monsters_submap( const tripoint &gp, bool ignore_sight, bool spawn_nonlocal = false );
// Helper #2 - spawns monsters on one submap and from one group on this submap There are a few calls outside of src/map_field.cpp: In function ‘void field_processor_monster_spawn(const tripoint&, field_entry&, field_proc_data&)’:
src/map_field.cpp:768:38: error: ‘void map::add_spawn(const MonsterGroupResult&, const tripoint&)’ is private within this context
768 | pd.here.add_spawn( mgr, *spawn_point );
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ That map extra src/map_extras.cpp: In function ‘bool MapExtras::mx_fungal_zone(map&, const tripoint&)’:
src/map_extras.cpp:2168:25: error: ‘void map::add_spawn(const mtype_id&, int, const tripoint&, bool, int, int, const std::string&)’ is private within this context
2168 | fungal_map.add_spawn( mon_fungaloid_queen, 1, suitable_location );
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monster reproduction src/monster.cpp: In member function ‘void monster::try_reproduce()’:
src/monster.cpp:607:31: error: ‘void map::add_spawn(const mtype_id&, int, const tripoint&, bool, int, int, const std::string&)’ is private within this context
607 | here.add_spawn( type->baby_monster, spawn_cnt, pos() );
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ JSON Mapgen: src/mapgen.cpp: In member function ‘virtual void jmapgen_monster::apply(const mapgendata&, const jmapgen_int&, const jmapgen_int&, const std::string&) const’:
src/mapgen.cpp:2458:36: error: ‘void map::add_spawn(const mtype_id&, int, const tripoint&, bool, int, int, const std::string&, const spawn_data&)’ is private within this context
2458 | dat.m.add_spawn( mgr.name, spawn_count * pack_size.get(),
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2459 | { x.get(), y.get(), dat.m.get_abs_sub().z() },
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2460 | friendly, -1, mission_id, chosen_name, data );
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The map extra is trivial, the rest probably aren't. |
Is add_spawn heavily tied to place_spawn in terms of backend code support? If not, why not just delete all of the backend code for add_spawn and use that method as an enforcement mechanism to keep it from coming up again? Or, is the backend tied to too many things for it to be reasonable? |
There are several building layouts in mapgen.cpp and building_generation.cpp that have add_spawn() calls placing specific monsters on the map instead of place_spawn, which is more generic and selects monsters from a group. This causes issues with the options that modify spawn behavior, because add_spawn() doesn't support those options.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: