Jump to content

Example, How to read a status bar in a game?


Chapi
 Share

Recommended Posts

Hi, this is how i do it.

Its a simple script, maybe is useless for most of you, but for bootings purpose is really usefull.

By using this you can read hp, mp, cp bars and any bar that has a constant color.

;~ ======================================================================
;~ Controlo el mp mediante la lectura de los pixeles de la barra de MP
;~ la unica coordenada que varia es X. La coordenada Y queda fija en 55
;~ ======================================================================
Func ControlMP()
Local $Cor = 19     ;Punto inicial de la barra de mana (En X). 
Local $CantMP = 0   ;Se usa para incrementar el porcentaje a medida que lee la barra.
Local $Negro        ;Contiene el valor del pixel leido (valor numerico que representa el color)
Local $PorcenMP = 11           ;Es la variable de retorno donde se almacena el porcentaje calculado

    While $Cor < 160 
        $Negro = PixelGetColor($Cor, 55)
        if $Negro > 30000 then
            if $CantMP < $PorcenMP Then
                $PorcenMP = $CantMP
                $Cor = 160
            EndIf
        EndIf
        $CantMP = $CantMP + 0.5
        $Cor = $Cor + 7
    WEnd
    If $PorcenMP = 11 Then
        $PorcenMP = 10
    EndIf
    $PorcenMP = $PorcenMP * 10
    
    Return $PorcenMP
EndFunc
Link to comment
Share on other sites

For what game you made it?

What must be screen resolution?

What must be bar width?

Where it shows valuse?

How to use this function?

How it gets value?

In what color must be life bar?

How u getvalues with out reading game memory?

for example my bar with is 5 cm long and life can be between 0 and 6730 and after I get my char next level this bar can have value between 0 and 8321, Then how I get that value?

Can you also add comments in english please?

Edited by au3scr
Link to comment
Share on other sites

For what game you made it?

What must be screen resolution?

What must be bar width?

Where it shows valuse?

How to use this function?

How it gets value?

In what color must be life bar?

How u getvalues with out reading game memory?

for example my bar with is 5 cm long and life can be between 0 and 6730 and after I get my char next level this bar can have value between 0 and 8321, Then how I get that value?

Can you also add comments in english please?

- For Lineage 2 C4

- Lineage 2 is 3D but the status bars, skills and everything in the hud is 2d. A change in the resoludtion dosn't affect how many pixels are in the hud.

- In the example script the bar begin in pixel (19, 55) and end in (159, 55)

- The value of the bar is returned by the function in percentage. To now the actual number yo need to do the maths whit the maximun value of the bar.

- For example maximun value of the bar is 4444 then:

$Max = 4444

$Percen = ControlMP()

$Current = ($Max * $Percen) / 100

- In the example the bar is blue and the backgorund (when is empty) black. This is controled by (if $Negro > 30000 then)

- The values aren't exacts, they are an approximation. To obtein more acurete values yo need to do more reads. In the example the bar is separated in 20 parts.

160 - 19 = 141

141 / 7 = 20.14

Then you have 20 parts.

Sorry for my bad english, i hope you understand something :)

Link to comment
Share on other sites

  • 3 months later...

Chapi, There are some ideas of how to read the status bar in the Gracia final?

The problem is that color is not homogeneous and the numbers are high, closing the entire strip.

In Interlude, I made this function:

; The function of the control strips MP returns the value as a percentage %

; $MPx - coordinate X, $MPy - coordinate Y, $len - length of line, $color - the color of the first pixel

Func ControlMP($MPx, $MPy, $len, $color)

Local $color2 = $color

Local $MPx2 = $MPx

While $color = $color2 ; cycle turning, until the color is equal

$MPx2 += 1 ; on each cycle adds 1 to the coordinate

$color2 = Hex(PixelGetColor($MPx2, $MPy), 6); checking whether the color has not changed

WEnd

$MPx2 -= 1 ; 1 discards the last turn of the cycle, because the color will not match.

$MPx2 -= $MPx ; subtract the initial coordinates to get the number of covered pixels.

$Percent = $MPx2 * 100 / $len ; calculate the percentage of

$Percent = Ceiling ($Percent) ; rounded off to whole number

Return $Percent

EndFunc

Edited by ynbIpb
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...