diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index d6f7f318ea..726e46fccc 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -449,7 +449,7 @@ struct DropItem native native readonly DropItem Next; native readonly name Name; native readonly int Probability; - native int Amount; + native readonly int Amount; } class SpotState : Object native diff --git a/wadsrc/static/zscript/doom/bossbrain.txt b/wadsrc/static/zscript/doom/bossbrain.txt index 5b87182c9a..fadc280e3d 100644 --- a/wadsrc/static/zscript/doom/bossbrain.txt +++ b/wadsrc/static/zscript/doom/bossbrain.txt @@ -318,11 +318,12 @@ extend class Actor { if (di.Name != 'None') { - if (di.Amount < 0) + int amt = di.Amount; + if (amt < 0) { - di.Amount = 1; // default value is -1, we need a positive value. + amt = 1; // default value is -1, we need a positive value. } - n += di.Amount; // this is how we can weight the list. + n += amt; // this is how we can weight the list. } } di = drop; @@ -331,7 +332,12 @@ extend class Actor { if (di.Name != 'none') { - n -= di.Amount; // logically, none of the -1 values have survived by now. + int amt = di.Amount; + if (amt < 0) + { + amt = 1; + } + n -= amt; } if ((di.Next != null) && (n >= 0)) { diff --git a/wadsrc/static/zscript/shared/randomspawner.txt b/wadsrc/static/zscript/shared/randomspawner.txt index b6e28cc371..7488fdd4d1 100644 --- a/wadsrc/static/zscript/shared/randomspawner.txt +++ b/wadsrc/static/zscript/shared/randomspawner.txt @@ -48,8 +48,9 @@ class RandomSpawner : Actor { if (!nomonsters || !IsMonster(di)) { - if (di.Amount < 0) di.Amount = 1; // default value is -1, we need a positive value. - n += di.Amount; // this is how we can weight the list. + int amt = di.Amount; + if (amt < 0) amt = 1; // default value is -1, we need a positive value. + n += amt; // this is how we can weight the list. } di = di.Next; } @@ -69,7 +70,9 @@ class RandomSpawner : Actor if (di.Name != 'None' && (!nomonsters || !IsMonster(di))) { - n -= di.Amount; + int amt = di.Amount; + if (amt < 0) amt = 1; + n -= amt; if ((di.Next != null) && (n > -1)) di = di.Next; else