AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help writing some very simple calculator equations

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
mtgtopdeck



Joined: 25 Mar 2009
Posts: 17

PostPosted: Sun Mar 29, 2009 6:16 pm    Post subject: Need help writing some very simple calculator equations Reply with quote

Right now all I really have is a GUI. The calculator is meant to be used to find out a persons kill ratios in a first person shooter game or other game. There are 4 edit fields for Kills, Deaths, Head Shots and Assists.
There are 4 read only edit fields which are assists/kills, kills/deaths, HeadShots/kills, and a slightly harder equation which will tell you how many more kills you need before your kill/death ration goes up by 0.01%.
Could anyone help me out?

Code:
#NoEnv
#SingleInstance force
SendMode Input

Gui, Add, Text, x38 y52 w30 h15 +Right, Kills:
Gui, Add, Text, x28 y82 w40 h15 +Right, Deaths:
Gui, Add, Text, x8 y112 w60 h15 +Right, Head Shots:
Gui, Add, Text, x28 y142 w40 h15 +Right, Assists:

Gui, Add, Edit, x76 y110 w70 h20 vheadshot,
Gui, Add, Edit, x76 y140 w70 h20 vassist,
Gui, Add, Edit, x76 y80 w70 h20 vdeath,
Gui, Add, Edit, x76 y50 w70 h20 vkill,

Gui, Add, Text, x178 y52 w60 h15 +Right, Kill / Death:
Gui, Add, Text, x148 y82 w90 h15 +Right, Head Shots / Kills:
Gui, Add, Text, x168 y112 w70 h15 +Right, Assists / Kills:
Gui, Add, Text, x56 y10 w120 h30 , Kills Needed for +0.01`% Kill / Death Ratio

Gui, Add, Edit, x186 y15 w70 h20 vpossitivekill +ReadOnly,
Gui, Add, Edit, x246 y110 w70 h20 vakratio +ReadOnly,
Gui, Add, Edit, x246 y80 w70 h20 vhskratio +ReadOnly,
Gui, Add, Edit, x246 y50 w70 h20 vkdratio +ReadOnly,
Gui, Add, Button, x171 y140 w140 h20 vbutton, Calculate
Gui, Show, x600 y0 h186 w336, KD Calc
Return

/* (The variables for quick reference)
headshot   input
assist      input
death      input
kill      input
possitivekill   output
akration   output
hskratio   output
kdratio      output
button
*/

GuiClose:
ExitApp
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5043
Location: the tunnel(?=light)

PostPosted: Sun Mar 29, 2009 9:51 pm    Post subject: Reply with quote

Is the 0.01% increase to be a reflection of a rounded ratio or only when the ratio itself will actually be equal to or greater than 0.01%?
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
mtgtopdeck



Joined: 25 Mar 2009
Posts: 17

PostPosted: Sun Mar 29, 2009 10:07 pm    Post subject: Reply with quote

sinkfaze wrote:
Is the 0.01% increase to be a reflection of a rounded ratio or only when the ratio itself will actually be equal to or greater than 0.01%?


either way would be fine. if it turns out that it will show you need 45.2511 kills that would be fine
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5043
Location: the tunnel(?=light)

PostPosted: Mon Mar 30, 2009 5:08 am    Post subject: Reply with quote

It seems that 0.01% is a very low threshold to cross, I have to obtain a wide difference in numbers to obtain an increase greater than 1. Could you post some sample statistics so I can get a better idea of what kind of math it should be doing?
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
mtgtopdeck



Joined: 25 Mar 2009
Posts: 17

PostPosted: Mon Mar 30, 2009 8:25 am    Post subject: Reply with quote

sinkfaze wrote:
It seems that 0.01% is a very low threshold to cross, I have to obtain a wide difference in numbers to obtain an increase greater than 1. Could you post some sample statistics so I can get a better idea of what kind of math it should be doing?


sure thing.

Kills - 53741
Deaths - 26081
Assists - 6429
Head Shots - 5325

once you hit calculate it should display:
Kill/Death ratio - 2.0605
Assists/Kills ratio - .1196
Head Shots/Kills ratio - .0991
Kills needed for next +0.01% Kill/Death ratio - 247 (I got this number by first finding the current kill death ratio then rounding down to the nerest 100th (2.06) then adding .01 (2.07) then multiplying by deaths (26081*2.07) then subtracting the current kills (53987.67-53741) and then rounding up to the nearest whole number (247).
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1651
Location: Denmark

PostPosted: Mon Mar 30, 2009 8:53 am    Post subject: Reply with quote

Code:
Kills=53741
Deaths=26081
Assists=6429
HeadShots=5325
/*
once you hit calculate it should display:
Kill/Death ratio - 2.0605
Assists/Kills ratio - .1196
Head Shots/Kills ratio - .0991
Kills needed for next +0.01% Kill/Death ratio - 247
*/
; I got this number by first finding the current kill death ratio
res := Kills/Deaths
msgbox %res%
; then rounding down to the nerest 100th (2.06)
res := Floor(res*100) / 100
msgbox %res%
; then adding .01 (2.07)
res += 0.01
msgbox %res%
; then multiplying by deaths (26081*2.07)
res *= Deaths
msgbox %res%
; then subtracting the current kills (53987.67-53741) and
res -= Kills
msgbox %res%
; then rounding up to the nearest whole number (247).
res := Ceil(res)
MsgBox %res%

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2
Back to top
View user's profile Send private message
mtgtopdeck



Joined: 25 Mar 2009
Posts: 17

PostPosted: Tue Mar 31, 2009 1:27 am    Post subject: Reply with quote

tonne wrote:
Code:
Kills=53741
Deaths=26081
Assists=6429
HeadShots=5325
/*
once you hit calculate it should display:
Kill/Death ratio - 2.0605
Assists/Kills ratio - .1196
Head Shots/Kills ratio - .0991
Kills needed for next +0.01% Kill/Death ratio - 247
*/
; I got this number by first finding the current kill death ratio
res := Kills/Deaths
msgbox %res%
; then rounding down to the nerest 100th (2.06)
res := Floor(res*100) / 100
msgbox %res%
; then adding .01 (2.07)
res += 0.01
msgbox %res%
; then multiplying by deaths (26081*2.07)
res *= Deaths
msgbox %res%
; then subtracting the current kills (53987.67-53741) and
res -= Kills
msgbox %res%
; then rounding up to the nearest whole number (247).
res := Ceil(res)
MsgBox %res%


thanks for that equation Smile
now all I need help with is the easy equations and the calculate button
Back to top
View user's profile Send private message
mtgtopdeck



Joined: 25 Mar 2009
Posts: 17

PostPosted: Wed Apr 01, 2009 3:32 am    Post subject: Reply with quote

bump
Back to top
View user's profile Send private message
mtgtopdeck



Joined: 25 Mar 2009
Posts: 17

PostPosted: Thu Apr 02, 2009 5:35 pm    Post subject: Reply with quote

still need some help
Back to top
View user's profile Send private message
Robbo



Joined: 27 Jul 2008
Posts: 47
Location: England

PostPosted: Thu Apr 02, 2009 10:34 pm    Post subject: Reply with quote

Don't tell me, you still need some help?
_________________
All scripts are untested unless otherwise mentioned.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Robbo



Joined: 27 Jul 2008
Posts: 47
Location: England

PostPosted: Thu Apr 02, 2009 11:41 pm    Post subject: Reply with quote

Ok, I decided to help:

Code:

#NoEnv
#SingleInstance force
SendMode Input

Gui, Add, Text, x38 y52 w30 h15 +Right, Kills:
Gui, Add, Text, x28 y82 w40 h15 +Right, Deaths:
Gui, Add, Text, x8 y112 w60 h15 +Right, Head Shots:
Gui, Add, Text, x28 y142 w40 h15 +Right, Assists:

Gui, Add, Edit, x76 y110 w70 h20 vHeadshot,
Gui, Add, Edit, x76 y140 w70 h20 vAssist,
Gui, Add, Edit, x76 y80 w70 h20 vDeath,
Gui, Add, Edit, x76 y50 w70 h20 vKill,

Gui, Add, Text, x178 y52 w60 h15 +Right, Kill / Death:
Gui, Add, Text, x148 y82 w90 h15 +Right, Head Shots / Kills:
Gui, Add, Text, x168 y112 w70 h15 +Right, Assists / Kills:
Gui, Add, Text, x56 y10 w120 h30 , Kills Needed for +0.01`% Kill / Death Ratio

Gui, Add, Edit, x186 y15 w70 h20 vpossitivekill +ReadOnly,
Gui, Add, Edit, x246 y50 w70 h20 vkdratio +ReadOnly,
Gui, Add, Edit, x246 y80 w70 h20 vhskratio +ReadOnly,
Gui, Add, Edit, x246 y110 w70 h20 vakratio +ReadOnly,
Gui, Add, Button, x171 y140 w140 h20 vbutton, Calculate
Gui, Show, x600 y0 h186 w336, KD Calc
Return

ButtonCalculate:
Gui, Submit, NoHide

kd := Kill/Death
hsk := Headshot/Kill
ak := Assist/Kill

pk := Kill/Death
pk := Floor(pk*100) / 100
pk += 0.01
pk *= Death
pk -= Kill

GuiControl,, possitivekill, %pk%
GuiControl,, kdratio, %kd%
GuiControl,, hskratio, %hsk%
GuiControl,, akratio, %ak%
Return,

GuiClose:
ExitApp


Hope your thankful Razz

Code has been tested and works

Edit: Thanks tonne for the equation to get %pk%. I couldn't be bothered!
_________________
All scripts are untested unless otherwise mentioned.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group