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

Allow adding to existing monster groups in json #24301

Merged
merged 4 commits into from Jul 20, 2018

Conversation

Projects
None yet
3 participants
@glamcube17
Copy link
Contributor

commented Jul 15, 2018

Currently, there is no way for a mod to modify the contents of a monster group without entirely overriding it. This makes it... rather difficult to get modded monsters to show up in existing locations. And by "rather difficult" I mean "this PR was the easiest way".

For situations where entirely overriding the group is desired, adding "override": true will result in the old behavior of discarding the existing contents.

Additionally, "freq_total": int and "auto_total": true change the maximum number to "roll" for spawns, rather than it being hardcoded at 1000. freq_total changes it to the number specified, while auto_total changes it to the sum of each entry's frequencies.

@@ -317,7 +317,14 @@ void MonsterGroupManager::LoadMonsterGroup( JsonObject &jo )
MonsterGroup g;

g.name = mongroup_id( jo.get_string( "name" ) );
g.defaultMonster = mtype_id( jo.get_string( "default" ) );
bool extending = false; //If already a group with that name, add to it instead of overwriting it
if( monsterGroupMap.count( g.name ) != 0 && !jo.get_bool( "override", false) ) {

This comment has been minimized.

Copy link
@DracoGriffin

DracoGriffin Jul 15, 2018

Member

Think you need a space after false here , false )

g = monsterGroupMap[g.name];
extending = true;
}
if( !extending || jo.has_string("default") ) { //Not mandatory to specify default if extending existing group

This comment has been minimized.

Copy link
@DracoGriffin

DracoGriffin Jul 15, 2018

Member

And I think "default" needs space on either side jo.has_string( "default" )

This comment has been minimized.

Copy link
@glamcube17

glamcube17 Jul 16, 2018

Author Contributor

Fixed, along with splitting a line that was too long. That should be all the astyle issues from what I could tell.

glamcube17 added some commits Jul 16, 2018

@ZhilkinSerg ZhilkinSerg self-assigned this Jul 18, 2018

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor

commented Jul 18, 2018

Can you please use it in some mod as an example?

@ZhilkinSerg ZhilkinSerg removed their assignment Jul 18, 2018

@glamcube17

This comment has been minimized.

Copy link
Contributor Author

commented Jul 20, 2018

Say you wanted to make bunnies sometimes spawn instead of zombies earlygame. You could do:

{
    "type":"monstergroup",
    "name":"GROUP_ZOMBIE",
    "freq_total": 1300,
    "monsters": [
      { "monster" : "mon_rabbit", "freq" : 150, "cost_multiplier" : 5 },
      { "monster" : "mon_rabbit", "freq" : 100, "cost_multiplier" : 15, "pack_size": [2,4] },
      { "monster" : "mon_rabbit", "freq" : 50, "cost_multiplier" : 25, "pack_size": [6,12] }
    ]
}

Or maybe you think mansions are too easy and want to turn them into a hellscape nightmarezone:

{
    "type":"monstergroup",
    "name":"GROUP_MANSION",
    "override": true,
    "auto_total": true,
    "default": "mon_null",
    "monsters": [
      { "monster" : "mon_blob_small", "freq" : 500, "cost_multiplier" : 2, "pack_size": [3,6] },
      { "monster" : "mon_blob", "freq" : 300, "cost_multiplier" : 5, "pack_size": [1,2] },
      { "monster" : "mon_blob_large", "freq" : 200, "cost_multiplier" : 7 },
      { "monster" : "mon_shoggoth", "freq" : 10, "cost_multiplier" : 30 },
      { "monster" : "mon_shoggoth", "freq" : 1, "cost_multiplier" : 300, "pack_size": [1,100], "//":"1d100 shoggoths" }
    ]
}

Or maybe you want mininuke hacks to occasionally spawn in the forest for some reason:

{
    "type":"monstergroup",
    "name":"GROUP_FOREST",
    "freq_total": 1001,
    "monsters": [
      { "monster" : "mon_mininuke_hack", "freq" : 1, "cost_multiplier" : 50 }
    ]
}

The second would be possible to do the way it currently works, but the first and third would require reproducing the whole list and scaling them proportionally to the ones you're adding.

@ZhilkinSerg ZhilkinSerg self-assigned this Jul 20, 2018

@ZhilkinSerg ZhilkinSerg merged commit a27701f into CleverRaven:master Jul 20, 2018

4 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.06%) to 23.272%
Details
gorgon-ghprb Build finished.
Details

@ZhilkinSerg ZhilkinSerg removed their assignment Jul 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.