Author Topic: Working on a pixel scan sub  (Read 4502 times)

0 Members and 1 Guest are viewing this topic.

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Working on a pixel scan sub
« on: December 15, 2011, 05:19:05 AM »
0
I want to execute a primary weapon move every 3 seconds so I don't get the penalty for doing them back to back.

I'll use pixel scanning to determine the condition of the icon...

Code: [Select]
gosub set_pixel 1 ArmorIgnore 35 0

sub set_pixel
  event macro %3 %4
  display ok Move mouse to your %2 Button.$You have 2 seconds
  wait 2s
  savePix #cursorX #cursorY %1
  wait 5
  display ok Pixel saved as # %1 $Do NOT move that icon!
return

That sets cmppix 1 to the active Armor Ignore icon.

What I want to do is keep checking that, amongst other things, and when it toggles to False (the icon is no longer red) set a 3 second timer. During this 3 second timer I don't want to recheck the icon at all. At the end of the 3 second timer I want to activate Armor Ignore again, which is easy enough. During that 3 second period the rest of the script must continue.

I'm thinking I'll need a "pixel checker" in the main loop with a timer attached.

Code: [Select]
set %timer_primary ( #sCnt2 + 60 )

gosub check_primary

sub check_primary
cmppix 1 f ; icon is NOT active
  {
  if %timer_primary > #sCnt2
    return
  event macro 35 0
  set %timer_primary ( #sCnt2 + 60 )
  wait 5
  }
return

I'm coffee lagged and can't determine if that is what I'm looking for? It seems like it.... Check the pixel, if it's NOT lit up that means I just armor ignored.

Anyways, need a fresh set of eyes on this, I'm not even sure I'm in the ballpark here.

Ultimate would be to include a different cmppix while waiting for the armor ignore ;) , like 3 lightning strikes - 1 armor ignore pattern.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Working on a pixel scan sub
« Reply #1 on: December 15, 2011, 05:00:58 PM »
0
off top of head code... not tested in the slightest.  Generic so you can define as many gumps to check as you want and check as many as needed.

Code: [Select]
gosub set_pixel 1 ArmorIgnore 35 0 3
gosub Set_pixel 2   name        macro timer ie 3sec

gosub Check_pixel 1
gosub Check_pixel 2
halt

sub set_pixel
  set %PixelName . %1 %2
  set %Pixelmacro1 . %1 %3
  set %Pixelmacro2 .  %1 %4
  set %PixelTime . %1 %5 * 1000
  event macro %3 %4
  set %PixelTimer . %1 #SYSTIME + %PixelTime . %1
  display ok Move mouse to your %2 Button.$You have 2 seconds
  wait 2s
  savePix #cursorX #cursorY %1
  set %PixelPosx  . %1 #cursorx
  set %PixelPosy .  %1 #cursorY
  set %PixelValue . %1  #pixcol
  wait 5
  display ok Pixel saved as # %1 $Do NOT move that icon!
return

sub check_pixel ; 1....
  if %PixelTimer . %1 > #SYSTIME
     {
    savePix #cursorX #cursorY
    if #pixcol <>  %PixelValue . %1  
       {
       event macro %Pixelmacro1 . %1  %Pixelmacro2 . %1
       set %PixelLastCall . %1  #SYSTIME + %PixelTime . %1  
       }
    if #pixcol =  %PixelValue . %1  
       set %PixelTimer . %1 %PixelLastCall . %1 ; done this way so dont have to wait to check was good checks on next loop.
     }
return
« Last Edit: December 15, 2011, 05:03:27 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Working on a pixel scan sub
« Reply #2 on: December 15, 2011, 06:29:44 PM »
0
These Subs Might Be Handy For You. Just wrote them tonight actually....

Gosub Move_PrimaryAbility (x) (y)

Pixel Scans the location to see if it can find proper Pixels for the Gump in the Location First, and if it Can't, pulls the Primary Gump and moves it to The Location. Works the Same for SecondaryAbility, MomentumStrike, And LightningStrike

I know it's Not "En" Pixel Scanning and Doesn't Compensate for all Resolutions, but seems to work okay.


Code: [Select]
;====================================
Sub Save_Pix2
Namespace Push
Namespace Local Save_Pix2
Set !SaveX %1
set !SaveY %2
Savepix !SaveX !SaveY 1
Namespace Pop
Return
;=====================================

Sub Move_PrimaryAbility
Namespace Push
Namespace Local Mwinc_Move_PrimaryAbility
set !LPC #LPC
set #LPC 9999
set !X %1
set !Y %2
set !X_Start !X + 25
set !X_End !X + 30
set !Y_Scan !Y + 27
set !Cipher
for !X_Scan !X_Start !X_End
{
Gosub Save_Pix2 !X_Scan !Y_Scan
Str Left #Pixcol 1
set !Cipher !Cipher , #Strres
}
if !Cipher = 431431 || !Cipher = 771862
{
set #Lpc !Lpc
NameSpace Pop
Return
}
Event macro 8 14
Gosub Cont_Timer 30 Contsize 406_249
Gosub Click_Offset 243 127 G
Gosub Cont_Timer 30 COntName AbilityIcon_Gump
if #ContName = AbilityIcon_Gump
{
Gosub Click_Offset 15 15 f
Contpos !X !Y
}
Event Macro 9 14
set #LPC !LPC
Namespace Pop
Return

;======================================

Sub Move_SecondaryAbility
Namespace Push
Namespace Local Mwinc_Move_PrimaryAbility
set !LPC #LPC
set #LPC 9999
set !X %1
set !Y %2
set !X_Start !X + 25
set !X_End !X + 30
set !Y_Scan !Y + 27
set !Cipher
for !X_Scan !X_Start !X_End
{
Gosub Save_Pix2 !X_Scan !Y_Scan
Str Left #Pixcol 1
set !Cipher !Cipher , #Strres
}
if !Cipher = 952948 || !Cipher = 411424
{
set #Lpc !Lpc
Namespace Pop
Return
}
Event macro 8 14
Gosub Cont_Timer 30 Contsize 406_249
Gosub Click_Offset 243 171 G
Gosub Cont_Timer 30 COntName AbilityIcon_Gump
if #ContName = AbilityIcon_Gump
{
Gosub Click_Offset 15 15 f
Contpos !X !Y
}
Event Macro 9 14
set #Lpc !LPC
Namespace Pop
Return
;====================================

Sub Move_LightningStrike
Namespace Push
Namespace Local Mwinc_Move_LightningStrike
set !Lpc #Lpc
set #Lpc 9999
set !X %1
set !Y %2
set !X_Start !X + 25
set !X_End !X + 30
set !Y_Scan !Y + 27
set !Cipher
for !X_Scan !X_Start !X_End
{
Gosub Save_Pix2 !X_Scan !Y_Scan
Str Left #Pixcol 1
set !Cipher !Cipher , #Strres
}
if !Cipher = 768888 || !Cipher = 334444
{
set #Lpc !Lpc
Namespace Pop
Return
}
Finditem QON C_ , #Backpackid
if #findcnt < 1
{
set #Lpc !Lpc
Namespace Pop
Return
}
Event macro 8 15
Gosub Cont_Timer 30 Contsize 406_249
if #Result = #True
{
set #Lpc !Lpc
Namespace Pop
Return
}
Gosub Click_Offset 335 18 x 3
Wait 10
Gosub Click_Offset 90 76 G
Gosub Cont_Timer 30 COntName SpellIcon_Gump
if #ContName = SpellIcon_Gump
{
Gosub Click_Offset 15 15 f
Contpos !X !Y
}
Event Macro 9 15
set #Lpc !Lpc
Namespace Pop
Return
;========================================
Sub Move_MomentumStrike
Namespace Push
Namespace Local Mwinc_Move_MomentumStrike
set !LPC #LPC
set #Lpc 9999
set !X %1
set !Y %2
set !X_Start !X + 25
set !X_End !X + 30
set !Y_Scan !Y + 27
set !Cipher
for !X_Scan !X_Start !X_End
{
Gosub Save_Pix2 !X_Scan !Y_Scan
Str Left #Pixcol 1
set !Cipher !Cipher , #Strres
}
if !Cipher = 776567 || !Cipher = 433333
{
Set #Lpc !Lpc
Namespace Pop
Return
}
Finditem QON C_ , #Backpackid
if #findcnt < 1
{
set #Lpc !Lpc
Namespace Pop
Return
}
Event macro 8 15
Gosub Cont_Timer 30 Contsize 406_249
if #Result = #True
{
set #Lpc !Lpc
Namespace Pop
Return
}
Gosub Click_Offset 335 18 x 3
Wait 10
Gosub Click_Offset 252 76 G
Gosub Cont_Timer 30 COntName SpellIcon_Gump
if #ContName = SpellIcon_Gump
{
Gosub Click_Offset 15 15 f
Contpos !X !Y
}
Event Macro 9 15
set #Lpc !Lpc
Namespace Pop
Return
;===================================
;========================================================
Sub Click_Offset
Namespace Push
Namespace Local Mwinc_ClickOffset
set !Clickx #contposx + %1
set !CLicky #contposy + %2
Click !Clickx !CLicky %3 %4
set %3 0
set %4 0
Namespace pop
Return
;========================================================
;==========================================================
Sub Cont_Timer
; Gosub Cont_Timer (Timer) ( Var ) ( Value )
Namespace Push
Namespace Local Mwinc_Cont_Timer
set !Lpc #Lpc
set #lpc 9999
set !Time_Limit #scnt2 + %1
set !Cont_Check # . %2
While !Cont_Check <> %3 && !Time_Limit > #scnt2
{
set !Cont_Check # . %2
wait 1
}
set #Lpc !LPC
if !Time_Limit <= #scnt2
{
Namespace Pop
Return #true
}
Namespace Pop
Return #False
;=========================================================

Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Working on a pixel scan sub
« Reply #3 on: December 15, 2011, 08:44:45 PM »
0
ROFL, Stupid me, Forgot that there are more than just one Kind of Special... That was Dumb..... Time for lots of Pixel Scanning.
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Working on a pixel scan sub
« Reply #4 on: December 16, 2011, 02:49:15 AM »
0
In LAME3.0 dxrom has it setup for Whirlwind primary and also Armor Ignore primary. His trick is to pixel scan the lower left corner of the icon. That spot doesn't change between the two different icons so it's a "safe place".

The true way would be what you gents have mentioned. A pixel scanner that would arrange the icons and scan do determine which icons are busy would be the very best case.

I was trying to get AI's every three seconds so I don't get spammed with "you need 24 mana to perform that action" messages all the darn time LOL. And eventually I'd love to have 2 or 3 lightning strikes then 1 armor ignore. Or even lightning strike until mana meets a criteria ( > 24 LOL ) then do an AI again.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Working on a pixel scan sub
« Reply #5 on: December 16, 2011, 07:45:28 AM »
0
Hehe, What I wound up doing was arranging my Gumps so there was a little space in between them, then I would scan top portion, which would give a code like

0111111111111111111111111111111111111110

the Zeros Representing the Black saying that its at least in the Right spot for the X Position Requested. I guess I could do the Same for The Y Position, but I like for the Script to start up as quickly as Possible.
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: Working on a pixel scan sub
« Reply #6 on: December 16, 2011, 11:23:00 AM »
0
I have an idea, but I'm still sorting out (mentally) how to explain it...

I'm gonna run to the store and get a case of beer, have a couple and by then I should have it worked out. I'll post it later tonight.



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: Working on a pixel scan sub
« Reply #7 on: December 16, 2011, 11:51:35 AM »
0
In LAME3.0 dxrom has it setup for Whirlwind primary and also Armor Ignore primary. His trick is to pixel scan the lower left corner of the icon. That spot doesn't change between the two different icons so it's a "safe place".

The true way would be what you gents have mentioned. A pixel scanner that would arrange the icons and scan do determine which icons are busy would be the very best case.

I was trying to get AI's every three seconds so I don't get spammed with "you need 24 mana to perform that action" messages all the darn time LOL. And eventually I'd love to have 2 or 3 lightning strikes then 1 armor ignore. Or even lightning strike until mana meets a criteria ( > 24 LOL ) then do an AI again.



I guess a more technical term would be that they have 4 things in common.



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Working on a pixel scan sub
« Reply #8 on: December 16, 2011, 11:54:30 AM »
0
I'd say they all have the lower right corner in common also. The closes one is the concussion blow, but even that has a clear spot in the lower right corner.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: Working on a pixel scan sub
« Reply #9 on: December 16, 2011, 12:15:13 PM »
0
Anywhere on that edge, really...



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: Working on a pixel scan sub
« Reply #10 on: December 17, 2011, 04:36:23 PM »
0
Code: [Select]
gosub set_pixel 1 ArmorIgnore 35 0

sub set_pixel
  event macro %3 %4
  display ok Move mouse to your %2 Button.$You have 2 seconds
  wait 2s
  savePix #cursorX #cursorY %1
  wait 5
  set %primCnt 0
  display ok Pixel saved as # %1 $Do NOT move that icon!
return




// set %timer_primary ( #sCnt2 + 60 )

gosub check_primary
gosub check_lightningStrike

sub check_lightningStrike
cmppix 2 f
 {
 if %primCnt < 3
return
 event macro 15 149
 set %primCnt 0
 wait 5
 }
return

sub check_primary
cmppix 1 f ; icon is NOT active
  {
  if %primCnt < 3
    return
  event macro 35 0
//  set %timer_primary ( #sCnt2 + 60 )
  set %primCnt + 1
  wait 5
  }
return

I was thinking something like that. However THAT is completely untested and I can guarantee will not work as is (left out alot of stuff, like setting the pixel for LS). But the basic concept is that instead of using a timer, to make a primary counter, that assume you hit. Every three Primaries will switch over to a lightning strike.



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline CervezaTopic starter

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Working on a pixel scan sub
« Reply #11 on: December 19, 2011, 08:19:20 AM »
0
Thinking here....

Code: [Select]
gosub check_pix

sub check_pix
cmppix 1 f ; icon not active
  {
  if %LSCount < 3
    {
    event macro 15 149
    set %LSCount ( %LSCount + 1 )
    return
    }
  }
event macro 35 0 ; armor ignore
set %LSCount 0
return

The missing part is knowing when the toggle for Armor Ignore ( cmppix 2 ) goes off to start the Lightning Strike cycle once more.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: Working on a pixel scan sub
« Reply #12 on: December 19, 2011, 08:47:10 PM »
0
I would make it so that after I utilize event macro 35 0 that it adds +1 to a counter... Once it reaches a certain point, (or mana is at a certain level) it switches to lightning strike, resetting the counter, or until mana is back.



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Tags: