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
Animal terrain finisher #1642
Animal terrain finisher #1642
Conversation
ASSERT(!"Unhandled world dimension"); | ||
break; | ||
} | ||
} // switch (dimension) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indenting is wrong inside the switch, there's a needless extra level.
Your indents are rather wrong, you'll need to check all of them. Don't compare set size to zero, use |
thanks for the feedback, should be all set. My formatter has been doing strange things.
|
I switched all the fast randoms to noise, but I'm wondering if the pack center and offsets should be fast random. If it's just a matter of making sure there are still cows at chunk [34, -2] then the center would not be important, especially considering they will wander. It may make a noticeable difference during generation if the chunk percentage is higher. |
// cFinishGen override: | ||
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; | ||
|
||
// Tries to spawn a mob in the center of the pack. If successful, spawns 0-5 more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use doxy-comments?
/** Tries to ... */
} | ||
} // switch (dimension) | ||
m_AnimalProbability = a_IniFile.GetValueSetI(SectionName, "AnimalSpawnChunkPercentage", DefaultAnimalSpawnChunkPercentage); | ||
if (m_AnimalProbability < 0 || m_AnimalProbability > 100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do use parenthesis for each individual comparison. It makes the conditions more understandable.
Sorry for making this so difficult |
That's great feedback, thanks for taking the time to look through it. |
I've just noticed your comment about fast random vs noise for pack centers. Don't worry about performance, the |
Hopefully that helps some, I'm still a bit fuzzy on one specific - should I 'doxy' 1-line comments on top of new methods, or just the new classes? |
@@ -18,6 +18,8 @@ | |||
#include "ComposableGenerator.h" | |||
#include "../Noise/Noise.h" | |||
#include "../ProbabDistrib.h" | |||
#include "../Mobs/Monster.h" | |||
#include "FastRandom.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FastRandom should not be needed anymore, is it?
m_AnimalProbability = a_IniFile.GetValueSetI(SectionName, "AnimalSpawnChunkPercentage", DefaultAnimalSpawnChunkPercentage); | ||
if ((m_AnimalProbability < 0) || (m_AnimalProbability > 100)) | ||
{ | ||
LOGWARNING("[Animals]: AnimalSpawnChunkPercentage is invalid, using the default of \"%d\".", DefaultAnimalSpawnChunkPercentage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You say you're using the default, but I see no code doing that.
I'm not sure what you mean by the comment "...using the default,... no code doing that.". Frankly, I just copied that from the function above but, as I understand it, the assertion will fail if none of the 3 vanilla dimensions are applicable. Should I add a line For the switch, in the case of oceans and mushroom islands, the only thing in the list should be squid and mooshroom, respectively, so the break there skips the default mobs. For the ocelot, horse, and wolf, they are added to the list in addition to the default animals, chick cow etc.. Having the default animals outside the switch would add them to the list even if in an ocean or mushIsle biome, which would just incur more cases in the TrySpawnAnimals section. |
re-read wiki, I thought animals spawned on grass in deserts on generation, but seems like only in random chunk spawning. Incorporated that into the latest build |
The warning message says that you're using the default value. But there's no code that actually sets |
As for the I suggest you put the default mobs into a separate function so that you can call it from the individual cases that do use the defaults, and then add calls to that function and breaks to the switch. |
Of course, if only cases worked as I wish they did... Thought about making a new function, but I did what you originally said and took the defaults outside the case. The only 2 cases where they do not get added are desert/end/nether and mushroom islands, which return out, so I figured it was easier that way. |
Please merge current master into this branch, run the CheckBasicStyle.lua script to find out the bad formatting, and fix that. Also, there's still the issue of default probability ( #1642 (comment) ) |
Haha, you must have got tired of telling me to format those conditionals... I see what you mean now about the default m_prob, should be all skippy now. Thanks again for being patient! |
Honestly, I just came up with a way to code the check in Lua's limited regexps, you may have been a catalyst, but certainly not the only target. |
I've made some fixes after merging. It seems to work for me, animals are spawned properly. :) |
That's awesome. Looks like: |
Adds animals to cChunkDesc entity list on chunk generation.
resolves #1595
Note: animals do not spawn, either the list does not get refreshed and sent to world, or the mobs spawn too far away and are removed shortly after.