Forum

> > CS2D > Scripts > Using settile in mass - reasonable?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Using settile in mass - reasonable?

5 replies
To the start Previous 1 Next To the start

old Using settile in mass - reasonable?

AbAeterno
User Off Offline

Quote
I kinda wanted to begin an experimental RPG-esque map inspired by Path of Exile. Read last paragraph for a tldr.

One of the pivotal features of this map would be that every area with monsters in it is dynamic and instanced, akin to PoE areas:
     • Dynamic: each area should have the ability to be procedurally generated or loaded from a file, independently from each other.

     • Instanced: for every base area, multiple instances of it can exist simultaneously. Each instance would belong to the player that created it, and would contain its own monsters/items/modifiers, independently from other instances. Players would be given the ability to join an older instance or create a new one when accessing a different area.

Town areas would NOT be instance-able, and are shared by everyone. From these you would be able to enter instance-able area with monsters.

The main issue is the instances system, given that map space is limited and hopping around different servers for each instance sounds completely unreasonable.

The idea I had is to have a dedicated region for each potential player (say, a 40x40 tiles square for each), so, if the server can have up to 20 players, then 20 of these regions would be distributed around the map area.

When an instance gets created for a certain player, the region associated to them would create the area they're about to enter (via proc. gen or file loading), then every tile in this region would change to whatever has been generated in the script, through the use of settile. Once the area has been set and monsters dropped, the player would then get teleported to this area.

EDIT: here's an explanation of PoE's instances system, which I think is more clear (most, if not all, of the functionality described here would also be implemented in this map):
Spoiler >


From a performance and bandwidth perspective, is it reasonable to use settile massively this way? (Considering up to 1600 tiles might get changed at a time, going with 40x40 regions). Would it become a problem if a player went back and forth, re-creating areas and spamming settile calls? (Measures such as a cooldown could prevent this).

old Re: Using settile in mass - reasonable?

AbAeterno
User Off Offline

Quote
@user Pagyra: looks kind of cool but it seems to be discontinued, so I wouldn't really know if it's using settile at all. For all we know the whole map is generated once and it just reveals sections as you approach them, which would be different to what I'm looking for.

old Re: Using settile in mass - reasonable?

MikuAuahDark
User Off Offline

Quote
If you plan on using cs2d cmd settile on lots, lots of tiles, please keep this in mind.

user VADemon at thread cs2d 【東方】Bad Apple!! 【影絵】 in CS2D has written
Don't give up though! The biggest improvement came from sending the cs2d cmd settile command in just one go. At first I used one call of
parse("settile X Y 123")
per pixel, but it was SO SLOW that even a turtle would beat it at moving pixels. As you have read above, up to 800 tiles can be changed at once and that's what I did. For the game it looked like a freaking mother of text of a command:
1
"settile 27 65 239;settile 29 65 154;settile 31 65 3;..."
- over 1000 symbols in just one function call...


I also experiment with "direct settile" call approach (calling the underlying functions directly bypassing cs2d cmd parse) but it's slightly slower than batching the call with cs2d cmd parse.

old Re: Using settile in mass - reasonable?

AbAeterno
User Off Offline

Quote
Sending them in batch and using timers to change only a few at a time doesn't seem to lag the client-side much (if at all), so I suppose this could be feasible in theory. Could use some stress testing though.

Thanks for the tip.

old Re: Using settile in mass - reasonable?

VADemon
User Off Offline

Quote
Sending too many settile in one frame will break networking and freeze everyone's game state. Settile is not the only command that goes towards the limit, people have triggered it with too many hudtxts before.

You'll need to be very cautious with implementation; slow command parsing (calling CS2D'S API from Lua) is just one part of it. I didn't have to care about network bandwidth at all for example.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview