Why does Combine act up in lag

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

Moderator: MacroQuest Developers

Socky

Why does Combine act up in lag

Post by Socky » Tue Oct 21, 2003 1:16 pm

Hey all, I have the all purpose combine script posted on this board, and it works perfectly on my fast uber computer, but on the slower one I get a lot of lag spikes which I believe are to due the cpu / ram. Anyways these spikes seem to cause the script to act weird, like it will be pressing the combine button like 8 times, and if it doesnt combine by then it will fail, I was wondering if you could help me figure out how to edit this soo it will keep trying, OR if you can help me find a more simple combine script, I dont need all that information on how many successes, trivials, and everything, also I only plan to combine 2 different items, not more like this script claims to support. I will paste the code below.



| All Purpose Combine Macro
| /macro combine KEEP/DESTROY "Combiner" "Item 1" "Item 2" "Item 3" "Item 4" "Item 5" "Item 6" "Item 7" "Item 8" "Item 9" "Item 10"
| Example: /macro combine KEEP "Pottery Wheel" "water flask" "ceramic lining sketch" "small brick of clay"
| KEEP will put all items produced into your inventory, DESTROY will destroy the first item produced on a successful combine.
| By default the combine mac works with exact item names, you can use similar item names by prefixing the name with a #
| Example: /macro combine KEEP "Pottery Wheel" #water #ceramic #clay
|
| Using #turbo with this macro seems to break it.
| This macro will open all your bags, inventory window and an enviromental combiner if necessary, it's important they don't overlap.

#event COMBINE_AlternateProduct "You have fashioned the items together to create an alternate product."
#event COMBINE_LackedSkills "You lacked the skills to fashion the items together."
#event COMBINE_Success "You have fashioned the items together to create something new!"
#event COMBINE_Skillup "You have become better at"
#event COMBINE_Trivial "You can no longer advance your skill from making this item."
#event COMBINE_DNC "You cannot combine these items in this container type!"
#define COMBINE_InventoryButton i
#define COMBINE_FREEINVSPACE 1

Sub Main

/if "@Param0"!="DESTROY" /if "@Param0"!="KEEP" /call COMBINE_Syntax

/cleanup

/declare COMBINE_CombinerLoc global
/declare COMBINE_CombinerInvEnv global
/declare COMBINE_Combined global
/declare COMBINE_AlternateProductTotal global
/declare COMBINE_LackedSkillsTotal global
/declare COMBINE_SuccessTotal global
/declare COMBINE_CombinesTotal global
/declare COMBINE_TrivialTotal global
/declare COMBINE_SkillupTotal global
/declare COMBINE_Destroy global
/varset COMBINE_AlternateProductTotal 0
/varset COMBINE_LackedSkillsTotal 0
/varset COMBINE_SuccessTotal 0
/varset COMBINE_TrivialTotal 0
/varset COMBINE_SkillupTotal 0
/varset COMBINE_CombinesTotal 0
/varset COMBINE_Combined 0
/call COMBINE_FindCombiner "@Param1"
/if n @COMBINE_CombinerLoc<=7 /call COMBINE_OpenInv
/if n @COMBINE_CombinerLoc==8 /call COMBINE_OpenEnv
/if n @COMBINE_CombinerLoc==99 {
/echo "Cannot find container-aborting"
/endmacro
}
/call COMBINE_OpenPacks

/if "@Param0"=="DESTROY" {
/echo DESTROYING FIRST ITEM FROM A SUCCESSFUL COMBINE!!!
/varset COMBINE_Destroy 1
}

/if "@Param0"=="KEEP" /varset COMBINE_Destroy 0

:COMBINE_MakeItem
/sendkey down ctrl
/if "$cursor()"=="TRUE" /goto :COMBINE_ClearCursor

/if "@Param2"~~# {
/finditem similar "$right($calc($strlen("@Param2")-1),"@Param2")"
/goto :COMBINE_Continue
}
/finditem "@Param2"
:COMBINE_Continue
/if "$find()"=="FALSE" /goto :COMBINE_Done
/click left @COMBINE_CombinerInvEnv 0

/if "@Param3"~~"Param3" /goto :COMBINE_Combine
/if "@Param3"~~# {
/finditem similar "$right($calc($strlen("@Param3")-1),"@Param3")"
/goto :COMBINE_Continue2
}
/finditem "@Param3"
:COMBINE_Continue2
/if "$find()"=="FALSE" /goto :COMBINE_Done
/click left @COMBINE_CombinerInvEnv 1

/if "@Param4"~~"Param4" /goto :COMBINE_Combine
/if "@Param4"~~# {
/finditem similar "$right($calc($strlen("@Param4")-1),"@Param4")"
/goto :COMBINE_Continue3
}
/finditem "@Param4"
:COMBINE_Continue3
/if "$find()"=="FALSE" /goto :COMBINE_Done
/click left @COMBINE_CombinerInvEnv 2

/if "@Param5"~~"Param5" /goto :COMBINE_Combine
/if "@Param5"~~# {
/finditem similar "$right($calc($strlen("@Param5")-1),"@Param5")"
/goto :COMBINE_Continue4
}
/finditem "@Param5"
:COMBINE_Continue4
/if "$find()"=="FALSE" /goto :COMBINE_Done
/click left @COMBINE_CombinerInvEnv 3

/if "@Param6"~~"Param6" /goto :COMBINE_Combine
/if "@Param6"~~# {
/finditem similar "$right($calc($strlen("@Param6")-1),"@Param6")"
/goto :COMBINE_Continue5
}
/finditem "@Param6"
:COMBINE_Continue5
/if "$find()"=="FALSE" /goto :COMBINE_Done
/click left @COMBINE_CombinerInvEnv 4

/if "@Param7"~~"Param7" /goto :COMBINE_Combine
/if "@Param7"~~# {
/finditem similar "$right($calc($strlen("@Param7")-1),"@Param7")"
/goto :COMBINE_Continue6
}
/finditem "@Param7"
:COMBINE_Continue6
/if "$find()"=="FALSE" /goto :COMBINE_Done
/click left @COMBINE_CombinerInvEnv 5

/if "@Param8"~~"Param8" /goto :COMBINE_Combine
/if "@Param8"~~# {
/finditem similar "$right($calc($strlen("@Param8")-1),"@Param8")"
/goto :COMBINE_Continue7
}
/finditem "@Param8"
:COMBINE_Continue7
/if "$find()"=="FALSE" /goto :COMBINE_Done
/click left @COMBINE_CombinerInvEnv 6

/if "@Param9"~~"Param9" /goto :COMBINE_Combine
/if "@Param9"~~# {
/finditem similar "$right($calc($strlen("@Param9")-1),"@Param9")"
/goto :COMBINE_Continue8
}
/finditem "@Param9"
:COMBINE_Continue8
/if "$find()"=="FALSE" /goto :COMBINE_Done
/click left @COMBINE_CombinerInvEnv 7

/if "@Param10"~~"Param10" /goto :COMBINE_Combine
/if "@Param10"~~# {
/finditem similar "$right($calc($strlen("@Param10")-1),"@Param10")"
/goto :COMBINE_Continue9
}
/finditem "@Param10"
:COMBINE_Continue9
/if "$find()"=="FALSE" /goto :COMBINE_Done
/click left @COMBINE_CombinerInvEnv 8

/if "@Param11"~~"Param11" /goto :COMBINE_Combine
/if "@Param11"~~# {
/finditem similar "$right($calc($strlen("@Param11")-1),"@Param11")"
/goto :COMBINE_Continue10
}
/finditem "@Param11"
:COMBINE_Continue10
/if "$find()"=="FALSE" /goto :COMBINE_Done
/click left @COMBINE_CombinerInvEnv 9

:COMBINE_Combine
/sendkey up ctrl

:COMBINE_WaitCombine
/click left @COMBINE_CombinerInvEnv combine
/doevents
/if n @COMBINE_Combined==1 /goto :COMBINE_ClearCursor
/goto :COMBINE_WaitCombine

:COMBINE_ClearCursor
/if n $freeinv(space)<COMBINE_FREEINVSPACE /if n $freeinv(space)<=0 /call COMBINE_OutofSpace
/varset COMBINE_Combined 0
/click left auto
/if "$cursor()"=="TRUE" /goto :COMBINE_ClearCursor

/goto :COMBINE_MakeItem

:COMBINE_Done
/call COMBINE_Finish

/return

Sub COMBINE_OpenInv
/varset COMBINE_CombinerInvEnv "pack @COMBINE_CombinerLoc"
/cleanup
/if "$invpanel"=="FALSE" /press COMBINE_InventoryButton
/click right inv @COMBINE_CombinerLoc
/if $pack(@COMBINE_CombinerLoc,empty)==FALSE /call COMBINE_CleanPack
/return

Sub COMBINE_OpenEnv
/cleanup
/varset COMBINE_CombinerLoc e
/varset COMBINE_CombinerInvEnv enviro
/face item

:COMBINE_WaitOpen
/click left item
/if $pack(@COMBINE_CombinerLoc,open)==NULL /goto :COMBINE_WaitOpen
/if $pack(@COMBINE_CombinerLoc,empty)==FALSE /call COMBINE_CleanPack
/return

Sub COMBINE_OpenPacks
/declare COMBINE_OpenPacksLoop local
/if "$invpanel"=="FALSE" /press COMBINE_InventoryButton
/for COMBINE_OpenPacksLoop 0 to 7
/if "$pack(@COMBINE_OpenPacksLoop,open)"=="FALSE" /click right inv @COMBINE_OpenPacksLoop
/next COMBINE_OpenPacksLoop

/return

Sub COMBINE_CleanPack
/declare COMBINE_CleanPackCombinerSlots local
/declare COMBINE_CleanPackLoop local
/varcalc COMBINE_CleanPackCombinerSlots $pack(@COMBINE_CombinerLoc,slots)-1

/sendkey down shift

/for COMBINE_CleanPackLoop 0 to @COMBINE_CleanPackCombinerSlots
/click left @COMBINE_CombinerInvEnv @COMBINE_CleanPackLoop
/click left auto
/next COMBINE_CleanPackLoop

/sendkey up shift

/if "$pack(@COMBINE_CombinerLoc,empty)"=="TRUE" /goto :COMBINE_PackClean
/echo Cannot empty combiner, free up some inventory space. Ending Macro.
/call COMBINE_Finish
/return

:COMBINE_PackClean
/return

Sub COMBINE_OutOfSpace
/echo Out of inventory space, please make space. Macro Ending
/call COMBINE_Finish
/return

Sub COMBINE_FindCombiner
/declare COMBINE_FindCombinerSearchLoop local
/varset COMBINE_CombinerLoc 99
/for COMBINE_FindCombinerSearchLoop 0 to 7
/if "$pack(@COMBINE_FindCombinerSearchLoop,combine)"=="@Param0" /varset COMBINE_CombinerLoc @COMBINE_FindCombinerSearchLoop
/next COMBINE_FindCombinerSearchLoop

/if n @COMBINE_CombinerLoc==99 {
/itemtarget @Param0
/if "$GETLASTERROR"=="ITEM_NOTFOUND" {
/echo Enviromental combiner not found. Ending macro.
/cleanup
/endmacro
}
/if n $distance(item)<=15 /varset COMBINE_CombinerLoc 8
}
/return @FIND_CombinerSlot

Sub COMBINE_Finish
/sendkey up ctrl
/call COMBINE_CleanPack
/cleanup

/echo Alternate Products: $int(@COMBINE_AlternateProductTotal) $int($calc(@COMBINE_AlternateProductTotal/@COMBINE_CombinesTotal*100))%
/echo Failures: $int(@COMBINE_LackedSkillsTotal) $int($calc(@COMBINE_LackedSkillsTotal/@COMBINE_CombinesTotal*100))%
/echo Success: $int(@COMBINE_SuccessTotal) $int($calc(@COMBINE_SuccessTotal/@COMBINE_CombinesTotal*100))%
/echo Trivial: $int(@COMBINE_TrivialTotal) $int($calc(@COMBINE_TrivialTotal/@COMBINE_CombinesTotal*100))%
/echo Skillup: $int(@COMBINE_SkillupTotal) $int($calc(@COMBINE_SkillupTotal/@COMBINE_CombinesTotal*100))%
/echo Non-Trivial: $int($calc(@COMBINE_CombinesTotal-@COMBINE_TrivialTotal-@COMBINE_LackedSkillsTotal)) $int($calc($calc(@COMBINE_CombinesTotal-@COMBINE_TrivialTotal)/@COMBINE_CombinesTotal*100))%
/echo Total Combines: $int(@COMBINE_CombinesTotal)
/endmacro

Sub Event_COMBINE_AlternateProduct
/varset COMBINE_Combined 1
/varcalc COMBINE_AlternateProductTotal @COMBINE_AlternateProductTotal+1
/varcalc COMBINE_CombinesTotal @COMBINE_CombinesTotal+1
/return

Sub Event_COMBINE_LackedSkills
/varset COMBINE_Combined 1
/varcalc COMBINE_LackedSkillsTotal @COMBINE_LackedSkillsTotal+1
/varcalc COMBINE_CombinesTotal @COMBINE_CombinesTotal+1
/return

Sub Event_COMBINE_Success
:COMBINE_SuccessCursorWait
/if $cursor()==NULL /goto :COMBINE_SuccessCursorWait

/varset COMBINE_Combined 1
/varcalc COMBINE_SuccessTotal @COMBINE_SuccessTotal+1
/varcalc COMBINE_CombinesTotal @COMBINE_CombinesTotal+1

/if n "@COMBINE_Destroy"=="1" /click left destroy
/return

Sub Event_COMBINE_Trivial
/varcalc COMBINE_TrivialTotal @COMBINE_TrivialTotal+1
/return

Sub Event_COMBINE_Skillup
/varcalc COMBINE_SkillupTotal @COMBINE_SkillupTotal+1
/return

Sub COMBINE_Syntax
/echo Error in macro parameters. Ending macro.
/echo /macro combine KEEP/DESTROY "Combiner" "Item 1" "Item 2" "Item 3" "Item 4" "Item 5" "Item 6" "Item 7" "Item 8" "Item 9" "Item 10"
/echo Example: /macro combine KEEP "Pottery Wheel" "water flask" "ceramic lining sketch" "small brick of clay"
/echo KEEP will put all items produced into your inventory, DESTROY will destroy the first item produced on a successful combine.
/echo By default the combine mac works with exact item names, you can use similar item names by prefixing the name with a #
/echo Example: /macro combine KEEP "Pottery Wheel" #water #ceramic #clay
/endmacro

Sub Event_COMBINE_DNC
/echo That recipe appears to be invalid, please check and try again.
/call COMBINE_Finish
/return

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Oct 21, 2003 1:30 pm

You've hit the nail on the head so to speak. The problem is speed.

MacroQuest runs substantially faster than EverQuest. This is due to the fact that MQ is small, and runs on the local machine instead of having to communicate with a remote server.

When you run any macro using /click the speed of the EQ client (based on your computer speed) and the speed of your network connection (lag) affect how quickly EQ can recognize that a click has been performed. The usual practice is to insert a /delay after any /click, giving EQ time to recognize that the mouse has been clicked and that an item is either on the cursor or no longer on the cursor.

Typical setting for a fast machine is to place /delay 2 after any /click. On a slower computer, or one with more network lag, it may need to be as high as 8.

Example. Using the same computer, and the same macro, my rather rudimentary smithing macros require a /delay 2 after /click left when I'm using a cable modem. Using a dialup I have to increase that to /delay 8.

A slower computer would cause similar problems, based on the fact that the EQ client is running slower and would require more time to recognize a click has been performed.
MQ2: Think of it as Evolution in action.

Zelker
a lesser mummy
a lesser mummy
Posts: 38
Joined: Fri Jan 03, 2003 3:01 pm

Post by Zelker » Tue Oct 21, 2003 3:48 pm

I think I noticed something similiar to what Shocky is refering to on the click combine delay. All my combine macros have a /delay 2 after a /click left place item type command. However when I need to do a /click left eviro combine it needs a /delay 5 after it. This is with any macro combining 2-8 items. At first I thought it was due to the minimum combination delay that was implemented, but with 8 items it take plenty of time yet still needs an extra 3 delay after the combine command to finish correctly. *shrugs Never could figure out what was cause for the extra time needed.

Zelker

EqMule
Developer
Developer
Posts: 2697
Joined: Fri Jan 03, 2003 9:57 pm
Contact:

Post by EqMule » Wed Oct 22, 2003 4:15 pm

well I looked at this "problem" when I had to write a macro for something that is nerfed now, but anyway, I have fast machines, i have slow machines, and the /delay I mostly (is that a real word?) use is 0 and it works like a charm.. your problem is not really MQ or EQ, its your macro...

If you want to make your macro work on all "speeds" you need to put in support for that.

example: (code that takes care of the problem with fast/slow computers are marked with yellow in a few example places...)

Code: Select all

Sub Combine
:startcombine
:clearcursor
/if $cursor()==TRUE {
	/autoinv
	/delay 0
	/goto :clearcursor
}
/if n $count("Small Loaf of Bread")==0 /return
/if n $count("Water Flask")==0 /return

:pickupstone
/sendkey down ctrl
/finditem "Small Loaf of Bread"
[color=yellow]:waitforfindingbread
/delay 0
/if $find()!=TRUE /goto :waitforfindingstone[/color]

[color=yellow]:waitforputtingbreadoncursor
/if "$cursor(name)"!="Small Loaf of Bread" {
	/delay 0
	/goto :waitforputtingbreadoncursor
}[/color]
/sendkey up ctrl
/call Placeit "Small Loaf of Bread"

:pickupwater
/sendkey down ctrl
/finditem "Water Flask"
[color=yellow]:waitforfindingwater
/delay 0
/if $find()!=TRUE /goto :waitforfindingwater
:waitforputtingwateroncursor
/if "$cursor(name)"!="Water Flask" {
	/delay 0
	/goto :waitforputtingwateroncursor
}[/color]
/sendkey up ctrl
/call Placeit "Water Flask"

:clickcombine
/if $gm==TRUE /call Crap
/varset combinedonetimer 12
/delay 0
/click left pack 7 combine
[color=yellow]:WaitCombine
/delay 0
/if n @combinedonetimer==0 /goto :clickcombine
/if $pack(7,empty)!=TRUE /goto :WaitCombine[/color]
/delay 0
:clearcursor0
/if $cursor()==TRUE {
	/autoinv
	/delay 0
	/goto :clearcursor0
}
/goto :startcombine
I dont wanna include the Placit sub, but it uses the same principles and logic with waiting for things to happen instead of delays as the above code and sell sub code......

and if you are gonna buy or sell stuff:

Code: Select all

Sub Sell
/if $gm==TRUE /call Crap
:targetloop
/target "Jangus Clawfinger"
/delay 0
/if "$target(name,clean)"!="Jangus Clawfinger" /goto :targetloop
[color=yellow]:openmerchantloop
/rclicktarget
/if $gm==TRUE /call Crap
/delay 2
/if $merchant(open)!=TRUE /goto :openmerchantloop[/color]

/varset combinedonetimer 60
:selectloop
/if n @combinedonetimer==0 /goto :sellloop
/if $gm==TRUE /call Crap
/if $selecteditem==NULL /goto :selectloop

:sellloop
/if n $count("Soaked Bread")==0 {
	/if n $count("@Gem")!=0 {
		:waitforclosing
		/click left merchant done
		/delay 0
		/if "$merchant(open)!"="FALSE" /goto :waitforclosing
	}
/return
}
/finditem "Soaked Bread"
:waitforfinding
/if $gm==TRUE /call Crap
/if $find()!=TRUE /goto :waitforfinding

/if "$selecteditem"=="Soaked Bread" /sellitem 1

:waitforsale
/if "$selecteditem"!="NULL" {
/if $gm==TRUE /call Crap
/goto :waitforsale
}
/goto :sellloop
anyway anyone can adapt their code to not use delays or events when it comes to buying and selling and combining... the above code is a little bit sloppy but its the best I can do to show one way of doing this, the macro gurus here can probably find both potential scenarios where this code will hang or macro end but overall it should give you an idea of what you can do to make your macro stable on all types of machines.

Quiz:

/if "$selecteditem"=="Soaked Bread" /sellitem 1

How can you improve that piece of code to be sure it really is selected not just "found"

a. use Super Glue.
b. Send the code to counseling and have it fix itself.
c. change the Double type into Int
d. use a loop to wait for it to become selected.

Copyright 2003 Dummies 101: macroing ;)
My status o/
If you like MQ2 and would like to contribute, please do. My goal is 25 donations per month.
So far I've received Image donations for this month's patches.

Bitcoin: 1Aq8ackjQ4f7AUvbUL7BE6oPfT8PmNP4Zq
Krono: PM me.
I can always use characters for testing, PM me if you can donate one.