hunt and sell script

Got a cool macro idea? Wanna request a macro? Here is the place for you!

Moderator: MacroQuest Developers

Riven
a lesser mummy
a lesser mummy
Posts: 68
Joined: Sat Jan 31, 2004 12:14 pm
Location: Missouri

hunt and sell script

Post by Riven » Mon Feb 09, 2004 6:13 pm

First, i think i might i have posted in the wrong forum the first time, thats why im reposting here.

I have modified a few scripts to make my self a hunter script for my druid.
I would like some help anding the part where it can sell the goods it loots.
Im still in the forums now looking for scripts that just sells.

I have found one that sells ONE item. thats it! plus its a macro.
I think i know how to do it but all my trials have failed.

I know i have to use a event watcher to tell the script that its bags are full.
Then run to a merchant in the zone and sell
Once it gets to the merchant it opens the merchant window. finds all items in the loot array and sells it.

Once all items of the lootarray are sold it goes back to hunting.

heres my script i want to incorprate the sell part.


Code: Select all

| Rainman.mac 
| v1.0 
| Hunt script with loot for new loot parser. 
| As always much of this script is inspired or taken directly from 
| pieces of macro's found at macroquest2.com's macro depot 
| Thank you to all the people who have donated their scripts which 
| made this possible.  And thank you to the MQ developers. 
| 
| Edit  /varset MainArray(1,0) "silk" and /varset MainArray(1,1) "skin" 
| Also edit /varset MainArray(2,0) "widow" and /varset MainArray(2,1) "wolf" 
| You can also make these arrays bigger.  If you want to search for 
| wolfs, widows and orcs you would have this 
| /varset MainArray(2,0) "widow" 
| /varset MainArray(2,1) "wolf" 
| /varset MainArray(2,2) "orc" 
| /varset MobArraySize 3 
| This picks a random number based on MobArraySize to pick which 
| Type of mob it will chose from the array. 
| 
| What type of loot you want can be expanded in a similar way to 
| the mobs you want to hunt.  Just add your array entry and update 
| /varset LootTotal 2 to be /varset LootTotal [# of loot entries] 
| 
| Another thing, for the code to actualy destroy items you don't want to 
| keep you must have fast item destroy turned on in the game.  I would 
| test the script for a while on your machine before doing this.  It would 
| really suck if it picks up your Eyepatch of Plunder and destroies it 
| due to a bug. 
|
| If you dont like the spell locs the script mems just run down to the bottom 
| of the script and change the loc.






#turbo 90 
#include SpellCast.inc 
#define HEAL "Nature's Infusion"      | Spell to heal yourself with. 
#define ROOT "Engorging Roots"        | Spell you want to Root with. 
#define NUKE "Firestrike"             | Spell you want to Nuke with. 
#define SNARE "Ensnare"               | Spell you want to Snare with. 
#define EVAC "Egress"                 | Spell to use to port out when your HP gets too low. 
#define SOW "Spirit of Wolf"          | Spell u use to up the speed of your legs.
#define DS  "Brackencoat"             | Spell that u have for a self damage shield.
#define SKIN "Protection of the Nine" | Spell to give u hps.

Sub Main 
   /declare MobPriority global 
   /declare MobToHunt global 
   /declare MainArray array2 
   /declare MyXLOC global 
   /declare MyYLOC global 
   /declare KSRadius global 
   /declare NotSee global 
   /declare TooFar global 
   /declare MyTarget global 
   /declare TargetDead global 
   /declare HasTarget global 
   /declare ObstCount global 
   /declare LootSlot global 
   /declare CheckLoot global 
   /declare LootTotal global 
   /declare MobArraySize global 
   /declare RangeMax global 
   /declare RangeMin global 
   /declare FastRange global 
   /press esc 
   /press esc 
   /press esc 
   /press esc 
   /press alt 
   /press shift 
   /press ctrl 
   /varset RangeMax 12 
   /varset RangeMin 10 
   /varset FastRange 14 
   /varset LootSlot 0 
   /varset CheckLoot 0 



| Add as many of these  as you want but make sure you 
| increase LootTotal 
   /varset MainArray(1,0) "silk" 
   /varset MainArray(1,1) "quality" 
   /varset MainArray(1,2) "egg"
   /varset MainArray(1,3) "bone"




| Add as many of these as you want but make sure you 
|  increase MobArraySize
   /varset MainArray(2,0) "spider" 
   /varset MainArray(2,1) "wolf" 
   /varset MainArray(2,2) "bear"
   /varset MainArray(2,3) "kodiak"
   /varset MainArray(2,4) "lion"
   /varset MainArray(2,5) "cat"
   /varset MainArray(2,6) "snake"
   /varset MainArray(2,7) "skeleton"



| Make sure u udate this part of the script if u add items to the moblist or the itemloot list. 
   /varset LootTotal 4 
   /varset KSRadius 60 
   /varset HasTarget 0 
   /varset ObstCount 0 
   /varset MobArraySize 8 


|Starting the script here

   :Start
   /call CheckHP 
   /call CheckMana 
   /call SetupSpells 
   /call Buffchecks
   /call GetTarget 
   /if @HasTarget=="1" /call MoveToMob 
   /if @HasTarget=="1" /call CombatSub 
   /if @HasTarget=="1" /call MoveToMob 
   /if @HasTarget=="1" /call LootMob 
   /call ResetSub 
   /goto :Start 
/return 



sub GetTarget 
   /varset MobPriority 0 
   :Aquire 
   /target nopcnear @KSRadius npc "@MainArray(2,@MobPriority)" 
   /target nopcnear @KSRadius npc "@MainArray(2,$rand(@MobArraySize))" 
   /varset MyTarget $target(id) 
   /varset TargetDead 0 
   /if n $target(id)==0 {
   /varadd MobPriority 1 
   /if n @MobPriority>=@MobArraySize /varset MobPriority 0 
   /goto :Aquire 
   } 
   /if $target()=="False" /goto :Aquire 
   /varset HasTarget 1 
   /varset MobToHunt $target(name) 
/return 



Sub MoveToMob 
   /face fast 
   /if n $target(distance)>=@FastRange /call Fastmove 
   /if n $target(distance)>@RangeMax { 
      /press up 
   } 
   /if n $target(distance)<@RangeMin { 
      /press down 
   } 
/return 

Sub Fastmove 
   /varset MyXLOC $char(x) 
   /varset MyYLOC $char(y) 
   /varset ObstCount 0 
   :fastmoveloop 
   /if $target()=="FALSE" { 
      /sendkey up up 
      /if $combat=="TRUE" { 
         /attack off 
         /return 
      } 
   } 
   /face fast 
   /if n $target(distance)>@FastRange { 
      /sendkey down up 
   } 
   /if n $target(distance)<=@FastRange { 
      /sendkey up up 
      /return 
   } 
   /varadd ObstCount 1 
   /if n @ObstCount>=3 { 
      /call CheckObst 
   } 
   /goto :fastmoveloop 
/return 

sub CombatSub 
   /if $target()=="FALSE" { 
      /varset HasTarget 0 
      /return 
   } 
   /delay 1s
   /echo Rooting:  $target(name,clean) 
   /call cast "ROOT" 
   /delay 3s
  /if ("$target()"=="TRUE" || n $target(hp,pct)>=1) /call dead
   /sendkey up up 
   /delay 1s 
   /target corpse 
   /lootn never 
   /delay 2s 
/return 

Sub dead
:nuke
    /if ("$target()"=="TRUE" || n $target(hp,pct)>=1)  
      /face nolook
      /sendkey down down 
      /delay 1s 
      /sendkey up down 
      /delay 1s 
      /echo The dam $target(name,clean) is not dead yet!
      /delay 1s 
      /echo Nuking:  $target(name,clean) 
        /call cast "NUKE" 
        /delay 3s 
   /if "$target()"=="TRUE" /goto :nuke  
/return 



sub LootMob 
   /loot 
   /delay 1s 
   :lootloop 
   /if n @LootSlot>=9 /goto :doneloot 
   /click left corpse @LootSlot 
   /delay 1s 
   /if "$cursor()"!="TRUE" /goto :doneloot 
   :lootChecker 
   /if "$cursor(name)"~~"@MainArray(1,@CheckLoot)" { 
      /delay 1s  
      /autoinventory 
      /delay 1s
      /varadd LootSlot 1 
      /goto :lootloop 
   } 
   /varadd CheckLoot 1 
   /if "$cursor()"=="TRUE" { 
      /if n @CheckLoot<@LootTotal /goto :lootchecker 
   } 
   /if "$cursor()"=="TRUE" { 
       /delay 1s
      /destroy 
       
   } 
   /varadd LootSlot 1 
   /varset CheckLoot 0 
   /goto :lootloop 
   :doneloot 
   /lootn always 
   /varset LootSlot 0 
/return 

sub ResetSub 
   /sendkey up up 
   /press esc 
   /press esc 
   /press esc 
   /press esc 
   /press alt 
   /press shift 
   /press ctrl 
   /varset CheckLoot 0 
   /varset HasTarget 0 
   /varset ObstCount 0 
   /delay 1s 
/return 

sub CheckObst 
   /if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) /call HitObst 5 
   /varset MyXLOC $char(x) 
   /varset MyYLOC $char(y) 
   /varset ObstCount 0 
/return 

sub HitObst 
   /sendkey up up 
   /sendkey down down 
   /if n $rand(99)>50 { 
      /delay 3s 
      /sendkey up down 
      /sendkey down Right 
      /delay @Param0 
      /sendkey up Right 
      /sendkey down up 
      /delay 3s 
      /sendkey up up 
   } else { 
      /delay 3s 
      /sendkey up down 
      /sendkey down left 
      /delay @Param0 
      /sendkey up left 
      /sendkey down up 
      /delay 3s 
      /sendkey up up        
   } 
   /sendkey up down 
   /sendkey up Right 
   /sendkey up Left 
   /sendkey down up 
/return 

Sub CheckHP 
| Check our current Hit Points and Port out if below 20%. 
   /if n $char(hp,pct)<=20 { 
      /echo HEY!!!  I'm DIEING!!!  Time to bug out!!!  [HP: $char(hp,pct)%] 
      /call cast "EVAC" 
   } 
| Check our current Hit Points and if below 60%, Heal until we reach 90%. 
   /if n $char(hp,pct)<=60 { 
      /target myself 
      :HealLoop 
         /echo LOW HEALTH!!!  Healing to 90%...  [HP: $char(hp,pct)%] 
         /call cast "HEAL" 
         /if n $char(hp,pct)<=90 /goto :HealLoop 
   } 
/return 


Sub CheckMana 
| Check our current Mana and Port out if below 20%. 
   /if n $char(mana,pct)<=30 { 
      /echo HEY!!!  I'm almost OOM!!!  Time to bug out!!!  [MANA: $char(mana,pct)%] 
      /call cast "EVAC" 
   } 
| Check our current Mana and if below 40%, Meditate until we reach 90%. 
   /if n $char(mana,pct)<=40 { 
      /echo LOW MANA!!!  Medding to 90%...  [MANA: $char(mana,pct)%] 
      :MedLoop 
         /if "$char(state)"!="SIT" /sit 
         /delay 15s 
         /if n $char(mana,pct)<=90 /goto :MedLoop 
   } 
/return 


Sub Buffchecks
| Checks your buff and updates if u dont have it.

  /if n $char(buff,"SOW")==0 {
   /target myself
   /call cast "SOW"
   /delay 3s
  }
  /if n $char(buff,"DS")==0 {
   /target myself
   /call cast "DS"
   /delay 3s
  }
  /if n $char(buff,"SKIN")==0 {
   /target myself
   /call cast "SKIN"
   /delay 3s 
  }
/return

Sub SetupSpells 
| Memorize our spells if they are not already memorized. 
| You can put these in any slot you want by changing the # after /memspell. 
   /if n $char(gem,"HEAL")==0 { 
      /memspell 8 "HEAL" 
      /delay 5s 
   } 
   /if n $char(gem,"ROOT")==0 { 
      /memspell 1 "ROOT" 
      /delay 5s 
   } 
   /if n $char(gem,"NUKE")==0 { 
      /memspell 3 "NUKE" 
      /delay 5s 
   } 
   /if n $char(gem,"SNARE")==0 { 
      /memspell 2 "SNARE" 
      /delay 5s 
   }   
  /if n $char(gem,"SOW")==0 { 
      /memspell 7 "SOW" 
      /delay 5s 
   } 
  /if n $char(gem,"SKIN")==0 {
      /memspell 4 "SKIN"
      /delay 5s
   }
  /if n $char(gem,"DS")==0 {
      /memspell 5 "DS"
      /delay 5s
   } 
   /if n $char(gem,"EVAC")==0 {
      /memspell 6 "EVAC"
      /delay 5s
   } 
/return 



Sub BackstabIt 
   /if n $char(ability,"Backstab")!=-2 { 
      /if $target()=="TRUE" { 
         /face fast 
         /doability "Backstab" 
      } 
   } 
/return

that is my hunting script.

i have loctated 2 more scripts that sells and looks for a merchant.


Code: Select all

| - merch_check.mac - 
| By: Onezero 
| Version: 0.0.2 
| 
| This macro goes through the list of merchants in the zone and checks 
| them all for a user-specified item.  If Search = 1 the macro will 
| check all merchants in the zone once, then end.  If Search = 0 the 
| macro will only check the nearest merchant. User can also specify a 
| limit to tell the macro when to stop buying the item. 
| 
| NOTE: This macro does NOT work well right now unless the zone you are 
|   in has very few buildings/obstructions.  If anyone could fix that 
|   part up for me I would be most grateful, until then, it sucks :) 
| 
| Usage: /mac merch_check.mac <item name> <search (Default=1)> <limit> 
| 
| Example: /mac merch_check.mac "Blue Diamond" 1 5 
|          (Goes to all merchants and buys up to 5 Blue Diamond from each) 
| 
|          /mac merch_check.mac "Water Flask" 0 20 
|          (Goes to nearest merchant and buys 20 Water Flask) 


#turbo 

#event nocash "You cannot afford " 

Sub Main(ItemName,Search,Limit) 

    /zapvars 

    /declare count local 
    /varset count 0 

    /declare counter local 

    /declare curID local 
    /varset curID 0 

    /declare retry local 
    /varset retry -1 

    /declare ids array2 

    /declare idcount local 
    /varset idcount 0 

    /echo Looking for @ItemName 
    /if $defined(ItemName)==FALSE /endmacro 
    /if $defined(Search)==FALSE { 
        /echo Searching all merchants. 
    } else { 
        /if n @Search==1 /echo Searching all merchants. 
        /if n @Search!=1 /echo Only checking nearest merchant. 
    } 
    /if $defined(Limit)==TRUE { 
        /echo Buy Limit: @Limit 
    } else { 
        /echo No buy limit defined! 
    } 

    :MainLoop 

    /if n @retry>=@idcount { 
        /echo All merchants have been searched.  Ending macro. 
        /endmacro 
    } 


    /if n @Search==1 { 
        /if n @curID==0 { 
            /varset curID $searchspawn(npc,class:merchant) 
            /varadd idcount 1 
        } else { 
            /varset curID $searchspawn(npc,id:@curID,class:merchant,next) 
            /varadd idcount 1 
        } 
    } else { 
        /target npc class merchant 
        /varset curID $target(id) 
    } 

    /echo Heading to $spawn(@curID,name,clean) 

    /for counter 0 to @idcount 
        /if n @curID==@ids(0,@counter) { 
            /varadd retry 1 
            /if n @Search==1 { 
                /goto :MainLoop 
            } else { 
                /goto :MacDone 
            } 
        } 
    /next counter 

    /varset ids(0,@idcount) @curID 

    /target npc id @curID 

    /call movetoloc $target(y),$target(x) 

    /click right target 
    /delay 15 

    /if $merchant(open)==FALSE { 
        /echo Could not open merchant window for $spawn(@curID,name,clean). 
        /if n @Search==1 { 
            /echo Moving on... 
            /goto :MainLoop 
        } else { 
            /goto :MacDone 
        } 
    } 

    /if $merchant(has,"@ItemName")==FALSE { 
        /echo Couldn't find @ItemName on $spawn(@curID,name,clean). 
        /click left merchant done 

        /if n @Search==1 { 
            /echo Moving on... 
            /goto :MainLoop 
        } else { 
            /goto :MacDone 
        } 
    } else { 
        :BuyLoop 

        /doevents 

        /if $merchant(has,"@ItemName")==TRUE { 

            /selectitem "@ItemName" merchant 

            /if $defined(Limit)==TRUE { 
                /if n @count<@Limit { 
                    /call BuyItem @ItemName @Limit 
                    /varadd count 1 
                    /goto :BuyLoop 
                } 
            } else { 
                /call BuyItem @ItemName @Limit 
                /varadd count 1 
                /goto :BuyLoop 
            } 
        } 
        /click left merchant done 

        /echo Bought $int(@count) @ItemName from $spawn(@curID,name,clean). 

        /if n @Search==1 { 
            /echo Moving on... 
            /goto :MainLoop 
        } else { 
            /goto :MacDone 
        } 
    } 
    :MacDone 

    /sendkey up ctrl 
    /sendkey up shift 
    /sendkey up alt 
/return 

Sub BuyItem(ItemName,Limit) 
    /sendkey down ctrl 

    /click left merchant buy 
    /delay 1s 

    /sendkey up ctrl 
/return 

Sub Event_nocash 
    /echo Not enough money.  Ending macro. 
    /click left merchant done 
    /endmacro 
/return 

Sub movetoloc(xloc,yloc) 
  /declare MyXLOC local 
  /declare MyYLOC local 
  /declare ObstCount local 

  /varset MyXLOC $char(x) 
  /varset MyYLOC $char(y) 
  /varset ObstCount 0 
  :locloop 
  /face nolook loc @xloc 
  /if "@yloc"=="u" /Press u 
  /call AutoRun 1 
  /varadd ObstCount 1 
  /if n @ObstCount>=3 { 
    /if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) { 
        /sendkey up up 
        /sendkey down down 
        /if n $rand(99)>50 { 
          /delay 1s 
          /sendkey up down 
          /sendkey down Right 
          /delay 5 
          /sendkey up Right 
          /sendkey down up 
          /delay 1s 
          /sendkey up up 
        } else { 
          /delay 1s 
          /sendkey up down 
          /sendkey down left 
          /delay 5 
          /sendkey up left 
          /sendkey down up 
          /delay 1s 
          /sendkey up up 
        } 

       /sendkey up down 
       /sendkey up Right 
       /sendkey up Left 
     } 
     /varset MyXLOC $char(x) 
     /varset MyYLOC $char(y) 
     /varset ObstCount 0 
    } 

  /if n $distance(@xloc)>10 /goto :locloop 

  } 
  /call autorun 0 
/return 

Sub AutoRun 
   /if @Param0==1 /sendkey down up 
   /if @Param0==0 /sendkey up up 
/return




Code: Select all

| - SellItem.mac - 
| 
| Usage: /macro SellItem "Bottle of Milk" 
| 11/21/03 

Sub Main 
   /declare OldMoney local 
   /declare NewMoney local 

   /autoinv 
   /sendkey down shift 

   :Finding 
      /if n $count("@Param0")==0 /goto :Done 
      /finditem "@Param0" 

   :WaitFind 
      /if "$cursor()"=="FALSE" /goto :WaitFind 

   :Selling 
      /delay 1s 
      /varset OldMoney $char(cash)      
      /sellitem $selecteditem(count) 
      /click left merchant sell 

   :WaitSell 
      /varset NewMoney $char(cash) 
      /if n @NewMoney==@OldMoney /goto :WaitSell 
      /goto :Finding 

   :Done 
      /sendkey up shift 
      /endmacro 

/return
 

User avatar
Bad Karma
a snow griffon
a snow griffon
Posts: 346
Joined: Sat Nov 22, 2003 9:34 pm
Contact:

Post by Bad Karma » Tue Feb 10, 2004 1:27 am

Nice to see my version of DruidFarm.mac is turning out to be so handy. =) Makes me wish I'd have spent more time on it. lol This must be the 3rd version of it I've seen posted so far. :D



OK, so you looted everything, and you want to get it to run off and sell now...then go back and hunt more....

First off, you'll probally want to #include advpath.inc and use it's capabilities for for the movement to and from your camp loc and the merchant you'll want to sell to.

You can use a sell.mac, renamed to sell.inc and rename Sub Main to something else like Sub Sell, then call to that....

Don't have time right this moment to dig into it, but that should give you some pointers to get you going.
[b]- Bad Karma
________________________________________[/b]

In our own quest for excellence, we should strive to take the time to help those who help themselves.

All others should [b]RTFM[/b]!!!!!!!!!