ID:140858
 
Code:
<b>mob
var
hp = //Health Points
pp = //Psynergy Points
attack = rand(1,5)//Attack
luck = rand(1,5) //Luck
agility = rand(1,5)//Agility
defense = rand(1,5) //Defense
maxhp = rand(10,30)//Max Health Points
maxpp = rand(10,30)//Max Psynergy Points</b>


Problem description: The problem I got is that I want to make these stats random when I start my game, but it wont let me.


You cannot set non-constant variables at compile time.

This means anything that isn't always the same (a numeric value. No references, no procs, no math involving either.) can't be used at compile time.

Also, you can't leave HP and PP blank like that.

You can however, do this:

mob
var
hp = 1 //Health Points
pp = 1//Psynergy Points
attack = 1//Attack
luck = 1 //Luck
agility = 1//Agility
defense = 1 //Defense
maxhp = 10//Max Health Points
maxpp = 10//Max Psynergy Points</b>
proc
Randomize()
maxhp=rand(10,30)
hp=maxhp
maxpp=rand(10,30)
pp=maxpp
attack=rand(1,5)
luck=rand(1,5)
agility=rand(1,5)
defense=rand(1,5)
New()
..() //Do all the stuff New() normally does
Randomize()
In response to AJX
AJX wrote:
This means anything that isn't always the same (a numeric value. No references, no procs, no math involving either.) can't be used at compile time.

The stuff in parentheses isn't so accurate, but that's understandable since this is kind of difficult to quickly define.
To an extent, you can use math and some procs (e.g. new()) at 'compile-time' as well as constant vars.
EDIT: Also, global vars can even be assigned at "compile-time" to virtually anything (that's accessible within the scope, that is), you can actually use proc calls to your own procs there.
In response to AJX
Thanks a lot for helping me out. :)
In response to Kaioken
Kaioken wrote:
To an extent, you can use math

Yer. But it cant have any procs or variables in it. I.E: you can put in 5+5, but not 5+HP. Trying to clarify that.

EDIT: Also, global vars can even be assigned at "compile-time" to virtually anything (that's accessible within the scope, that is), you can actually use proc calls to your own procs there.

ERr rly? Had never tried that... But meh. Didn't know.