Yeah, looking at the code, the issue appears to be what @SIsilicon28 said. As for why it is not giving you the issue there, that is a good question.
My hunch is that in the randomized loot, you might be defining a new local variable called rng
, and so Godot overrides the local variable rather than the class variable (the RandomNumberGenerator
object). For example, the following code works, though is not advisable (untested):
extends Node
var string = "Hello world!"
func _ready():
var string = 10
print (string + 10)
Which should execute correctly, but it will print 20 rather than cause an error by trying to add 10
to a string.
I'm guessing something like that is happening with rng
in the randomized loot, though I'm just guessing.
I'd recommend changing the line so that it uses a new local variable with a unique name, like var rng_attack
. Then you can use rng
to get the random number:
var rng_attack = (rng.randi_range(16, 1) * press) - press
Then all you have to do is change the code in that chunk to use rng_attack
rather than rng
and that should fix the issue.