Randomly spawned items and monsters?

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.
User avatar
lizardcommando
Posts: 1489
Joined: Thu Sep 07, 2006 12:24 pm
Location: Boringland, California

Randomly spawned items and monsters?

Post by lizardcommando »

Hey guys, I need help with some DECORATE stuff again.

Alright, if anyone's played the EDGE version of Immoral Conduct, sometimes items or monsters would randomly spawn. Now how would I be able to do this with DECORATE?

I have 4 different kinds of armor that I want in my mod. One gives 50% armor, another gives 100% armor, the third armor gives 150% armor and the last one gives 200% armor.

How would I have it so that the green armor can randomly spawn one of the four armors when the level starts? Could this method be applied for random monster spawning?
User avatar
Kinsie
Posts: 7402
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33
Contact:

Post by Kinsie »

This is done by replacing the original armor pickup with an object that uses A_Jump to randomly jump to a frame where it drops an item, then vanishes.

See either WildWeasel's (i'm tired and think that's his name) The Stranger, or Deathz0r's OMG Weapons And Monsters for an example.
User avatar
Amuscaria
Posts: 6634
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Post by Amuscaria »

Make your spawnstate something like this:

Spawn:
ARM1 A 0 A_Jump(85,5)
ARM1 A 0 A_Jump(85,6)
ARM1 A 0 A_Jump(85,7)
ARM1 A 0 A_SpawnnItem("item1",0,0)
stop;
ARM1 A 0 A_SpawnnItem("item2",0,0)
stop;
ARM1 A 0 A_SpawnnItem("item3",0,0)
stop;
ARM1 A 0 A_SpawnnItem("item4",0,0)
stop;
User avatar
TheDarkArchon
Posts: 7656
Joined: Sat Aug 07, 2004 5:14 am
Location: Some cold place

Post by TheDarkArchon »

Fixed:

Code: Select all

Spawn: 
ARM1 A 0 A_Jump(64,4) 
ARM1 A 0 A_Jump(64,4) 
ARM1 A 0 A_Jump(64,4) 
ARM1 A 0 A_SpawnnItem("item1",0,0) 
stop 
ARM1 A 0 A_SpawnnItem("item2",0,0) 
stop
ARM1 A 0 A_SpawnnItem("item3",0,0) 
stop
ARM1 A 0 A_SpawnnItem("item4",0,0) 
stop //STOP's don't count in jumps nor need a semicolon. Also there are 4 outcomes so each needs a 1 in 4 ~= 64 in 255 chance in occuring for the outcome to be fair
User avatar
Amuscaria
Posts: 6634
Joined: Mon Jul 26, 2004 12:59 pm
Location: Growing from mycelium near you.

Post by Amuscaria »

damn it, I always forget about that. :lol:
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

Fixed again:

Code: Select all

Spawn: 
ARM1 A 0 A_Jump(128,4) 
ARM1 A 0 A_Jump(128,2) 
ARM1 A 0 A_SpawnnItem("item1",0,0) 
stop 
ARM1 A 0 A_SpawnnItem("item2",0,0) 
stop 
ARM1 A 0 A_Jump(128,2) 
ARM1 A 0 A_SpawnnItem("item3",0,0) 
stop 
ARM1 A 0 A_SpawnnItem("item4",0,0)
stop
// Now each item has an equal chance of spawning
User avatar
lizardcommando
Posts: 1489
Joined: Thu Sep 07, 2006 12:24 pm
Location: Boringland, California

Post by lizardcommando »

Hmm, ok. I'll go test this out. BTW, what do the zeros mean in the SpawnItem part?

ARM1 A 0 A_SpawnnItem("item1",0,0)
User avatar
Ryan Cordell
Posts: 4349
Joined: Sun Feb 06, 2005 6:39 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia (Modern GZDoom)
Location: Capital of Explodistan

Post by Ryan Cordell »

First 0 digit means Distance, second 0 digit means Z-Position. Fourth digit would mean the new Translation bool. I think third digit is the spawnactor_xy thing..
User avatar
Anakin S.
Posts: 1067
Joined: Fri Nov 28, 2003 9:39 pm
Location: A long time ago in a galaxy far, far away...

Post by Anakin S. »

A distance of 0 actually means that it will be spawned just outside of the radius of the spawner. A distance of 1 means that it will be spawned 1 map unit away from the center of the spawner.
User avatar
lizardcommando
Posts: 1489
Joined: Thu Sep 07, 2006 12:24 pm
Location: Boringland, California

Post by lizardcommando »

Ok, I keep getting an error when trying to get this thing to work. I've applied the coding for a random pistolammo spawner and I keep getting an error saying that the A_Jump offset is out of bounds or something. What's that mean and how do I fix it?
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

It means you're trying to jump too far. Make sure you are counting frames and not lines for your jump commands.

In other words, this works:

Code: Select all

see:
TNT1 A 0 A_Jump(128, 6)
TNT1 ABCDE 5 A_Chase
TNT1 F A_Chase
goto see
It works because ABCDEF and are frames, so it would jump to the F frame 50% of the time.

This doesn't work:

Code: Select all

spawn:
TNT1 A 5 A_Jump(128, 2)
TNT1 B 5 A_Look
goto spawn
The goto statement is not counted as a frame, therefore the jump tries to go out of the current state.
User avatar
lizardcommando
Posts: 1489
Joined: Thu Sep 07, 2006 12:24 pm
Location: Boringland, California

Post by lizardcommando »

Hmm, so do I have to have to change this zero than to some other number? The bold faced zero being the number I change.

ARM1 A 0 A_SpawnItem("item4",0,0)

Or is it that I have to change the number in the A_Jump code?
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

Change the second number in the A_Jump code. The 0 you have bolded is the duration that frame is displayed. A 0 means "don't actually display this frame, just activate the code pointer"
User avatar
lizardcommando
Posts: 1489
Joined: Thu Sep 07, 2006 12:24 pm
Location: Boringland, California

Post by lizardcommando »

Ah, alright. I'll go try fiddling with that. Thanks.
User avatar
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Post by Risen »

HotWax wrote:// Now each item has an equal chance of spawning
Could also be done without rearranging frames:

Code: Select all

ARM1 A 0 A_Jump(64,4) // 1 in 4: 25% chance
ARM1 A 0 A_Jump(85,4) // 1 in 3: 1/3 of remaining 75% chance == 25%
ARM1 A 0 A_Jump(128,4) // 1 in 2: 1/2 of remaining 50% == 25%
// leaving last 25% here.
I find this easier when the number of outcomes is considerably longer, and/or not easily divisible.
Locked

Return to “Editing (Archive)”