PDA

View Full Version : Working on a Random Encounter Table.



dgrhm
October 14th, 2004, 05:36 PM
I've been tinkering with arrays, and I've been working on creating a generic Dungeons & Dragons type random encounter, combat simulator.

I've created a random weapon generator like this:
//random weapon chooser
weapon = int(Math.random()*4);
randWeapon = new Array("dagger", "sword", "battle axe", "spear");
//trace ("The orc is armed with a "+randWeapon[weapon]+".");
orcArm = randWeapon[weapon];

Similarly, I can create a random monster generator using the same idea. I'm still pretty much a noob in regard to working with OOP. I think I could create an opponent using prototypes, and weapons using prototypes. The thing is, I'm not too clear about using them. I'll start simple, with weapons and hit points, then work up to adding armor, and opponent levels. Any suggestions?

Dr Warm
October 15th, 2004, 03:48 AM
I'm not quite sure what ur asking? ur array seems fine, then for the weapons have like
//have the orc mc have linkage name orc
_root.attachMovie("orc", "orc"+i, 100+i);
_root["orc"+i].gotoAndStop(randWeapon);
_root["orc"+i].onEnterFrame = orcAI;

function orcAI(){};

is this what u mean or didn't i understand?