Axe Software Forums
  Quest Developer Forum
  Random Values


Author Topic:   Random Values
Corlen Belspar posted 24-12-2001 07:14 GMT     
I am making an RPG text adventure, and I need to know the string for random values so the enemies will do different damage when they attack.
Computer Whizz posted 24-12-2001 16:47 GMT          
Right - to get a random number then you need to know 2 things:
1) The lowest random number you want to be chosen,
2) The highest random number you want to be chosen.

With these you then type this:
set numeric <generatednumber; $rand(lowest; highest)$>

Computer Whizz

Corlen Belspar posted 24-12-2001 22:56 GMT          
Ok, I got that to work, but now I need to know how to mkae a conditional event that if hitormiss = 1 then to show the damage done else if it is 0, it says you missed.
Computer Whizz posted 26-12-2001 01:39 GMT          
Well:

if (hitormiss = 1) then {
script
}
else {
if (hitormiss = 0) then {
script
}
}

Should do it - so in QDK you'd have a conditional with "hitormiss = 1", and the actions you want to happen in the "then" part - and ANOTHER conditional in the "else" part of this conditional, with the actions in THAT "then".

Computer Whizz

carlii posted 01-01-2001 07:26 GMT          
Can someone tell me how to use these hit/miss and random values in QDK? I really don't know how to use code all that well. ^_^
Tyrant posted 01-01-2001 16:52 GMT          
This is something I use a lot in my RPG battle system. Carlii, in QDK, make a numeric variable called "attack" (or whatever you want), then give it the random value:

Numeric Name: attack
New Value: $rand(1;4)$

This means that attack will have a random value of either 1, 2, 3, or 4. You could set any numbers you want. If you only want two random damage values, just set 1;2 for the random instead of 1;4.

Anyway, when the time comes, make a condition. If %attack% equals 1, then deal 5 damage. If %attack% equals 2, then deal 6 damage. And so on....

I noticed that random values are very important in making a game fresh.

carlii posted 05-01-2001 08:08 GMT          
If I wanted to specify certain numbers would I do this in QDK:

Numeric Name: attack
New Value: $rand(1,11,14,22)$

???

Instead of using a RANGE (2;16)

Thanks for your help BTW that really clears it up for me! :P

Computer Whizz posted 05-01-2001 13:49 GMT          
Why would you want to do that?

Anyway, you would do it by doing this (or at least I would ;) )

var1; $rand(1;4)$

If (var1 = 1) then {
newvar; 1
}
If (var1 = 2) then {
newvar; 11
}
If (var1 = 3) then {
newvar; 14
}
If (var1 = 4) then {
newvar; 22
}

NOTE:: This is NOT proper code, and might be understandable by you.... What I did was create 4 "If"'s and have the random number pick ONE of them (in a way). Then have the If say which number you want.... sure a "select case #" might have been easier here ;) (nudges Alex) but we'll just have to wait for that function!

Computer Whizz