 |
chaossdragon Wanderer
Joined: 09 Apr 2008 Posts: 52
|
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: 3861 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) |
|
|
_________________ Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34 |
|
|
 |
chaossdragon Wanderer
Joined: 09 Apr 2008 Posts: 52
|
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: 3861 Location: Pensacola, FL, USA
|
Posted: Tue Dec 05, 2017 8:54 am |
%int(@maxPowerRegen)
|
|
_________________ Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34 |
|
|
 |
|
|