fug5333 Posted March 5, 2010 Report Share Posted March 5, 2010 This is for a game. I have a standard and simple attack sequence, but I leave it running overnight and sometimes I die. I thought it would be great to add a way to hit a healing potion if I'm low. Here it is: Repeat Start (Repeat 1000 times) // Target Enemy Text Type: <TAB> Get Pixel Window Coords: 624,33 into %N1%(Their health bar) If Variable %N1% = 198 // Attack - Range Text Type: 3 Delay 1.3 Seconds Text Type: 2 Delay 1.3 Seconds Text Type: 1 Delay: 8 Seconds Macro fails when I put this next: //If HP Low, Heal Get Pixel: Window Coords: 150,15 into %N2%(my own health) If Variable %N2% <> 198 Text Type: - //Attack - Melee Text Type: <F3> Delay 1.3 Seconds Text Type: <F2> Delay 1.3 Seconds Text Type: <F1> Delay 1.0 Seconds End If Repeat End Most of this is just basic. Hit TAB to select the mob, run through an attack sequence. I thought it would be neat if it could heal itself too. I thought the macro should just do what I usually do when I'm sitting there. I don't know if the middle 'IF' statement gets handled first or last or where it is, but it's messing things up. The macro will hit TAB and then just sit there. I'm fairly new at this, so the complex stuff might need to be explained a bit. Any help would be great! Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted March 6, 2010 Report Share Posted March 6, 2010 There's something missing. You have 2 If's but only 1 End If (with no And or Or). The code is executed top to bottom and then back to the top at the end of the repeat. "If Variable %N2% <> 198" should this be <198? Why heal if you are high? You should explain what you are trying achieve with the problem step - game description is not much help. Text type "-" could be "End Game" for all I know. I have to say, I don't see any point in playing a game automatically. Why not get a cheat code and finish all levels by the end of the day? THAT'S cheating. Quote Link to comment Share on other sites More sharing options...
fug5333 Posted March 6, 2010 Author Report Share Posted March 6, 2010 There's something missing. You have 2 If's but only 1 End If (with no And or Or). The code is executed top to bottom and then back to the top at the end of the repeat. "If Variable %N2% <> 198" should this be <198? Why heal if you are high? You should explain what you are trying achieve with the problem step - game description is not much help. Text type "-" could be "End Game" for all I know. I have to say, I don't see any point in playing a game automatically. Why not get a cheat code and finish all levels by the end of the day? THAT'S cheating. I knew there would be some explaining. '198' is the color(decimal). It's a red health bar. The thought is, when the color is anything other than 198, then hit a health potion. It's hard to see, but I'm pretty sure there's some sort of texture "behind" the health bar. Text type '-' is the keyboard command for hitting a potion. The idea behind making a macro for this game is that there is nothing out there.. nothing! :/ Leveling is very slow. Thanks. Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted March 6, 2010 Report Share Posted March 6, 2010 I was being a bit thick, I should have realized. You did not say whether it's a changing colour bar or whether it's a moving bar of fixed colour. Pure red is decimal BGR 255 so your red 198 is more crimson. You are using 198 for your opponent not(?) being healthy so why aren't you healing at 198? Whatever you use to decide to attack your opponent you should be using the same logic to decide to heal yourself first. If their health is 198 and that is weak, you are going to be in trouble if your health is exactly 198 - you will not heal. You should run the mouse locator along the bar and see if the colour varies (with the texture). A single pixel measurement may not be enough. If necessary, have a Repeat loop and move the mouse a few pixels, take another Get Pixel Color reading etc. Then if none of the values are 198 you heal (IF 198 means good health). Put Text Box Displays after the pixel measurements while you are testing and display the colours picked off. They may not be what you are expecting. If the bar changes colour then you can be more sophisticated and heal at other degrees of colour. That requires changing the decimal BGR from Pixel Get Color to Hex BGR so you can look at the Green value for shades of, say, orange eg R=FF(255) G<66(102). I'll not go into that at this stage as it's quite complicated. You did not address the lack of End Ifs. None of the colour info problems should cause the macro to fail, although you don't say what "fail" is - you die? ME locks up? Quote Link to comment Share on other sites More sharing options...
fug5333 Posted March 6, 2010 Author Report Share Posted March 6, 2010 I was being a bit thick, I should have realized. You did not say whether it's a changing colour bar or whether it's a moving bar of fixed colour. Pure red is decimal BGR 255 so your red 198 is more crimson. You are using 198 for your opponent not(?) being healthy so why aren't you healing at 198? Whatever you use to decide to attack your opponent you should be using the same logic to decide to heal yourself first. If their health is 198 and that is weak, you are going to be in trouble if your health is exactly 198 - you will not heal. 198 is the color for the red health bar. Depending on where I'm checking from, it's the enemies or my own health bar. The first time it's checked, it's the enemies health bar, since I do not want to start my attack sequence if I don't have an enemy targeted. The second time, the time it doesn't work, it is my health bar. If I'm low, then I need to hit a health potion. The red does not change, there is no texture and it just slowly get's smaller. When I check to see if my health is low, I put 'if pixel is not 198 at these coords, hit a health potion(-).' You should run the mouse locator along the bar and see if the colour varies (with the texture). That's the 198(red) that I'm checking. There is no texture. A single pixel measurement may not be enough. If necessary, have a Repeat loop and move the mouse a few pixels, take another Get Pixel Color reading etc. Then if none of the values are 198 you heal (IF 198 means good health). Put Text Box Displays after the pixel measurements while you are testing and display the colours picked off. They may not be what you are expecting. That's an obvious to me. Should have done that already! /kicks self If the bar changes colour then you can be more sophisticated and heal at other degrees of colour. That requires changing the decimal BGR from Pixel Get Color to Hex BGR so you can look at the Green value for shades of, say, orange eg R=FF(255) G<66(102). I'll not go into that at this stage as it's quite complicated. You did not address the lack of End Ifs. None of the colour info problems should cause the macro to fail, although you don't say what "fail" is - you die? ME locks up? My actual macro has the proper End Ifs. I had to type that manualy, otherwise a copy/paste would put it in "direct" mode and less readable. Why I say 'fail', just nothing happens. It could run the first line of the macro and just stop. The macro might do exactly what I'm "telling" it to do, just not what is expected. I don't mean to seem rude by quoting everything you said as a way to "jump back", just wanted to address each point. Thanks for the follow up! Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted March 6, 2010 Report Share Posted March 6, 2010 (edited) I assumed you were checking the target's health to make sure the enemy was weak enough. I can't see the point of checking the colour of your health bar. You know it's going to be 198 red. You are not checking for size. If 198 is not found then your health bar does not exist at that location, right? (edit) Is this health bar like a progress bar - the left end is fixed and the right end moves (ie shorter rather than smaller)? You really should put in the Text Display Boxes as I suggested - they stop the macro so that you can read what is going on. You can use Breakpoints too but with multiple TDBs it's easy to keep going round the repeat loop. I wonder if the problem is that you seem to have everything in one loop. Have you thought about having a loop to deal with the target; once dealt with that, you have a loop for your health; once dealt with that you have the melee? I'm not clear on the manually typing End Ifs. To post the code you select the code in the Script Editor and then Edit/Copy Command Text. Edited March 7, 2010 by JohnS Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.