Jump to content

Looking for help adding/tweaking a spawn mechanic for a drifter mod.


Recommended Posts

Greetings.

I'm working on a version of a mod that makes drifters more dynamic in their attack and behavior.  One major feature of the mod is that higher tier drifters have a very small chance to spawn anywhere in the world from surface to mantle.

Basically I treat the surface and underground as two halves to the world. Surface drifters spawn anywhere above ground, and deep drifters are the lower world counterpart to surface drifters, spawning anywhere underground down to the mantle.

Tainted through nightmare drifters can spawn anywhere where there is a light level of zero. Tainted are more common (though still pretty uncommon compared to surface and deep drifters), corrupt drifters are rare, and nightmare drifters are very rare.  This sort of makes corrupt and nightmare drifters sort of a mini-boss that shows up from time to time.

The issue is, I want them to show up more often underground while remaining rare on the surface. For that, I need to add code to the mod that enables higher spawn chances underground (and increasing spawn chances the deeper you go, if that does not prove too hard to accomplish). If this parameter could be configurable, that would be fantastic.

I can modify .json files, but I can't write code. If any of you code wizards would be interested and willing to collaborate with me on this particular feature in the mod, I'd be grateful.

~TH~

Editing to add some additional info to give an idea on what I'm working on and why this is such a desired feature for the project:

Via .json editing I've been able to develop drifter attributes that give the following changes:

  • Faster in various, specific ways
  • Unpredictable, with balanced, random leaping attacks that vary by type,
  • Much harder to dodge if one gets too close, but still avoidable if you can learn the timing of the various drifter types' attacks. Running through a pack of drifters without damage is near impossible, and carelessly getting to close to one has a much increased chance of their landing a hit, but even with all that I have worked to keep a balanced feel to combat with them,
  • Drifters have a slightly higher vertical reach, making the two-block high "nerd poling" tactic, as some call it, obsolete,
  • Some drifters have had an unused animation in their shape file added to them, causing them at times to crawl rapidly toward you (quite creepy coming at you in the dark out of brush and tall grass),
  • Added "Rage Mode" sort of behavior that can be triggered if you tick them off enough (do enough damage),
  • Reduced spawn sizes and greatly reduced spawn chances for top three tier of drifters, but encounters with them are much more memorable,
  • Adjusted loot drops to make more rare and more dangerous higher tier drifters more valuable,
  • Mr1k3's vision and reworking of the way drifters look in his Better Drifters mod (of which this is a branch I've been working on for my server, with permission), has rendered them much larger than their vanilla counterparts and quite terrifying and intimidating to encounter. The only edit I've made is to make corrupt drifters much larger.
  • Lowered light level requirements for all drifters, making it easier to prevent spawning via using light sources,
  • Spawning parameters that make encountering all drifter types likely regardless of your elevation in the world, though corrupt and nightmare drifters are very, very rare anywhere (which is one thing I am hoping to change the deeper you go below ground, which is what the op request here is seeking to address).

This feels like one last element I'm looking for in my vision for how drifters will work in the game world, but it is beyond my abilities to implement, since it requires code work. 😔

Edited by Thalius
  • Like 1
Link to comment
Share on other sites

Hello, im not a code wizard but something i can code too :D.

Here is the codefile. It makes, that only the third part of the drifters, which spawn above the Y-Position 100, really spawn. You can open the file with the normal text-editor or a better programm and change the properties. Its written down there, where you must change.

Dont forget to create a "src" folder next to the assets folder, change your modtype to "code" and change the drifterclass to th class "EntityDrifter".

I've tested the mod out and even if you spawn a drifter with the spawnitem, there is a chance, that he does'nt spawn. In fact, the naturally spawning and the spawning with the item is the same.

I hope i could help you, and sorry for my writing mistakes, im not english :D

Class1.cs

  • Like 2
Link to comment
Share on other sites

10 hours ago, Vintagebob said:

Hello, im not a code wizard but something i can code too :D.

Here is the codefile. It makes, that only the third part of the drifters, which spawn above the Y-Position 100, really spawn. You can open the file with the normal text-editor or a better programm and change the properties. Its written down there, where you must change.

Dont forget to create a "src" folder next to the assets folder, change your modtype to "code" and change the drifterclass to th class "EntityDrifter".

I've tested the mod out and even if you spawn a drifter with the spawnitem, there is a chance, that he does'nt spawn. In fact, the naturally spawning and the spawning with the item is the same.

I hope i could help you, and sorry for my writing mistakes, im not english :D

Class1.cs 1.83 kB · 3 downloads

Thank you for the file!

I'm looking it over and trying to understand what it does, exactly. I don't know .cs code at all. :P

Link to comment
Share on other sites

Posted (edited)

@Vintagebob
I've been looking over the way you wrote that code up, and I've concluded that it is not going to have the result the mod needs to work right.  I think it will work as you wrote it, but the results are not quite what I'm looking for.

It did give me something to think on though, and I thought it might be helpful to share here in case you or anyone else is still thinking on this.

Based on your code and the way you used the "y" axis in a formula to modify spawn chances, I've come up with a formula that should explain more clearly what I have in mind. No idea how hard this might be to code in, but here it goes. ;)

ms= x/(y/m)

Where:
"ms" equals the modified spawn chance we are looking for,
"x" equals the spawn chance assigned to an entity,
"y" equals the y axis coordinate,
"m" equals the modifier.

An example:
 

Spoiler

A  nightmare drifter has a default spawn chance (x) of .1.
World height (y) is 200.
Modifier (m) is set at 10.

ms = x/(y/m)
ms = .1/(200/10)
ms = .1/20
ms = .005

Nightmare drifters thus would have a .5% chance of spawning at a world height of 200.



Another example:
 

Spoiler

A nightmare drifter has default spawn chance of .1,
World height is 100,
Modifier is 10.

ms = x/(y/m)
ms = .1/(100/10)
ms = .1/10
ms = .01

Nightmare drifters would thus have a 1% chance of spawning at a world height of 100.


If I want spawn rates of a specific drifter to be higher, I modify the spawn chance assigned to that specific drifter. If I wan the spawn rates of all drifters to be higher or lower at various depths, I adjust the modifier smaller or larger accordingly. If this code/modifier spawn behavior could be included in the entity's .json file under spawn conditions and adjusted there, that would be fantastic. If not, I'd imagine it should be easy to add a config file to set the modifier as desired.

The only issue is that at very low world heights, the spawn chance is going to jump very high, very quickly.
Example:

Spoiler

A nightmare drifter has a default spawn chance of .1.
World height is 5.
Modifier is 10.

ms = x/(y/m)
ms = .1/(5/10)
ms = .1/.5
ms = .2

Nightmare drifters would thus have a 20% chance of spawning at a world height of 5.


At the mantle, (y=1), the spawn chance is 1.0.  Pretty much overrun at a 100% spawn chance.

To address this there would need to be a line that did the following:
If: ms > x, Then: ms = x.

The aim would be to prevent the modified spawn chance from ever exceeding the entity's unmodified spawn chance.

I've heard from one other who is looking into this, but I have no clue who else out there might be giving this some thought.  I figured it might be helpful to add this to the thread for consideration and for clarity on what I've got in mind.

Thank you to those taking an interest in this! It is much appreciated. ;)

~TH~

Edited by Thalius
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.