View Full Version : Random Monster RPG Problem
WarrOrange
March 16th, 2004, 04:45 PM
I have just tried to program my random monster AS but it doesnt seem to work... it would be nice if someone could point out a couple of flaws for me. function Monster() {
temp = Math.floor(Math.random() * (100 - 0)) + 0;
if (temp = 25 or temp < 25){
((Monster == "Grey"))
}
else if (temp < 51 && temp > 25){
((Monster == "Blue"))
}
else if (temp < 76 && temp > 50){
((Monster == "Green"))
}
else if (temp > 76){
((Monster == "Black"))
}
}
setInterval(Monster, 0);
WarrOrange
March 16th, 2004, 04:48 PM
keep in mind this is just simple AS and i will add much more such as adding AS for switching symbols and varying hp and exp ect... and the ((Monster == "Black")) was just a test to see if that function was working
flash4food
March 17th, 2004, 12:38 AM
((Monster == "Black"))
this doesnt set the monster variable, == is an equality tester, u have to use = for setting the value of monster inside these conditional statements,
also
if (temp = 25 ....
here u DO have to use the equality tester == or else itll set temp to 25 all the time
WarrOrange
March 17th, 2004, 07:26 AM
thanks for the help man i was kind of out if it yesterday, good catch ;)
flashcat
March 17th, 2004, 10:47 AM
function Monster() {
temp = random(4);
switch(temp) {
case 0 : Monster = "Grey";
break;
case 1 : Monster = "Blue";
break;
case 2 : Monster = "Green";
break;
case 3 : Monster = "Black";
break;
}
};
setInterval(Monster, 250);
WarrOrange
March 17th, 2004, 10:58 AM
lol i think im becoming retarted why did i make it 100?... anywho thanks:crazy:
WarrOrange
March 17th, 2004, 06:43 PM
Alright I hit a new road block, i was using ur action script flashcat, and when i use the monster function i only want it to display once,because using the interval of 250 makes it continue to change the variable (Monster). If you need me to restate that clearer please say so ;) thanks a bunch
flash4food
March 17th, 2004, 08:22 PM
just dont use that setinterval, u can use the function as u like or in a loop, maybe flashcat was thinking that every amount of time new mosters would appear and thats why she uses that setinterval
flashcat
March 18th, 2004, 07:29 AM
yes i thought random monsters every amount of time! :sure:
just call:
Monster();
and i am a female! :sure:
WarrOrange
March 18th, 2004, 11:52 AM
sorry! and ty again
SeiferTim
March 18th, 2004, 01:00 PM
arg, I had a really unique, and cool Random Monster generator when I first started working on my game engine a few years ago... It got lost when I lost my HD, but essentially, it would Take the party's average level, and then pick monsters based on that level, and then give them a level to make the battle either just a little bit harder, or easier than the party's level.... I made it so that all the monsters could have their own levels, so that it would change the difficulty of the battle. It worked really good, but I can't remember how I did it... (I used VB, and had a bunch of objects and things)...
But your way looks okay, too... :)
WarrOrange
March 18th, 2004, 10:02 PM
nice.... thats pretty spiff! if u ever figure it out again, give it a post bro.
WarrOrange
March 18th, 2004, 10:28 PM
Ive had one more problem... ive had a lot of problem with freekin random scripts lately and i dont know why, anywho here it is
function expgain() {
_root.expg = Math.floor(Math.random() * (100 - 50)) + 50;
_root.explvl = _root.explvl - _root.expg
}
expgain();
there it is the function is to show the viewer after the battle victory how much experience they have gained, and then take that randomly generated exp gained and subtracted to the non viewable script that holds the information on exp needed for next levels and such. Anyway, the problem is instead of just showing the exp gained from the battle it continues to change the numbers using the random script. I thought it was because the frame kept reloading, but i put the stop actionscript function at the end. Any help would be appreciated. :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.