Hi again. Just a question, how would you randomise an array that spawns weapons. Eg here is the array
int randomweapons[22] = { "DoubleBladedChainsaw", "Enforcer", "SMG", "Shotgun", "SuperShotgun", "Drummle", "HunterShotgun", "Chaingun", "AK47", "Autogun", "MP40", "RocketLauncher", "UberMinigun", "PlasmaRifle", "40MMGrenadeLauncher", "Channeler", "NuclearMissileLauncher", "BFG9000", "SniperRifle", "UTNTFlamethrower", "STBFG10K" };
Now how would I spawn them randomly? I'm trying to create a mystery box effect just like in WAW Zombies so please give me some info. Thanks
Randomising Arrays
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
- solarsnowfall
- Posts: 1581
- Joined: Thu Jun 30, 2005 1:44 am
Re: Randomising Arrays
Code: Select all
#define NUM_WEAPS 22
#define SPAWN_FOG TRUE
str weapons[NUM_WEAPS] = {
"DoubleBladedChainsaw",
"Enforcer",
"SMG",
"Shotgun",
"SuperShotgun",
"Drummle",
"HunterShotgun",
"Chaingun",
"AK47",
"Autogun",
"MP40",
"RocketLauncher",
"UberMinigun",
"PlasmaRifle",
"40MMGrenadeLauncher",
"Channeler",
"NuclearMissileLauncher",
"BFG9000",
"SniperRifle",
"UTNTFlamethrower",
"STBFG10K"
};
script 1 (int spot_tid, int new_tid, int angle)
{
int n = random(0, NUM_WEAPS - 1);
if (SpawnSpot(weapons[n], spot_tid, new_tid, angle) && SPAWN_FOG)
{
SpawnSpot("TeleportFog", spot_tid, 0, 0);
}
}