I’ve checked HP incrementing and os.time(), socket.gettime(). It seems that problem is in damage dealing, not in hp incrementing.
Here is the brief example:
Chrome:
Firefox:
As you may see, in Chrome version mob has passed the whole second floor, but in Firefox not (you also may notice how much hp he has: initial hps for Chrome - 575, for Firefox - 657). It seems that Сhrome processes messages slower and this causing lower hp damage. ~0-1 ms for Firefox, ~2+ ms in Chrome.
I have the following code for damage dealing:
--laser script
function on_message(self, message_id, message, sender)
if message_id == hash("collision_response") then
msg.post(message.other_id, "do_damage", {damage = self.damage * self.damage })
end
end
--mob script
function on_message(self, message_id, message, sender)
if message_id == hash("do_damage") then
self.hp = self.hp - message.damage
end
end
If I understand all this thing right, I need to add a timer here? To kinda slow down Firefox to not receive messages too fast. What’s the best way to implement this? I need to send only one message at a time not the bunch of messages.
P.S. Also, the problem is not in the Chrome itself. It’s in the performance of the device and browser. Lower performance = slower message passing = lower hp damage. I’ve added timer to sending messages but this doesn’t work well. It seems that “collision_response” behaves very differently. With timer there can be such a situation that mobs will not be damaged at all for some amount of time. Don’t know what to do with all of this - I just can’t balance the game, because browsers and performance may vary. Really annoying.