imbue.mac (Imbue/Enchant macro)

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

imbue.mac (Imbue/Enchant macro)

Post by kagonis » Wed Oct 22, 2003 6:30 pm

This macro is untested at the moment, but it should work ;)

Please note that even though it requires you to feed it with the item name, it will Imbue/Enchant everything it can untill the spell runs out of components. It only uses the Component Name to check how many is left, and if it should use Mass or Single Imbue/Enchant.

It will stop up and med up every time it runs out of mana, and continue when it has medded to full mana.

It will also sit between each cast to conserve mana. I know some will say that it's minimal what you will gain from that, but you will never the less gain some from it. It will offcourse not sit between each cast if you are on a mount.

Only one thing should perhaps be added, but that I myself don't need, and that is a limit of how many it should enchant.
I tend to only put whatever in my inventory that I wish to enchant, some might want it to only enchant the number they want it to.
This should be easy to calculate by taking a dump of the number of items in the inventory before actually starting the casting loop, and store that number. Then on each loop check if @Original-@Current==@Limit.
Or you could merely do an incrementing variable on each loop (however then you need to take into account recasts).

Code: Select all

#turbo 
#event NOCOMPONENT "You are missing some required spell components." 
#event NOSPELL "You do not seem to have that spell memorized." 
#event NOMANA "Insufficient Mana to cast this spell!" 
#event INTERRUPTED "Your spell is interrupted." 
#event FIZZLED "Your spell fizzles!" 

Sub Main 
|+ Declaring all variables. 
|-------------------------------------------------- 
   /declare mount global 
   /declare recast global 
   /declare mass global 
   /declare spellname global 
   /declare itemname global 
   /declare tmpspellname global 
|---------- 

|+ (Re-)Setting default values 
|-------------------------------------------------- 
   /varset mount 0 
   /varset recast 0 
   /varset mass 0 
   /varset spellname 0 
   /varset tmpspellname 0 
   /varset itemname 0 
|---------- 

|+ Do some simple checking before starting. 
|-------------------------------------------------- 
   /if "$defined(Param1)"=="FALSE" /call Syntax 
   /if "$defined(Param1)"=="TRUE" /varset itemname "@Param1" 
   /if n $char(gem,"@Param0")>0 /varset spellname "@Param0" 
   /if n $char(gem,"Mass @spellname")>0 /varset mass 1 
   /if n $char(buff,"Summon Horse")>0 /varset mount 1 
   /if n @mount==0 /if n $char(buff,"Summon Drogmor")>0 /varset mount 1 
|---------- 
|+ Run the imbue/enchant loop. 
|-------------------------------------------------- 
   :Loop 
      /if "$char(state)"!="STAND" /stand 
      /if n @mass==1 /if n $count("@itemname")>=5 { 
         /varset tmpspellname "Mass @spellname" 
      } else { 
         /varset tmpspellname "@spellname" 
      } 
      /cast "@tmpspellname" 
      /doevents 
      /if n @recast==1 { 
         /varset recast 0 
         /goto :Loop 
      } 
      /delay $calc($spell("@tmpspellname",casttime)+1)s    
      /doevents 
      /if n @recast==1 { 
         /varset recast 1 
         /goto :Loop 
      } 
      /if n @mount==0 /if $char(state)!="SIT" /sit 
      /click left auto 
      /delay $calc($spell("@tmpspellName",recoverytime)+5)s 
   /goto :Loop 
|---------- 
/return 

Sub Syntax 
   /echo Syntax: /macro imbue "Single Imbue/Enchant Component Spellname" "Component Name" 
   /echo Example: /macro imbue "Enchant Clay" "Large Block of Clay" 
   /echo You are recommended to memorize both the "Mass Imbue/Enchant" and the "Single Imbue/Enchant" spell, if you have it. 
   /echo The macro will automatically use the right one, according to the number of components left to imbue/enchant. 
   /endmacro 
/return 

Sub Event_NOMANA 
   /varset recast 1 
   /if "$char(state)"!="SIT" /if n @mount==0 /sit 
   :Loop 
      /delay 6s 
   /if n $char(mana,cur)<$char(mana,max) /goto :Loop 
/return 

Sub Event_FIZZLED 
   /varset recast 1 
/return 

Sub Event_INTERRUPTED 
   /varset recast 1 
/return 

Sub Event_NOSPELL 
   /endmacro 
/return 

Sub Event_NOCOMPONENT 
   /endmacro 
/return
Last edited by kagonis on Fri Oct 24, 2003 7:52 pm, edited 1 time in total.

User avatar
FreQuency
a hill giant
a hill giant
Posts: 215
Joined: Tue Sep 23, 2003 6:03 pm

Post by FreQuency » Wed Oct 22, 2003 11:31 pm

Nice code but there were a few small errors, all corrected now(me thinks)

~forgot to declare tmpspellname
~never passed Param1 into item name
~/cast needed to have variable enclosed in " "s
~fiddled with delays, 2nd delay was ending before spellw as ready causing a lock up(these may still need to be looked at but did work good on my trials)

But overall very nice

Corrected Code

Code: Select all

#turbo 
#event NOCOMPONENT "You are missing some required spell components." 
#event NOSPELL "You do not seem to have that spell memorized." 
#event NOMANA "Insufficient Mana to cast this spell!" 
#event INTERRUPTED "Your spell is interrupted." 
#event FIZZLED "Your spell fizzles!" 

Sub Main 
|+ Declaring all variables. 
|-------------------------------------------------- 
   /declare mount global 
   /declare recast global 
   /declare mass global 
   /declare spellname global 
   /declare itemname global 
   /declare tmpspellname global
|---------- 

|+ (Re-)Setting default values 
|-------------------------------------------------- 
   /varset mount 0 
   /varset recast 0 
   /varset mass 0 
   /varset spellname 0 
   /varset tmpspellname 0
   /varset itemname 0
|---------- 

|+ Do some simple checking before starting. 
|-------------------------------------------------- 
   /if "$defined(Param1)"=="FALSE" /call Syntax 
   /if "$defined(Param1)"=="TRUE" /varset itemname "@Param1"
   /if n $char(gem,"@Param0")>0 /varset spellname "@Param0"
   /if n $char(gem,"Mass @spellname")>0 /varset mass 1 
   /if n $char(buff,"Summon Horse")>0 /varset mount 1 
   /if n @mount==0 /if n $char(buff,"Summon Drogmor")>0 /varset mount 1 
|---------- 
|+ Run the imbue/enchant loop. 
|-------------------------------------------------- 
   :Loop 
      /if "$char(state)"!="STAND" /stand 
      /if n @mass==1 /if n $count("@itemname")>=5 { 
         /varset tmpspellname "Mass @spellname" 
      } else { 
         /varset tmpspellname "@spellname" 
      } 
      /cast "@tmpspellname"
      /doevents 
      /if n @recast==1 { 
         /varset recast 0 
         /goto :Loop 
      } 
      /delay $calc($spell("@tmpspellname",casttime)+1)s	
      /doevents 
      /if n @recast==1 { 
         /varset recast 1 
         /goto :Loop 
      } 
      /if n @mount==0 /if $char(state)!="SIT" /sit 
      /click left auto 
      /delay $calc($spell("@tmpspellName",recoverytime)+5)s
   /goto :Loop 
|---------- 
/return 

Sub Syntax 
   /echo Syntax: /macro imbue "Single Imbue/Enchant Component Spellname" "Component Name" 
   /echo Example: /macro imbue "Enchant Clay" "Large Block of Clay" 
   /echo You are recommended to memorize both the "Mass Imbue/Enchant" and the "Single Imbue/Enchant" spell, if you have it. 
   /echo The macro will automatically use the right one, according to the number of components left to imbue/enchant. 
   /endmacro 
/return 

Sub Event_NOMANA 
   /varset recast 1 
   /if "$char(state)"!="SIT" /if n @mount==0 /sit 
   :Loop 
      /delay 6s 
   /if n $char(mana,cur)<$char(mana,max) /goto :Loop 
/return 

Sub Event_FIZZLED 
   /varset recast 1 
/return 

Sub Event_INTERRUPTED 
   /varset recast 1 
/return 

Sub Event_NOSPELL 
   /endmacro 
/return 

Sub Event_NOCOMPONENT 
   /endmacro 
/return

Dantuss1

wont mass imbue

Post by Dantuss1 » Tue Oct 28, 2003 11:16 pm

This macro works great for imbueing 1 item at a time.
But it will not use the mass imbue spell.

Example with Imbue Emerald and Mass Imbue Emerald both up and a 10 slot bag full of emeralds this is what happens.

/macro imbue "imbue emerald" "emerald"

It will cast "imbue emerald" instead of "mass imbue emerald"

Other then this it works great.

Am I doing something wrong?

Jaerin
Developer
Developer
Posts: 133
Joined: Mon Mar 10, 2003 7:37 pm
Contact:

Post by Jaerin » Wed Oct 29, 2003 12:37 pm

I don't know what you typed for a command, but you should have both the single and the mass spells memed.

Then call the command with just name of the single.

/macro imbue "Enchant Clay" "Large Block of Clay"

It will check to see if you also have Mass Enchant Clay memorized and use that depending on how many components you have.

You should not use it like:

/macro imbue "Mass Enchant Clay" "Large Block of Clay"

Dunno though...

Wink-
a ghoul
a ghoul
Posts: 122
Joined: Tue Apr 27, 2004 2:41 pm

Post by Wink- » Tue Apr 27, 2004 2:58 pm

Any chance of getting this one working again? I am working on it myself but I am still a super newbie.

bob_the_builder
a hill giant
a hill giant
Posts: 275
Joined: Tue Jul 22, 2003 1:22 pm

Post by bob_the_builder » Tue Apr 27, 2004 5:20 pm

I made this one , its kinda stripped down version. I use it for skill ups and for making items. Can always add to it or use to convert the original

Code: Select all

| castgem.mac
| /macro castgem <gem #>
| Use for skill up
| Use for making items
| Bob_the_builder
| 4/24/04

#include spellcast.inc
#event NoComponents "You are missing some required spell components."

Sub Main
   /declare SpellName global
   /varset SpellName "${Me.Gem[@Param0]}"
   /if (${Me.State.Equal[SIT]}) /stand

   :CheckMana
   /if (${Me.PctMana}<20) /goto :SitDown

   :CheckCursor
   /if (${Cursor.ID}) {
      /autoinv
      /goto :CheckCursor
   }

   :CastSpell
   /call cast "@SpellName"
   /doevents
   /goto :CheckMana

   :SitDown
   /if (${Me.State.Equal[STAND]}) /sit on

   :HowMuchMana
   /if (${Me.PctMana}<98) /goto :HowMuchMana
   /goto :CheckMana
/endmacro

Sub Event_NoComponents
   /popup No More Items to Make
   /endmacro 
/return
Bob

Wink-
a ghoul
a ghoul
Posts: 122
Joined: Tue Apr 27, 2004 2:41 pm

Post by Wink- » Tue Apr 27, 2004 6:05 pm

I finished it with help from Preocts and Lax!
Doh, it does not work for quanties not divisible by 5, but I will fix that later.

Code: Select all


|Remember to open up your inventory prior to starting this.

#turbo 
#event NOCOMPONENT "You are missing some required components." 
#event NOSPELL "You do not seem to have that spell memorized." 
#event NOMANA "Insufficient Mana to cast this spell!" 
#event INTERRUPTED "Your spell is interrupted." 
#event FIZZLED "Your spell fizzles!" 

Sub Main 
|+ Declaring all variables. 
|-------------------------------------------------- 
   /declare mount global 
   /declare recast global 
   /declare mass global 
   /declare spellname global 
   /declare itemname global 
   /declare tmpspellname global 
|---------- 

|+ (Re-)Setting default values 
|-------------------------------------------------- 
   /varset mount 0 
   /varset recast 0 
   /varset mass 0 
   /varset spellname 0 
   /varset tmpspellname 0 
   /varset itemname 0 
|---------- 

|+ Do some simple checking before starting. 
|-------------------------------------------------- 
|   /if "$defined(Param1)"=="FALSE" /call Syntax 
    /if (${Defined[Param1]}==FALSE) /call Syntax

|   /if "$defined(Param1)"=="TRUE" /varset itemname "@Param1" 
    /if (${Defined[Param1]}) /varset itemname "@Param1" 

|   /if n $char(gem,"@Param0")>0 /varset spellname "@Param0" 
    /if (${Me.Gem["@Param0"]}) /varset spellname "@Param0" 

|   /if n $char(gem,"Mass @spellname")>0 /varset mass 1 
    /if (${Me.Gem["Mass @spellname"]}) /varset mass 1

|   /if n $char(buff,"Summon Horse")>0 /varset mount 1 
    /if (${Me.buff["Summon Horse"]}) /varset mount 1

|   /if n @mount==0 /if n $char(buff,"Summon Drogmor")>0 /varset mount 1 
    /if (${Me.buff["Summon Drogmor"]}) /varset mount 1

|---------- 
|+ Run the imbue/enchant loop. 
|-------------------------------------------------- 
   :Loop 
|      /if "$char(state)"!="STAND" /stand 
       /if (${Me.state[STAND]}==FALSE) /stand

|  
|/if n @mass==1 /if n $count("@itemname")>=5 { 
|         /varset tmpspellname "Mass @spellname" 
|      } else { 
|         /varset tmpspellname "@spellname" 
|      } 
|

        /if (@mass==1) /if (${FindItemCount["@itemname"]}>=5 )  {
	  /varset tmpspellname "Mass @spellname" 
	} else {
	  /varset tmpspellname "@spellname"
	}


      /cast "@tmpspellname" 
      /doevents 

      /if  (@recast==1) { 
         /varset recast 0 
         /goto :Loop 
      } 
|      /delay $calc($spell("@tmpspellname",casttime)+1)s    
       /delay ${Math.Calc[${Spell[@tmpspellName].CastTime}+1]}s


      /doevents 
      /if  (@recast==1) { 
         /varset recast 1 
         /goto :Loop 
      } 
| /if  (@mount==0) (/if $char(state)!="SIT") /sit 
  /if  (@mount==0) /if (${Me.state[SIT]}==FALSE) /sit  

       /click left auto 
|      /delay $calc($spell("@tmpspellName",recoverytime)+5)s 
       /delay ${Math.Calc[${Spell[@tmpspellName].RecoveryTime}+5]}s


   /goto :Loop 
|---------- 
/return 

Sub Syntax 
   /echo Syntax: /macro imbue "Single Imbue/Enchant Component Spellname" "Component Name" 
   /echo Example: /macro imbue "Enchant Clay" "Large Block of Clay" 
   /echo You are recommended to memorize both the "Mass Imbue/Enchant" and the "Single Imbue/Enchant" spell, if you have it. 
   /echo The macro will automatically use the right one, according to the number of components left to imbue/enchant. 
   /endmacro 
/return 

Sub Event_NOMANA 
   /varset recast 1 

|   /if "$char(state)"!="SIT" /if n @mount==0 /sit 
    /if  (@mount==0) /if (${Me.state[SIT]}==FALSE) /sit
   
   :Loop 
      /delay 6s 

|   /if n $char(mana,cur)<$char(mana,max) /goto :Loop 
    /if ((${Me.CurrentMana})<(${Me.MaxMana})) /goto :Loop

/return 

Sub Event_FIZZLED 
   /varset recast 1 
/return 

Sub Event_INTERRUPTED 
   /varset recast 1 
/return 

Sub Event_NOSPELL 
   /endmacro 
/return 

Sub Event_NOCOMPONENT 
   /endmacro 
/return
Thanks to the original author, imbueing a billion emeralds is the lose without it!