Fiesta bot

You may request or share scripts for MicroMacro in this forum.
Message
Author
User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Fiesta bot

#1 Post by Administrator » Fri Jan 11, 2008 7:15 pm

Designed for MicroMacro 0.96

Step 1: Install No-XTrap patch
First, download this zip:
<removed: broken - wait for a new patch>
Unzip it to your Fiesta folder (C:/Program Files/Outspark/Fiesta/ by default) and allow it to overwrite the originals.
Now you're ready to log in and play like normal :)

This bot is designed to work in Fiesta at 1024*768 resolution only. Other resolutions might work, but haven't been tested. Also, make sure you haven't moved the enemy's HP bar that shows up at the top when selected.

Usage: Open fiestabot.lua with notepad to edit it. You will need to modify the settings in this file to work with your character. Begin by modifying this section:

Code: Select all

-- EDIT THESE!
-------------------------
class           = CLASS_CLERIC; -- class determins the logic to take
HP_restamt 	= 150; 		-- HP to rest at   (not used for cleric's)
HP_potion	= 235; 		-- Use a HP potion (or heal skill for cleric)
HP_stone	= 180; 		-- Use a HP stone
SP_restamt 	= 200; 		-- SP to rest at
SP_potion	= 300;      	-- Use a SP potion
SP_stone	= 240;          -- Usa a SP stone


key_attack 	= key.VK_1; 	-- normal melee attack
key_pickup      = key.VK_2;     -- pickup items
key_skill1 	= key.VK_5; 	-- offensive and defensive spells...
key_skill2 	= key.VK_6; 	-- check your class's fight function
key_skill3 	= key.VK_7; 	-- for documentation on what each skill
key_skill4 	= key.VK_8; 	-- will be used for

key_scroll1 	= key.VK_9; 	-- offensive and defensive spells...
key_scroll2 	= key.VK_0; 	-- check your class's fight function
key_scroll3 	= key.VK_DASH; 	-- for documentation on what each skill
key_scroll4 	= key.VK_EQUAL; -- will be used for

key_hppotion 	= key.VK_3;     -- CLERICS: map this to your heal spell
key_hpstone 	= key.VK_Q;
key_sppotion 	= key.VK_4;
key_spstone 	= key.VK_E;
Below this area, you can turn buffs and buff scrolls on/off if you want. Make sure your hotkeys in-game match the ones in the script.


Now open micromacro.exe, type "fiestabot.lua" (without quotes), and press enter. Now go back to Fiesta and find a place with lots of monsters nearby, and press F5 to start botting. F6 will pause it (F5 to resume), and CTRL+L to load or re-load. MicroMacro must be run with Administrator privileges, and appears to have access problems with Windows Vista -- read the FAQ or help file included with MicroMacro if you are using Vista.
Attachments
fiestabot.lua
(16.49 KiB) Downloaded 727 times

aaronthen
Posts: 6
Joined: Sat Feb 02, 2008 11:03 pm

Re: Fiesta bot

#2 Post by aaronthen » Sat Feb 02, 2008 11:13 pm

The bot its working fine at the beginning untill it comes to time when need to use sp stone. Its acting weird, instead of using 1 stone it sometimes uses more than 3. How can i fix this problem?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Fiesta bot

#3 Post by Administrator » Sun Feb 03, 2008 1:31 am

Check and make sure it's actually using them. The bot window might say that it is being used like 2 or 3 times, but it actually will only be used once.

aaronthen
Posts: 6
Joined: Sat Feb 02, 2008 11:03 pm

Re: Fiesta bot

#4 Post by aaronthen » Mon Feb 04, 2008 12:08 am

It does using it in game :( And i tried something stupid, i use knight setting for cleric, instead of using mp stone it uses sp stone. The reason i use that setting, coz of the skill. I cant use bash and restore when i use cleric setting. But 1st this 1st, how do i fix the stone's problem, its wasted lots of stones.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Fiesta bot

#5 Post by Administrator » Mon Feb 04, 2008 2:57 pm

Post your configuration (just the top section of the script where you made changes).

Are stones instant reuse now? Before, it took a couple seconds before you could reuse them. If they are instant, that would explain this problem. It should be a simple fix though. Go to function hp_stone() in your script, and change it to this:

Code: Select all

-- use a hp stone!
function hp_stone()
  keyboardHold(key_hpstone);
  yrest(100);
  keyboardRelease(key_hpstone);

  HP = HP + 500; -- so we don't keep using them while our client updates the variables

  print("HP stone used.")

  yrest(500);
end

aaronthen
Posts: 6
Joined: Sat Feb 02, 2008 11:03 pm

Re: Fiesta bot

#6 Post by aaronthen » Mon Feb 04, 2008 8:28 pm

It does fixed the problem, thanks a milliones. U're the man :) Got a small request to ask, if its not too hard. Is there a way to make it use scroll while in battle? Coz i need a skill that kepp casting every 14 second, only in scroll i can put timer. If cant, maybe u can make a key slot lets say 5, to hit the key every 14 second. Its for cleric skill calls restore, it heals 60++ every 1.2 second for 14 second. It save lots of sp when fighting.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Fiesta bot

#7 Post by Administrator » Mon Feb 04, 2008 11:33 pm

This can't be done easily, no. It would take a lot more code. Maybe you could try this though:

Code: Select all

function regen_scroll()
  keyboardPress(key.VK_5); -- lets pretend 5 is the hotkey
end
And in function main(), add this:

Code: Select all

  registerTimer("regen_scroll", 14000, regen_scroll);

aaronthen
Posts: 6
Joined: Sat Feb 02, 2008 11:03 pm

Re: Fiesta bot

#8 Post by aaronthen » Tue Feb 05, 2008 1:34 pm

Ok it was just a suggestion, i can just use the normal scroll function and set timer to 14000. There's another, as i said i'm a cleric and i'm trying to use KNIGHT setting for CLERIC, everything seems fine at the start, when it comes to stone using, instead of using SP stone it uses HP stone. Can this be fix? KNIGHT setting aloowed me using my atk skill, normal hit takes too long to kill a monster. Sorry for troubleing u, i knwo nothign about coding :(

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Fiesta bot

#9 Post by Administrator » Tue Feb 05, 2008 2:43 pm

Go to the knight_fight() function, and edit this section:

Code: Select all

    if( HP < HP_potion) then hp_potion(); end
    if( HP < HP_stone) then hp_stone(); end
    if( SP < SP_potion) then sp_potion(); end
    if( SP < SP_stone) then sp_stone(); end
Make sure that the final condition is calling sp_stone().

aaronthen
Posts: 6
Joined: Sat Feb 02, 2008 11:03 pm

Re: Fiesta bot

#10 Post by aaronthen » Wed Feb 06, 2008 5:58 am

Thanks for all the codes you've show me, i've learn alot from you. If u figure out how to makes the script use scroll/buff pls post here. That would be awesome.

Code: Select all

 if( math.random(100) > 92 ) then
      if( math.random(100) >= 50 ) then
        keyboardHold(key_skill1);
        yrest(50);
        keyboardRelease(key_skill1);
      else
        keyboardHold(key_skill2);
        yrest(50);
        keyboardRelease(key_skill2);
      end
    end

    yrest(200);
What should i change to make the skill1 use every 20 second and skill2 every 14 second?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Fiesta bot

#11 Post by Administrator » Wed Feb 06, 2008 12:04 pm

That function doesn't work by timing things out, but rather, by random chance. The reason for this is to make it appear less bot-like. GMs and other staff typically look for repeated, pre-determined behavior.

If you wanted to time it, you would need to write some functions to toggle switches, install timers for those functions, check those timers, and finally call their instructions when switched on.

aaronthen
Posts: 6
Joined: Sat Feb 02, 2008 11:03 pm

Re: Fiesta bot

#12 Post by aaronthen » Wed Feb 06, 2008 1:53 pm

That sounded hard to make one for me lol. Guess i have to forget about that function :( Thanks again for all the helps u did :)

charmingiv
Posts: 12
Joined: Mon Feb 18, 2008 4:52 pm

Re: Fiesta bot for high lvl cleric!

#13 Post by charmingiv » Tue Feb 19, 2008 6:59 pm

Ok now I have a nice code for my cleric low level, now I have a cleric high level which has more than 5 buff(skills) and needs to use more than 5 scrolls, so I am trying to edit the code like this( I think the problem is the virtual keys) :

Code: Select all

key_attack    = key.VK_1;    -- normal melee attack
key_pickup    = key.VK_2;     -- pickup items
key_skill1    = key.VK_5;    -- offensive and defensive spells...
key_skill2    = key.VK_6;    -- check your class's fight function
key_skill3    = key.VK_7;    -- for documentation on what each skill
key_skill4    = key.VK_8;    -- will be used for
key_skill5    = key.VK_SHIFT_1 -- my add for more skills?

key_scroll1    = key.VK_9;    -- offensive and defensive spells...
key_scroll2    = key.VK_0;    -- check your class's fight function
key_scroll3    = key.VK_DASH;    -- for documentation on what each skill
key_scroll4    = key.VK_EQUAL; -- will be used for
key_scroll5    = key.VK_SHIFT_2 -- my add virtual key!!!!!!!!
Then I changed this:

Code: Select all

-- Scroll settings  (read instructions below Buff settings first)
-------------------------
scroll1_duration    = 3500000;
scroll_1            = 1;
scroll2_duration    = 3500000;
scroll_2            = 1;
scroll3_duration    = 3500000;
scroll_3            = 1;
scroll4_duration    = 3500000;
scroll_4            = 1;
scroll5_duration    = 3500000;
scroll_5            = 1;
-------------------------


-- Buff settings (only for clerics)
-------------------------
buff1_duration       = 3500000;
buff_1               = 1;
buff2_duration       = 3500000;
buff_2               = 1;
buff3_duration       = 3500000;
buff_3               = 1;
buff4_duration       = 3500000;
buff_4               = 1;
buff5_duration       = 3500000;
buff_5               = 1;
-- NOTE:  set on 59 minutes
-- buff / scroll durations in msec    time = minutes x 60000
-- to de- activate non used buffs / scrolls replace "1" with "0"
-- to activate buff / scroll replace "0" with "1"
-- scrolls can be used too as buff
-------------------------
Then this:

Code: Select all

buff1_needed      = true;
buff2_needed      = true;
buff3_needed      = true;
buff4_needed      = true;
buff5_needed      = true;
scroll1_needed      = true;
scroll2_needed      = true;
scroll3_needed      = true;
scroll4_needed      = true;
scroll5_needed      = true;
need_heal      = false;
can_rest      = true;
then this

Code: Select all

-- toggle cast needed for buff1
function buff1_timer()
  buff1_needed = true;
end

-- toggle cast needed for buff2
function buff2_timer()
  buff2_needed = true;
end

-- toggle cast needed for buff3
function buff3_timer()
  buff3_needed = true;
end

-- toggle cast needed for buff4
function buff4_timer()
  buff4_needed = true;
end

--toggle cast needed for buff5?
fucntion buff5_timer()
  buff5_needed = true;

-- toggle cast needed for scroll1
function scroll1_timer()
  scroll1_needed = true;
end

-- toggle cast needed for scroll2
function scroll2_timer()
  scroll2_needed = true;
end

-- toggle cast needed for scroll3
function scroll3_timer()
  scroll3_needed = true;
end

-- toggle cast needed for scroll4
function scroll4_timer()
  scroll4_needed = true;
end

-- toggle cast needed for scroll5?
function scroll5_timer()
  scroll5_needed = true;
end
then this:

Code: Select all


  registerTimer("update_vars", 100, update_vars);

  if( class == CLASS_CLERIC ) then         
   registerTimer("buff1_timer", buff1_duration, buff1_timer);
   registerTimer("buff2_timer", buff2_duration, buff2_timer); 
   registerTimer("buff3_timer", buff3_duration, buff3_timer);
   registerTimer("buff4_timer", buff4_duration, buff4_timer);
   registerTimer("buff5_timer", buff5_duration, buff5_timer);
  end
  
  registerTimer("scroll1_timer", scroll1_duration, scroll1_timer);
  registerTimer("scroll2_timer", scroll2_duration, scroll2_timer);
  registerTimer("scroll3_timer", scroll3_duration, scroll3_timer);
  registerTimer("scroll4_timer", scroll4_duration, scroll4_timer);
  registerTimer("scroll5_timer", scroll5_duration, scroll5_timer);
Then this:

Code: Select all

 if( buff_4 == 1 ) then 
         if( buff4_needed ) then
                keyboardHold(key_skill4);
                yrest(100);
                keyboardRelease(key_skill4);
           print(os.date("buff 4 casted   %X"))
                buff4_needed = false;
                yrest(2000);
           end
         end

	if( buff_5 == 1 ) then 
         if( buff5_needed ) then
                keyboardHold(key_skill5);
                yrest(100);
                keyboardRelease(key_skill5);
           print(os.date("buff 5 casted   %X"))
                buff5_needed = false;
                yrest(2000);
           end
         end
	
    end
    
    if( scroll_1 == 1 ) then
        if( scroll1_needed ) then
           keyboardHold(key_scroll1);
           yrest(100);
                keyboardRelease(key_scroll1);
          print(os.date("scroll 1 used   %X"))
             scroll1_needed = false;
             yrest(3200);
          end
   end
   
   if( scroll_2 == 1 ) then
        if( scroll2_needed ) then
           keyboardHold(key_scroll2);
           yrest(100);
                keyboardRelease(key_scroll2);
       print(os.date("scroll 2 used   %X"))
             scroll2_needed = false;
             yrest(3200);
          end
   end
   
    if( scroll_3 == 1 ) then
        if( scroll3_needed ) then
           keyboardHold(key_scroll3);
           yrest(100);
                keyboardRelease(key_scroll3);
       print(os.date("scroll 3 used   %X"))
             scroll3_needed = false;
             yrest(3200);
          end
   end
   
   if( scroll_4 == 1 ) then
        if( scroll4_needed ) then
           keyboardHold(key_scroll4);
           yrest(100);
                keyboardRelease(key_scroll4);
       print(os.date("scroll 4 used   %X"))
             scroll4_needed = false;
             yrest(3200);
          end
   end
    
    if( scroll_5 == 1 ) then
        if( scroll5_needed ) then
           keyboardHold(key_scroll5);
           yrest(100);
                keyboardRelease(key_scroll5);
       print(os.date("scroll 5 used   %X"))
             scroll5_needed = false;
             yrest(3200);
          end
   end
Well I changed all that and still did not work, my guess is the declaration of the VKs is wrong! What do you think? :oops:

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Fiesta bot

#14 Post by Administrator » Tue Feb 19, 2008 11:44 pm

You're right. Those virtual keys won't work. You need to emulate a key hold for those.

Code: Select all

  keyboardHold( key.VK_SHIFT );
  yrest(50);
  keyboardPress( key.VK_1 );
  yrest(50);
  keyboardRelease( key.VK_SHIFT );

charmingiv
Posts: 12
Joined: Mon Feb 18, 2008 4:52 pm

Re: Fiesta bot

#15 Post by charmingiv » Sat Feb 23, 2008 1:09 am

Sorry but the bot cant read the memory address of the hp and sp, even after I install the new patch or change the name of the files!

User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: Fiesta bot

#16 Post by 3cmSailorfuku » Sat Feb 23, 2008 7:39 am

charmingiv wrote:Sorry but the bot cant read the memory address of the hp and sp, even after I install the new patch or change the name of the files!
Are you sure that xtrap is gone and that Fiesta doens't have new offsets?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Fiesta bot

#17 Post by Administrator » Sat Feb 23, 2008 8:35 am

I forgot to mention... I just uploaded the new, fixed patch. Download it and extract it to your Fiesta folder, overwriting files if asked.

charmingiv
Posts: 12
Joined: Mon Feb 18, 2008 4:52 pm

Re: Fiesta bot

#18 Post by charmingiv » Sat Feb 23, 2008 9:42 pm

You did it again! LOL! you are great!

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Fiesta bot

#19 Post by Administrator » Sat Feb 23, 2008 9:59 pm

charmingiv wrote:You did it again! LOL! you are great!
That's why I'm your fearless leader. Well, mostly fearless. I don't like spiders. Nor any bugs, honestly.

charmingiv
Posts: 12
Joined: Mon Feb 18, 2008 4:52 pm

Re: Fiesta bot

#20 Post by charmingiv » Sat Feb 23, 2008 10:45 pm

I am doing a lua for my high lvl cleric and so far it attacks if there is a targert close, if not it will start the buffs and scrolls until it gets to scroll 4, it will look for target if it finds it it will kill it and the the lua stops telling me that :
micromacro\lib\lib,lua:64:bad argumentt #1 to 'create' (Lua Fucntion expected)
here is my code

Code: Select all

-- Credits:
--   A. M.  "MystikFox"
--          "Mangler"


version = getVersion();
if( version < 96 ) then
  printf("ERROR! You are using an old version of MicroMacro that is not compatable with this script.\n");
  printf("Please download a newer version from http://solarimpact.servegame.com\n");
  return;
end;

-------------------------
-- do NOT edit these!!
CLASS_KNIGHT    = 0;
CLASS_CLERIC    = 1;
CLASS_MAGE    	= 2;
CLASS_ARCHER    = 3;


-- EDIT THESE!
-------------------------
class           = CLASS_CLERIC; -- class determins the logic to take
HP_restamt      = 10;       -- HP to rest at   (not used for cleric's)
HP_potion       = 500;      -- Use a HP potion (or HEAL SKILL FOR CLERIC)
HP_stone        = 350;      -- Use a HP stone
SP_restamt      = 10;       -- SP to rest home at this SP value
SP_potion       = 300;      -- Use a SP potion
SP_stone        = 400;      -- Usa a SP stone


key_attack     = key.VK_1;    -- melee attack
key_attack2    = key.vK_SHIFT -- trip attack  -- normal melee attack
key_pickup     = key.VK_2;    -- pickup items

key_skill1     = key.VK_5;    -- offensive and defensive spells...   This is my bash
key_skill2     = key.VK_6;    -- check your class's fight function
key_skill3     = key.VK_7;    -- for documentation on what each skill
key_skill4     = key.VK_8;    -- will be used for
key_skill5     = key.VK_RIGHT -- buff right now for time healign           -- for more skills?

key_scroll1    = key.VK_9;    -- offensive and defensive spells...
key_scroll2    = key.VK_0;    -- check your class's fight function
key_scroll3    = key.VK_DASH; -- for documentation on what each skill
key_scroll4    = key.VK_EQUAL;-- will be used for
key_scroll5    = key.VK_ALT;
key_scroll6    = key.VK_U;

key_hppotion   = key.VK_3;     -- CLERICS: this is  my heal skill
key_hpstone    = key.VK_Q;     -- this is my HP stone
key_sppotion   = key.VK_4;     -- this is my SP potion
key_spstone    = key.VK_E;     -- this is my SP stone

-- NOTE: if SP_potion is higher than SP_restatm, you will use SP potions
-- instead of resting, unless you do not have any left. same goes for HP potions.
-- you will always use potions while fighting if the values fall below
-- the emergency amount.
-------------------------




-- Scroll settings  (read instructions below Buff settings first)
-------------------------
scroll1_duration    = 3500000;
scroll_1            = 1;
scroll2_duration    = 3500000;
scroll_2            = 1;
scroll3_duration    = 3500000;
scroll_3            = 1;
scroll4_duration    = 3500000;
scroll_4            = 1;
scroll5_duration    = 3500000;
scroll_5            = 1;
scroll6_duration    = 3500000;
scroll_6            = 1;

-------------------------


-- Buff settings (only for clerics)
-------------------------
buff1_duration       = 3500000;
buff_1               = 1;
buff2_duration       = 3500000;
buff_2               = 1;
buff3_duration       = 3500000;
buff_3               = 1;
buff4_duration       = 3500000;
buff_4               = 1;
buff5_duration       = 3500000;
buff_5               = 1;
-- NOTE:  set on 59 minutes
-- buff / scroll durations in msec    time = minutes x 60000
-- to de- activate non used buffs / scrolls replace "1" with "0"
-- to activate buff / scroll replace "0" with "1"
-- scrolls can be used too as buff
-------------------------






-- should not need to be changed, except for HP_addr/SP_addr when
-- a patch makes them no longer work
proc              = 0;
win               = 0;
HP_addr           = "00758FE7";
HPmax_addr        = "007590B8";
SP_addr           = "00758FEB";
SPmax_addr        = "007590BC";
restcheck_addr    = "01F66B04";
HP                = 10000;    -- default, this corrects itself (don't change it!)
HPmax             = HP;    -- default, this corrects itself (don't change it!)
SP                = 10000;   -- default, this corrects itself (don't change it!)
SPmax             = SP;         -- default, this corrects itself (don't change it!)

buff1_needed      = true;
buff2_needed      = true;
buff3_needed      = true;
buff4_needed      = true;
buff5_needed      = true;

scroll1_needed    = true;
scroll2_needed    = true;
scroll3_needed    = true;
scroll4_needed    = true;
scroll5_needed    = true;
scroll6_needed    = true;

need_heal         = false;
can_rest          = true;
-----------------------------------------------------
-----------------------------------------------------

function fight_timer()
  keyboardHold(key_attack);
  yrest(100);
  keyboardRelease(key_attack);

  yrest(100);
  
  keyboardHold(key_attack2);
  yrest(100);
  keyboardRelease(ke_attack2);
end


-----------------------------------------------------
-- fighting functions
-----------------------------------------------------

-----------------------------------------------------
-- FIGHTING AS A KNIGHT
-----------------------------------------------------

function knight_fight()
  -- skill1 : offensive skill
  -- skill2 : offensive skill
  -- skill3 : offensive skill
  -- skill4 : offensive skill

  keyboardHold(key_attack);
  yrest(50);
  keyboardRelease(key_attack);

  registerTimer("fight_timer", 3000, fight_timer);
  while(have_target()) do
    if( HP < HP_potion) then hp_potion(); end
    if( HP < HP_stone) then hp_stone(); end
    if( SP < SP_potion) then sp_potion(); end
    if( SP < SP_stone) then hp_stone(); end

    keyboardHold(key_attack);
    yrest(50);
    keyboardRelease(key_attack);

    if( math.random(100) > 92 ) then
      if( math.random(100) >= 50 ) then
        keyboardHold(key_skill1);
        yrest(50);
        keyboardRelease(key_skill1);
      else
        keyboardHold(key_skill2);
        yrest(50);
        keyboardRelease(key_skill2);
      end
    end

    yrest(50);
  end
  unregisterTimer("fight_timer");

  for i = 0,8 do
    pickup();
    yrest(50);
  end

  can_rest = false;
  registerTimer("can_rest_timer", 3000, can_rest_timer);

end

----------------------------------------------------------
-- fight function for cleric
----------------------------------------------------------

function cleric_fight()
  -- skill1 : buff 1
  -- skill2 : buff 2
  -- skill3 : buff 3
  -- skill4 : buff 4

  keyboardHold(key_attack);
  yrest(100);
  keyboardRelease(key_attack);
  
  yrest(100);
	
  keyboardHold(key_attack2);
  yrest(100);
  keyboarRelease(key_attack2);

  registerTimer("fight_timer", 3000, fight_timer);
  while(have_target()) do
    if( HP < HP_potion) then hp_potion(); end
    if( HP < HP_stone) then hp_stone(); end
    if( SP < SP_potion) then sp_potion(); end
    if( SP < SP_stone) then sp_stone(); end

    yrest(100);
  end
  unregisterTimer("fight_timer");

  for i = 0,8 do
    pickup();
    yrest(50);
  end

  can_rest = false;
  registerTimer("can_rest_timer", 3000, can_rest_timer);
end

--------------------------------------------------------
-- FIGTHING AS A MAGE
--------------------------------------------------------

function mage_fight()
  -- skill1 : offensive spell
  -- skill2 : offensive spell
  -- skill3 : offensive spell
  -- skill4 : offensive spell

  while(have_target()) do
    if( HP < HP_potion) then hp_potion(); end
    if( HP < HP_stone) then hp_stone(); end
    if( SP < SP_potion) then sp_potion(); end
    if( SP < SP_stone) then hp_stone(); end

    keyboardHold(key_skill1);
    yrest(200);
    keyboardRelease(key_skill1);

    yrest(100);

    keyboardHold(key_skill2);
    yrest(200);
    keyboardRelease(key_skill2);

    yrest(100);

    keyboardHold(key_skill3);
    yrest(200);
    keyboardRelease(key_skill3);

    yrest(100);

    keyboardHold(key_skill4);
    yrest(200);
    keyboardRelease(key_skill4);

    yrest(100);

    keyboardHold(key_skill5);
    yrest(200);
    keyboardRelease(key_skill5);

    yrest(100);
  end

  for i = 0,8 do
    pickup();
    yrest(50);
  end

  can_rest = false;
  registerTimer("can_rest_timer", 3000, can_rest_timer);
end

--------------------------------------------------------
-- FIGHT AS AN ARCHER
--------------------------------------------------------

function archer_fight()
  -- skill1 : DOT / offensive skill (entry attack)
  -- skill2 : DOT / offensive skill (entry attack)
  -- skill3 : offensive skill
  -- skill4 : offensive skill

  -- entry skill
  if( math.random(100) >= 50 ) then
    keyboardHold(key_skill1);
    yrest(50);
    keyboardRelease(key_skill1);
  else
    keyboardHold(key_skill2);
    yrest(50);
    keyboardRelease(key_skill2);
  end
    yrest(500);

  keyboardHold(key_attack);
  yrest(50);
  keyboardRelease(key_attack);

  registerTimer("fight_timer", 3000, fight_timer);
  while(have_target()) do
    if( HP < HP_potion) then hp_potion(); end
    if( HP < HP_stone) then hp_stone(); end
    if( SP < SP_potion) then sp_potion(); end
    if( SP < SP_stone) then hp_stone(); end

    --keyboardHold(key_attack);
    --yrest(50);
    --keyboardRelease(key_attack);

    if( math.random(100) > 80 ) then
      if( math.random(100) >= 50 ) then
        keyboardHold(key_skill2);
        yrest(50);
        keyboardRelease(key_skill2);
      else
        keyboardHold(key_skill3);
        yrest(50);
        keyboardRelease(key_skill3);
      end
      yrest(200);
    end

    yrest(200);
  end
  unregisterTimer("fight_timer");

  for i = 0,8 do
    pickup();
    yrest(100);
  end

  can_rest = false;
  registerTimer("can_rest_timer", 3000, can_rest_timer);
end

-----------------------------------------------------
-----------------------------------------------------
-----------------------------------------------------
-----------------------------------------------------

-----------------------------------------------------
-- toggle cast needed for buff1
-----------------------------------------------------

function buff1_timer()
  buff1_needed = true;
end

-----------------------------------------------------
-- toggle cast needed for buff2
-----------------------------------------------------

function buff2_timer()
  buff2_needed = true;
end

----------------------------------------------------
-- toggle cast needed for buff3
----------------------------------------------------

function buff3_timer()
  buff3_needed = true;
end

----------------------------------------------------
-- toggle cast needed for buff4
----------------------------------------------------

function buff4_timer()
  buff4_needed = true;
end

----------------------------------------------------
-- toggle cast needed for buff5
----------------------------------------------------

function buff5_timer()
  buff5_needed = true;
end

----------------------------------------------------
-- toggle cast needed for scroll1
----------------------------------------------------

function scroll1_timer()
  scroll1_needed = true;
end

----------------------------------------------------
-- toggle cast needed for scroll2
----------------------------------------------------

function scroll2_timer()
  scroll2_needed = true;
end

----------------------------------------------------
-- toggle cast needed for scroll3
----------------------------------------------------

function scroll3_timer()
  scroll3_needed = true;
end

----------------------------------------------------
-- toggle cast needed for scroll4
----------------------------------------------------

function scroll4_timer()
  scroll4_needed = true;
end

----------------------------------------------------
-- toggle cast needed for scroll5
----------------------------------------------------

function scroll5_timer()
  scroll5_needed = true;
end

----------------------------------------------------
-- toggle cast needed for scroll6
----------------------------------------------------

function scroll6_timer()
  scroll6_needed = true;
end


-------------------------------------------------------------------------
-- you have died!? oh noOOOes!
-------------------------------------------------------------------------

function death_return()
  keyboardPress(key.VK_SNAPSHOT);
  print(os.date("Alguien te mato.   %X"))
  print("A screen capture has been taken. Open MS Paint and paste it.");
  stopPE(); -- this turns the macro off!
  coroutine.yield(); -- yield to make sure the protected environment stops
end

--------------------------------------------------------------------------
-- moves forward a bit...makes you seem less bot-like.
-- allows you to cover more ground
--------------------------------------------------------------------------

function move_forward()
  keyboardHold(key.VK_W);
  if( math.random(100) >= 80 )
    then keyboardHold(key.VK_A);
  else if( math.random(100) >= 80 )
    then keyboardHold(key.VK_D); 
  else if( math.random(100) >= 80 )
    then keyboardHold(key.VK_SPACE);end
  end

  yrest( math.random(2000) );

  keyboardRelease(key.VK_W);
  keyboardRelease(key.VK_A);
  keyboardRelease(key.VK_D);
  keyboardRelease(key.VK_SPACE);
end

--------------------------------------------------------------------------
-- rotate camera
--------------------------------------------------------------------------

function rotate_cam()
  wx,wy = windowRect(win);

  mouseSet(wx+512, wy+384);
  yrest(100);
  mouseRHold();
  yrest(100);
  mouseSet(wx+514, wy+384);
  yrest(100);
  mouseRRelease();
  yrest(100);
end

--------------------------------------------------------------------------
-- pickup nearby items
--------------------------------------------------------------------------

function pickup()
  keyboardHold(key_pickup);
  yrest(50);
  keyboardRelease(key_pickup);
  yrest(50);
end

--------------------------------------------------------------------------
-- selects a nearby monster
--------------------------------------------------------------------------

function target_monster()
  keyboardHold(key.VK_TAB);
  yrest(50);
  keyboardRelease(key.VK_TAB);
end

-------------------------------------------------------------------------
-- checks if you have a target
-------------------------------------------------------------------------

function have_target()
  local r,g,b = getPixel(hdc, 540, 1);

  -- check for the gray in the monster's HP window
  if( r >= 229 and r <= 240 and g >= 245 and g <= 255 and b >= 250 ) then
    return true;
  else
    return false;
  end
end

-------------------------------------------------------------------------
-- updates variables from client
-------------------------------------------------------------------------

function update_vars()
  HP    = memoryReadInt(proc, HP_addr);
  HPmax = memoryReadInt(proc, HPmax_addr);
  SP    = memoryReadInt(proc, SP_addr);
  SPmax = memoryReadInt(proc, SPmax_addr);
end

------------------------------------------------------------------------
-- toggle can_heal to true, disable timer
------------------------------------------------------------------------

function can_rest_timer()
  unregisterTimer("can_rest_timer");
  can_rest = true;
end

-----------------------------------------------------------------------
-- rest untill healed
-----------------------------------------------------------------------

function rest_heal()
  if( can_rest == false ) then return; end

  printf("Entering rest state\t%s\n", os.date("%X"));

  keyboardHold(key.VK_HOME);
  yrest(500);
  keyboardRelease(key.VK_HOME);

  need_heal = true;
  last_hp = HP;
  while( need_heal ) do
    yrest(100);

    if( HP == HPmax and SP == SPmax ) then
      need_heal = false;
    end;

    if (HP < last_hp)  then
      print("Under attack! Exiting rest.");
      can_rest = false;
      registerTimer("can_rest_timer", 3000, can_rest_timer);
      break;
    else
      last_hp = HP;
    end
  end

  --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  -- BROKEN!! IGNORE THIS!
  -- while( 1 ) do
  --  keyboardHold(key.VK_HOME);
  --  yrest(500);
  --  keyboardRelease(key.VK_HOME);
  --
  --  yrest(500);
  --  local val = memoryReadByte(proc, restcheck_addr);
  --  printf("Rest check val: %d\n", val);
  --
  --  if( val ~= 1 ) then -- 1 = resting, 2 = standing
  --    break; end;       -- so if not resting, exit
  --  end
  --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  printf("Exiting rest state\t%s\n", os.date("%X"));
end

------------------------------------------------------------------
-- use a hp potion!
------------------------------------------------------------------

function hp_potion()
  keyboardHold(key_hppotion);
  yrest(100);
  keyboardRelease(key_hppotion);

  yrest(500);
end

------------------------------------------------------------------
-- use a hp stone!
------------------------------------------------------------------

function hp_stone()
  keyboardHold(key_hpstone);
  yrest(100);
  keyboardRelease(key_hpstone);
  print("HP stone used.")

  yrest(500);
end

------------------------------------------------------------------
-- use a sp potion!
------------------------------------------------------------------

function sp_potion()
  keyboardHold(key_sppotion);
  yrest(100);
  keyboardRelease(key_sppotion);

  yrest(500);
end

------------------------------------------------------------------
-- use a sp stone!
------------------------------------------------------------------

function sp_stone()
  keyboardHold(key_spstone);
  yrest(100);
  keyboardRelease(key_spstone);
  print("SP stone used.")

  yrest(500);
end




------------------------------------------------------------------
-- the configuration of the window
------------------------------------------------------------------

function main()
  win = findWindow("FiestaOnline");
  local wx,wy,ww,wh = windowRect(win);

  if( ww ~= 1024 or wh ~= 768 ) then
    printf("Error! You must run Fiesta in 1024*768 resolution.\n");
    return;
  end;

  if( win == 0 ) then printf("Error! Could not locate Fiesta window!\n"); return; end;
  hdc = openDC(win);
  proc = openProcess( findProcess("FiestaOnline") );
  attach(win);

  registerTimer("update_vars", 100, update_vars);

-------------------------------------------------------------------
--CLeric logic only
-------------------------------------------------------------------

  if( class == CLASS_CLERIC ) then         
   registerTimer("buff1_timer", buff1_duration, buff1_timer);
   registerTimer("buff2_timer", buff2_duration, buff2_timer); 
   registerTimer("buff3_timer", buff3_duration, buff3_timer);
   registerTimer("buff4_timer", buff4_duration, buff4_timer);
   registerTimer("buff5_timer", buff5_duration, buff5_timer);
  end
  
  registerTimer("scroll1_timer", scroll1_duration, scroll1_timer);
  registerTimer("scroll2_timer", scroll2_duration, scroll2_timer);
  registerTimer("scroll3_timer", scroll3_duration, scroll3_timer);
  registerTimer("scroll4_timer", scroll4_duration, scroll4_timer);
  registerTimer("scroll5_timer", scroll5_duration, scroll5_timer);
  registerTimer("scroll6_timer", scroll6_duration, scroll6_timer);
  end
 
  while( 1 ) do
    if( HP == 0 ) then death_return(); end
    if( HP < HP_potion ) then hp_potion(); end
    if( HP < HP_stone )  then hp_stone(); end
    if( SP < SP_potion ) then sp_potion(); end
    if( SP < SP_stone )  then sp_stone(); end
    if( HP < HP_restamt and can_rest == true ) then rest_heal(); end
    if( SP < SP_restamt and can_rest == true ) then rest_heal(); end

    yrest(100);

    target_monster();
    yrest(200);
    if( have_target() ) then
      can_rest = false; -- prevent resting during battle
                        -- for the few that have this bug
      if( class == CLASS_KNIGHT ) then knight_fight(); end
      if( class == CLASS_CLERIC ) then cleric_fight(); end
      if( class == CLASS_MAGE   ) then mage_fight();   end
      if( class == CLASS_ARCHER ) then archer_fight(); end
      can_rest = true;
    else
    
-----------------------------------------------------------------------
-- cleric only logic
-----------------------------------------------------------------------

      if( class == CLASS_CLERIC ) then
          if( buff_1 == 1 ) then 
           if( buff1_needed ) then
                keyboardHold(key_skill1);
              yrest(100);
                    keyboardRelease(key_skill1);
          print(os.date("buff 1 casted   %X"))
                buff1_needed = false;
                yrest(2000);
           end
          end

        if( buff_2 == 1 ) then 
         if( buff2_needed ) then
                keyboardHold(key_skill2);
                yrest(100);
                keyboardRelease(key_skill2);
                print(os.date("buff 2 casted   %X"))
                buff2_needed = false;
                yrest(2000);
           end
          end
        
        if( buff_3 == 1 ) then 
         if( buff3_needed ) then
               keyboardHold(key_skill3);
                yrest(100);
                keyboardRelease(key_skill3);
           print(os.date("buff 3 casted   %X"))
                buff3_needed = false;
                yrest(2000);
           end
          end

        if( buff_4 == 1 ) then 
         if( buff4_needed ) then
                keyboardHold(key_skill4);
                yrest(100);
                keyboardRelease(key_skill4);
           print(os.date("buff 4 casted   %X"))
                buff4_needed = false;
                yrest(2000);
           end
         end

	if( buff_5 == 1 ) then 
         if( buff5_needed ) then
                keyboardHold(key_skill5);
                yrest(100);
                keyboardRelease(key_skill5);
           print(os.date("buff 5 casted   %X"))
                buff5_needed = false;
                yrest(2000);
           end
	end
    end

    if( scroll_1 == 1 ) then
        if( scroll1_needed ) then
           keyboardHold(key_scroll1);
           yrest(100);
                keyboardRelease(key_scroll1);
          print(os.date("scroll 1 used   %X"))
             scroll1_needed = false;
             yrest(4000);
          end
   end
   
   if( scroll_2 == 1 ) then
        if( scroll2_needed ) then
           keyboardHold(key_scroll2);
           yrest(100);
                keyboardRelease(key_scroll2);
       print(os.date("scroll 2 used   %X"))
             scroll2_needed = false;
             yrest(4000);
          end
   end
   
    if( scroll_3 == 1 ) then
        if( scroll3_needed ) then
           keyboardHold(key_scroll3);
           yrest(100);
                keyboardRelease(key_scroll3);
       print(os.date("scroll 3 used   %X"))
             scroll3_needed = false;
             yrest(4000);
          end
   end
   
   if( scroll_4 == 1 ) then
        if( scroll4_needed ) then
           keyboardHold(key_scroll4);
           yrest(100);
                keyboardRelease(key_scroll4);
       print(os.date("scroll 4 used   %X"))
             scroll4_needed = false;
             yrest(4000);
          end
   end
    
   if( scroll_5 == 1 ) then
        if( scroll5_needed ) then
           keyboardHold(key_scroll5);
           yrest(100);
                keyboardRelease(key_scroll5);
       print(os.date("scroll 5 used   %X"))
             scroll5_needed = false;
             yrest(4000);
          end
   end

   if( scroll_6 == 1 ) then
        if( scroll6_needed ) then
           keyboardHold(key_scroll6);
           yrest(100);
                keyboardRelease(key_scroll6);
       print(os.date("scroll 6 used   %X"))
             scroll5_needed = false;
             yrest(4000);
          end
   end


--------------------------------------------------------------------
-- Rotate the camera
--------------------------------------------------------------------

      rotate_cam();
      if( math.random(100) > 90 ) then
        move_forward(); end
    end

    pickup();
  end

  detach();
  closeProcess(proc);
end

startMacro(main);
do u think I should start the code again from the normal lua?

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests