switch/case

I'm trying to make a special wandering monster table, and am uncertain how to proceed.
This is all I have. I just don't know how to structure the switch/case thingy or if a custom function is the right approach? I want each case to be a different critter???
void WanderingMonsters() { object oPC; object oTarget; object oSpawn; location lTarget; oTarget = oPC; lTarget = GetLocation(oTarget); oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "resref", lTarget); } void main() { switch () { case 0: break; case 1: // statements ... break; case 2: // statements ... break; default: // statements ... break; } }
This is all I have. I just don't know how to structure the switch/case thingy or if a custom function is the right approach? I want each case to be a different critter???
0
Comments
Change WanderingMonsters to accept a string: Add Random to your switch case. In your cases, list all the ResRefs you want:
You'll need to define oPC. Let me know if you need help with that. Depending on where this script is being called from, it will be different.
https://nwnlexicon.com/index.php?title=Switch_case_Statement
Yeah, I went to that exact page before I posted and didn't fully understand what I was looking at.
I took what ForSerious taught me and made my own custom function. It works well I might add.
I know it's not the shiniest script in the code-verse, but I'm proud of it.
It's just for a goblin encampment - background noise sort of thing.
Thanks again guys. I am a slow learner, but I do learn.
Indeed.
BTW there is a downloadable version of the Lexicon too but it doesn't cover the new functions introduced by the EE and is PC only. On the other hand it is so much easier and faster to seach.
TR