|
chaossdragon Apprentice
Joined: 09 Apr 2008 Posts: 168
|
Posted: Mon Dec 04, 2017 12:15 pm
i suck at math... |
OK, I figured out for the most part what I needed to use to calculate a couple variables... however my math and cmud math is off by like 13
the PMS Bonus is 0.5% per Glvl. I am currently Glvl 55 (27.5%) so... base power of 650 / 100 * 27.5 = 178.75 yet as you can see below....
in mud my total power is 828. Power Regen is + 1 per 50 Power... so the decimal is ignored.
**the math works fine when I am an even number Glvl... it's only off on Odd number where the PMSBonus is a ##.5
Code: |
Power Management System
Base Power Pool : 650
PMS Bonus Power : 165
Total Power Pool : 815
Max Power Regen : + 16.3
Cur Power Regen : + 16
|
How I am attempting to get the above results.
Code: |
<alias name="pmscheck" id="2697">
<value>#IF (%1 = "reset") {
#SHOW " Resetting PMS Values "
basePower = 0
bonusPMSPower = 0
totalPowerPool = 0
maxPowerRegen = 0
curPowerRegen = 0
} {
//Initalize Script
implants p
#WA 2500
//Run calculations
#SHOW " Calculating... "
#MATH basePower @implantFlywheel+@implantUltraCapacitor+@implantBattery
#IF (@implantPMS == true) {
#MATH implantPMSBonus @SI*.5
#MATH bonusPMSPower @basePower/100*@implantPMSBonus
}
#MATH totalPowerPool @basepower+@bonusPMSPower
#MATH maxPowerRegen @totalPowerPool/50
#MATH curPowerRegen @implantColdFusion+@implantNukeReactor+@implantSolarCell
#WA 2500
//Print results
#SHOW ""
#SHOW " Power Management System "
#SHOW ""
#SHOW " Base Power Pool : "%eval(@basePower)" "
#SHOW " PMS Bonus Power : "%eval(@bonusPMSPower)" "
#SHOW " Total Power Pool : "%eval(@totalPowerPool)" "
#SHOW ""
#SHOW " Max Power Regen : + "%eval(@maxPowerRegen)" "
#SHOW " Cur Power Regen : + "%eval(@curPowerRegen)" "
#SHOW ""
}</value>
</alias>
|
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Mon Dec 04, 2017 5:31 pm |
Try to always use floating point math if you expect a decimal answer. That means giving all raw numbers the .0
CMUD math can be stupid at times especially in the order of operations. Force the order you want with extra parenthesis.
it will do 650/100 first, and without the .0 that will return 6*27.5 instead of 6.5*27.5, which is where your ~=13 discrepancy comes from.
I recall hearing something about the #MATH command being depreciated, try converting it to encapsulated commands:
Code: |
basePower = (@implantFlywheel + @implantUltraCapacitor + @implantBattery)
#IF (@implantPMS == true) {
implantPMSBonus = (@SI * 0.5)
bonusPMSPower = ((@basePower / 100.0) * @implantPMSBonus )
}
totalPowerPool = (@basepower + @bonusPMSPower)
maxPowerRegen = (@totalPowerPool / 50.0)
curPowerRegen = (@implantColdFusion + @implantNukeReactor + @implantSolarCell) |
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
chaossdragon Apprentice
Joined: 09 Apr 2008 Posts: 168
|
Posted: Tue Dec 05, 2017 7:29 am |
ok, next question then...
Max Power Regen : + 17.92
Cur Power Regen : + 16
how do i get it to drop the decimal and anything after for Max Power Regen ? just need the whole number for that, as we can't really have fractional regen. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Tue Dec 05, 2017 8:54 am |
%int(@maxPowerRegen)
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
chris123zugg Apprentice
Joined: 23 Aug 2013 Posts: 175
|
Posted: Mon Aug 03, 2020 5:37 am |
i also suck at math, and this has some relevant sticking points with a math problem im having...
i need any number(s) turned into how long of a time it takes to reach 0. I have the number value, i just need the math to turn it into mins/hours etc...
218942 is the number.... now the basic "max" i could get per round is (40*40)*10
can you please help me formulate this into minutes?
edit:
got alot of help with this one from another mudder. i was wayyyy off with the formula, so im sure someone (shalimar:P) would have made this formula possible, but i had some key portions unthought of/added into this equation. thanks though, im all set now:) |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Mon Aug 03, 2020 2:16 pm |
#HELP %mod
Shows it all
Quote: |
seconds=3917
#SHOW hours:%eval(@seconds/3600) mins:%mod(@seconds/60,60) secs:%mod(@seconds,60)
Displays: hours:1 mins:5 secs:17 |
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|