Jump to content

Chaos Damage in Oblivion


Recommended Posts

Hello, i have this idea to take what Skyrim's enchantment of chaos damage was, "50% chance for each element of fire, frost, and shock to do X points of damage." and use as a enchantment on a weapon i have a few ideas but don't really know how oblivion will respond to it

since it has to be able to do this

1 in 8 chance (12.5%): For just Fire

1 in 8 chance (12.5%): For just Frost

1 in 8 chance (12.5%): For just Shock

1 in 8 chance (12.5%): For Fire & Frost

1 in 8 chance (12.5%): For Frost & Shock

1 in 8 chance (12.5%): For Shock & Fire

1 in 8 chance (12.5%): For all 3

1 in 8 chance (12.5%): For none

i have an idea to use GetRandomPercent to get the chance need to do any of the above^ but of course here is the problem that i am running into

i want to take the number generated and divide that by 12.5 and whatever comes out is the effect used, but here is the issue let's say that the random number is 67 and we divide that by 12.5 we get 5.36 so how does oblivion take this? does it round up or down(for the decimals) or for the code since i use floats, decimals aren't a problem but if i put

if chance == 5
;enter code here
endif

will oblivion just remove the decimal to make it correct or do i need to add a range for the decimals.

also for the effects i want to do it by spells, but if it can be done by scripting that would be awesome

Link to comment
Share on other sites

I noticed that you're dividing by 12.5 - shouldn't you be dividing by 8 since you have eight possibilities?

 

To answer your question, while GetRandomPercent always outputs an integer, you could divide the output and store it either as a float to retain the decimal places or a short/long for it to be rounded (not sure whether down or nearest).

 

Float will be more accurate, but you are going to have to use < instead of ==. Short/long may have rounding errors so not all results will have an equal chance of happening.

 

A simpler option might be to use rand instead:

 

set n to rand 0 8

if n < 1

(just fire damage)

elseif n < 2

(just frost damage)

...

etc

 

Probably the simplest would be for Fire, Frost and Shock damage each having a 1/3 chance of occurring, independent of each other. :)

Link to comment
Share on other sites

I noticed that you're dividing by 12.5 - shouldn't you be dividing by 8 since you have eight possibilities?

 

To answer your question, while GetRandomPercent always outputs an integer, you could divide the output and store it either as a float to retain the decimal places or a short/long for it to be rounded (not sure whether down or nearest).

 

Float will be more accurate, but you are going to have to use < instead of ==. Short/long may have rounding errors so not all results will have an equal chance of happening.

 

A simpler option might be to use rand instead:

 

set n to rand 0 8

if n < 1

(just fire damage)

elseif n < 2

(just frost damage)

...

etc

 

Probably the simplest would be for Fire, Frost and Shock damage each having a 1/3 chance of occurring, independent of each other. :smile:

to answer the first point, in my head it made more sense to divide the random number by the chance rather than the whole number(more accurate read as the final number ends at 8 itself) instead either way i would have to still deal with decimals

also i take it rand is a CSE command, i would rather like it to stay as a CS command use if possible as i would like to use this enchantment without the use of OBSE

Edited by bomo99
Link to comment
Share on other sites

Ah, I didn't realise this needed to be OBSE free.

 

In that case, rather than dividing, I'd just stick to integers:

 

set n to GetRandomPercent
if n < 12
(fire damage)
elseif n < 24
(frost damage)

etc

 

Each possibility has 12/100 chance of happening. There will be 4/100 left over which you can distribute to whichever result you want to be slightly favour.

Link to comment
Share on other sites

but then it wouldn't be 1 in 8 chance (12.5%): i was just going to leave the no effects 1 in 8 chance (12.5%): For none be blank, i guess no effect could be worse but would prefer it to be equal if possible, could this work?

(Result < 0) && (Result >= 0.99)

or am i still stuck with just whole numbers?

Link to comment
Share on other sites

What about this ?

float chance
short damselect 
.....
set damselected to 0
set chance to GetRandomPercent
set chance to chance/12.5 ;it will give 8 possibilities
;here begins cascade of ifs
if chance > 0
   set damselect to 1
endif
if chance >= 1
   set damselect to 2
endif
if chance >= 2
   set damselect to 3
endif
if chance >= 3
   set damselect to 4
endif
if chance >= 4
   set damselect to 5
endif
if chance >= 5
   set damselect to 6
endif
if chance >= 6
   set damselect to 7
endif
if chance >= 7
   set damselect to 8
endif
if chance != 0
   .....
endif

This cascade of ifs looks kind of stupid, but in the end you should get right value free of rounding errors. But it still not guarantee true 12.5% chance, it's just scaling.

Edited by RomanR
Link to comment
Share on other sites

What about this ?

float chance
short damselect 
.....
set damselected to 0
set chance to GetRandomPercent
set chance to chance/12.5 ;it will give 8 possibilities
;here begins cascade of ifs
if chance > 0
   set damselect to 1
endif
if chance >= 1
   set damselect to 2
endif
if chance >= 2
   set damselect to 3
endif
if chance >= 3
   set damselect to 4
endif
if chance >= 4
   set damselect to 5
endif
if chance >= 5
   set damselect to 6
endif
if chance >= 6
   set damselect to 7
endif
if chance >= 7
   set damselect to 8
endif
if chance != 0
   .....
endif

This cascade of ifs looks kind of stupid, but in the end you should get right value free of rounding errors. But it still not guarantee true 12.5% chance, it's just scaling.

is that similar to doing it like this?

float rnd
set rnd to 8.0/99 * Getrandompercent       ;  => 0.00 to 8.00

just did the calculations on all possible answers the above will spit out and i have a good idea of what will happen here are the results

0 = 12

1 = 12

2 = 13

3 = 12

4 = 12

5 = 13

6 = 12

7 = 12

8 = 2

this is all done by doing this (8/99*(1-100)) i just grabbed how many all equal 0.00 and just put it into a chart just to see that variables it appears to be not even like i wanted gonna try something else

Edited by bomo99
Link to comment
Share on other sites

To ensure all possibilities have equal chance, simply roll again if the result is 96 - 99.

 

From a practical perspective, would any player actually notice if some options are 1% more likely, even if they tally results with a pen and paper?

Link to comment
Share on other sites

To ensure all possibilities have equal chance, simply roll again if the result is 96 - 99.

 

From a practical perspective, would any player actually notice if some options are 1% more likely, even if they tally results with a pen and paper?

i would agree, but i would know and thats the issue i just wanted all of them to be equal but use the whole range but if there is 4 left over i could do this

13: For just Fire

13: For just Frost

13: For just Shock

12: For Fire & Frost

12: For Frost & Shock

12: For Shock & Fire

12: For all 3

13: For none

makes it more likely to get none or 1 element and making the 2 elements and all 3 of them a little bit more difficult

Link to comment
Share on other sites

What about comparing the result against the old one ? So for my example it would continue like this:

....
short damselectold ;extra variable
....

if chance != 0 && damselect != 0
   if damselect == damselectold ;same dam.type as before
      set damselect to damselect + 1
      if damselect > 8
         set damselect to 1
      endif
      set damselectold to damselect
   endif
   ......
endif   

It should at least avoid repeating the same damage type.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...