Master Angler 1.0

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

Feonix762
orc pawn
orc pawn
Posts: 15
Joined: Thu Feb 26, 2004 5:53 am

Master Angler 1.0

Post by Feonix762 » Thu Feb 26, 2004 5:57 am

Alright, this Macro is designed to be run with 7 empty backpacks, and 1 backpack full of bait. It should be started at a specific spot right next to the GoD zone in and will then fish until it loses it's pole, runes out of bait, or needs to sell. It was working great, then I decided to delete my fishing pole to test my code. All it does is face the proper location and move forward about 1 foot then it starts trying to fish again. It goes into a loop here, as it's still missing a pole it just moves forward a foot again and then goes back to fishing over and over. Anyone have any ideas?

If you have GoD expansion, just zone into Natimbi wayfarer camp and turn it on, if you don't have a fishing pole in hand you'll see the problem occur immediatley as it begins running one step and trying to fish over and over.

It seems to me like it's simple skipping the /goto commands and is immediatley returning to Main after it tries one location.

Code: Select all

| - angler.mac -
| Created by Feonix762, lots of bits and pieces and ideas taken from other people. Thanks!
#turbo
#include routines.mac

#event BrokenPole "You can't fish without a pole, go buy one."
#event NoBait "You can't fish without fishing bait, go buy some."
#event NoRoom "There was no place to put that! The item has dropped to the ground!"


Sub Main

   /declare GokkLocX global
   /declare GokkLocY global
   /declare NearGokkLocX global
   /declare NearGokkLocY global
   /declare NearFishLocX global
   /declare NearFishLocY global
   /declare FishLocX global
   /declare FishLocY global
   /varset GokkLocX -820
   /varset GokkLocY -1601
   /varset NearGokkLocX -910
   /varset NearGokkLocY -1560
   /varset NearFishLocX -1173
   /varset NearFishLocY -1581
   /varset FishLocX -1262
   /varset FishLocY -1657
   /varset SellSaltWater 50
   /varset BuyBait 8

| Check for Fishing Pole and start fishing.

   :Fish
      /if $invpanel==TRUE /press i
      /call CheckPole 
      /if $return==1 /return
      /doability Fishing
      /delay 65 
      /if "$cursor(name)"=="Tattered Cloth Sandal" /destroy
      /if "$cursor(name)"=="Rusty Dagger" /destroy
      /if "$cursor(name)"=="Fish Scales" /destroy
      /if "$cursor(name)"=="Fresh Fish" /destroy
      /if "$cursor(name)"=="Crawdad" /destroy
      /if "$cursor(name)"=="Waterleaf Scale" /destroy
      /if "$cursor(name)"~~"Saltwater" /autoinventory
      /autoinv
      /if n $char(hp,pct)<75 /call Gate
   /goto :Fish
/return

| Make sure Fishing Pole is equiped, or else call GokkRun, buy pole, then equip and run back.

Sub CheckPole
   /if $invpanel==TRUE /press i
   /if "$equip(primary,name)"=="Fishing Pole" /return 0
   /call GokkRun
   /delay 1s
   /target Gokk
   /delay 5
   /click right target
   /delay 5
   /mouseto merchant 2
   /delay 5
   /click left
   /delay 5
   /mouseto merchant buy
   /delay 5
   /click left
   /delay 5
   /mouseto merchant done
   /delay 5
   /click left
   /delay 5
   /if $invpanel==FALSE /press i
   /finditem "Fishing Pole"
   /delay 5
   /finditem "Fishing Pole"
   /if $invpanel==TRUE /press i
   /autoinv
   /call FishRun
/return 0

| Run to first location, then second, then in front of Gokk and go back to buying/selling.

Sub GokkRun

   :NearFish
      /face loc NearFishLocX, NearFishLocY
      /sendkey down up
      /if n ($char(x)<> NearFishLocX) and  n ($char(y)<> NearFishLocY) then /goto NearFish
      /sendkey up up
   :NearGokk
      /face loc NearGokkLocX, NearGokkLocY
      /sendkey down up
      /if n ($char(x)<> NearGokkLocX) and  n ($char(y)<> NearGokkLocY) then /goto :NearGokk
      /sendkey up up
   :Gokk
      /face loc GokkLocX, GokkLocY
      /sendkey down up
      /if n ($char(x)<> GokkLocX) and  n ($char(y)<> GokkLocY) then /goto :Gokk
      /sendkey up up

/return

| Run from Gokk back to the fishing spot and start fishing again.

Sub FishRun

   :NearGokk
      /face loc NearGokkLocX, NearGokkLocY
      /sendkey down up
      /if n ($char(x)<> NearGokkLocX) and  n ($char(y)<> NearGokkLocY) then /goto :NearGokk
      /sendkey up up
   :NearFish
      /face loc NearFishLocX, NearFishLocY
      /sendkey down up
      /if n ($char(x)<> NearFishLocX) and  n ($char(y)<> NearFishLocY) then /goto :NearFish
      /sendkey up up
   :Fish
      /face loc FishLocX, FishLocY
      /sendkey down up
      /if n ($char(x)<> FishLocX) and  n ($char(y)<> FishLocY) then /goto :NearFish
      /sendkey up up
   /face loc -1336, -1614

/return

| If we run out of bait go buy some from Gokk.

Sub NoBait

   /if $invpanel==TRUE /press i
   /call GokkRun
   /target Gokk
   /delay 5
   /click right target
   /delay 5
  :BuyBait
   /if n @BuyBait<=0 /goto :Done
   /varsub @BuyBait 1
   /mouseto merchant 3
   /delay 5
   /click left
   /delay 5
   /mouseto merchant buy
   /delay 5
   /click left
   /delay 5
   /press enter
   /delay 5
  /goto :BuyBait
  :Done
   /mouseto merchant done
   /delay 5
   /click left
   /delay 5
   /cleanup
   /call FishRun
/return

| If we run out of room, go sell to Gokk.

Sub SellItems

   /if $invpanel==TRUE /press i
   /call GokkRun
   /target Gokk
   /delay 5
   /click right target
   /delay 5
  :SellSalt
   /if n @SellSaltWater<=0 /goto :Done
   /varsub @SellSaltWater 1
   /finditem similar "saltwater"
   /delay 5
   /mouseto merchant sell
   /delay 5
   /click left
   /delay 5
  /goto :SellSalt
  :Done
   /mouseto merchant done
   /delay 5
   /click left
   /delay 5
   /if $invpanel==TRUE /press i
   /autoinv
   /cleanup
   /call FishRun
/return

Sub Event_BrokenPole
   /call CheckPole
/return

Sub Event_NoBait
   /call NoBait
/return

Sub Event_NoRoom
   /call SellItems
/return

| Emergency

Sub Gate

   /cast 6
   /delay 1s
   /cast 6
   /delay 1s
   /cast 6
   /delay 1s
   /cast 6
   /delay 1s
   /cast 6
   /delay 1s
   /cast 6
   /delay 1s
   /cast 6
   /delay 1s
   /cast 6
   /delay 1s
   /camp desktop
Last edited by Feonix762 on Thu Feb 26, 2004 6:33 pm, edited 1 time in total.

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Thu Feb 26, 2004 6:58 am

I am not testing the macro, but a few things caught my eye:

Code: Select all

| Check for Fishing Pole and start fishing. 

   :Fish 
      /if $invpanel==TRUE /press i 
      /call CheckPole 
      [color=cyan]/if $return==1 /return[/color] 
      /doability Fishing 
      /delay 65
The light blue line above... where does it return to?

Code: Select all

Sub CheckPole 
   /if $invpanel==TRUE /press i 
   /if "$equip(primary,name)"=="Fishing Pole" /return 0 
   /call GokkRun 
   /delay 1s 
   /target Gokk 
   /delay 5 
   /click right target 
   /delay 5 
   /mouseto merchant 2 
   /delay 5 
   /click left 
   /delay 5 
   /mouseto merchant buy 
   /delay 5 
   /click left 
   /delay 5 
   /mouseto merchant done 
   /delay 5 
   /click left 
   /delay 5 
   /if $invpanel==FALSE /press i 
   /finditem "Fishing Pole" 
   /delay 5 
   /finditem "Fishing Pole" 
   /if $invpanel==TRUE /press i 
   /autoinv 
   /call FishRun 
/return 0
In Sub Checkpole, nothing sets a return value to 1, so in effect you will never have a fishing pole equipped if I read this right.

There are quite a few other problems with the macro also. Will see if I can take a look sometime.

Feonix762
orc pawn
orc pawn
Posts: 15
Joined: Thu Feb 26, 2004 5:53 am

Post by Feonix762 » Thu Feb 26, 2004 2:06 pm

The light blue line above... where does it return to?
CheckPole returns a 0 value if the pole is equipped, otherwise it returns a 1 which returns to the line after pole check, which equips a pole and then returns a 0.

Code: Select all

/if "$equip(primary,name)"=="Fishing Pole" /return 0 
This is where it returns a 0 value, sorry they're backwards. 0 = True and 1 = False

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Thu Feb 26, 2004 3:31 pm

CheckPole returns a 0 value if the pole is equipped, otherwise it returns a 1 which returns to the line after pole check, which equips a pole and then returns a 0.
Again, where does it return to? Where is the /return 1? I only see /return 0

Feonix762
orc pawn
orc pawn
Posts: 15
Joined: Thu Feb 26, 2004 5:53 am

Post by Feonix762 » Thu Feb 26, 2004 4:54 pm

Below is the code for calling CheckPole, it runs before each fishing attempt.

Code: Select all

     /call CheckPole 
      /if $return==1 /return

And here is the code that does the return.

Code: Select all

     /if "$equip(primary,name)"=="Fishing Pole" /return 0 
Each time it does a fishing cycle, it calls CheckPole, which sees if you have a Fishing Pole, if you DO have a pole, it will return a 0, if you do NOT have a pole, it returns a 1. Then in the Fishing Cycle, it asks return if it's 1 or other, if it's 1 then it will return BACK to the CheckPole at the line after the check, meaning it will go through the buy a pole code. If it returned a 0, then it simply continues fishing.

CheckPole checks for a pole, and if it has one it returns a 0 meaning it will just keep fishing, if it does not have a pole, then it returns a 1, which makes the buy code go.

Get it?

Besides, there's nothing wrong with this part of the code, it will fish normal if I have a pole, but if I delete my pole to see if it will go buy a new one, it starts trying to buy one, but it never reaches the first waypoint I have setup on the way to the vendor, it just faces that point, walks a little, then stops and tries to fish again. The problem is somewhere in the GokkRun sub, it's like it''s going through all the code in the Sub in 1 second insted of following the /goto until it gets to that location.

Oh, and by the way. It seems like all of the code works perfectly except for the GokkRun and FishRun subs. I can stand next to the vendor (Gokk) and delete my pole and it'll go through it like normal, still messing up on the running, but since I'm next to him it goes through the entire buy and everything, equips it. No problems at all, same with if I have no bait, or if I have no room.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Thu Feb 26, 2004 6:52 pm

Wassup wrote:I am not testing the macro, but a few things caught my eye:

Code: Select all

| Check for Fishing Pole and start fishing. 

   :Fish 
      /if $invpanel==TRUE /press i 
      /call CheckPole 
      [color=cyan]/if $return==1 /return[/color] 
      /doability Fishing 
      /delay 65
The light blue line above... where does it return to?

Code: Select all

Sub CheckPole 
   /if $invpanel==TRUE /press i 
   /if "$equip(primary,name)"=="Fishing Pole" /return 0 
   /call GokkRun 
   /delay 1s 
   /target Gokk 
   /delay 5 
   /click right target 
   /delay 5 
   /mouseto merchant 2 
   /delay 5 
   /click left 
   /delay 5 
   /mouseto merchant buy 
   /delay 5 
   /click left 
   /delay 5 
   /mouseto merchant done 
   /delay 5 
   /click left 
   /delay 5 
   /if $invpanel==FALSE /press i 
   /finditem "Fishing Pole" 
   /delay 5 
   /finditem "Fishing Pole" 
   /if $invpanel==TRUE /press i 
   /autoinv 
   /call FishRun 
/return 0
In Sub Checkpole, nothing sets a return value to 1, so in effect you will never have a fishing pole equipped if I read this right.

There are quite a few other problems with the macro also. Will see if I can take a look sometime.
Wassup's comments were right on the money. You don't have a single line in your macro that is doing a:

/return 1

Also, don't /return within your main loop. If you are trying to avoid doing the commands below that line just /goto a label to form a loop.

You should also get in the habit of using numeric comparisons on lines like:

/if $return==1

should be:

/if n $return==1

It won't always come back to bite you in the ass, but if you perform a math function on the variable you are checking it will change the number to a decimal form and will screw up your non-numeric comparison.

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Thu Feb 26, 2004 10:21 pm

Feonix762 wrote:Below is the code for calling CheckPole, it runs before each fishing attempt.

Code: Select all

     /call CheckPole 
      /if $return==1 /return

And here is the code that does the return.

Code: Select all

     /if "$equip(primary,name)"=="Fishing Pole" /return 0 
Each time it does a fishing cycle, it calls CheckPole, which sees if you have a Fishing Pole, if you DO have a pole, it will return a 0, if you do NOT have a pole, it returns a 1. Then in the Fishing Cycle, it asks return if it's 1 or other, if it's 1 then it will return BACK to the CheckPole at the line after the check, meaning it will go through the buy a pole code. If it returned a 0, then it simply continues fishing.

CheckPole checks for a pole, and if it has one it returns a 0 meaning it will just keep fishing, if it does not have a pole, then it returns a 1, which makes the buy code go.

Get it?
Nope, I don't get it... You don't have a /return 1 anywhere. So... you just have fun trying to figure it out. Good luck to you, and will probably see this thread continue on for a few months until you understand what I am talking about.

BTW take a look at these lines of code that have these same comparisons:

Code: Select all

/if n ($char(x)<> NearFishLocX) and  n ($char(y)<> NearFishLocY) then /goto NearFish
They will not work

Feonix762
orc pawn
orc pawn
Posts: 15
Joined: Thu Feb 26, 2004 5:53 am

Post by Feonix762 » Thu Feb 26, 2004 11:54 pm

I see what you meant now, but what do you mean by those other lines with the same comparisons? Those aren't using return at all, they're using /goto

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Fri Feb 27, 2004 12:25 am

This has several problems:

Code: Select all

/if n ($char(x)<> NearFishLocX) and  n ($char(y)<> NearFishLocY) then /goto NearFish 
Should look like this:

Code: Select all

/if (n $char(x)!=@NearFishLocX && n $char(y)!=@NearFishLocY) /goto :NearFish 
Not only that, but it might be hard to get an exact coordinate like you are doing. So basically, your coding and logic are both at fault.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Fri Feb 27, 2004 12:27 am

You seriously need to read through others code and see how to do things, and read the readme.html file in your release directory. Also, you might not want to cop an attitude with people here when they try to point out your mistakes constructively. You are likely to get no help at all in the future if you take offense to positive advice people give you.