Randomly spawned items and monsters?
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.
- lizardcommando
- Posts: 1489
- Joined: Thu Sep 07, 2006 12:24 pm
- Location: Boringland, California
Randomly spawned items and monsters?
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?
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?
- Kinsie
- Posts: 7402
- Joined: Fri Oct 22, 2004 9:22 am
- Graphics Processor: nVidia with Vulkan support
- Location: MAP33
- Contact:
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.
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.
- TheDarkArchon
- Posts: 7656
- Joined: Sat Aug 07, 2004 5:14 am
- Location: Some cold place
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
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
- lizardcommando
- Posts: 1489
- Joined: Thu Sep 07, 2006 12:24 pm
- Location: Boringland, California
- 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
- lizardcommando
- Posts: 1489
- Joined: Thu Sep 07, 2006 12:24 pm
- Location: Boringland, California
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:
It works because ABCDEF and are frames, so it would jump to the F frame 50% of the time.
This doesn't work:
The goto statement is not counted as a frame, therefore the jump tries to go out of the current state.
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
This doesn't work:
Code: Select all
spawn:
TNT1 A 5 A_Jump(128, 2)
TNT1 B 5 A_Look
goto spawn
- lizardcommando
- Posts: 1489
- Joined: Thu Sep 07, 2006 12:24 pm
- Location: Boringland, California
- lizardcommando
- Posts: 1489
- Joined: Thu Sep 07, 2006 12:24 pm
- Location: Boringland, California
Could also be done without rearranging frames:HotWax wrote:// Now each item has an equal chance of spawning
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.