Jump to content

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")

$data = IniReadSectionNames("Characters.ini")
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)
    
    $str = Number(IniRead("Characters.ini",GUICtrlRead($name),"STR","0"))
    $dex = Number(IniRead("Characters.ini",GUICtrlRead($name),"DEX","0"))
    $int = Number(IniRead("Characters.ini",GUICtrlRead($name),"INT","0"))
    $luk = Number(IniRead("Characters.ini",GUICtrlRead($name),"LUK","0"))
    $wattack = Number(GUICtrlRead($weapon))
    $mast = Number(GUICtrlRead($mastery))
    
    If GUICtrlRead($weapon) = $weaponchoice[0] Then
        $max = (($str * 4.0 + $dex) / 100) * $wattack
        $min = ($str * 0.9 * 4.0 * $mast + $dex) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[1] Then
        $max = (($str * 4.4 + $dex) / 100) * $wattack
        $min = ($str * 0.9 * 3.2 * $mast + $dex) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[2] Then
        $max = (($str * 4.4 + $dex) / 100) * $wattack
        $min = ($str * 0.9 * 3.2 * $mast + $dex) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[3] Then
        $max = (($str * 4.6 + $dex) / 100) * $wattack
        $min = ($str * 0.9 * 4.6 * $mast + $dex) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[4] Then
        $max = (($str * 4.8 + $dex) / 100) * $wattack
        $min = ($str * 0.9 * 3.4 * $mast + $dex) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[5] Then
        $max = (($str * 4.8 + $dex) / 100) * $wattack
        $min = ($str * 0.9 * 3.4 * $mast + $dex) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[6] Then
        $max = (($str * 5.0 + $dex) / 100) * $wattack
        $min = ($str * 0.9 * 3.0 * $mast + $dex) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[7] Then
        $max = (($str * 5.0 + $dex) / 100) * $wattack
        $min = ($str * 0.9 * 3.0 * $mast + $dex) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[8] Then
        $max = (($str * 4.0 + $dex) / 100) * $wattack
        $min = ($str * 0.9 * 4.0 * $mast + $dex) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[9] Then
        $max = (($luk * 3.6 + $str + $dex) / 100)* $wattack
        $min = ($luk * 0.9 * 3.6 * $mast + $str + $dex) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[10] Then
        $max = (($dex * 3.4 + $str) / 100) * $wattack
        $min = ($dex * 0.9 * 3.4 * $mast + $str) / 100 * $wattack
    EndIf
    
    If GUICtrlRead($weapon) = $weaponchoice[11] Then
        $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
Link to comment
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")

$data = IniReadSectionNames("Characters.ini")

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)

$str = Number(IniRead("Characters.ini",GUICtrlRead($name),"STR","0"))

$dex = Number(IniRead("Characters.ini",GUICtrlRead($name),"DEX","0"))

$int = Number(IniRead("Characters.ini",GUICtrlRead($name),"INT","0"))

$luk = Number(IniRead("Characters.ini",GUICtrlRead($name),"LUK","0"))

$wattack = Number(GUICtrlRead($weapon))

$mast = Number(GUICtrlRead($mastery))

If GUICtrlRead($weapon) = $weaponchoice[0] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[1] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[2] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[3] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[4] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[5] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[6] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[7] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[8] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[9] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[10] Then

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

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

EndIf

If GUICtrlRead($weapon) = $weaponchoice[11] Then

$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? :whistle:

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
Link to comment
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)

If that's not what you wanted, address your order of operations. :whistle:

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
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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