Crafting System Suggestions
#11
(12-20-2019, 06:31 AM)Mohenjo Daro Wrote: I'm all for spawning items in. The only performance impact should be when rendering more of them, but there shouldn't be any noticeable difference outside of render distance; if there is, then there's likely an underlying issue with the code. Items should only really need the item id, unique id, and position in the world, and none of it needs to be checked unless there's a spawn timer on it.

it's not a Db related issue that I'm referring to here but rather a higher CPU and bandwidth usage for the master client.
There is obviously a need for compromise but the question is, is it worth it ? and is there a better way ?
Reply
#12
(12-20-2019, 06:49 AM)sha1 Wrote: it's not a Db related issue that I'm referring to here but rather a higher CPU and bandwidth usage for the master client.
There is obviously a need for compromise but the question is, is it worth it ? and is there a better way ?

I don't think the impact on anything would be noticeable. The RAM usage would be low (around 40bytes per object: object id, unique id, x, y, z all being long data types), the bandwidth would be that much as well (would also have a header added, then be compressed), and CPU would only have to validate object positions

The best way I can think to add this would be
1) Player clients generate new objects and their locations in the world (can NOT be interacted with nor rendered)
2) They then send the whole list to the master client (and remove them from memory)
3) Master client validates all items on the list
4) Master client sends all valid objects to all player clients (including the one that generated the objects)
5) Clients spawn those new objects into the world (can be interacted with and rendered)



As all the data is sent in a list and compressed, the bandwidth shouldn't take a hit. Say a player generates 100 objects into the world around them, that's 4KB to the master, then 4KB sent to each player (so 8KB if there are 2 players). Even dial-up is faster than that lol. Let's say there are 100 users (101 including the master), that would be around 404KB each time a player sends a list of 100 objects, and each player sending it would send a total of 40.4MB. This does sound like a bit much, but these shouldn't be sent at the same time, they should be spread apart to reduce lag and make it unnoticeable

This bandwidth impact could be further reduced by spreading out the object lists the master client send to the players. Players farther away from the objects doesn't need the list as soon as the players closer to it, so they can be sent the list seconds later. This makes the 404KB/s closer to 4-40KB/s (which is still playable on dial-up lol)


As for CPU impact, player clients can check if they're leaving the area of objects, and if so, send a request to the master to remove them. It also not a big deal if the objects are missed once in awhile since they don't cost any CPU to have sitting around, just to send to new players, but that can be spread out to reduce lag as well. If keeping them loaded for no reason does cause issues (like using too much RAM), then the master client can always check 1 object every couple hundred game loops to see if it should be removed or not (no sens in checking things in bulk and increasing lag needlessly)


If done poorly, then wrong it will definitely cause far more problems than it's worth, but if done right and spread out to reduce lag... It could definitely add a lot. The biggest thing to remember is spread the workload out, otherwise lag can become a big issue
Reply
#13
(12-19-2019, 08:40 PM)sha1 Wrote: I'm not all for spawning stuff. I assume that in order for people to find sticks and stones easily they'll have to be spawned frequently...now imagine 5 people in-game constantly spawning these items for such a little addition but with such an impact on the master client.

But other than spawning, trees could be both source of sticks and wood, only for wood you need an axe, but with your hand you can only get sticks .
However for stone, I'm not too sure, more ideas welcome.

The master client no longer is responsible for all these tasks. That has been fixed many many updates ago. The only thing the master client handles is the time (but no extra cpu needed, as he writes, the other read, same cpu load) and some extra stuff when a player dies or leaves.

Spawning in of zombies, animals, items are all handled by the players themselves. If you spawn in a rock, then all players will spawn in that rock. Same load.

So there really isn't much against spawning rocks and sticks. As long as it's not too frequent, and not too many.
Reply
#14
(12-20-2019, 11:05 AM)chaozz Wrote:
(12-19-2019, 08:40 PM)sha1 Wrote: I'm not all for spawning stuff. I assume that in order for people to find sticks and stones easily they'll have to be spawned frequently...now imagine 5 people in-game constantly spawning these items for such a little addition but with such an impact on the master client.

But other than spawning, trees could be both source of sticks and wood, only for wood you need an axe, but with your hand you can only get sticks .
However for stone, I'm not too sure, more ideas welcome.

The master client no longer is responsible for all these tasks. That has been fixed many many updates ago. The only thing the master client handles is the time (but no extra cpu needed, as he writes, the other read, same cpu load) and some extra stuff when a player dies or leaves.

Spawning in of zombies, animals, items are all handled by the players themselves. If you spawn in a rock, then all players will spawn in that rock. Same load.

So there really isn't much against spawning rocks and sticks. As long as it's not too frequent, and not too many.

Oh ok this is very cool then, however, the idea of stone axe being accessible means that the ressources for crafting it will have to be accessible, and that means both these pebbles and sticks will have to spawn at a decent rate.

The issue for me is that, both pebbles and sticks are not reused throughout the crafting system and are only required for a very specific task. Yet, they will be spawning at a decent rate and everybody will be spawning them. Imagine running around spawning sticks and pebbles that you don't even need because they are only needed for a specific thing that is not recurrent.

Seems unbalanced to me in terms of cost and benefit.

I suggest walking up to trees, if you have an axe, you hit it and get wood, if you are empty handed you click E and grab a stick (could make it take a few seconds with a timer)

For the pebbles I guess you could spawn them, but I don't know how people are gonna see them on the ground, specially with the grass. 

Anyways I personally think spawning stuff could be left for better and more reusable stuff.
Reply
#15
my spawn script is pretty smart in that it removes the items when you walk away from them. it also never spawns more than x items before destroying the items spawned first. so if I set the number of pebbles to 4 per player, you will never spawn more of them.

plus you only spawn them in places where there are no houses.

pressing E on a tree for a stick is of course also an option. same could go for a rock. press E for pebbles.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)