Decimals (percentage lower than 1%) and last weapon used function

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
Psycho
 
Posts: 29
Joined: Sun Dec 01, 2013 9:11 pm
Location: Brazil

Decimals (percentage lower than 1%) and last weapon used function

#1

Post by Psycho » Sat Sep 19, 2015 1:30 am

I don't know if this is an actual limitation that the doom engine has, or its just my big noobish when it comes to coding stuff, but here we go.

How can someone use decimals for monsters/weapons replacement chances (e.g. complex doom). I mean, when trying to code something really OP to spawn, I can't see to make a spawn chance lower than 1% possible. Tried using 0.01 and 0,01 and even 1/100, but none of them seen to work for me.

Is it even possible to use decimals for such a thing, and how could I make it work properly? If it's not possible, then what is problem with implementing such an apperrent trivial thing?

On a side note, I wonder why does zandronum doesn't have a last weapon used option for when configurating the controls, and if it's possible to code it (would be better to have it as a standart option in the menu).

User avatar
Ænima
Addicted to Zandronum
Posts: 3579
Joined: Tue Jun 05, 2012 6:12 pm

RE: Decimals (percentage lower than 1%) and last weapon used function

#2

Post by Ænima » Sat Sep 19, 2015 1:49 am

It depends how you're spawning the actors in question. If you're using the DropItem property of a RandomSpawner then just increase the "weight" of all the other actors listed in that spawner.


If it's decorate you can do something like this:

TNT1 AA 0 A_Jump(255, "NotPowerfulMonster")
TNT1 A 0 A_spawnitemex(powerful monster here)

That means that in order to make it to that SpawnItemEx call, you have a 1/65536 chance of making it past the A_jump calls because they are both 255/256 chances of jumping away from the super-OP-monster-spawning state and there's 2 of them in a row. Pretty simple.

Edit: math mistake
Last edited by Ænima on Sat Sep 19, 2015 9:47 pm, edited 1 time in total.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

User avatar
Dusk
Developer
Posts: 581
Joined: Thu May 24, 2012 9:59 pm
Location: Turku

RE: Decimals (percentage lower than 1%) and last weapon used function

#3

Post by Dusk » Sat Sep 19, 2015 11:24 am

That actually has 1/256 · 1/256 = 1 / 256² = 1/65536 ≈ 0.0015% to spawn. You can't just sum denominators together, go learn some math.
Last edited by Dusk on Sat Sep 19, 2015 11:26 am, edited 1 time in total.

User avatar
Ivan
Addicted to Zandronum
Posts: 2229
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

RE: Decimals (percentage lower than 1%) and last weapon used function

#4

Post by Ivan » Sat Sep 19, 2015 1:49 pm

Psycho wrote: I don't know if this is an actual limitation that the doom engine has, or its just my big noobish when it comes to coding stuff, but here we go.

How can someone use decimals for monsters/weapons replacement chances (e.g. complex doom). I mean, when trying to code something really OP to spawn, I can't see to make a spawn chance lower than 1% possible. Tried using 0.01 and 0,01 and even 1/100, but none of them seen to work for me.

Is it even possible to use decimals for such a thing, and how could I make it work properly? If it's not possible, then what is problem with implementing such an apperrent trivial thing?

On a side note, I wonder why does zandronum doesn't have a last weapon used option for when configurating the controls, and if it's possible to code it (would be better to have it as a standart option in the menu).
Dusk wrote: That actually has 1/256 · 1/256 = 1 / 256² = 1/65536 ≈ 0.0015% to spawn. You can't just sum denominators together, go learn some math.
Ouch, denominator sum op.

Anyway, I'd rather use Randomspawners as Decorate jump statement blocks (notice, not just one jump involved if you have more than 2 monsters) can lead to some weird chances of spawning. With randomspawner, you have the option to give it a weight, which is effectively the chance to spawn in this case. See this:

Code: Select all

Actor MySpawner : Randomspawner {
    DropItem "HellKnight", 255, 16
    DropItem "BaronofHell", 255, 16
    DropItem "Cyberdemon", 255, 1
}
In here, the Cyberdemon effectively has a chance of 1/33 to spawn. Using this, you can achieve your percentages easily. You just have to figure out your weights. For instance, a 0.1% is effectively a 1 / 1000, so you can just have weights be 499, 500, 1 to achieve that. (There is an unequal chance of having Baron and Hellknight now, yes, but you know it's better than nothing) The rest have 499/1000 and 500/1000 (which is 50% effectively for both) chance to spawn.

Altenratively you can use ACS to handle all your spawning. That way you can have more power through some if statements to check if your random value is in the desired range.
Last edited by Ivan on Sat Sep 19, 2015 1:50 pm, edited 1 time in total.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

User avatar
Ænima
Addicted to Zandronum
Posts: 3579
Joined: Tue Jun 05, 2012 6:12 pm

RE: Decimals (percentage lower than 1%) and last weapon used function

#5

Post by Ænima » Sat Sep 19, 2015 2:46 pm

Dusk wrote: That actually has 1/256 · 1/256 = 1 / 256² = 1/65536 ≈ 0.0015% to spawn. You can't just sum denominators together, go learn some math.
Easy bro, easy. I know, math was never my strong suit. I had a feeling it was actually squared and not just doubled because hitting 1/256 twice in a row should be like super rare but oh well. The method I was trying to tell him is still valid advice, though.
Last edited by Ænima on Sat Sep 19, 2015 2:50 pm, edited 1 time in total.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

Lollipop
Zandrone
Posts: 1124
Joined: Tue Jul 24, 2012 10:34 am
Location: Denmark

RE: Decimals (percentage lower than 1%) and last weapon used function

#6

Post by Lollipop » Sat Sep 19, 2015 5:54 pm

Well, if you want a completely even distribution between barons and hellknights, then you can use the number 2 for the cyberdemon and fit the other numbers. 0.1% = 2/2000.
Cyberdemon: 2
Baron: 999
Hellknight: 999

That way they are easily distributed with the same chance to spawn the cyberdemon.
Not a big deal, but whatever.
Combinebobnt wrote:i can see the forum league is taking off much better than the ctf ones
GalactusToday at 1:07 PM
are you getting uncomfortable jap
feeling something happen down there

Post Reply