Can I detect if a player (not a radar) revealed a chunk?
Posted: Fri Dec 06, 2019 4:53 am
I'm looking at ways to incentivize leaving the base and exploring the world. For my idea to work, I'd need to know when a character is revealing portions of the map, rather than a radar dish. If I detect a player revealed a chunk, I'll give them a small reward.
It looks like the main event I'd have to use is on_chunk_charted, but that only gets me the surface, chunk, and force. The event description also says it fires when a chunk is re-charted, which isn't going to be something I want.
I think I've devised a workaround, but asking here in case there's a better/simpler solution.
To filter out re-charts, I'll need to keep a table of all the chunks that have been charted on that surface. For a chunk identifier, I'm thinking of serializing the chunk position (e.g. "X5Y3"). When a chunk is revealed, I check if it's already in the table, and if so, ignore the event. If it's not in the table, I add it to the table and then try to guess if a radar or a player charted it. (There's also an on_sector_scanned event, but it doesn't seem to add anything over what on_chunk_charted has.)
To filter out radar charts, I'll check the charted chunk's position and compare it to each player's character position (/32 to convert to chunk position). If a player is <= 2 chunks in the X or Y away (character sight radius is 2 chunks, right? any way to modify that?), I assume that player revealed it. Otherwise, I assume it was the radar. This isn't perfect as a radar might chart a chunk a player is moving towards, but I think crediting the player in these rare cases is acceptable.
I'll also need to exclude the chunks charted around the player at the start of the game, because those are freebies.
Is this plan feasible? I'm worried that the memory and search time cost of the charted chunk table could cause problems on big maps. My personal games haven't gone far beyond 100k chunks, but I've seen some screenshots of players with 1.7M chunks charted, and I have no idea how many chunks mods like Space Exploration will use.
It looks like the main event I'd have to use is on_chunk_charted, but that only gets me the surface, chunk, and force. The event description also says it fires when a chunk is re-charted, which isn't going to be something I want.
I think I've devised a workaround, but asking here in case there's a better/simpler solution.
To filter out re-charts, I'll need to keep a table of all the chunks that have been charted on that surface. For a chunk identifier, I'm thinking of serializing the chunk position (e.g. "X5Y3"). When a chunk is revealed, I check if it's already in the table, and if so, ignore the event. If it's not in the table, I add it to the table and then try to guess if a radar or a player charted it. (There's also an on_sector_scanned event, but it doesn't seem to add anything over what on_chunk_charted has.)
To filter out radar charts, I'll check the charted chunk's position and compare it to each player's character position (/32 to convert to chunk position). If a player is <= 2 chunks in the X or Y away (character sight radius is 2 chunks, right? any way to modify that?), I assume that player revealed it. Otherwise, I assume it was the radar. This isn't perfect as a radar might chart a chunk a player is moving towards, but I think crediting the player in these rare cases is acceptable.
I'll also need to exclude the chunks charted around the player at the start of the game, because those are freebies.
Is this plan feasible? I'm worried that the memory and search time cost of the charted chunk table could cause problems on big maps. My personal games haven't gone far beyond 100k chunks, but I've seen some screenshots of players with 1.7M chunks charted, and I have no idea how many chunks mods like Space Exploration will use.