"Randomizing weapons"

Archive of the old editing forum
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.
asdf
Posts: 193
Joined: Mon Jun 19, 2006 1:50 pm

Post by asdf »

oh yeah, i forgot to say that!
User avatar
Jimmy
 
 
Posts: 4728
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him
Contact:

Post by Jimmy »

Sure you did. It works now. Cheers! (_)3
User avatar
DBThanatos
Posts: 3101
Joined: Fri Apr 14, 2006 3:17 pm
Location: in "the darkness that lurks in our mind"

Post by DBThanatos »

jimmy91 wrote:Here's the new decorate, it's still only spawning an IDShotgun.

Code: Select all

actor _Shotgun 2001
{
  States
  {
  Spawn:
    SHOT A 0 A_Jump(136,2)
    SHOT A 1 A_SpawnItem("IDShotgun")
    Stop
    SHOT A 0 A_Jump(136,2)
    SHOT A 1 A_SpawnItem("IDSuperShotgun")
    Stop
    SHOT A 0 A_Jump(136,2)
    SHOT A 1 A_SpawnItem("M16AssaultRifle")
    Stop
    SHOT A 0 A_Jump(136,2)
    SHOT A 1 A_SpawnItem("HeavyShotgun")
    Stop
    SHOT A 0 A_Jump(136,2)
    SHOT A 1 A_SpawnItem("RiotGun")
    Stop
    SHOT A 1 A_SpawnItem("DoubleBarrelHandgun")
    Stop
  }
}
OK, but the thing is that as far as I see, the "136" value, will not be really random, that is why I used two technics to make it more random (still its doesnt, but whatever).


This is the first one (decreasing probability) :

Code: Select all

Actor ShotgunSpawner 2001
{
Radius 20
Height 0
	States
	{
	Spawn:
		NULL A 0
		NULL A 0 A_Jump(210,2)
		NULL A 1 A_SpawnItem("Q2Shotgun",1)
		Goto Death
		NULL A 0 A_Jump(205,2)
		NULL A 1 A_SpawnItem("Doom3Shotgun",1)
		Goto Death
		NULL A 0 A_Jump(200,2)
		NULL A 1 A_SpawnItem("DShotgun2",1)
		Goto Death
		NULL A 0 A_Jump(195,2)
		NULL A 1 A_SpawnItem("FCrossBow",1)
		Goto Death
		NULL A 0 A_Jump(190,2)
		NULL A 1 A_SpawnItem("AutomaticShotgun",1)
		Goto Death
		NULL A 0 A_Jump(185,2)
		NULL A 1 A_SpawnItem("Magnum",1)
		Goto Death
		NULL A 0 A_Jump(180,2)
		NULL A 1 A_SpawnItem("FLightningSpell",1)
		Stop
		NULL A 0
		Loop

	Death:
		NULL A 0
		Stop
	}
}
And the second one (first jump state) (i think it works fine, but im not really sure, that is why this is supossed to be random...)

Code: Select all

Actor ZombieManSpawner 3004
{
	+IsMonster
	Radius 20
	States
	{
	Spawn:
		NULL A 0
		NULL A 0 A_Jump(158,27)
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FZombieMan",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FInvisibleGuy",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FQ2Soldier1",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FFistMarine",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FQuakeDog",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FQuakeZombie",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FCultist2",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FArmoredGuy",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FPistolMarine",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FGrunt",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FPlasmaZombie",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FGrenadeZombie",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FInvisibleGuy2",1)
		Goto Death
		NULL A 0 A_Jump(160,2)
		NULL A 1 A_SpawnItem("FRocketZombie",1)
		Stop
		NULL A 0
		Goto Spawn

	Death:
		NULL A 0
		Stop
	}
}
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Post by Zippy »

DBThanatos wrote: OK, but the thing is that as far as I see, the "136" value, will not be really random.
To be precise, with the DECORATE posted the chances roughly are:
IDShotgun - 47%
IDSuperShotgun - 25%
M16AssaultRifle - 13%
HeavyShotgun - 7%
RiotGun - 4%
DoubleBarrelHandgun - 4%

At least, that's how the math works out. To balance out, the probabilities need to be carried forward. So for example with only 3 weapons, the values for jump chances should be 170 (66% chance not to spawn the first weapon on the list) and 128 (50% chance to skip the second weapon on the list.) This carries forward properly because .66 * .5 = .33, or a 1/3 chance to select the second or third weapon (which matches the 1/3 chance to get the first.)
Locked

Return to “Editing (Archive)”