spell_routines.inc ( updated: 11/07/2004 )

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

Hannibal
orc pawn
orc pawn
Posts: 19
Joined: Sat Jul 03, 2004 10:28 pm

Post by Hannibal » Mon Oct 04, 2004 10:11 am

I'm having an issue with /call Cast "Item Name" item and the 'auto-swap' of items. If the item is in a BAG slot, instead of an ITEM slot in a BAG - it won't swap, instead it tries to cast it from inventory.

Code: Select all

   /if ( ${FindItem[${spellName}].InvSlot}>29 ) { 
      /varset swapItemBack true 
      /if ( ${FindItem[${spellName}].WornSlot[1]} ) { 
         /varset slotName ${FindItem[${spellName}].WornSlot[1]} 
      } else { 
         /varset slotName 29 
      } 
      /varset slotID ${InvSlot[${slotName}].ID}      
      /varset oldSlotID ${FindItem[${spellName}].InvSlot.ID} 
      /varset oldItemName ${InvSlot[${slotID}].Item.Name} 
      /call SwapItem "${spellName}" ${slotID} 
   } 
The problem appears to be here, since inventory slots are less than 29. I'm unsure if I can check if the item is inventory castable or not - will keep digging.

Rusty~
a hill giant
a hill giant
Posts: 244
Joined: Wed Apr 14, 2004 2:55 pm

Post by Rusty~ » Wed Oct 06, 2004 6:30 pm

Ok, this latest update should fix the problem above. Also several misc changes I've made over the last month.

Hannibal
orc pawn
orc pawn
Posts: 19
Joined: Sat Jul 03, 2004 10:28 pm

Post by Hannibal » Wed Oct 06, 2004 10:16 pm

NOTE: If this is crashing for you - a temp fix until the next MQ2 zip, is to change:

Code: Select all

      /for i 1 to 9 
         /declare spellRecastTime${i} timer outer 
         /if ( ${Me.SpellReady[${i}]} ) { 
            /varset spellRecastTime${i} 0 
         } else { 
            /varcalc spellRecastTime${i} 10*${Me.Gem[${i}].RecastTime} 
         } 
      /next i 
to

Code: Select all

      /for i 1 to 8 
         /declare spellRecastTime${i} timer outer 
         /if ( ${Me.SpellReady[${i}]} ) { 
            /varset spellRecastTime${i} 0 
         } else { 
            /varcalc spellRecastTime${i} 10*${Me.Gem[${i}].RecastTime} 
         } 
      /next i 
Otherwise, it crashes for people without the 9th slot AA.

Rusty~
a hill giant
a hill giant
Posts: 244
Joined: Wed Apr 14, 2004 2:55 pm

Post by Rusty~ » Thu Oct 07, 2004 12:44 am

Ok changed a few more things. Now it *should* click inventory usable items in your inventory slots without equiping them. Also, should fix the very annoying modrod "destroying" items in your inventory if you have one in a bag and cast it. Tested it out on a raid tonight with a mod rod in bag. Works fine for me now. Problem was, since oow, if you pick a mod rod up right after clicking it, it wasnt updating the charges, and that just ended up messin things up bad... so now it waits for the charges to update before picking it up and putting it back.

On the 9th spell gem.. thanks. I havent tried this out on a character without the 9th spell so didnt know about that. It's not working anyways, as /cast "spell name" isn't working for spells in 9th gem yet. Hopefully this will be fixed soon.. for now I changed it back to 8

Also fixed minor problem with casting spells that have the same name as NPC spells. It will now use ${Me.Casting.ID} while casting to get the recast and recovery info on the spell.

Hannibal
orc pawn
orc pawn
Posts: 19
Joined: Sat Jul 03, 2004 10:28 pm

Post by Hannibal » Thu Oct 07, 2004 8:59 am

The fix for the unable to cast 9th slot by name, is to edit MQ2Commands.cpp

Look for the following code block - it should be line 2958:

Code: Select all

   for (Index=0;Index<8;Index++) {
      if (pCharInfo->MemorizedSpells[Index]!=0xFFFFFFFF) {
         PCHAR SpellName = GetSpellNameByID(pCharInfo->MemorizedSpells[Index]);
         if (!stricmp(szBuffer,SpellName)) {
            DebugSpew("SpellName = %s",SpellName);
            cmdCast(pChar,itoa(Index+1,szBuffer,10));
            DebugSpew("pChar = %x SpellName = %s %s",pChar,SpellName,itoa(Index+1,szBuffer,10));
            return;
         }
      }
   }
Change where it says Index < 8 to Index < 9 - new block should look like:

Code: Select all

   for (Index=0;Index<9;Index++) {
      if (pCharInfo->MemorizedSpells[Index]!=0xFFFFFFFF) {
         PCHAR SpellName = GetSpellNameByID(pCharInfo->MemorizedSpells[Index]);
         if (!stricmp(szBuffer,SpellName)) {
            DebugSpew("SpellName = %s",SpellName);
            cmdCast(pChar,itoa(Index+1,szBuffer,10));
            DebugSpew("pChar = %x SpellName = %s %s",pChar,SpellName,itoa(Index+1,szBuffer,10));
            return;
         }
      }
   }

dman
a hill giant
a hill giant
Posts: 181
Joined: Fri Dec 05, 2003 12:54 pm

Post by dman » Fri Oct 08, 2004 8:20 am

:cast_alt
/if ( !${Me.AltAbilityReady[${spellName}]} ) /return CAST_NOTREADY
/echo Using AA Ability: ${AltAbility[${spellName}].Name}
/alt activate ${AltAbility[${spellName}].ID}

/call WaitCast ${mySub}

/if ( ${castReturn.Equal[CAST_CANCELLED]} ) {
/echo Spell was cancelled...
/return CAST_CANCELLED
}

/doevents BeginCast
/doevents Interrupt
/doevents Standing
/doevents OutOfRange
/doevents NoLOS
/doevents Resisted
/doevents Immune
/doevents Stunned
/doevents NoTarget

/if ( !${castReturn.Equal[CAST_SUCCESS]} ) {
/if ( ${castReturn.Equal[CAST_RESTART]} ) /goto :cast_item_loop
/if ( ${castReturn.Equal[CAST_STUNNED]} ) {
/if ( ${Me.Stunned} ) {
/delay 3s !${Me.Stunned}
} else {
/delay 7
}
/goto :cast_alt
}
/if ( ${castReturn.Equal[CAST_INTERRUPTED]} ) {
/if ( ${giveUpTimer} ) {
/echo Spell was interrupted. Recasting...
/goto :cast_alt_loop
}
/echo Spell was interrupted...
/return CAST_INTERRUPTED
}
}
/return ${castReturn}
While glancing through the code, I notcied these 2 things, while its possible they will never be called, they might want to be changed.
/goto :cast_item_loop from within the AA casting loop? Why would we want to leave it?
/goto :cast_alt_loop, the label :cast_alt_loop doesn't exist...perhaps you want /goto :cast_alt ?
I didn't say you were at fault,
I said I was going to blame you.

Rusty~
a hill giant
a hill giant
Posts: 244
Joined: Wed Apr 14, 2004 2:55 pm

Post by Rusty~ » Fri Oct 08, 2004 12:56 pm

thanks heh.. yeah i kinda copy pasted and missed that part. having aa skills interrupted doesnt happen much but if it did it would have messed things up.

stm69
Secret Asian Man
Posts: 65
Joined: Sun Jan 25, 2004 1:31 am

Post by stm69 » Mon Oct 11, 2004 10:55 am

Hannibal wrote:The fix for the unable to cast 9th slot by name, is to edit MQ2Commands.cpp

Look for the following code block - it should be line 2958:
2598. Thanks!

Rusty~
a hill giant
a hill giant
Posts: 244
Joined: Wed Apr 14, 2004 2:55 pm

Post by Rusty~ » Thu Oct 21, 2004 12:03 am

Ok.... 9th slot thing works now. Also added in special event handling for AE spells. If you are close to a mob and cast something like AE snare and you resist it, it wont return resist (unless of course one or more mobs resist it). This should help a lot for wizards :smile:

Chill
Contributing Member
Contributing Member
Posts: 435
Joined: Fri May 07, 2004 5:06 pm
Location: Erie, PA

Post by Chill » Tue Oct 26, 2004 4:19 pm

One small change I keep making after your updates, is to add the percentage that each spell gets casted at to the echos. I use it to keep track of what my macros are doing and help fine tune them:

Code: Select all

... on >> ${Target.CleanName} << at ${Target.PctHPs}%,]}
Thought it might be helpful for others.

ins
a lesser mummy
a lesser mummy
Posts: 74
Joined: Wed Jun 16, 2004 6:48 pm

NoHold Event

Post by ins » Wed Oct 27, 2004 9:59 am

There is an event defined for spells that won't take hold, but there is no event sub. Easy to add the missing sub, just might want to add it to posted code.

Furiousness
a lesser mummy
a lesser mummy
Posts: 62
Joined: Tue Aug 26, 2003 3:48 pm

Chain Casting?

Post by Furiousness » Wed Oct 27, 2004 10:37 am

Hi,

Could someone post me a quick idea on how to chain cast?

I have a loop that runs two nukes, basically I want to cast the next as soon as the previous has finished, rinse repeat....

But I am getting spammed with "Can't use that command while casting..."

Which from testing seems to be due to it trying to cast still.

I have an if statement in that I thought should stop it,(ignore syntax)
ie if !me.casting.id && me.spellready[nuke] /cast nuke

Alas I am puzzled.

Help appreciated.

Cheers

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Wed Oct 27, 2004 10:41 am

woohoo! yet another chance to test out my psychic abilities! /cheer!

seriously . . . why don't you post your code so we can tell you what's wrong with it.
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]

A_Druid_00
Macro Maker Extraordinaire
Posts: 2378
Joined: Tue Jul 13, 2004 12:45 pm
Location: Rolling on the Lawn Farting

Re: Chain Casting?

Post by A_Druid_00 » Wed Oct 27, 2004 10:47 am

Furiousness wrote:ie if !me.casting.id && me.spellready[nuke] /cast nuke
It looks like he already did, though not quite in a complete format, and lacking /code brackets.

It seems to me, if me.casting.id is TRUE, then me.spellready is going to be false by default anyway. I'm guessing you have them both wrapped up in a /if NOT statement, so it won't work. Though, thinking about it, if that were the case then it should never cast... /shrug

Maybe just try:

Code: Select all

/if ${me.spellready[WTFeveryourspellis]} /cast WTFeveryourspellis


I'm very much an amateur at this though, so I could be totally wrong!
[quote]<DigitalMocking> man, A_Druid_00 really does love those long ass if statements
<dont_know_at_all> i don't use his macro because i'm frightened of it[/quote]
[quote][12:45] <dont_know_at_all> never use a macro when you can really fuck up things with a plugin[/quote]

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Wed Oct 27, 2004 10:55 am

I was thinking the entire sub, as the code actually exists. Just on the off chance that what he typed out didn't quite match up to what he put here.
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]