kibook / redm-undead

Replace human peds with the undead
10 stars 5 forks source link

Improvement Proposal: Zombie spawning should be carried out around the player, and not by replacing some NPCs with others. #3

Open KamiliaBlow opened 3 years ago

KamiliaBlow commented 3 years ago

If you use this script and set the NPC population to 0, then the zombies will not spawn. In addition, zombies spawn in too many numbers if you set the spawn setting to "world"

KamiliaBlow commented 3 years ago

image This is an extremely high number of npc for a given area.

kibook commented 3 years ago

This resource currently works by literally replacing human peds with "zombie" peds, so if you remove all human peds it will have nothing to replace.

What exactly is "too many numbers"? I have my population density multipliers at 1 (max) on my server, and while it certainly ends up spawning a lot of zombies, I don't see that as a bad thing. If you lower the population density multipliers, you should also get less zombies.

I think the only things that could be done here are to either co-opt the functionality of the popdensity resource, so that this resource can adjust the multiplier itself and set it to a fixed number for clients inside the zombie zone, and/or to manage spawnpoints itself instead of replacing human peds spawned by the game.

I think ultimately the best solution would be a combination of the two: allow it to control population density to disable normal spawns while inside the zone, and then spawn the zombies on its own. That would fix the issues mentioned here as well as an issue where you sometimes can see human peds getting deleted.

In that case, it will still be incompatible with the popdensity resource, since both need to control the population density multipliers. It could be possible to add exports to popdensity, allowing this resource to control the population through it instead of on its own, and basically making popdensity a dependency of this resource, but I'd have to look into that.

KamiliaBlow commented 3 years ago

I put this resource (popdensity) on purpose in the hope of controlling population density. But if you implement this, there will be no point in this script. I install the script in the hope of completely removing the population, since I literally see them appear and immediately disappear.

As for the large number, yes, I can really reduce the population, but then there will be fewer zombies in the city than expected. It may be worth making a condition under which, if zombies spawn in the city, there are more of them than zombies outside the city.

kibook commented 3 years ago

I put this resource (popdensity) on purpose in the hope of controlling population density. But if you implement this, there will be no point in this script.

I may make it so the undead resource uses the popdensity resource to control the population density multipliers for players inside an undead zone (or all players if the zone is "world"). So, your default settings for popdensity will be applied when not in an undead zone, and when inside a zone the undead resource will override them. I don't believe there's any way to make these scripts "compatible" with each other without some form of communication between them, since they are both doing the same thing but possibly in conflicting ways. popdensity will therefore become a dependency of this resource, like uiprompt and uifeed.

I've already added client-side exports to popdensity which will allow another resource to adjust the density multipliers per client. The next step is calling these exports in the undead resource to set and reset the multipliers when you enter and exit an undead zone.

It should be something like this: when you enter an undead zone, it calls:

exports.popdensity:setMultiplier("ambientPeds", 0.75)

and when you leave an undead zone, it calls:

exports.popdensity:resetMultiplier("ambientPeds")

As for the large number, yes, I can really reduce the population, but then there will be fewer zombies in the city than expected. It may be worth making a condition under which, if zombies spawn in the city, there are more of them than zombies outside the city.

Even with a lower density multiplier, I believe there will still be more peds in the city than in a smaller town. In other words, I think the multipliers are relative, a multiplier of 0.5 means 50% of the max population, but that max population is higher for a big city than a small town. I can't say with 100% certainty that this is true, but I do set my multipliers to 1.0 (max) on my server, and towns like Valentine don't seem to get nearly as many peds as Saint Denis, so it seems like it's correct.

That said, it should be possible to detect which town/city you are in and adjust the multipliers based on that, maybe with a configuration option for each town, but I'd have to see if that's even necessary.

KamiliaBlow commented 3 years ago

I think I figured out why I have so many npc. Your script removes the newly created normal npc and replaces it with zombies, and does this until the new npc stops spawning. It seems that replacing NPCs is not the best option for spawning zombies, as it is more spamming zombies than spawning them

kibook commented 3 years ago

Yes, that's exactly what it does. It watches for any new human peds being spawned, deletes them and spawns a zombie ped where they were, though the latter part only happens if that ped wasn't in view of a player. It was a quick and dirty method of doing spawns out of sight without needing to lay out a bunch of spawn points all over the map by hand. I'm guessing there may be a way to use actual spawn points (possibly using SPAWNPOINTS_START_SEARCH), but it isn't something I'm familiar with yet.

The number of zombies hasn't been an issue for me, but I agree that there should be a better, more customizable way to do the spawning.

KamiliaBlow commented 3 years ago

I looked at the implementation of zombie spawn on Fivem, it looks like they use spawn around the player in a certain radius.

As presented here: https://github.com/Dislaik/esx_zombiesystem/blob/master/client/main.lua

This is certainly not the best spawning option, but more optimized than replacing Peds.

majkolin commented 2 years ago

Script is wonderful but it crashes client when there are more players in zone I guess because of load of peds. But great work