Help adapting a script

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

BigDaddyDinDin
orc pawn
orc pawn
Posts: 11
Joined: Fri Aug 27, 2004 3:22 pm
Location: USA

Help adapting a script

Post by BigDaddyDinDin » Fri Aug 27, 2004 3:29 pm

I think I am going to adapt the Hunter Macro for use with a caster class such as a Magician or a BeastLord.....possibly even a Necro. Definately a pet class though.

I am not much for coding but I have a decent idea of how these things work. I am going to ask for help even after I searched and read I still didnt get the complete mechanics of it. Can you tell me in the Hunter script I am posting here how I could modify it to cast spells and summon a pet? Is this system set up where I can just cut from one script, and use it in another fairly eaisly? If so a few of the scripts that came up in my search I might be able to cut and paste from.

I would like to start programing myself so if you could just give me an example of where it could go in the following script I would be grateful.

Or, if you could just point me to a good script that is proven to work that I could cut and paste from that would be great.

Code: Select all

 Hunter Macro 
| Hunter.mac 
| Author      : robdawg 
| Version     : v1.2 2004-05-13 10:06pm PST 
| Useage      : /macro Hunter 
| Description : This macro will run your character around killing any mobs in your 
|      RV_MobArray.  Then it will attempt to loot all items in your 
|      RV_LootArray.  This is definitely a work in progress and I am sure 
|      someone can think of plenty of upgrades for this. 
|------------------------------------------------------------------------------------ 

#turbo 10 

Sub Main 

   |------------------------------------------------------------ 
   |How many times should aquire target fail before delaying? 
   |------------------------------------------------------------ 
   /declare RV_FailMax          int outer  3 
   |------------------------------------------------------------ 
   |How far would you like to target a mob? 
   |------------------------------------------------------------ 
   /declare RV_MaxRadius        int outer  3000 
   |------------------------------------------------------------ 
   |How far is the combat range? 
   |------------------------------------------------------------ 
   /declare RV_Range            int outer 10 
   |------------------------------------------------------------ 
   |What is the minimum Z Value of mobs I should target? 
   |------------------------------------------------------------ 
   /declare RV_MinZRange        int outer  -1000 
   |------------------------------------------------------------ 
   |What is the maximum Z Value of mobs I should target? 
   |------------------------------------------------------------ 
   /declare RV_MaxZRange        int outer  1000 
   |------------------------------------------------------------ 
   |Should I loot all items? 
   |------------------------------------------------------------ 
   /declare RV_LootAllItems     int outer  0 
   |------------------------------------------------------------ 
   |Should I display stats? 
   |------------------------------------------------------------ 
   /declare RV_DisplayStats     int outer  1 

   |------------------------------------------------------------ 
   |Loot Array Information. 
   |------------------------------------------------------------ 
   /call ReadINI HunterMob.ini "${Zone.Name}" Mob 
   /if (!${Defined[RV_MobArray]}) { 
      /echo Mob Array Creation Error, ending macro... 
      /endmacro 
   } 

   |------------------------------------------------------------ 
   |Mob Array Information. 
   |------------------------------------------------------------ 
   /call ReadINI HunterLoot.ini "${Zone.Name}" Loot 
   /if (!${Defined[RV_LootArray]}) { 
      /echo No Loot Array Created... 
   } 

   |------------------------------------------------------------ 
   |Variables that you don't need to worry about. 
   |------------------------------------------------------------ 
   /declare RV_FailCounter      int outer  0 
   /declare RV_MyTargetID       int outer  0 
   /declare RV_MyTargetName     string outer 
   /declare RV_MyTargetDead     int outer  0 
   /declare RV_InvalidTargetID  int outer  0 
   /declare RV_HasTarget        int outer  0 
   /declare RV_RandomWait       int outer  0 
   /declare RV_LootSlot         int outer  0 
   /declare RV_CheckLook        int outer  0 
   /declare RV_Fighting         int outer  0 
   /declare RV_TargetDead       int outer  0 
   /declare RV_MyXLOC           int outer  0 
   /declare RV_MyYLOC           int outer  0 
    
   /declare RV_FastRange        int outer 
   /declare RV_RangeMax         int outer 
   /declare RV_RangeMin         int outer 
   /varcalc RV_FastRange ${RV_Range}+3 
   /varcalc RV_RangeMax ${RV_Range}+1 
   /varcalc RV_RangeMin ${RV_Range}-1 

   :Start 
   /doevents 
   /call GMCheck 
   /call GetTarget 

   :KillAdds 
   /if (${RV_HasTarget}) /call MoveToMob 
   /if (${RV_HasTarget}) /call CombatSub 
   /if (${RV_HasTarget}) /call MoveToMob 
   /if (${RV_HasTarget} && (${Defined[RV_LootArray]} || ${RV_LootAllItems})) /call LootMob 
   /if (${RV_DisplayStats}) /call DisplayStats 
   /call ResetSub 

   /varset RV_RandomWait ${Math.Rand[5]} 
   /varcalc RV_RandomWait ${RV_RandomWait}+1 
   /echo Paranoia - Waiting ${RV_RandomWait} seconds before resuming 
   /delay ${RV_RandomWait}s 
    
   /if (${Target.ID}) { 
      /echo Looks like something is attacking us, killing it... 
      /delay 1s 
      /varset RV_HasTarget 1 
      /varset RV_Fighting 1 
      /goto :KillAdds 
   } 
    
   /goto :Start 
    
/return 

|-------------------------------------------------------------------------------- 
|SUB: Aquire Target 
|-------------------------------------------------------------------------------- 
Sub GetTarget 

   /declare RV_CurrentRadius   int local 
   /declare RV_TargetSub   int local 
   :Acquire 
   /for RV_CurrentRadius 100 to ${RV_MaxRadius} step 100 
      /for RV_TargetSub 1 to ${RV_MobArray.Size} 
         /squelch /target radius ${RV_CurrentRadius} nopcnear notid ${RV_InvalidTargetID} npc "${RV_MobArray[${RV_TargetSub}]}" 
         /varset RV_MyTargetID ${Target.ID} 
         /varset RV_MyTargetDead 0 
         /if (${Target.ID}) { 
            /if (${Int[${Target.PctHPs}]}<100) { 
               /echo Mob NOT a Full Health, picking another... 
               /varset RV_InvalidTargetID ${Target.ID} 
               /call ResetSub 
               /goto :Acquire 
            } 
            /if (${Int[${Target.Z}]}<${RV_MinZRange}) { 
               /echo Mob is BELOW Min Z Range, picking another... 
               /varset RV_InvalidTargetID ${Target.ID} 
               /call ResetSub 
               /goto :Acquire 
            } 
            /if (${Int[${Target.Z}]}>${RV_MaxZRange}) { 
               /echo Mob is ABOVE Max Z Range, picking another... 
               /varset RV_InvalidTargetID ${Target.ID} 
               /call ResetSub 
               /goto :Acquire 
            } 
            /varset RV_HasTarget 1 
            /varset RV_MyTargetName ${Target.CleanName} 
            /echo Acquired ${Target.CleanName} at range ${Int[${Target.Distance}]} 
            /return 
         } 
      /next RV_TargetSub 
      /delay 2 
   /next RV_CurrentRadius 

   /if (!${Target.ID}) { 
      /delay 2s 
      /varcalc RV_FailCounter ${RV_FailCounter}+1 
      /echo Failed to Acquire Target in Range ${RV_MaxRadius} ${RV_FailCounter} Time(s) 
      /if (${RV_FailCounter}>=${RV_FailMax}) { 
         /echo Waiting for Respawns, Resetting Failure Counter... 
         /delay 60s 
         /varset RV_FailCounter 0 
      } 
      /goto :Acquire 
   } 
/return 

|-------------------------------------------------------------------------------- 
|SUB: Moving 
|-------------------------------------------------------------------------------- 
Sub MoveToMob 

   /varset RV_MyXLOC ${Int[${Me.X}]} 
   /varset RV_MyYLOC ${Int[${Me.Y}]} 
   /declare RV_DistanceTimer timer 15 
    
   /doevents 
    
   :MovementLoop 

   /if ((!${RV_Fighting})&&(!${RV_TargetDead})&&(${Target.PctHPs}<100)) { 
      /echo Mob not at full health, picking another... 
      /varset RV_InvalidTargetID ${Target.ID} 
      /varset RV_HasTarget 0 
      /call ResetSub 
      /return 
   } 

   /if (${Target.ID}) { 
      /face fast 
   } 
   /if (${Int[${Target.Distance}]}>${RV_FastRange}) { 
      /keypress forward hold 
   } 
   /if (${Int[${Target.Distance}]}<${RV_FastRange}&&${Int[${Target.Distance}]}>${RV_RangeMax}) { 
      /keypress forward 
   } 
   /if (${Int[${Target.Distance}]}<${RV_RangeMin}) { 
      /keypress back 
   } 
   /if (!${RV_DistanceTimer}) { 
      /if ((${RV_MyXLOC}==${Int[${Me.X}]})&&(${RV_MyYLOC}==${Int[${Me.Y}]})) /call HitObstacle 
      /varset RV_MyXLOC ${Int[${Me.X}]} 
      /varset RV_MyYLOC ${Int[${Me.Y}]} 
      /varset RV_DistanceTimer 15 
      /goto :Movementloop 
   } 
   /if (${Int[${Target.Distance}]}>${RV_FastRange}) /goto :MovementLoop 

/return 

|-------------------------------------------------------------------------------- 
|SUB: Combat 
|-------------------------------------------------------------------------------- 
Sub CombatSub 

   /echo Attacking Mob NOW! 
   /varset RV_Fighting 1 
   /varset RV_TargetDead 0 
    
   :CombatLoop 
   /doevents 
   /attack on 
    
   /call MoveToMob 
   /call SpecialIT 

   /if (!${Target.ID}) { 
      /attack off 
      /keypress forward 
      /keypress back 
      
      /varset RV_TargetDead 1 
      /varset RV_Fighting 0 
      /delay 1s 
      /target radius 30 corpse 
      /delay 1s 
      /if (!${Target.ID}) { 
         /call ResetSub 
         /return 
      } 
      /face fast 
   } 
   /if (!${RV_TargetDead}) { 
      /goto :CombatLoop 
   } 
    
/return 

|-------------------------------------------------------------------------------- 
|SUB: Special Combat 
|-------------------------------------------------------------------------------- 
Sub SpecialIt 

   /declare TempID    int inner  0 

   /if ((${Target.Distance}<11)&&(${Me.AbilityReady["Bash"]})) /doability "Bash" 
    
   /if ((${Int[${Me.PctHPs}]}<50)&&(${Me.Gem["Light of Nife"]})&&(${Me.SpellReady["Light of Nife"]})) { 
      /varset TempID ${Target.ID} 
      /keypress forward 
      /keypress back 
      /keypress F1 
      /echo Casting Heal Spell because of low health... 
      /cast "Light of Nife" 
      /delay 3s 
      /target id ${TempID} 
   } 
    
/return 

|-------------------------------------------------------------------------------- 
|SUB: Looting 
|-------------------------------------------------------------------------------- 
Sub LootMob 

   /declare LootSlot    int inner  0 
   /declare LootCheck   int inner  0 
   /declare LootTotal   int inner  0 
    
   /face fast 
    
   /keypress forward 
   /keypress back 
    
   /fastdrop on 
   /lootn never 
   /delay 2s 
   /loot 
   /delay 2s 
   /if (!${Corpse.Items}) { 
      /echo NO LOOT! Cheap Bastard! 
      /return 
   } 

   /varset LootTotal ${Corpse.Items} 
   /for LootSlot 1 to ${LootTotal} 
      /itemnotify loot${LootSlot} leftmouseup 
      /delay 1s 
      /if (${RV_LootAllItems}) { 
         /echo Keeping a ${Cursor.Name}... WOOT! 
         /autoinventory 
         /delay 1s 
      } else { 
         /for LootCheck 1 to ${RV_LootArray.Size} 
            /if (${Cursor.Name.Find[${RV_LootArray[${LootCheck}]}]}) { 
               /echo Keeping a ${Cursor.Name}... WOOT! 
               /varcalc RV_LootStats[${LootCheck}] ${RV_LootStats[${LootCheck}]}+1 
               /autoinventory 
               /delay 1s 
            } 
         /next LootCheck 
      } 
      /if (${Cursor.ID}) { 
         /echo Destroying a ${Cursor.Name}... 
         /destroy 
         /delay 1s 
      } 
   /next LootSlot 
    
   /notify LootWnd DoneButton leftmouseup 
   /delay 2 
    
/return 

|-------------------------------------------------------------------------------- 
|SUB: Reset 
|-------------------------------------------------------------------------------- 
Sub ResetSub 

   /keypress esc 
   /keypress esc 
   /keypress esc 
   /keypress esc 
    
   /varset RV_HasTarget 0 
   /varset RV_TargetDead 0 
   /varset RV_Fighting 0 
    
/return 

|-------------------------------------------------------------------------------- 
|SUB: Obstacle Avoidance 
|-------------------------------------------------------------------------------- 
Sub HitObstacle 

   /echo Obstacle hit, moving around it... 
   /keypress forward 
   /keypress back hold 
   /delay 3 
   /keypress back 
   /if (${Math.Rand[100]}+1>50) { 
     /keypress strafe_right hold 
   } else { 
     /keypress strafe_left hold 
   } 
   /delay 5 
   /keypress strafe_right 
   /keypress strafe_left 
   /keypress forward hold 
    
/return 

|-------------------------------------------------------------------------------- 
|SUB: GM Check 
|-------------------------------------------------------------------------------- 
Sub GMCheck 

   /if (${Spawn[gm].ID}) { 
      /beep 
      /beep 
      /beep 
      
      /echo GM has entered the zone! 
      /echo FUCK HIM but ending the macro... 

      /keypress forward 
      /keypress back 

      /quit 
      /endmacro 
   } 
    
/return 

|-------------------------------------------------------------------------------- 
|SUB: Reading from an INI File 
|-------------------------------------------------------------------------------- 
Sub ReadINI(FileName,SectionName,ArrayType) 

   /echo Attempting to Read Section "${SectionName}" Zone Information from ${FileName}... 
   /delay 1s 
    
   /if (${Ini[${FileName},${SectionName},-1,NO].Equal[NO]}) { 
      /echo "${SectionName}" is not a Valid Section for FILE:${FileName}, ending macro... 
      /delay 1s 
      /return 
   } 
   /declare nValues     int local  1 
   /declare nArray      int local  0 
   /declare KeySet      string local  ${Ini[${FileName},${SectionName}]} 

   :CounterLoop 
   /if (${String[${Ini[${FileName},${SectionName},${ArrayType}${nValues}]}].Equal[null]}) { 
      /varcalc nValues ${nValues}-1 
      /goto :MakeArray 
   } 
   /varcalc nValues ${nValues}+1 
   /goto :CounterLoop  

   :MakeArray 
   /if (!${nValues}) /return 
   /if (${FileName.Equal["HunterMob.ini"]}&&${nValues}>0) { 
      /echo Declaring Mob Array... 
      /declare RV_MobArray[${nValues}]   string outer 
      /declare RV_MobStats[${nValues}]   string outer 
   } 
   /if (${FileName.Equal["HunterLoot.ini"]}&&${nValues}>0) { 
      /echo Declaring Loot Array... 
      /declare RV_LootArray[${nValues}]  string outer 
      /declare RV_LootStats[${nValues}]  string outer 
   } 
   /for nArray 1 to ${nValues} 
      /if (${FileName.Equal["HunterMob.ini"]}) { 
         /varset RV_MobArray[${nArray}] ${Ini[${FileName},${SectionName},${ArrayType}${nArray}]} 
         /varset RV_MobStats[${nArray}] 0 
      } 
      /if (${FileName.Equal["HunterLoot.ini"]}) { 
         /varset RV_LootArray[${nArray}] ${Ini[${FileName},${SectionName},${ArrayType}${nArray}]} 
         /varset RV_LootStats[${nArray}] 0 
      } 
   /next nArray 
    
   /echo "${SectionName}" Zone Information Read Successfully from ${FileName}... 
   /delay 1s 
    
/return 

|-------------------------------------------------------------------------------- 
|SUB: Display Stats 
|-------------------------------------------------------------------------------- 
Sub DisplayStats 

   /declare nArray  int local 
    
   /if (${Defined[RV_LootArray]}) { 
      /for nArray 1 to ${RV_LootArray.Size} 
         /echo ${Int[${RV_LootStats[${nArray}]}]} ${RV_LootArray[${nArray}]}'s 
      /next nArray 
   } 
    
/return 


HunterMob.ini 

Code: 
[Eastern Plains of Karana] 
Mob1=Spider 
Mob2=Lion 
Mob3=Griffawn 

[East Commonlands] 
Mob1=Spiderling 

[The Feerrott] 
Mob1=Spider 


HunterLoot.ini 

Code: 
[Eastern Plains of Karana] 
Loot1=Silk 
Loot2=High Quality 
Loot3=Medium Quality 
Loot4=Feather 

[East Commonlands] 
Loot1=Spiderling Silk 

[The Feerrott] 
Loot1=Spiderling Silk 

BigDaddyDinDin
orc pawn
orc pawn
Posts: 11
Joined: Fri Aug 27, 2004 3:22 pm
Location: USA

Post by BigDaddyDinDin » Fri Aug 27, 2004 3:57 pm

I have been looking at the unattended shrink wand camp for a Necro and was wondering how that could be adapted to fit in the script I posted. I am not a great coder....lousy in fact.

Mainly I need a basic generic combat spell script help and a basic summon a pet and get it to attack script help.

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Fri Aug 27, 2004 4:02 pm

I believe there is already a beastlord-specific hunter script out there. (A quick search for "beastlord" yields http://macroquest2.com/phpBB2/viewtopic.php?t=7894 which certainly sounds like a beastlord-specific hunter script to me, though I'm not bst expert.) Perhaps by comparing this script to the one you posted you could find an entering-wedge towards making the modifications you mention.

Terramantian
a ghoul
a ghoul
Posts: 120
Joined: Thu May 13, 2004 6:20 pm

Post by Terramantian » Fri Aug 27, 2004 4:16 pm

wolf5 has done an excellent job with NBH. It's taken my bl from 30 to 52. If you're looking into making any type of pet-hunter, I'd start there rather than hunter. (Nothing against it, I've personally just not used it because I don't usually play melees)

BigDaddyDinDin
orc pawn
orc pawn
Posts: 11
Joined: Fri Aug 27, 2004 3:22 pm
Location: USA

Post by BigDaddyDinDin » Fri Aug 27, 2004 4:21 pm

I have read that one and I still just cannot grasp where the pet summoning and attacking are and where the offensive spells are getting cast.

It is just my inexperience with the code.

BigDaddyDinDin
orc pawn
orc pawn
Posts: 11
Joined: Fri Aug 27, 2004 3:22 pm
Location: USA

Post by BigDaddyDinDin » Fri Aug 27, 2004 4:24 pm

Ok....after a bit of reading of a few posts of raw code I think I am getting this down more than I was.

I am currently looking at Wolf5's BL code. THanks for the heads up about it.

I will see if I can adapt it to a mage as well as a BL.

Terramantian
a ghoul
a ghoul
Posts: 120
Joined: Thu May 13, 2004 6:20 pm

Post by Terramantian » Fri Aug 27, 2004 4:25 pm

The subs are clearly marked.

EG:

Code: Select all

|----------------------------------------------------------------------------
|SUB: MainAttack - Handles the fighting
|----------------------------------------------------------------------------
Sub MainAttack(int targID)
    /declare timeoutcnt1 int local 0
    
    |Any VERY IMPORTANT buffs worn off? ie SoW for fleeing - dont do it to often
    /if ( ${Math.Rand[50]}<=2 ) /call MaintainCriticalSelfBuffs

    |Check to see if its time to check for new target, as we are moving in. (approx every 2 second + processing time)
    /if ( !${initiatedattack} ) {
	    /declare tt int local
	    /varcalc tt ${tickcnt} / 20

	    /declare oID int local
	    /varset oID ${TargetID}
	    /if ( ${tt}>${aqtargcnt} ) {
	       |To prevent doing circles on heavy targetsearching
	       /call MoveLeftStop
	       /call MoveRightStop
	       DEBUG_1 >Checking if any target is closer than the current: ${Spawn[${TargetID}].CleanName} (${TargetID}) ${Spawn[${TargetID}].Distance}...
	 	   /varset aqtargcnt ${tt}
		   /call TargetIt
		   /if (${oID}<>${TargetID}) {
		   	  /if ( ${TargetID}==0 ) {
		   	  	 DEBUG_1 Target Lost
		   	  	 /return 0
		   	  }
		   	  DEBUG_1 Target switched to: ${Spawn[${TargetID}].CleanName}, Lvl: ${Spawn[${TargetID}].Level}, Class: ${Spawn[${TargetID}].Class}
		   }
		}
	}
.
.
.
Is part of the attack code. Going through it all will be tough if you're not experienced with the language... but then so would creating any macro like this.

BigDaddyDinDin
orc pawn
orc pawn
Posts: 11
Joined: Fri Aug 27, 2004 3:22 pm
Location: USA

Post by BigDaddyDinDin » Fri Aug 27, 2004 4:47 pm

Starting to see the hooks. And now I see the pet attack and summon and that sort of thing.

Can anyone point me in the direction of an offensive spell snippet?

I think I have the pet and pet attack hooks down and can adapt them to my needs.

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Fri Aug 27, 2004 5:37 pm

Part of the spell casting is set by hardcoding it into the script.

Code: Select all

|-- Should we nuke when we pull?
#define DO_NUKE_ON_PULL False
|-- Prevent nuking when mana below % to not waste mana
#define NUKE_ABOVE_MANA_PCT 80
|-- Prevent nuking low lvls, they arent worth it
#define NUKE_ABOVE_LEVEL 30
|-- Name of nuke spell
#define NUKE_SPELL "Ice Shard"
|-- Favorite gem spot for the nuke (1-8)
#define NUKE_GEM 2
That should give you a start as to what to look for.

Read through it top to bottom, take your time, and get to understand how it works. Macroing isn't hard to learn to read, but it can be interesting to try and put together if you're unsure of how a statement works.

Good luck.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

Jeegan
orc pawn
orc pawn
Posts: 14
Joined: Tue Aug 24, 2004 3:14 pm

Post by Jeegan » Fri Aug 27, 2004 6:00 pm

Actually I have modified that script to work with my beastlord, there are still a couple things I am working on, such as making the special abilities such as kick and bash and so forth work, and also getting the Avoid Mob Array to work. But other than that, it is decent, it does what the original macro does but also will buff you and your pet and keep you both buffed and heal you and med you after a fight if needed, it doesn't yet heal your pet, but I am working on getting that in there. I personally have tried the NBH and can't get the thing to work. Is there anything special to making it work, short of just running /mac nbh target? Anyway, here is my updated macro.

Code: Select all

| Hunter Macro
| Hunter.mac
| Author      : robdawg
| Version     : v1.2 2004-05-13 10:06pm PST
| Useage      : /macro Hunter
| Description : This macro will run your character around killing any mobs in 

your
|      RV_MobArray.  Then it will attempt to loot all items in your
|      RV_LootArray.  This is definitely a work in progress and I am sure
|      someone can think of plenty of upgrades for this.
|-------------------------------------------------------------------------------

-----
#include spellcast.inc

#turbo 10

Sub Main

   |------------------------------------------------------------
   |How many times should aquire target fail before delaying?
   |------------------------------------------------------------
   /declare RV_FailMax          int outer  3
   |------------------------------------------------------------
   |How far would you like to target a mob?
   |------------------------------------------------------------
   /declare RV_MaxRadius        int outer  3000
   |------------------------------------------------------------
   |How far is the combat range?
   |------------------------------------------------------------
   /declare RV_Range            int outer 10
   |------------------------------------------------------------
   |What is the minimum Z Value of mobs I should target?
   |------------------------------------------------------------
   /declare RV_MinZRange        int outer  -1000
   |------------------------------------------------------------
   |What is the maximum Z Value of mobs I should target?
   |------------------------------------------------------------
   /declare RV_MaxZRange        int outer  1000
   |------------------------------------------------------------
   |Should I loot all items?
   |------------------------------------------------------------
   /declare RV_LootAllItems     int outer  0
   |------------------------------------------------------------
   |Should I display stats?
   |------------------------------------------------------------
   /declare RV_DisplayStats     int outer  1

   |------------------------------------------------------------
   |Loot Array Information.
   |------------------------------------------------------------
   /call ReadINI HunterMob.ini "${Zone.Name}" Mob
   /if (!${Defined[RV_MobArray]}) {
      /echo Mob Array Creation Error, ending macro...
      /endmacro
   }

   |------------------------------------------------------------
   |Mob Array Information.
   |------------------------------------------------------------
   /call ReadINI HunterLoot.ini "${Zone.Name}" Loot
   /if (!${Defined[RV_LootArray]}) {
      /echo No Loot Array Created...
   }

   |------------------------------------------------------------
   |Avoid Mob Array Information.
   |------------------------------------------------------------
   /call ReadINI HunterAvoidMob.ini "${Zone.Name}"
   /if (!${Defined[AB_AvoidList]}) {
      /echo No Avoid List Array Created...
   }

   |------------------------------------------------------------
   |Variables that you don't need to worry about.
   |------------------------------------------------------------
   /declare RV_FailCounter      int outer  0
   /declare RV_MyTargetID       int outer  0
   /declare RV_MyTargetName     string outer
   /declare RV_MyTargetDead     int outer  0
   /declare RV_InvalidTargetID  int outer  0
   /declare RV_HasTarget        int outer  0
   /declare RV_RandomWait       int outer  0
   /declare RV_LootSlot         int outer  0
   /declare RV_CheckLook        int outer  0
   /declare RV_Fighting         int outer  0
   /declare RV_TargetDead       int outer  0
   /declare RV_MyXLOC           int outer  0
   /declare RV_MyYLOC           int outer  0
   
   /declare RV_FastRange        int outer
   /declare RV_RangeMax         int outer
   /declare RV_RangeMin         int outer
   /declare AB_PetSpellName string outer "Spirit of Sharik"
   /declare AB_Slow string outer "Sha's Advantage"
   /declare AB_NumberOfBuffs int outer 1
   /declare AB_MyBuffs[${AB_NumberOfBuffs}] string outer
   /declare AB_NumberOfPetBuffs int outer 1
   /declare AB_PetBuffs[${AB_NumberOfPetBuffs}] string outer
   /varcalc RV_FastRange ${RV_Range}+3
   /varcalc RV_RangeMax ${RV_Range}+1
   /varcalc RV_RangeMin ${RV_Range}-1

|Buffs to be kept up on self
/varset AB_MyBuffs[1] "Inner Fire"

|Buffs to be kept up on pet   
/varset AB_PetBuffs[1] "Inner Fire"

   /pet hold

   :Start
   /doevents
   /call GMCheck
   /call MaintainBuffs
   /call Heal
   /call Mana
   /call GetTarget

   :KillAdds
   /if (${RV_HasTarget}) /call MoveToMob
   /if (${RV_HasTarget}) /call CombatSub
   /if (${RV_HasTarget}) /call MoveToMob
   /if (${RV_HasTarget} && (${Defined[RV_LootArray]} || ${RV_LootAllItems})) 

/call LootMob
   /if (${RV_DisplayStats}) /call DisplayStats
   /call ResetSub

   /varset RV_RandomWait ${Math.Rand[5]}
   /varcalc RV_RandomWait ${RV_RandomWait}+1
   /echo Paranoia - Waiting ${RV_RandomWait} seconds before resuming
   /delay ${RV_RandomWait}s
   
   /if (${Target.ID}) {
      /echo Looks like something is attacking us, killing it...
      /delay 1s
      /varset RV_HasTarget 1
      /varset RV_Fighting 1
      /goto :KillAdds
   }
   
   /goto :Start
   
/return

|-------------------------------------------------------------------------------

-
|SUB: Aquire Target
|-------------------------------------------------------------------------------

-
Sub GetTarget

   /declare RV_CurrentRadius   int local
   /declare RV_TargetSub   int local
   :Acquire
   /for RV_CurrentRadius 100 to ${RV_MaxRadius} step 100
      /for RV_TargetSub 1 to ${RV_MobArray.Size}
         /squelch /target radius ${RV_CurrentRadius} nopcnear notid 

${RV_InvalidTargetID} npc "${RV_MobArray[${RV_TargetSub}]}"
         /varset RV_MyTargetID ${Target.ID}
         /varset RV_MyTargetDead 0
         /if (${Target.ID}) {
            /if (${Int[${Target.PctHPs}]}<100) {
               /echo Mob NOT a Full Health, picking another...
               /varset RV_InvalidTargetID ${Target.ID}
               /call ResetSub
               /goto :Acquire
            }
            /if (${Int[${Target.Z}]}<${RV_MinZRange}) {
               /echo Mob is BELOW Min Z Range, picking another...
               /varset RV_InvalidTargetID ${Target.ID}
               /call ResetSub
               /goto :Acquire
            }
            /if (${Int[${Target.Z}]}>${RV_MaxZRange}) {
               /echo Mob is ABOVE Max Z Range, picking another...
               /varset RV_InvalidTargetID ${Target.ID}
               /call ResetSub
               /goto :Acquire
            }
            /varset RV_HasTarget 1
            /varset RV_MyTargetName ${Target.CleanName}
            /echo Acquired ${Target.CleanName} at range 

${Int[${Target.Distance}]}
            /return
         }
      /next RV_TargetSub
      /delay 2
   /next RV_CurrentRadius

   /if (!${Target.ID}) {
      /delay 2s
      /varcalc RV_FailCounter ${RV_FailCounter}+1
      /echo Failed to Acquire Target in Range ${RV_MaxRadius} ${RV_FailCounter} 

Time(s)
      /if (${RV_FailCounter}>=${RV_FailMax}) {
         /echo Waiting for Respawns, Resetting Failure Counter...
         /delay 30s
         /varset RV_FailCounter 0
      }
      /goto :Acquire
   }
/return

|-------------------------------------------------------------------------------

-
|SUB: Moving
|-------------------------------------------------------------------------------

-
Sub MoveToMob

   /varset RV_MyXLOC ${Int[${Me.X}]}
   /varset RV_MyYLOC ${Int[${Me.Y}]}
   /declare RV_DistanceTimer timer 15
   
   /doevents

   :MovementLoop

   /if ((!${RV_Fighting})&&(!${RV_TargetDead})&&(${Target.PctHPs}<100)) {
      /echo Mob not at full health, picking another...
      /varset RV_InvalidTargetID ${Target.ID}
      /varset RV_HasTarget 0
      /call ResetSub
      /return
   }
   /if (${Target.ID}) {
      /face fast
   }
   /if (${Int[${Target.Distance}]}>${RV_FastRange}) {
      /keypress forward hold
   }
   /if 

(${Int[${Target.Distance}]}<${RV_FastRange}&&${Int[${Target.Distance}]}>${RV_Ran

geMax}) {
      /keypress forward
   }
   /if (${Int[${Target.Distance}]}<${RV_RangeMin}) {
      /keypress back
   }
   /if (!${RV_DistanceTimer}) {
      /if ((${RV_MyXLOC}==${Int[${Me.X}]})&&(${RV_MyYLOC}==${Int[${Me.Y}]})) 

/call HitObstacle
      /varset RV_MyXLOC ${Int[${Me.X}]}
      /varset RV_MyYLOC ${Int[${Me.Y}]}
      /varset RV_DistanceTimer 15
      /goto :Movementloop
   }
   /if (${Int[${Target.Distance}]}>${RV_FastRange}) /goto :MovementLoop

/return

|-------------------------------------------------------------------------------

-
|SUB: Combat
|-------------------------------------------------------------------------------

-
Sub CombatSub

   /echo Attacking Mob NOW!
   /varset RV_Fighting 1
   /varset RV_TargetDead 0
   /pet attack

   :CombatLoop
   /doevents
   /attack on

   /call MoveToMob
   /call SpecialIT

   /if (!${Target.ID}) {
      /attack off
      /keypress forward
      /keypress back
     
      /varset RV_TargetDead 1
      /varset RV_Fighting 0
      /delay 1s
      /target radius 30 corpse
      /delay 1s
      /if (!${Target.ID}) {
         /call ResetSub
         /return
      }
      /face fast
   }
   /if (!${RV_TargetDead}) {
      /goto :CombatLoop
   }
   
/return

|-------------------------------------------------------------------------------

-
|SUB: Special Combat
|-------------------------------------------------------------------------------

-
Sub SpecialIt

   /declare TempID    int inner  0

   /if ((${Target.Distance}<11)&&(${Me.AbilityReady["Slam"]})) /doability 1

   /if ((${Int[${Me.PctHPs}]}<50)&&(${Me.Gem["Light of 

Nife"]})&&(${Me.SpellReady["Light of Nife"]})) {
      /varset TempID ${Target.ID}
      /keypress forward
      /keypress back
      /keypress F1
      /echo Casting Heal Spell because of low health...
      /cast "Light of Nife"
      /delay 3s
      /target id ${TempID}
   }
   
/return

|-------------------------------------------------------------------------------

-
|SUB: Death
|-------------------------------------------------------------------------------

-
#event Dead "Returning to home point, please wait..."

Sub Event_Dead
   /endmacro
/return

|-------------------------------------------------------------------------------

-
|SUB: Looting
|-------------------------------------------------------------------------------

-
Sub LootMob

   /declare LootSlot    int inner  0
   /declare LootCheck   int inner  0
   /declare LootTotal   int inner  0
   
   /face fast
   
   /keypress forward
   /keypress back
   
   /fastdrop on
   /lootn never
   /delay 2s
   /loot
   /delay 2s
   /if (!${Corpse.Items}) {
      /echo NO LOOT! Cheap Bastard!
      /return
   }

   /varset LootTotal ${Corpse.Items}
   /for LootSlot 1 to ${LootTotal}
      /itemnotify loot${LootSlot} leftmouseup
      /delay 1s
      /if (${RV_LootAllItems}) {
         /echo Keeping a ${Cursor.Name}... WOOT!
         /autoinventory
         /delay 1s
      } else {
         /for LootCheck 1 to ${RV_LootArray.Size}
            /if (${Cursor.Name.Find[${RV_LootArray[${LootCheck}]}]}) {
               /echo Keeping a ${Cursor.Name}... WOOT!
               /varcalc RV_LootStats[${LootCheck}] 

${RV_LootStats[${LootCheck}]}+1
               /autoinventory
               /delay 1s
            }
         /next LootCheck
      }
      /if (${Cursor.ID}) {
         /echo Destroying a ${Cursor.Name}...
         /destroy
         /delay 1s
      }
   /next LootSlot
   
   /notify LootWnd DoneButton leftmouseup
   /delay 2
   
/return

|-------------------------------------------------------------------------------

-
|SUB: Healing
|-------------------------------------------------------------------------------

-
Sub Heal
   
/declare TempID    int inner  0

   /if ((${Int[${Me.PctHPs}]}<=40)&&(${Me.Gem["Minor 

Healing"]})&&(${Me.SpellReady["Minor Healing"]})) {
      /varset TempID ${Target.ID}
      /keypress Esc
      /keypress F1
      :HealLoop
      /echo Casting Heal Spell because of low health...
      /cast "Minor Healing"
      /delay 3s
      /if (${Me.PctMana}<5) /call Mana
      /if (${Me.PctHPs}<85) /goto :HealLoop      
      /keypress Esc
   }   

/return

|-------------------------------------------------------------------------------

-
|SUB: Mana Regen
|-------------------------------------------------------------------------------

-
Sub Mana
   
   /if (${Me.PctMana}<=20) {
        /book
   :ManaLoop
        /delay 1
        /if (${Me.PctMana}<65) /goto :ManaLoop
           }
   /stand

/return

|-------------------------------------------------------------------------------

-
|SUB: Reset
|-------------------------------------------------------------------------------

-
Sub ResetSub

   /call MaintainBuffs
   /keypress esc
   /keypress esc
   /varset RV_HasTarget 0
   /varset RV_TargetDead 0
   /varset RV_Fighting 0
   /doevents

/return

|-------------------------------------------------------------------------------

-
|SUB: MaintainBuffs
|-------------------------------------------------------------------------------

-
Sub MaintainBuffs
/declare PetBuffLoop    int inner  0
/declare MyBuffLoop    int inner  0
/declare iCount int 1
/declare tmp
/doevents
   /for MyBuffLoop 1 to ${AB_NumberOfBuffs}
      /if (!${Me.Buff[${AB_MyBuffs[${iCount}]}].ID}) {
         /target ${Me}
         /call Cast ${AB_MyBuffs[${iCount}]}
         /delay 1s
         /doevents
      }
      /varcalc iCount ${iCount}+1
   /next MyBuffLoop

   /varset iCount 1

   |If we have pet, make one     
   /if ( !${Me.Pet.ID} ) {
         /echo Creating new pet
         /call Cast ${AB_PetSpellName}
         /delay 1s
         /doevents
   }
   /for PetBuffLoop 1 to ${AB_NumberOfPetBuffs}
      /if (!${Me.PetBuff[${AB_PetBuffs[${iCount}]}]}) {
         /target ${Me.Pet.Name}
         /call Cast ${AB_PetBuffs[${iCount}]}
         /delay 1s
         /doevents
      }
      /varcalc iCount ${iCount}+1
   /next PetBuffLoop
/keypress esc

/return

|-------------------------------------------------------------------------------

-
|SUB: Obstacle Avoidance
|-------------------------------------------------------------------------------

-
Sub HitObstacle

   /echo Obstacle hit, moving around it...
   /keypress forward
   /keypress back hold
   /delay ${Math.Calc[${Math.Rand[5]}+6]}
   /keypress back
   /if (${Math.Rand[2]}) {
     /keypress strafe_right hold
     /keypress forward hold
   } else {
     /keypress strafe_left hold
     /keypress forward hold
   }
   /delay ${Math.Calc[${Math.Rand[15]}+12]}
   /keypress strafe_right
   /keypress strafe_left
   
/return

|-------------------------------------------------------------------------------

-
|SUB: GM Check
|-------------------------------------------------------------------------------

-
Sub GMCheck

   /if (${Spawn[gm].ID}) {
      /beep
      /beep
      /beep
     
      /echo GM has entered the zone!
      /echo FUCK HIM but ending the macro...

      /keypress forward
      /keypress back

      /quit
      /endmacro
   }
   
/return

|-------------------------------------------------------------------------------

-
|SUB: Reading from an INI File
|-------------------------------------------------------------------------------

-
Sub ReadINI(FileName,SectionName,ArrayType)

   /echo Attempting to Read Section "${SectionName}" Zone Information from 

${FileName}...
   /delay 1s
   
   /if (${Ini[${FileName},${SectionName},-1,NO].Equal[NO]}) {
      /echo "${SectionName}" is not a Valid Section for FILE:${FileName}, ending 

macro...
      /delay 1s
      /return
   }
   /declare nValues     int local  1
   /declare nArray      int local  0
   /declare KeySet      string local  ${Ini[${FileName},${SectionName}]}

   :CounterLoop
   /if (!${KeySet.Arg[${nValues},|].Length}) {
      /varcalc nValues ${nValues}-1
      /goto :MakeArray
   }
   /varcalc nValues ${nValues}+1
   /goto :CounterLoop 

   :MakeArray
   /if (!${nValues}) /return
   /if (${FileName.Equal["HunterMob.ini"]}&&${nValues}>0) {
      /echo Declaring Mob Array...
      /declare RV_MobArray[${nValues}]   string outer
      /declare RV_MobStats[${nValues}]   string outer
   }
   /if (${FileName.Equal["HunterLoot.ini"]}&&${nValues}>0) {
      /echo Declaring Loot Array...
      /declare RV_LootArray[${nValues}]  string outer
      /declare RV_LootStats[${nValues}]  string outer
   }
   /if (${FileName.Equal["HunterAvoidMob.ini"]}&&${nValues}>0) {
      /echo Declaring AvoidMob Array...
      /declare AB_AvoidList[${nValues}]  string outer 
   }
   /for nArray 1 to ${nValues}
      /if (${FileName.Equal["HunterMob.ini"]}) {
         /varset RV_MobArray[${nArray}] 

${Ini[${FileName},${SectionName},${ArrayType}${nArray}]}
         /varset RV_MobStats[${nArray}] 0
      }
      /if (${FileName.Equal["HunterLoot.ini"]}) {
         /varset RV_LootArray[${nArray}] 

${Ini[${FileName},${SectionName},${ArrayType}${nArray}]}
         /varset RV_LootStats[${nArray}] 0
      }
      /if (${FileName.Equal["HunterAvoidMob.ini"]}) {
         /varset AB_AvoidList[${nArray}] 

${Ini[${FileName},${SectionName},${KeySet.Arg[${nArray},|]},NULL]}
         /echo ${AB_AvoidList[${nArray}]}
      }
   /next nArray
   
   /echo "${SectionName}" Zone Information Read Successfully from ${FileName}...
   /delay 1s
   
/return

|-------------------------------------------------------------------------------

-
|SUB: Display Stats
|-------------------------------------------------------------------------------

-
Sub DisplayStats

   /declare nArray  int local
   
   /if (${Defined[RV_LootArray]}) {
      /for nArray 1 to ${RV_LootArray.Size}
         /echo ${Int[${RV_LootStats[${nArray}]}]} ${RV_LootArray[${nArray}]}'s
      /next nArray
   }
   
/return

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Fri Aug 27, 2004 7:58 pm

In snippets there is an INC file that you can attach which already is set to activate abilities, just have to set up the parameters in your macro. That or rip it for the parts you specifically need.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!