Requesting code review

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

yoda
orc pawn
orc pawn
Posts: 19
Joined: Thu Feb 12, 2004 6:44 pm

Requesting code review

Post by yoda » Thu Apr 22, 2004 11:12 am

Converted my fishing macro using new parms and stuff, hopeing maybe a couple people can look over it and see if I made any mistakes.

Thanks in advance.

Code: Select all

|***************************************************************************************
| - Fish.mac -                                                                         *
| - By: Yoda                                                                           *
| - v1.1                                                                               *
|                                                                                      *
| Usage:                                                                               *
| To Fish using a Fisherman's Companion.                                               *
| Will Gate, Sit and /afk when you run out of bait.                                    *
|                                                                                      *
|***************************************************************************************

#turbo 

#event BrokenPole "You can't fish without a fishing pole, go buy one." 
#event NoBait "You can't fish without fishing bait, go buy some."
#event Fizzle "Your spell fizzles" 

Sub Main 

   /cleanup 

   :Fish 
	/call CheckPole  
	/doability Fishing 
	/delay 65  
	/doevents

	/newif (${Cursor.Name.Equal[Tattered Cloth Sandal]}) /destroy
	/delay 1
	/newif (${Cursor.Name.Equal[Rusty Dagger]}) /destroy
	/delay 1
	/newif (${Cursor.ID}) /call KeepItem
	/goto :Fish 

/return 

Sub KeepItem

	/newif (${Cursor.Name.NotEqual[Fish Scales]}) /call DoLog "I caught some (${Cursor.Name})"
	/autoinventory

/return

Sub CheckPole 
   
	/newif (${Me.Inventory["primary"].Name.Equal["Brell's Fishin' Pole"]}) /return 
	/newif (${Me.State.Equal["SIT"]}) /stand
	/delay 4
	/cast item "Fisherman's Companion"
	/delay 11s 
	/autoinventory 
	/sit     

/return 

Sub GateMe 

	/delay 6 
	/newif (${Me.State.Equal["SIT"]}) /stand
	/cast "Gate"
	/delay 5
	/doevents
	/delay 6s
	/newif (${Me.State.Equal["STAND"]}) /sit
	/afk
	/endmacro 

/return
    
Sub DoLog(Text)
	
	/mqlog @Text
	/echo @Text

/return

Sub Event_BrokenPole 

	/call CheckPole 

/return 

Sub Event_NoBait 

	/call GateMe 

/return

Sub Event_Fizzle
	
	/call GateMe 

/return
Last edited by yoda on Thu Apr 22, 2004 1:19 pm, edited 4 times in total.

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Thu Apr 22, 2004 11:53 am

1) All /if or /newif (same thing now) must have () around the conditions, like:
/if (condition) /command

2) /newif ${Cursor} /call KeepItem
This will look like:
/newif Fish Scales /call KeepItem

which the parser cannot figure out where the conditions end and the command begins, and cannot determine whether you want "Fish Scales" to be true or false. What you want is:
/newif (${Cursor.ID}) /call KeepItem

I dont see anything too obvious other than that
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

Chaesar
orc pawn
orc pawn
Posts: 15
Joined: Mon Feb 23, 2004 1:28 pm

Post by Chaesar » Thu Apr 22, 2004 12:39 pm

Shouldn't the two instances of

Code: Select all

/newif (${Me.State.Equal["SIT"]}) /sit
be

Code: Select all

/newif (${Me.State.Equal["SIT"]}) [color=red]/stand[/color]
in order to stand for casting your fishing pole and gate?

yoda
orc pawn
orc pawn
Posts: 19
Joined: Thu Feb 12, 2004 6:44 pm

Post by yoda » Thu Apr 22, 2004 12:43 pm

/sit /stand does the same thing, so yes, I could change it.

What if all I want to know, is if there is something on the cursor? that is what I was trying to do with this:

Code: Select all

/newif (${Cursor.ID}) /call KeepItem 
also,

Code: Select all

/call DoLog "Caught (${Cursor.Name}) ..."
Will that put the name of what is on the cursor in that statement?
Last edited by yoda on Thu Apr 22, 2004 1:14 pm, edited 1 time in total.

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Thu Apr 22, 2004 12:47 pm

/newif (${Cursor.ID}) /call KeepItem

that's what that does.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

yoda
orc pawn
orc pawn
Posts: 19
Joined: Thu Feb 12, 2004 6:44 pm

Post by yoda » Thu Apr 22, 2004 1:24 pm

Thanks alot Lax, how does it look now?


Will this put the name of the item on the cursor in the Text for the DoLog subroutine, or does it need to be (${Cursor.ID})?

Code: Select all

/newif (${Cursor.Name.NotEqual[Fish Scales]}) /call DoLog "I caught some (${Cursor.Name})"

Sub DoLog(Text) 
    
   /mqlog @Text 
   /echo @Text 

/return

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Thu Apr 22, 2004 1:58 pm

ID is the item number, not the name

You're doing fine. You can also skip the .Name part in ${Cursor} unless you need to do string operations on the name (you dont), because the "To String" of "item" is "Same as Name". No big deal there, just letting you know
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

yoda
orc pawn
orc pawn
Posts: 19
Joined: Thu Feb 12, 2004 6:44 pm

different logic question

Post by yoda » Thu Apr 22, 2004 2:35 pm

Thanks again lax, onto a Logic question, looking for some advice, I am also converting this fish macro to work for a necro that will FD while fishing. Everything is mostly the same, except one problem. my Event_fizzle now could be from either of the 2 spells that I cast, Gate or Feign Death, I need some logic, so that if it is gate that fizzled, it recast gate, but if FD fizzled, i need to cast FD again and continue on with the macro, any help would be great...

Code: Select all

|***************************************************************************************
| - NecroFish.mac -                                                                    *
| - By: Yoda                                                                           *
| - v1.0                                                                               *
|                                                                                      *
| Usage: For Necros                                                                    *
| To Fish using a Fisherman's Companion.                                               *
| Will Gate, Sit and /afk when you run out of bait.                                    *
| Destroys Tattered Cloth Sandals and Rusty Daggers, keeps everything else.            *
|***************************************************************************************

#event BrokenPole "You can't fish without a fishing pole, go buy one." 
#event NoBait "You can't fish without fishing bait, go buy some."
#event Fizzle "Your spell fizzles" 
#event Death "You die"

Sub Main 

   /cleanup 
   /call Feign
   /call Fishin

/endmacro

Sub Fishin

   :Fish 
	/call CheckPole
	/doability Fishing 
	/delay 65  
	/doevents
	/newif (${Cursor.Name.Equal[Tattered Cloth Sandal]}) /destroy
	/delay 1
	/newif (${Cursor.Name.Equal[Rusty Dagger]}) /destroy
	/delay 1
	/newif (${Cursor.ID}) /call KeepItem
	/goto :Fish 

/return 

Sub CheckPole 
   
	/newif (${Me.Inventory["primary"].Name.Equal["Brell's Fishin' Pole"]}) /return 
	/newif (${Me.State.Equal["SIT"]}) /stand 
	/delay 4
	/cast item "Fisherman's Companion"
	/delay 11s 
	/autoinventory 
	/call Feign
	
/return 

Sub Feign

	/newif (${Me.State.Equal["SIT"]}) /stand
	/cast "Feign Death"
	/delay 6s
	/doevents

/return 

Sub KeepItem

	/newif (${Cursor.Name.NotEqual[Fish Scales]}) /call DoLog "Caught (${Cursor}) ..."
	/autoinventory

/return

Sub GateMe 

	/delay 6 
	/sit
	/newif (${Me.State.Equal["SIT"]}) /stand
	/cast "Gate" 
	/delay 5
	/doevents
	/delay 6s
	/newif (${Me.State.Equal["STAND"]}) /sit
	/afk
	/endmacro 
/return
    
Sub DoLog(Text)

	/mqlog @Text
	/echo @Text

/return

Sub Event_BrokenPole 

	/call CheckPole 

/return 

Sub Event_NoBait 

	/call GateMe 

/return

Sub Event_Fizzle
	

/return

Sub Event_Death
 

/return

newb-n-training
a lesser mummy
a lesser mummy
Posts: 39
Joined: Mon Apr 19, 2004 8:51 pm

Post by newb-n-training » Thu Apr 22, 2004 2:41 pm

Just a newb here Yoda so take the logic as you will but could you simply always recast your spell (Gate, FD, whathaveyou) and end the macro on "LOADING, PLEASE WAIT" in the instance of Gate?

One other thing I thought I'd mention is an event of the gate collapsing (no fizzle, just no gate). Might need to account for that depending on your plans.

yoda
orc pawn
orc pawn
Posts: 19
Joined: Thu Feb 12, 2004 6:44 pm

Post by yoda » Thu Apr 22, 2004 4:16 pm

How about this, anyone see any problems?

Code: Select all

|***************************************************************************************
| - NecroFish.mac -                                                                    *
| - By: Yoda                                                                           *
| - v1.1                                                                               *
|                                                                                      *
| Usage: For Necros                                                                    *
| To Fish using a Fisherman's Companion.                                               *
| Will Gate, Sit and /afk when you run out of bait.                                    *
| Destroys Tattered Cloth Sandals and Rusty Daggers, keeps everything else.            *
|***************************************************************************************

#event BrokenPole "You can't fish without a fishing pole, go buy one." 
#event NoBait "You can't fish without fishing bait, go buy some."
#event Death "You die"
#event Unstable "unstable"
#event Zone "LOADING, PLEASE WAIT"
#Event End "You stop fishing" 
#Event End "Trying to catch land sharks perhaps?" 
#Event End "You must be on dry land to fish."

Sub Main 

   /cleanup 
   /call Feign

/endmacro

Sub Fishin

   :Fish 
	/call CheckPole
	/doability Fishing 
	/delay 65  
	/doevents
	/newif (${Cursor.Name.Equal[Tattered Cloth Sandal]}) /destroy
	/delay 1
	/newif (${Cursor.Name.Equal[Rusty Dagger]}) /destroy
	/delay 1
	/newif (${Cursor.ID}) /call KeepItem
	/goto :Fish 

/return 

Sub CheckPole 
   
	/newif (${Me.Inventory["primary"].Name.Equal["Brell's Fishin' Pole"]}) /return 
	/sit
	/newif (${Me.State.Equal["SIT"]}) /stand 
	/delay 4
	/cast item "Fisherman's Companion"
	/delay 11s 
	/autoinventory 
	/call Feign
	
/return 

Sub Feign

	/newif (${Me.State.Equal["SIT"]}) /stand
   :Death
	/cast "Feign Death"
	/delay 7s
	/doevents
	/goto :Death

/return 

Sub KeepItem

	/newif (${Cursor.Name.NotEqual[Fish Scales]}) /call DoLog "Caught (${Cursor}) ..."
	/autoinventory

/return

Sub GateMe 

	/delay 6 
	/sit
	/newif (${Me.State.Equal["SIT"]}) /stand
   :Gate
	/cast "Gate" 
	/delay 6s
	/doevents
	/goto :Gate
	
/return
    
Sub DoLog(Text)

	/mqlog @Text
	/echo @Text

/return

Sub Event_BrokenPole 

	/call CheckPole 

/return 

Sub Event_NoBait 

	/call GateMe 

/return

Sub Event_Zone
	
	/newif (${Me.State.Equal["STAND"]}) /sit
	/afk
	/endmacro 

/return

Sub Event_Death

	/call Fishin

/return

Sub Event_Unstable
 
	/call GateMe 

/return

Sub Event_End
 
	/endmacro 

/return