GiveCrystals.INC - Have bots give crystals/coin to one toon.

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

Agripa
a ghoul
a ghoul
Posts: 97
Joined: Tue Nov 23, 2004 10:16 pm

GiveCrystals.INC - Have bots give crystals/coin to one toon.

Post by Agripa » Thu Aug 18, 2005 8:00 am

Code: Select all

|* GiveCrystals.INC - http://www.macroquest2.com/phpBB2/viewtopic.php?t=11945
|*
|* 0.30 - 20070719 Agripa - Updated documentation.  I do not remember when I added
|*                          the DoN token code.
|* 0.20 - 20060106 Agripa - Added sender and reciever authorization.
|* 0.10 - 20050818 Agripa
|*
|* This is a simple event which can be used to have multiple bots give all coin or DoN 
|* crystals to one toon.  It relies on an IRC command channel but can use an
|* in game chat channel with suitable modifications to the #event.
|*
|* It also supports having multiple bots give their Norrath's Keepers Tokens to 
|* Tatsujiro the Serene if within about range 50.
|*
|* Notes:
|*
|*    Requires the MQ2MoveUtils plugin to be installed.
|*
|* Installation:
|*
|*    Save as GiveCrystals.INC and use #include GiveCrystals.INC in your macro.
|*
|*       or
|*
|*    Insert the #event and Sub into your macro.
|*
|*    Make a list of toons to accept commands from in the FindS1 declare.
|*
|* Examples:
|*
|*    /i say Give Crystals             
|*    /i say Give Coin
|*    /i say Give Token

#event GiveMe "<#1#> Give #2#"

Sub Event_GiveMe(string line, string 1, string 2)
   /declare I int  local
   /declare J int  local
   /declare K int  local
   /declare L bool local
   /declare FindS1 string local PutAListOfToonNamesToAcceptCommandsFromHere

   /if ( ${1.Equal[${Me.Name}]} ) {
      /echo Give: Can not give to myself.
      /return
   }

   /if ( !${FindS1.Find[${1}]} || !${FindS1.Find[${Me.Name}]} ) {
      /echo Give: Name not authorized.
      /return
   }

   /if ( !${Spawn[PC ${1}].ID} || !${Spawn[PC ${1}].LineOfSight} ) {
      /echo Give: Spawn not valid.
      /return
   }

   /varset L TRUE
   /if ( ${2.Find[crystal]} && ( ${Window[InventoryWindow].Child[IW_GoodPoints].Text} || ${Window[InventoryWindow].Child[IW_EvilPoints].Text} || ${FindItem[Ebon Crystal].InvSlot} || ${FindItem[Radiant Crystal].InvSlot} ) ) /varset L FALSE
   /if ( ${2.Find[coin]} && ${Me.Cash} ) /varset L FALSE
   /if ( ${2.Find[token]} ) /varset L FALSE
   /if ( ${L} ) {
      /echo Give: Nothing to do.
      /return   
   }

   /target id ${Spawn[PC ${1}].ID}

   /if ( ${Me.Sitting}  ) /stand
   /if ( ${Me.Mount.ID} ) /dismount
   /if ( ${Me.Ducking}  ) /keypress duck
   /stick 10 hold
   /delay 1s  ${Me.Moving}
   /delay 6s !${Me.Moving}

   /if ( ${Target.Distance}>15 ) {
      /echo Give: Target too far away after move.
      /return
   }

   /if ( !${Window[InventoryWindow].Open} ) {
      /keypress inventory
      /delay 3s ${Window[InventoryWindow].Open}
   }

   /for I 1 to 6
      /if ( ${Cursor.ID} ) {
         /autoinv
         /delay 1s !${Cursor.ID}
         /varset I 1
      } else {
         /varset I 6
      }
   /next I

   /if ( ${2.Find[crystal]} ) {

      /if ( ${FindItem[Ebon Crystal].InvSlot} || ${FindItem[Radiant Crystal].InvSlot} ) {
         /declare GoodPoints int local ${Window[InventoryWindow].Child[IW_GoodPoints].Text}
         /declare EvilPoints int local ${Window[InventoryWindow].Child[IW_EvilPoints].Text}
         /notify InventoryWindow IW_ReclaimButton leftmouseup
         /delay 1s ( ${GoodPoints}!=${Window[InventoryWindow].Child[IW_GoodPoints].Text} || ${EvilPoints}!=${Window[InventoryWindow].Child[IW_EvilPoints].Text} )
      }

      /if ( ${Window[InventoryWindow].Child[IW_GoodPoints].Text} ) {
         /nomodkey /shiftkey /notify InventoryWindow IW_GoodPoints leftmouseup
         /delay 3s ${Cursor.ID}

         /call Give_GiveItem

      }

      /if ( ${Window[InventoryWindow].Child[IW_EvilPoints].Text} ) {
         /nomodkey /shiftkey /notify InventoryWindow IW_EvilPoints leftmouseup
         /delay 3s ${Cursor.ID}

         /call Give_GiveItem

      }

   }

   /for I 1 to 2
      /if ( ${2.Find[coin]} && ${Me.Cash} ) {
         /for J 0 to 3
            /if ( ${Window[InventoryWindow].Child[IW_Money${J}].Text} ) {
               /echo Give: Getting IW_Money${J}
               /for K 1 to 2
                  /if ( ${Window[InventoryWindow].Child[IW_Money${J}].Text} ) {
                     /nomodkey /shiftkey /notify InventoryWindow IW_Money${J} leftmouseup
                     /delay 1s ( !${Window[InventoryWindow].Child[IW_Money${J}].Text} )
                     /varset K 1
                  } else {
                     /varset K 2
                  }
               /next K
               /call Give_GiveItem coin
            }
         /next J
         /varset I 1
      } else {
         /varset I 2
      }
   /next I

   /if ( ${2.Find[token]} ) {

      /if ( ${FindItem[Norrath's Keepers Token].InvSlot} && ${Spawn[NPC Tatsujiro the Serene].Distance} < 50 ) {

         /if ( !${Window[InventoryWindow].Open} ) {
            /keypress I
            /delay 1s ( ${Window[InventoryWindow].Open} )
         }

         /if ( ${InvSlot[${FindItem[Norrath's Keepers Token].InvSlot}].Pack} && !${Window[${InvSlot[${FindItem[Norrath's Keepers Token].InvSlot}].Pack.Name}].Open} ) {
            /nomodkey /itemnotify ${InvSlot[${FindItem[Norrath's Keepers Token].InvSlot}].Pack} rightmouseup
            /delay 1s ( ${Window[${InvSlot[${FindItem[Norrath's Keepers Token].InvSlot}].Pack.Name}].Open} && ${InvSlot[${FindItem[Norrath's Keepers Token].InvSlot}].Item.ID} )
         }

         /nomodkey /ctrlkey /itemnotify ${FindItem[Norrath's Keepers Token].InvSlot} leftmouseup
         /delay 1s ( ${Cursor.ID} )

         /target NPC Tatsujiro the Serene
         /stick 10 hold
         /delay 1s ( ${Me.Moving} )
         /delay 6s ( !${Me.Moving} )

         /call Give_GiveItem
   
         /if ( ${Window[InventoryWindow].Open} ) {
            /keypress I
            /delay 1s ( !${Window[InventoryWindow].Open} )
         }


      }
         
   }

   /for I 1 to 6
      /if ( ${Window[TradeWnd].Open} ) { 
         /notify TradeWnd TRDW_Trade_Button leftmouseup 
         /delay 1s !${Window[TradeWnd].Open} 
         /varset I 1
      } else {
         /varset I 6
      }
   /next I

   /for I 1 to 6
      /if ( ${Window[GiveWnd].Open} ) {
         /notify GiveWnd GVW_Give_Button leftmouseup 
         /delay 1s !${Window[GiveWnd].Open} 
         /varset I 1
      } else {
         /varset I 6
      }
   /next I

   /if ( ${Window[InventoryWindow].Open} ) {
      /keypress inventory
      /delay 3s !${Window[InventoryWindow].Open}
   }

   /stick off

/return

Sub Give_GiveItem(string options)

   /if ( !${Target.ID} ) {
      /echo Give_GiveItem: No Target
      /return
   }

   /declare I int    local
   /declare J int    local
   /declare L bool   local
   /declare A int    local
   /declare S string local

   /if ( !${Defined[options]} ) /declare options string local

   /if ( ${options.Find[coin]} && !${Cursor.ID} ) {
      /varset S ${Window[TradeWnd].Child[TRDW_MyMoney0].Text}${Window[TradeWnd].Child[TRDW_MyMoney1].Text}${Window[TradeWnd].Child[TRDW_MyMoney2].Text}${Window[TradeWnd].Child[TRDW_MyMoney3].Text}
      /echo Give_GiveItem: ${S}
      /click left target
      /delay 6s ( ${S.NotEqual[${Window[TradeWnd].Child[TRDW_MyMoney0].Text}${Window[TradeWnd].Child[TRDW_MyMoney1].Text}${Window[TradeWnd].Child[TRDW_MyMoney2].Text}${Window[TradeWnd].Child[TRDW_MyMoney3].Text}]} )
      /if ( ${S.Equal[${Window[TradeWnd].Child[TRDW_MyMoney0].Text}${Window[TradeWnd].Child[TRDW_MyMoney1].Text}${Window[TradeWnd].Child[TRDW_MyMoney2].Text}${Window[TradeWnd].Child[TRDW_MyMoney3].Text}]} ) {
         /varset A ${Me.Cash}
         /autoinv
         /delay 6s ( ${Me.Cash}!=${A} )
      }
   }

   /for I 1 to 6
      /if ( ${Cursor.ID} ) {
         /varset J ${Cursor.ID}
         /click left target
         /delay 1s ( !${Cursor.ID} || ${J}!=${Cursor.ID} )
         /varset I 1
      } else {
         /varset I 6
      }
   /next I

   /for I 1 to 6
      /if ( ${Cursor.ID} ) {
         /varset J ${Cursor.ID}
         /autoinv
         /delay 1s ( !${Cursor.ID} || ${J}!=${Cursor.ID} )
         /varset I 1
      } else {
         /varset I 6
      }
   /next I

/return
Last edited by Agripa on Thu Jul 19, 2007 8:34 am, edited 3 times in total.

DigitalMocking
a grimling bloodguard
a grimling bloodguard
Posts: 620
Joined: Mon Apr 04, 2005 5:53 pm

Post by DigitalMocking » Sun Aug 21, 2005 1:28 pm

thanks for this, just makes another annoying task trivial :D

Agripa
a ghoul
a ghoul
Posts: 97
Joined: Tue Nov 23, 2004 10:16 pm

Post by Agripa » Tue Aug 23, 2005 6:40 am

Aye. I am probably going to expand this to automate my crew handing in all of the faction items to the DoN merchant as well as handing all their coin to one toon.