Sign in to follow this  
Followers 0
Delta01

Game's HP bar (Making in AI)

13 posts in this topic

Hey,

Well, I want to make an HP bar that records your character's current HP from the game and displays it in an autoit gui. (I can get the current HP from memory and have that working)

What function would I use to make an HP bar, naturally it'd need to update quickly and be able to go up and down..

Thnx

Share this post


Link to post
Share on other sites



The obvious answer would be a progressbar,you can even change the image of it.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Edit: Nevermind previous post o_0.

Use a progress bar, why would you use anything else? Why should that evan be a question? Unless your going to get all technical and make a custom AVI clip and have it look all fancy and waste a few hours on making this ridiculously overdone health bar, then yes, use a prgress bar.

Edited by fear1313

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Share this post


Link to post
Share on other sites

heres a simple progress setup...that may help you

;Global Const $PBS_MARQUEE           = 0x00000008; The progress bar moves like a marquee
Global $i=0

; Create GUI
$Form1 = GUICreate("Progress Demo By CyberZeroCool", 401, 301, 341, 258)
$Progress1 = GUICtrlCreateProgress(0, 0, 25, 297, BitOR($PBS_SMOOTH,$PBS_VERTICAL,$PBS_MARQUEE))
$Progress2 = GUICtrlCreateProgress(104, 0, 289, 25)
$Progress3 = GUICtrlCreateProgress(104, 56, 289, 25, $PBS_MARQUEE)
$Label1 = GUICtrlCreateLabel("-1 (NO STYLE)", 104, 32, 75, 17)
$Label2 = GUICtrlCreateLabel("$PBS_MARQUEE", 104, 88, 91, 17)
$Label3 = GUICtrlCreateLabel("$PBS_MARQUEE+$PBS_SMOOTH+$PBS_VERTICAL", 32, 280, 268, 17)
$Progress4 = GUICtrlCreateProgress(32, 0, 25, 265, BitOR($PBS_VERTICAL,$PBS_MARQUEE))
$Progress5 = GUICtrlCreateProgress(104, 112, 289, 25, $PBS_SMOOTH)
$Label4 = GUICtrlCreateLabel("$PBS_SMOOTH", 104, 144, 84, 17)
$Progress6 = GUICtrlCreateProgress(104, 162, 289, 25, BitOR($PBS_SMOOTH,$PBS_MARQUEE))
$Label5 = GUICtrlCreateLabel("$PBS_MARQUEE+$PBS_SMOOTH", 104, 194, 177, 17)
$Label6 = GUICtrlCreateLabel("$PBS_MARQUEE+$PBS_VERTICAL", 64, 248, 182, 17)
$Progress7 = GUICtrlCreateProgress(64, 0, 25, 233, $PBS_VERTICAL)
$Label7 = GUICtrlCreateLabel("$PBS_VERTICAL", 92, 220, 89, 17)

GUISetState()

AdlibEnable("Advance", 50)

; Loop until user exits
do
until GUIGetMsg() = $GUI_EVENT_CLOSE

Func Advance()
$i=$i+1
GUICtrlSetData($Progress1, $i)
GUICtrlSetData($Progress2, $i)
GUICtrlSetData($Progress3, $i)
GUICtrlSetData($Progress4, $i)
GUICtrlSetData($Progress5, $i)
GUICtrlSetData($Progress6, $i)
GUICtrlSetData($Progress7, $i)
If $i = 100 Then $i = 0
EndFunc

Share this post


Link to post
Share on other sites

Sorry for the gay question =)

Is there anyway I can put a label on my progress bar without having it blink when the progress bar / label updates?

ATM, I've tried GuiCtrlSetData to change the values on the label, but whenever the label or the bar updates it blinks

Share this post


Link to post
Share on other sites

Is it even possible to have a label over a progress bar without it blinking when it updates?

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

My code is...

GuiCreate("My HP tool", 300, 100)
$HP = GuiCtrlCreateProgress(5, 20, 150, 30, $PBS_SMOOTH)
$HpLabel = GuiCtrlCreateLabel("00000/00000", 45, 30, -1, 14, $GUI_ONTOP)



GuiSetState()

AdlibEnable("GetHp")

WinSetOnTop("My HP tool", "", 1)

Do
Until GuiGetMsg() = $GUI_EVENT_CLOSE

Func GetHP()
;Gets the current HP value
$Val1 = $CurHP / $MaxHp 
$HpBarVal = $Val1*100
GuiCtrlSetData($HP, $HPBarVal)
GuiCtrlSetData($HpLabel, $CurHp & "/" & $MaxHp)

EndFunc 

Func _FindNewAddress(ByRef $Pointer, ByRef $OSet)
;Used for dynamic reading
EndFunc

The parts where it gets the HP value shouldn't really matter

Share this post


Link to post
Share on other sites

My code is...

GuiCreate("My HP tool", 300, 100)
$HP = GuiCtrlCreateProgress(5, 20, 150, 30, $PBS_SMOOTH)
$HpLabel = GuiCtrlCreateLabel("00000/00000", 45, 30, -1, 14, $GUI_ONTOP)



GuiSetState()

AdlibEnable("GetHp")

WinSetOnTop("My HP tool", "", 1)

Do
Until GuiGetMsg() = $GUI_EVENT_CLOSE

Func GetHP()
;Gets the current HP value
$Val1 = $CurHP / $MaxHp 
$HpBarVal = $Val1*100
GuiCtrlSetData($HP, $HPBarVal)
GuiCtrlSetData($HpLabel, $CurHp & "/" & $MaxHp)

EndFunc 

Func _FindNewAddress(ByRef $Pointer, ByRef $OSet)
;Used for dynamic reading
EndFunc

The parts where it gets the HP value shouldn't really matter

another thing that you could do, instead of a progress bar, is use an image of a color that is stretched depending on the value. you really wouldn't be adding a whole lot of code over the implementation with the progress bar, but would have a little bit more power to customize and make it look the way i think you want it to. all an HP bar would be is like a black rectangle with a border of whatever length, and then another image over it that is slightly smaller vertically, and about a hundred times narrower. say your background of the hp bar is 100x 20, then make another image that's 1x18 and sits right on top of it in a control that you resize based on calculations like $picwidth = $hp/$backgroundwidth*10000 so that when HP is maxed, the HP completely covers the width of the background, and moves down 1% every 1% of damage is taken. make sense? another thing to look at since you're grabbing the HP from memory, why not only update the bar when it changes? you'll eliminate a lot of your blinking, and reduce the resource need of your script, and throw a Sleep() into your loop, checking for change every 100 milliseconds or so will still keep it accurate but it will again reduce the overhead and make everything else run better

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

another thing that you could do, instead of a progress bar, is use an image of a color that is stretched depending on the value. you really wouldn't be adding a whole lot of code over the implementation with the progress bar, but would have a little bit more power to customize and make it look the way i think you want it to. all an HP bar would be is like a black rectangle with a border of whatever length, and then another image over it that is slightly smaller vertically, and about a hundred times narrower. say your background of the hp bar is 100x 20, then make another image that's 1x18 and sits right on top of it in a control that you resize based on calculations like $picwidth = $hp/$backgroundwidth*10000 so that when HP is maxed, the HP completely covers the width of the background, and moves down 1% every 1% of damage is taken. make sense? another thing to look at since you're grabbing the HP from memory, why not only update the bar when it changes? you'll eliminate a lot of your blinking, and reduce the resource need of your script, and throw a Sleep() into your loop, checking for change every 100 milliseconds or so will still keep it accurate but it will again reduce the overhead and make everything else run better

Ahhh, ok. That's a good idea, I'll see what I can do : )

Share this post


Link to post
Share on other sites

I tired that and no, it still flashes.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I tired that and no, it still flashes.

can i see your code for that attempt?

***edit***

P.S. did it atleast reduce system load while your script is running?

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Check this out: :D

#include <guiconstants.au3>
GuiCreate("My HP tool", 300, 100)
XPStyleToggle(1) ; Use this if you running in a Windows XP machine
$HP = GuiCtrlCreateProgress(5, 20, 150, 30, $PBS_SMOOTH)
$HpLabel = GuiCtrlCreateLabel("00000/00000", 45, 30, -1, 14, $GUI_ONTOP)
Global $HpValue = 0


GuiSetState()

WinSetOnTop("My HP tool", "", 1)


Do
    $HpValue += 2
    $tol=255;
    $red=$tol-100-$hpValue;
    if ($hpValue<50) then $tol=150;
    $sec=Int($tol*($hpValue/100));
    $color =$sec + 256 * $sec + 65536* $red 
    GUICtrlSetData($Hp,$HpValue)
    GUICtrlSetColor($hp,  $color)
GuiCtrlSetData($HpLabel, $HpValue)
    If $hpValue >=100 then $hpValue = 0
    Sleep(50)
Until GuiGetMsg() = $GUI_EVENT_CLOSE

Func XPStyleToggle($OnOff = 1) 
    If Not StringInStr(@OSTYPE, "WIN32_NT") Then Return 0
    If $OnOff Then
        $XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
        Return 1
    ElseIf IsArray($XS_n) Then
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
        $XS_n = ""
        Return 1
    EndIf
    Return 0
EndFunc   ;==>XPStyleToggle, for changing progress bar colors
Edited by Linux

You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!"

Share this post


Link to post
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
Sign in to follow this  
Followers 0