HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Ow, Integer and Real values hurt.

07-18-2004, 11:30 PM#1
Scyze
Mining/Smithing Formula:

Each ore type needs a certain level to be mined/smithed. They also have a certain SR (Success Ratio). Levels and SRs are below. How it works is you need to be a certain level in order to mine something, and then every level higher than the level needed to mine something makes it easier to mine the ore by .25.

Tin: 0/5
Copper: 0/5
Iron: 10/13
Coal: 15/19
Gold: 20/30
Mithril: 30/39
Rune: 50/50

See that? Thats how it should work, and here is my trigger:

Code:
Mine Ore
    Events
        Unit - A unit Begins casting an ability
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Destructible-type of (Target destructible of ability being cast)) Equal to Unidentified Ore (Gold)
            Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        MiningLevel[(Player number of (Owner of (Casting unit)))] Greater than or equal to 20
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Random real number between 1.00 and (30.00 - ((Real(MiningLevel[(Player number of (Owner of (Casting unit)))])) x 0.25))) Equal to 1.00
                            Then - Actions
                                Hero - Create Gold Ore and give it to (Casting unit)
                                Player Group - Add (Owner of (Casting unit)) to Player
                                Game - Display to Player the text: You have mined some...
                                Player Group - Remove all players from (All players)
                            Else - Actions
                                Player Group - Add (Owner of (Casting unit)) to Player
                                Game - Display to Player the text: You failed to mine ...
                                Player Group - Remove all players from (All players)
                    Else - Actions
                        Player Group - Add (Owner of (Casting unit)) to Player
                        Game - Display to Player the text: You need to be leve...
                        Player Group - Remove all players from (All players)
            Else - Actions

I'm trying to get it so that it can be a value of 1.00 or less, but I want the ratio to be exactly 1 - 30 chance but with those modifiers of .25 chance... It has to be that way. How can I fix it? >_>;;
07-19-2004, 03:33 AM#2
CynicalYouth
If I understand you right you want each level after the first to add .25 to your chance of sucess. But you want a base of 30%. Try this

(Random real number between 1 and 100) + (((Real(MiningLevel[(Player number of (Owner of (Casting unit)))])) x 0.25))) > to 30.00

this will create a random number from 1 to 100, a percent. and add the .25 bonus to it. And if its greater then 30 it is a sucess.
07-19-2004, 05:34 AM#3
Scyze
Quote:
Originally Posted by CynicalYouth
If I understand you right you want each level after the first to add .25 to your chance of sucess. But you want a base of 30%. Try this

(Random real number between 1 and 100) + (((Real(MiningLevel[(Player number of (Owner of (Casting unit)))])) x 0.25))) > to 30.00

this will create a random number from 1 to 100, a percent. and add the .25 bonus to it. And if its greater then 30 it is a sucess.

That wont work! It is a surefire--IF YOU HAVE ENOUGH LEVELS. It gives absolutely no chance to work if your not high enough of a level.
07-19-2004, 01:38 PM#4
th15
Cynical put you on the right path.

Code:
(Random real number between 1.00 and (30.00 - ((Real(MiningLevel[(Player number of (Owner of (Casting unit)))])) x 0.25))) Equal to 1.00

This is your problem. You are checking is a random real number from 1.00 to 30.00 is EXACTLY 1.00. Real numbers include the decimals. Thats a 1 in 30000 chance. If you had done this with integers then it would be a 1/30 chance. I'm sure you can figure things out from here.
07-19-2004, 05:41 PM#5
Anitarf
real comparison - (random real between 0 and 30) less than or equal to (1 x (((level of mining) - (level required to mine ore)) x 0.25) + 1 )

This is your condition, I believe. If the level of mining skill is the same as the level required to mine the ore, you will have 1 out of 30 chance to get the ore. If your mining level is higher by 4 from the required level, you have 2 (1 + (0.25 x 4)) out of 30 chance to get the ore. If your mining skill level is higher than the required skill for the ore by 116 levels, you have a 30 out of 30 chance to be succesful.

I hope I understood correctly, basically, with this formula, your chances increase by 0.25 of base chance to get the ore each level. If you want it to increase by 0.25 of your previous level chance, instead of the base chance, the proper formula would be:

real comparison - (random real between 0 and 30) less than or equal to (1 x (power 1.25, ((level of mining) - (level required to mine ore))) + 1 )