diff --git a/addons/netfox.extras/weapon/network-weapon.gd b/addons/netfox.extras/weapon/network-weapon.gd index b7e1bc0..b678d60 100644 --- a/addons/netfox.extras/weapon/network-weapon.gd +++ b/addons/netfox.extras/weapon/network-weapon.gd @@ -7,10 +7,12 @@ class_name NetworkWeapon var _projectiles: Dictionary = {} var _projectile_data: Dictionary = {} var _reconcile_buffer: Array = [] +var _rng = RandomNumberGenerator.new() static var _logger: _NetfoxLogger = _NetfoxLogger.for_extras("NetworkWeapon") func _ready(): + _rng.randomize() NetworkTime.before_tick_loop.connect(_before_tick_loop) ## Check whether this weapon can be fired. @@ -132,9 +134,12 @@ func _before_tick_loop(): func _generate_id(length: int = 12, charset: String = "abcdefghijklmnopqrstuvwxyz0123456789") -> String: var result = "" + + # Generate a random ID for i in range(length): - var idx = randi_range(0, charset.length() - 1) + var idx = _rng.randi_range(0, charset.length() - 1) result += charset[idx] + return result @rpc("any_peer", "reliable", "call_remote")