# Math Problems

## Recommended Posts

I am trying to work on a program that would do damage calculations for a game called maple story. So far i am having problems with it. For some odd reason it keeps generating the numbers 0 for the min and max damage. You can get the information about it here. http://www.hidden-street.net/damagecalc.php

Here is the code I have so far. Can anyone tell me what might be wrong with it?

```#include <GUIConstants.au3>
#include <Array.au3>

\$weaponchoice =  _ArrayCreate("One Handed Sword","One Handed Axe","One Handed Blunt Weapon","Two Handed Sword","Two Handed Axe","Two Handed Blunt Weapon","Spear","Polearm","Dagger","Dagger & Throwing Stars","Bow","Crossbow")

GUICreate("Maple Story - Calculate Damage",300,190)

\$weaponlabel = GUICtrlCreateLabel("Weapon :",52,10,50)
\$namelabel = GUICtrlCreateLabel("Name :",65,35,50)
\$attacklabel = GUICtrlCreateLabel("Weapon Attack :",18,60,81)
\$masterylabel = GUICtrlCreateLabel("Skill Mastery :",35,85,65)
\$mastery2label = GUICtrlCreateLabel("%",290,85)
\$note = GUICtrlCreateLabel("* Mastery equals to 10% if no mastery skill",100,110,195)
\$damage = GUICtrlCreateLabel("Damage : ",30,135,150)

\$weapon = GUICtrlCreateCombo("",100,5,200)
\$name = GUICtrlCreateCombo("",100,30,200)
\$attack = GUICtrlCreateInput("",100,55,200)
\$mastery = GUICtrlCreateInput("",100,80,190)

GUICtrlSetData(\$weapon,_ArrayToString(\$weaponchoice,"|"),"One Handed Sword")

GUICtrlSetData(\$name,_ArrayToString(\$data,"|",1),\$data[1])

\$create = GUICtrlCreateButton("Calculate",10,160)
\$cancel = GUICtrlCreateButton("Cancel",65,160)

GUISetState()

While 1
\$msg = GUIGetMsg()

If \$msg = \$GUI_EVENT_CLOSE Then ExitLoop
If \$msg = \$create Then Check()
Wend

Func Calc()
\$max = Number(0.0)
\$min = Number(0.0)

\$max = ((\$str * 4.0 + \$dex) / 100) * \$wattack
\$min = (\$str * 0.9 * 4.0 * \$mast + \$dex) / 100 * \$wattack
EndIf

\$max = ((\$str * 4.4 + \$dex) / 100) * \$wattack
\$min = (\$str * 0.9 * 3.2 * \$mast + \$dex) / 100 * \$wattack
EndIf

\$max = ((\$str * 4.4 + \$dex) / 100) * \$wattack
\$min = (\$str * 0.9 * 3.2 * \$mast + \$dex) / 100 * \$wattack
EndIf

\$max = ((\$str * 4.6 + \$dex) / 100) * \$wattack
\$min = (\$str * 0.9 * 4.6 * \$mast + \$dex) / 100 * \$wattack
EndIf

\$max = ((\$str * 4.8 + \$dex) / 100) * \$wattack
\$min = (\$str * 0.9 * 3.4 * \$mast + \$dex) / 100 * \$wattack
EndIf

\$max = ((\$str * 4.8 + \$dex) / 100) * \$wattack
\$min = (\$str * 0.9 * 3.4 * \$mast + \$dex) / 100 * \$wattack
EndIf

\$max = ((\$str * 5.0 + \$dex) / 100) * \$wattack
\$min = (\$str * 0.9 * 3.0 * \$mast + \$dex) / 100 * \$wattack
EndIf

\$max = ((\$str * 5.0 + \$dex) / 100) * \$wattack
\$min = (\$str * 0.9 * 3.0 * \$mast + \$dex) / 100 * \$wattack
EndIf

\$max = ((\$str * 4.0 + \$dex) / 100) * \$wattack
\$min = (\$str * 0.9 * 4.0 * \$mast + \$dex) / 100 * \$wattack
EndIf

\$max = ((\$luk * 3.6 + \$str + \$dex) / 100)* \$wattack
\$min = (\$luk * 0.9 * 3.6 * \$mast + \$str + \$dex) / 100 * \$wattack
EndIf

\$max = ((\$dex * 3.4 + \$str) / 100) * \$wattack
\$min = (\$dex * 0.9 * 3.4 * \$mast + \$str) / 100 * \$wattack
EndIf

\$max = ((\$dex * 3.6 + \$str) / 100) * \$wattack
\$min = (\$dex * 0.9 * 3.6 * \$mast + \$str) / 100 * \$wattack
EndIf

;\$max = Round(\$max - .5)
;\$min = Round(\$min - .5)

GUICtrlSetData(\$damage,"Damage : " & \$min & "-" &\$max)
EndFunc

Func Check()
\$correct = 1
If StringIsInt(GUICtrlRead(\$attack)) <> 1 Then \$correct = 0
If StringIsInt(GUICtrlRead(\$mastery)) <> 1 Then \$correct = 0
If \$correct = 1 Then
Calc()
Else
MsgBox(0,"Error","One or more of the values needs to be a number.")
EndIf
EndFunc```

##### Share on other sites

I am trying to work on a program that would do damage calculations for a game called maple story. So far i am having problems with it. For some odd reason it keeps generating the numbers 0 for the min and max damage. You can get the information about it here. http://www.hidden-street.net/damagecalc.php

Here is the code I have so far. Can anyone tell me what might be wrong with it?

CODE

#include <GUIConstants.au3>

#include <Array.au3>

\$weaponchoice = _ArrayCreate("One Handed Sword","One Handed Axe","One Handed Blunt Weapon","Two Handed Sword","Two Handed Axe","Two Handed Blunt Weapon","Spear","Polearm","Dagger","Dagger & Throwing Stars","Bow","Crossbow")

GUICreate("Maple Story - Calculate Damage",300,190)

\$weaponlabel = GUICtrlCreateLabel("Weapon :",52,10,50)

\$namelabel = GUICtrlCreateLabel("Name :",65,35,50)

\$attacklabel = GUICtrlCreateLabel("Weapon Attack :",18,60,81)

\$masterylabel = GUICtrlCreateLabel("Skill Mastery :",35,85,65)

\$mastery2label = GUICtrlCreateLabel("%",290,85)

\$note = GUICtrlCreateLabel("* Mastery equals to 10% if no mastery skill",100,110,195)

\$damage = GUICtrlCreateLabel("Damage : ",30,135,150)

\$weapon = GUICtrlCreateCombo("",100,5,200)

\$name = GUICtrlCreateCombo("",100,30,200)

\$attack = GUICtrlCreateInput("",100,55,200)

\$mastery = GUICtrlCreateInput("",100,80,190)

GUICtrlSetData(\$weapon,_ArrayToString(\$weaponchoice,"|"),"One Handed Sword")

GUICtrlSetData(\$name,_ArrayToString(\$data,"|",1),\$data[1])

\$create = GUICtrlCreateButton("Calculate",10,160)

\$cancel = GUICtrlCreateButton("Cancel",65,160)

GUISetState()

While 1

\$msg = GUIGetMsg()

If \$msg = \$GUI_EVENT_CLOSE Then ExitLoop

If \$msg = \$create Then Check()

Wend

Func Calc()

\$max = Number(0.0)

\$min = Number(0.0)

\$max = ((\$str * 4.0 + \$dex) / 100) * \$wattack

\$min = (\$str * 0.9 * 4.0 * \$mast + \$dex) / 100 * \$wattack

EndIf

\$max = ((\$str * 4.4 + \$dex) / 100) * \$wattack

\$min = (\$str * 0.9 * 3.2 * \$mast + \$dex) / 100 * \$wattack

EndIf

\$max = ((\$str * 4.4 + \$dex) / 100) * \$wattack

\$min = (\$str * 0.9 * 3.2 * \$mast + \$dex) / 100 * \$wattack

EndIf

\$max = ((\$str * 4.6 + \$dex) / 100) * \$wattack

\$min = (\$str * 0.9 * 4.6 * \$mast + \$dex) / 100 * \$wattack

EndIf

\$max = ((\$str * 4.8 + \$dex) / 100) * \$wattack

\$min = (\$str * 0.9 * 3.4 * \$mast + \$dex) / 100 * \$wattack

EndIf

\$max = ((\$str * 4.8 + \$dex) / 100) * \$wattack

\$min = (\$str * 0.9 * 3.4 * \$mast + \$dex) / 100 * \$wattack

EndIf

\$max = ((\$str * 5.0 + \$dex) / 100) * \$wattack

\$min = (\$str * 0.9 * 3.0 * \$mast + \$dex) / 100 * \$wattack

EndIf

\$max = ((\$str * 5.0 + \$dex) / 100) * \$wattack

\$min = (\$str * 0.9 * 3.0 * \$mast + \$dex) / 100 * \$wattack

EndIf

\$max = ((\$str * 4.0 + \$dex) / 100) * \$wattack

\$min = (\$str * 0.9 * 4.0 * \$mast + \$dex) / 100 * \$wattack

EndIf

\$max = ((\$luk * 3.6 + \$str + \$dex) / 100)* \$wattack

\$min = (\$luk * 0.9 * 3.6 * \$mast + \$str + \$dex) / 100 * \$wattack

EndIf

\$max = ((\$dex * 3.4 + \$str) / 100) * \$wattack

\$min = (\$dex * 0.9 * 3.4 * \$mast + \$str) / 100 * \$wattack

EndIf

\$max = ((\$dex * 3.6 + \$str) / 100) * \$wattack

\$min = (\$dex * 0.9 * 3.6 * \$mast + \$str) / 100 * \$wattack

EndIf

;\$max = Round(\$max - .5)

;\$min = Round(\$min - .5)

GUICtrlSetData(\$damage,"Damage : " & \$min & "-" &\$max)

EndFunc

Func Check()

\$correct = 1

If StringIsInt(GUICtrlRead(\$attack)) <> 1 Then \$correct = 0

If StringIsInt(GUICtrlRead(\$mastery)) <> 1 Then \$correct = 0

If \$correct = 1 Then

Calc()

Else

MsgBox(0,"Error","One or more of the values needs to be a number.")

EndIf

EndFunc

Your use of \$wattack is confusing me. You get it from:

`\$wattack = Number(GUICtrlRead(\$weapon))`

The control \$weapon that you are reading is a list of text strings created by:

```\$weapon = GUICtrlCreateCombo("",100,5,200)
GUICtrlSetData(\$weapon,_ArrayToString(\$weaponchoice,"|"),"One Handed Sword")```

So... how are you using \$wattack in your math?

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

##### Share on other sites

Ok ok i am stupid. But i fixed that to \$attack instead of \$weapon. And now i am starting to get numbers but the numbers are wrong.

##### Share on other sites

Ok ok i am stupid. But i fixed that to \$attack instead of \$weapon. And now i am starting to get numbers but the numbers are wrong.

So now you are doing the following math:

```; Calculate MAX (4.0 varies by weapon)
\$max = ((\$str * 4.0 + \$dex) / 100) * \$attack

; Calculate MIN (4.0 varies by weapon)
\$min = (\$str * 0.9 * 4.0 * \$mast + \$dex) / 100 * \$attack```

Now we break down the math:

```\$max = \$str * 4.0
\$max = \$max + \$dex
\$max = \$max / 100
\$max = \$max * \$attack

\$min = \$str * 0.9
\$min = \$min * 4.0
\$min = \$min * \$mast
\$min = \$min + \$dex
\$min = \$min / (100 * \$attack)```

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...