Open galaxian85 opened 5 years ago
I misunderstanding the meaning of
Config.get('entityTickFrequency', 100)
in the main process.
The 100 there is default setting, not hard-coded. so here is the new code :)
const { Config } = require('ranvier');
...
..
.
updateTick: state => {
const tickFrequency = Config.get('entityTickFrequency', 100);
const serverStartTime = Math.trunc(Date.now() / tickFrequency);
return function (config) {
const respawnInterval = config.interval || 30;
const upTime = Math.trunc(Date.now() / tickFrequency - serverStartTime);
if (upTime % (respawnInterval * (1000 / tickFrequency)) == 0) {
for (const [id, room] of this.rooms) {
room.emit('respawnTick', state);
}
}
};
},
@galaxian85 thanks for your fix, I had the same issue, the area with lower respan interval resets counter for other areas then just the area with lowest respawn interval was respawned, with this fix every area respawn correctly.
Thanks.
I hope @shawncplus will consider your fix and approve its merge.
I have 3 areas (limbo, mapped and myarea) in my ranvier starter kit. The manifest settings are:
And I noticed only limbo will trigger the event correctly. I insert some code try to find out why.
And here is the console log.
As you can see, limbo trigger the event and update the lastRespawnTick variable same time. Means other areas will never respawn and makes this bundle unusable.
So I change the logic. No count in millisecond anymore, it should be counted in ticks = Config.get(entityTickFrequency) Since entityTickFrequency is hardcoded in main process, so I just use magic number 100 & 10 here.
First time using github and English is not my native language(JavaScript neither). Hope this post will not offend anybody.
At last, thanks you guys making this awesome software, have a nice day!