Bug, crashes on cast spell with macro

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

A Troll
a lesser mummy
a lesser mummy
Posts: 30
Joined: Fri May 21, 2004 10:04 am

Bug, crashes on cast spell with macro

Post by A Troll » Mon Aug 16, 2004 6:22 am

[MQ2]Call - Calling subroutine cast with params "Zevfeer's Bite"
[MQ2]GetFuncParam(1): 'string spellName'
[MQ2]Next - End of loop 1 to 8
[MQ2]Next - End of loop 2 to 8
[MQ2]Next - End of loop 3 to 8
[MQ2]Next - End of loop 4 to 8
[MQ2]Next - End of loop 5 to 8
[MQ2]Next - End of loop 6 to 8
[MQ2]Next - End of loop 7 to 8
[MQ2]Next - End of loop 8 to 8
(d70.20c): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000001 ebx=0012aec8 ecx=03f96d48 edx=0088bd17 esi=00000028 edi=00000001
eip=012eb4da esp=0012ae78 ebp=00000000 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00210202
*** WARNING: Unable to verify checksum for E:\MQ2\MQ2Main.dll
MQ2Main!MQ2CharacterType::GetMember+0xd7a:
012eb4da 8b5024 mov edx,[eax+0x24] ds:0023:00000025=????????
0:000> g
(d70.20c): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000000 ebx=0012aa9c ecx=005d66fc edx=000a6b63 esi=0088f478 edi=005d66fc
eip=004b1064 esp=0012aa48 ebp=0012aa6c iopl=0 nv up ei ng nz ac pe cy
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00210293
*** WARNING: Unable to verify checksum for E:\Games\EverQuest\eqgame.exe
*** ERROR: Module load completed but symbols could not be loaded for E:\Games\EverQuest\eqgame.exe
eqgame+0xb1064:
004b1064 8b38 mov edi,[eax] ds:0023:00000000=????????
0:000> g
[MQ2]MQ2EQBugFix Module Unloaded
[MQ2]MQ2ChatWnd Module Unloaded
[MQ2]MQ2Bzsrch Module Unloaded
[MQ2]MQ2Map Module Unloaded
[MQ2]MQ2HUD Module Unloaded
[MQ2]MQ2CustomBinds Module Unloaded
[MQ2]MQ2ItemDisplay Module Unloaded
[MQ2]MQ2Labels Module Unloaded
eax=76330000 ebx=00000000 ecx=77d10000 edx=00140608 esi=7c91e88e edi=00000000
eip=7c91eb94 esp=0012e758 ebp=0012e854 iopl=0 nv up ei pl zr na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00200246
ntdll!KiFastSystemCallRet:
7c91eb94 c3 ret


Thats what i got with WinDBG.
It crashes if my macro tries to cast an spell on an npc
Maybe it can help you

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Mon Aug 16, 2004 3:18 pm

Two more things I need:

1. Do the crash again and type 'kv' in windbg, also 'r'. Do both of these after the first crash (ie, no need to type 'g' at all).
2. Copy/paste the part of the macro that is causing the crash

....#1 was in the instructions on the board for reporting a crash....

A Troll
a lesser mummy
a lesser mummy
Posts: 30
Joined: Fri May 21, 2004 10:04 am

Post by A Troll » Mon Aug 16, 2004 8:33 pm

There we go :

WinDbg
(fc.848): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000006 ebx=0012aec8 ecx=03b96770 edx=0088bd1b esi=00000028 edi=00000001
eip=012eb4da esp=0012ae78 ebp=00000000 iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00210206
*** WARNING: Unable to verify checksum for E:\MQ2\MQ2Main.dll
MQ2Main!MQ2CharacterType::GetMember+0xd7a:
012eb4da 8b5024 mov edx,[eax+0x24] ds:0023:0000002a=????????
0:000> r
eax=00000006 ebx=0012aec8 ecx=03b96770 edx=0088bd1b esi=00000028 edi=00000001
eip=012eb4da esp=0012ae78 ebp=00000000 iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00210206
MQ2Main!MQ2CharacterType::GetMember+0xd7a:
012eb4da 8b5024 mov edx,[eax+0x24] ds:0023:0000002a=????????
0:000> kv
ChildEBP RetAddr Args to Child
0012ae8c 012e63d2 06ac62c0 0012b6f7 0012aec8 MQ2Main!MQ2CharacterType::GetMember+0xd7a (FPO: [EBP 0x0012b6ec] [4,2,4]) (CONV: thiscall) [E:\MQ\MQ2Main\MQ2DataTypes.cpp @ 1734]
0012b6c4 012e669a 0012b6f4 0012b6ec 06e49910 MQ2Main!ParseMQ2DataPortion+0x7e2 (FPO: [EBP 0x0012cf40] [2,517,4]) (CONV: cdecl) [E:\MQ\MQ2Main\MQ2DataAPI.cpp @ 230]
0012bef0 0130a5c6 0012cf20 00000000 013f6100 MQ2Main!ParseMacroData+0x13a (FPO: [EBP 0x00000005] [1,516,4]) (CONV: cdecl) [E:\MQ\MQ2Main\MQ2DataAPI.cpp @ 556]
0012bf00 012d3f5c 06e49910 0012cf20 0000000c MQ2Main!ParseMacroParameter+0x26 (FPO: [2,0,1]) (CONV: cdecl) [E:\MQ\MQ2Main\MQ2ParseAPI.cpp @ 124]
0012d71c 0130b90e 06e49910 02253c50 00000000 MQ2Main!HideDoCommand+0x31c (FPO: [EBP 0x0000000c] [3,1536,4]) (CONV: cdecl) [E:\MQ\MQ2Main\MQ2CommandAPI.cpp @ 120]
0012df44 0130c115 00496435 00000001 01710048 MQ2Main!DoNextCommand+0x18e (FPO: [0,514,3]) (CONV: cdecl) [E:\MQ\MQ2Main\MQ2Pulse.cpp @ 57]
*** WARNING: Unable to verify checksum for E:\Games\EverQuest\eqgame.exe
*** ERROR: Module load completed but symbols could not be loaded for E:\Games\EverQuest\eqgame.exe
0012df48 00496435 00000001 01710048 00000000 MQ2Main!Detour_ProcessGameEvents+0x5 (FPO: [0,0,0]) (CONV: cdecl) [E:\MQ\MQ2Main\MQ2Pulse.cpp @ 311]
WARNING: Stack unwind information not available. Following frames may be wrong.
0012df50 01710048 00000000 00000321 00000258 eqgame+0x96435
00000001 00000000 00000000 00000000 00000000 <Unloaded_eqmain.dll>+0x100048


Macro part thea causes the crash:

Code: Select all

   /if (${Me.Class.Name.Equal[Shadow Knight]}) /if (${Target.ID}==${MobID}) /if (!${Me.Casting.ID}) /if (${Target.Distance}<=${MeleeDistance}) /goto :attackSpellsSK 
  /goto :attackMeleeLoop 

  :attackSpellsSK 

 
|    /if (${Me.SpellReady["Zevfeer's Bite"]}) /if (${Me.PctMana}>20) /if (${Target.PctHPs}<97) /echo Spell RDY
     /if (${Me.SpellReady["Zevfeer's Bite"]}) /if (${Me.PctMana}>20) /if (${Target.PctHPs}<97) /call cast "Zevfeer's Bite" 
|    /if (${Me.SpellReady[Aura of Hate]}) /if (${Me.PctMana}>20) /if (${Target.PctHPs}<96) /call cast "Aura of Hate" 
|    /if (${Me.SpellReady[Spear of Decay]}) /if (${Me.PctMana}>20) /if (${Target.PctHPs}<95) /call cast "Spear of Decay"
|    /if (${Me.SpellReady[Spear of Plague]}) /if (${Me.PctMana}>20) /if (${Target.PctHPs}<95) /call cast "Spear of Plague" 
|    /if (${Me.SpellReady[Bond of Death]}) /if (${Me.PctHPs}<90)  /if (${Me.PctMana}>20) /if (${Target.PctHPs}<90) /call cast "Bond of Death" 
  /goto :attackMeleeLoop 
The /call cast "Zevfeer's Bite" is the command that causes the casch

Now the inc file for the spellcasts. its the actual spell_routines.inc from Rusty

Code: Select all

| spell_routines.inc
|
| Written by Rusty~
| Last Modified 8/12/2004
|
| *Note: this will no longer cast AA abilities, until the AA ability struct is fixed (which i hope they havent given up on)
|
| Features:
| - Casts spells, clicks items, or uses AA abilities for you
| - Allows back to back casting without waiting on spell gems to pop all the way up
| - Will interrupt spell if target dies while casting. If on a mount, it will dismount and duck if the time left
|   is greater than 7 seconds, else it will move forward a bit to interrupt, then move you back
|    ** IMPORTANT: if you don't want to interrupt a spell while mounted, put this at the top of your macro: **
|    **   /declare noInterrupt int outer 1                                                                  **
| - Allows you to use items in bags. Equips item, clicks it, then returns it to its previous location
| - Lets you set how long you want to keep trying to cast the spell (defaults to 0)
|   If the spell is interrupted before the given time, it will recast, else it will return CAST_INTERRUPTED
| - Lets you call a custom subroutine while waiting for spell to finish casting
|   Try to keep custom subroutines very small. A common use would be to interrupt the spell if a certain condition is true
| - This file also includes a sub named Interrupt. You can call this to interrupt any spell you're casting instantly.
| - You can also use the SwapItem sub included in this to swap items to certain slots
| - Note: if you don't want this to cast spells while you're invis, in your main macro have this at the top:
|      /declare noInvis int outer 1
|   This will wait till invis is off to cast the spell
|
|======================================================================================================================
|  SwapItem:  a subroutine which is used in the Cast sub itself. You don't need to do this to cast an item in a bag
|             but you can call it in your macro to SwapItems (such as weapons or focus items)
|    Usage:   
|        /call SwapItem "item name" slotname|slotID
|    Examples:
|   
|    To swap Darkblade of the Warlord to your main hand:
|        /call SwapItem "Darkblade of the Warlord" mainhand
|
|    To swap stat food in one bag with other food in another bag:
|        /call SwapItem "Bristlebanes Party Platter" ${FindItem[halas 10lb meat pie].InvSlot}
|
|======================================================================================================================
|  Cast: the main subroutine that casts spells or items for you|
|     Usage:
|        /call Cast "spellname|itemname|AAname|AA#" [item|alt|gem#] [give up time][s|m] [custom subroutine name]
|     Examples:
|
|     To cast Howl of Tashan and mem it in slot 3 if not memmed:
|       /call Cast "Howl of Tashan" gem3
|
|     To cast Arcane Rune and keep trying for 7 seconds, in case of interrupts.
|       /call Cast "Arcane Rune" gem5 7s
|
|     To click Grim Aura earring that's in a bag:
|       /call Cast "Shrunken Goblin Skull Earring" item
|
|     To use AA ability Eldritch Rune:
|       /call Cast "Eldritch Rune" alt
|         or
|       /call Cast "173" alt
|
|     To call a subroutine that interrupts CH if target gets healed before it lands:
|       /call Cast "Complete Healing" gem1 0 CheckHP
|     Then in your macro have somewhere:
|       Sub CheckHP
|          /if ( ${Target.PctHPs}>=80 ) /call Interrupt
|       /return
|
| Returns these values:
|----------------------+----------------------------------------------------------------------+
| CAST_CANCELLED       | Spell was cancelled by ducking (either manually or because mob died) |
| CAST_CANNOTSEE       | You can't see your target                                            |
| CAST_IMMUNE          | Target is immune to this spell                                       |
| CAST_INTERRUPTED     | Casting was interrupted and exceeded the given time limit            |
| CAST_NOTARGET        | You don't have a target selected for this spell                      |
| CAST_NOTMEMMED       | Spell is not memmed and you gem to mem was not specified             |
| CAST_NOTREADY        | AA ability or spell is not ready yet                                 |
| CAST_OUTOFMANA       | You don't have enough mana for this spell!                           |
| CAST_OUTOFRANGE      | Target is out of range                                               |
| CAST_RESISTED        | Your spell was resisted!                                             |
| CAST_SUCCESS         | Your spell was cast successfully! (yay)                              |
| CAST_UNKNOWNSPELL    | Spell/Item/Ability was not found                                     |
|----------------------+----------------------------------------------------------------------+

#event BeginCast "You begin casting#*#"
#event Collapse "Your gate is too unstable, and collapses.#*#"
#event Fizzle "Your spell fizzles#*#"
#event Immune "Your target is immune to changes in its attack speed#*#"
#event Immune "Your target is immune to changes in its run speed#*#"
#event Immune "Your target cannot be mesmerized#*#"
#event Interrupt "Your casting has been interrupted#*#"
#event Interrupt "Your spell is interrupted#*#"
#event NoLOS "You cannot see your target.#*#"
#event NoTarget "You must first select a target for this spell!#*#"
#event NotReady "Spell recast time not yet met.#*#"
#event OutOfMana "Insufficient Mana to cast this spell!#*#"
#event OutOfRange "Your target is out of range, get closer!#*#"
#event Recover "You haven't recovered yet...#*#"
#event Recover "Spell recovery time not yet met#*#"
#event Resisted "Your target resisted the #*#"
#event Standing "You must be standing to cast a spell#*#"
#event Stunned "You are stunned#*#"
#event Stunned "You cannot cast while stunned#*#"
#event Stunned "You *CANNOT* cast spells, you have been silenced!#*#"


Sub Cast(string spellName,string spellType,timer giveUpTimer,string mySub)
   /if ( ${Me.Invis} && ${noInvis} ) /echo You're invis... waiting to cast
:wait_for_stop
   /if ( ${Me.Casting.ID} || ( ${Me.Invis} && ${noInvis} ) ) {
      /delay 1
      /goto :wait_for_stop
   } 
   /if ( ${Me.Speed} ) {
   :wait_for_stop2
      /delay 1
      /if ( ${Me.Moving} ) /goto :wait_for_stop2
   }
   /if ( !${Defined[giveUpTimer]} ) /declare giveUpTimer timer local 0
   /if ( !${Defined[spellRecastTime1]} ) {
      /if ( !${Defined[noInterrupt]} ) /declare noInterrupt int outer 0
      /declare lastSpell string outer
      /declare refreshTime timer outer 0
      /declare itemRefreshTime float outer 0
      /declare i int local
      /declare castReturn string outer
      /delay 5
      /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
   }
   /declare currentTarget int local
   /declare currentTargetType string local
   /declare swapItemBack bool local false
   /declare delayTime timer local
   /declare castEndTime timer local
   /declare moveBack bool local
   /if ( !${Defined[spellType]} ) /declare spellType string local spell
   /if ( ( ${spellType.Equal[spell]} || ${spellType.Left[3].Equal[gem]} ) && !${Int[${Me.Book[${spellName}]}]} ) {
      /echo Spell: "${spellName}" was not found in your book
      /return CAST_UNKNOWNSPELL
   }
   /if ( ${spellType.Equal[spell]} || ${spellType.Left[3].Equal[gem]} ) {
      /if ( !${Me.Gem[${spellName}]} ) {
         /if ( ${spellType.Left[3].Equal[gem]} ) {
            /memspell ${spellType.Right[1]} "${spellName}"
         } else {
            /return CAST_NOTMEMMED
         }
         /delay 6s ${Me.Gem[${spellName}]}
         /if ( !${Me.Gem[${spellName}]} ) {
            /echo Spell mem interrupted...
            /return CAST_INTERRUPTED
         }
         :wait_for_mem
         /delay 15s ${Me.SpellReady[${spellName}]}
         /if ( !${Me.SpellReady[${spellName}]} ) {
            /if ( ${giveUpTimer} ) /goto :wait_for_mem
            /return CAST_NOTREADY
         }
      }
      /varset spellType spell
   }
   /if ( ${spellName.Find[illusion: ]} ) /alt activate 217 | && ${Me.AltAbility[project illusion]} ) /call Cast "project illusion" "alt"
   /declare slotName int local
   /declare slotID int local
   /declare oldSlotID int local
   /declare oldItemName string local
:clear_events
   /if ( ${Me.SpellReady[${spellName}]} ) /varset spellRecastTime${Me.Gem[${spellName}]} 0
   /call ClearReturn
   /doevents Recover
   /doevents BeginCast
   /doevents Fizzle
   /doevents Interrupt
   /doevents Standing
   /doevents OutOfRange
   /doevents OutOfMana
   /doevents NoLOS
   /doevents Resisted
   /doevents Immune
   /doevents Stunned
   /doevents Collapse
   /doevents NoTarget
   /doevents NotReady
   /if ( !${castReturn.Equal[CAST_SUCCESS]} ) {
      /delay 1
      /goto :clear_events
   }
   /varset giveUpTimer ${giveUpTimer.OriginalValue}
   /declare recoverWaitTime timer local 30
:cast_loop
   /if ( ${Me.Ducking} ) /keypress duck
   /if ( !${Me.Standing} ) /stand
   /if ( ${spellType.Equal[item]} ) {
      /if ( !${FindItem[${spellName}].InvSlot} ) {
         /echo Cannot find item: ${spellName}
         /return CAST_UNKNOWNSPELL
      }     
      /if ( ${FindItem[${spellName}].InvSlot}>29 ) {
         /varset swapItemBack true
         /if ( ${FindItem[${spellName}].WornSlot[1]} ) {
            /varset slotName ${FindItem[${spellName}].WornSlot[1]}
         } else {
            /varset slotName pack8
         }
         /varset slotID ${InvSlot[${slotName}].ID}
         /varset oldSlotID ${FindItem[${spellName}].InvSlot.ID}
         /varset oldItemName ${InvSlot[${slotID}].Item.Name}
         /call SwapItem "${spellName}" ${slotID}
      }
      /varset itemRefreshTime ${Math.Calc[${MacroQuest.Running}+200]}
      /echo Casting: ${FindItem[${spellName}].Spell.Name}${If[!${FindItem[${spellName}].Spell.TargetType.Equal[PB AE]} && !${FindItem[${spellName}].Spell.TargetType.Equal[self]} && ${Target.ID}, on >> ${Target.CleanName} <<,]}
      /cast item "${spellName}"
   } else /if ( ${spellType.Equal[spell]} ) {
   :wait_for_spell
      /if ( ${spellRecastTime${Me.Gem[${spellName}]}} ) {
         /if ( !${giveUpTimer} ) /return CAST_NOTREADY
         /delay 1
         /goto :wait_for_spell
      }
      /if ( !${refreshTime} ) /goto :skip_delay
   :wait_on_refresh
      /if ( ${refreshTime}>0 ) {
         /delay 1
         /goto :wait_on_refresh
      }
      /varcalc delayTime 10*(1.5-${Spell[${spellName}].MyCastTime})
   :cast_delay_loop
      /if ( ${delayTime}>0 ) {
         /delay 1
         /goto :cast_delay_loop
      }
   :skip_delay
      /cast "${spellName}"
   } else {
      /if ( !${Me.AltAbilityReady[${spellName}]} ) /return CAST_NOTREADY
      /varset itemRefreshTime ${Math.Calc[${MacroQuest.Running}+200]}
      /echo Using AA Ability: ${AltAbility[${spellName}].Name}
      /alt activate ${AltAbility[${spellName}].ID}
   }
   /if ( ${Me.Casting.ID} ) {
      /varcalc castEndTime ${Me.Casting.MyCastTime}*10
      /if ( ${spellType.Equal[spell]} ) /echo Casting: ${Me.Casting.Name}${If[!${Me.Casting.TargetType.Equal[PB AE]} && !${Me.Casting.TargetType.Equal[self]} && ${Target.ID}, on >> ${Target.CleanName} <<,]}
   }
   /varset currentTarget ${Target.ID}
   /varset currentTargetType ${Target.Type}
   /varset moveBack false
:wait_cast_loop
   /if ( ${Defined[mySub]} ) /call ${mySub}
   /if ( ${Me.Casting.ID} ) {
      /if ( ${currentTarget} && !${Spawn[${currentTarget}].Type.Equal[${currentTargetType}]} ) {
         /if ( !${Me.Casting.TargetType.Equal[PB AE]} && !${Me.Casting.TargetType.Equal[self]} && !${moveBack} && ( !${Me.Mount.ID} || !${noInterrupt} ) ) {
            /if ( !${Me.Mount.ID} || ${castEndTime}>70 ) {
               /call Interrupt
            } else /if ( ${Me.Casting.RecastTime}>3 && ${spellType.Equal[spell]} ) {
               /keypress forward hold
               /delay 6
               /keypress forward
               /varset moveBack true
               /varset castReturn CAST_CANCELLED
            }
         }
      }
      /if ( ${Me.State.Equal[DUCK]} ) /varset castReturn CAST_CANCELLED
      /delay 1
      /goto :wait_cast_loop
   }
   /if ( ${moveBack} ) {
      /keypress back hold
      /delay 6
      /keypress back
      /delay 15 !${Me.Moving}
   }
   /if ( ${swapItemBack} ) {
      /if ( ${FindItem[${oldItemName}].ID} ) {
         /call SwapItem "${oldItemName}" ${slotID}         
      } else /if ( ${FindItem[${spellName}].ID} ) {
         /call SwapItem "${spellName}" ${oldSlotID}
      }
   }
   /if ( ${castReturn.Equal[CAST_CANCELLED]} ) {
      /echo Spell was cancelled...
      /return CAST_CANCELLED
   }
   /call ClearReturn
   /doevents Recover
   /doevents BeginCast
   /doevents Fizzle
   /doevents Interrupt
   /doevents Standing
   /doevents OutOfRange
   /doevents OutOfMana
   /doevents NoLOS
   /doevents Resisted
   /doevents Immune
   /doevents Stunned
   /doevents Collapse
   /doevents NoTarget
   /doevents NotReady

   /if ( !${castReturn.Equal[CAST_SUCCESS]} ) {
      /if ( ${castReturn.Equal[CAST_NOTREADY]} ) /return CAST_NOTREADY
      /if ( ${castReturn.Equal[CAST_FIZZLE]} ) {
         /echo Spell Fizzled. Recasting...
         /goto :cast_loop
      }
      /if ( ${castReturn.Equal[CAST_RECOVER]} && ${spellType.Equal[spell]} ) {
         /if ( !${recoverWaitTime} ) {
            /varcalc spellRecastTime${Me.Gem[${spellName}]} 10*${Spell[${spellName}].RecastTime}
            /if ( !${giveUpTimer} ) /return CAST_NOTREADY
         }
         /goto :cast_loop
      }
      /if ( ${castReturn.Equal[CAST_RESTART]} ) /goto :cast_loop
      /if ( ${castReturn.Equal[CAST_STUNNED]} ) {
         /if ( ${Me.Stunned} ) {
            /delay 3s !${Me.Stunned}
         } else {
            /delay 7
         }
         /goto :cast_loop
      }
      /if ( ${castReturn.Equal[CAST_INTERRUPTED]} ) {
         /if ( ${giveUpTimer} ) {
            /echo Spell was interrupted. Recasting...
            /goto :cast_loop
         }
         /echo Spell was interrupted...
         /return CAST_INTERRUPTED
      }
   }
   /if ( ${spellType.Equal[spell]} ) {
      /varset lastSpell ${spellName}
      /if ( !${castReturn.Equal[CAST_CANNOTSEE]} && !${castReturn.Equal[CAST_OUTOFRANGE]} && !${castReturn.Equal[CAST_OUTOFMANA]} && !${castReturn.Equal[CAST_NOTARGET]} ) {
         /varcalc refreshTime 10*${Spell[${spellName}].RecoveryTime}
         /varcalc spellRecastTime${Me.Gem[${spellName}]} 10*${Spell[${spellName}].RecastTime}
      }
   } else {
      /varset lastSpell ${spellType}
   :wait_item_loop
      /if ( ${itemRefreshTime} > ${MacroQuest.Running} ) {
         /delay 1
         /goto :wait_item_loop
      }
   }
   /if ( ${castReturn.Equal[CAST_COLLAPSE]} ) {
      /varset giveUpTimer 200
      /goto :cast_loop
   }
   /return ${castReturn}

Sub SwapItem(string itemName,string slotName)
   /if ( ${Me.Inventory[${slotName}].Name.Equal[${itemName}]} ) /return
   /declare slotID int local
   /declare oldSlotID int local
   /declare oldItem string local
   /varset slotID ${InvSlot[${slotName}].ID}       | slotID = slot you're swapping item to
   /varset oldSlotID ${FindItem[${itemName}].InvSlot.ID} | oldSlotID = slot the item was originally in
   /varset oldItem ${InvSlot[${slotName}].Item.Name}     | oldItem = name of item in the slot you're swapping to
   /if ( !${slotID} ) {
      /echo Invalid slot name: ${slotName}
      /return
   }
   /if ( !${oldSlotID} ) {
      /echo Could not find item ${itemName}
      /return
   }
:auto_inv
   /if ( ${Cursor.ID} && !${Cursor.Container} ) {
      /autoinventory
      /goto :auto_inv
   }

:pick_up_item
 | if the item is in a bag and it's not open, then open it!
   /if ( ${InvSlot[${oldSlotID}].Pack} && !${Window[${InvSlot[${oldSlotID}].Pack.Name}].Open} ) /nomodkey /itemnotify ${InvSlot[${oldSlotID}].Pack} rightmouseup

 | if the slot you're putting it in is inside a bag and it's not open, then open it!
   /if ( ${InvSlot[${slotID}].Pack} && !${Window[${InvSlot[${slotID}].Pack.Name}].Open} ) /nomodkey /itemnotify ${InvSlot[${slotID}].Pack} rightmouseup

 | ok.. pick up the item now!
   /squelch /nomodkey /shiftkey /itemnotify ${InvSlot[${oldSlotID}]} leftmouseup

 | if item isn't on your cursor, try again!
   /if ( !${Cursor.Name.Equal[${itemName}]} && ${FindItem[${itemName}].ID} ) /goto :pick_up_item

:exchange_items
   /if ( ${InvSlot[${oldSlotID}].Pack} && !${Window[${InvSlot[${oldSlotID}].Pack.Name}].Open} ) /nomodkey /itemnotify ${InvSlot[${oldSlotID}].Pack} rightmouseup
   /if ( ${InvSlot[${slotID}].Pack} && !${Window[${InvSlot[${slotID}].Pack.Name}].Open} ) /nomodkey /itemnotify ${InvSlot[${slotID}].Pack} rightmouseup

 | put the item in the new slot, and pick up whatever item was there
   /squelch /nomodkey /shiftkey /itemnotify ${slotID} leftmouseup

 | if it didnt get exchanged, try again!
   /if ( !${InvSlot[${slotID}].Item.Name.Equal[${itemName}]} && ${Cursor.Name.Equal[${itemName}]} ) /goto :exchange_items
:drop_item
   /if ( !${Cursor.Container} || ( ${InvSlot[${oldSlotID}]}<30 && ${InvSlot[${oldSlotID}]}>=22 ) ) {
      /if ( ${InvSlot[${oldSlotID}].Pack} && !${Window[${InvSlot[${oldSlotID}].Pack.Name}].Open} ) /nomodkey /itemnotify ${InvSlot[${oldSlotID}].Pack} rightmouseup
      /if ( ${InvSlot[${slotID}].Pack} && !${Window[${InvSlot[${slotID}].Pack.Name}].Open} ) /nomodkey /itemnotify ${InvSlot[${slotID}].Pack} rightmouseup
      /squelch /nomodkey /itemnotify ${oldSlotID} leftmouseup
      /if ( ${Cursor.ID} ) {
         /if ( !${Cursor.Name.Equal[${oldItem}]} && !${Cursor.Container} ) /autoinventory
         /goto :drop_item
      }
   }
:close_pack
   /if ( ${InvSlot[${oldSlotID}].Pack} && ${Window[${InvSlot[${oldSlotID}].Pack.Name}].Open} && ( ${Cursor.Name.Equal[${itemName}]} || ${FindItem[${itemName}].ID} ) ) {
      /squelch /nomodkey /itemnotify ${InvSlot[${oldSlotID}].Pack} rightmouseup
      /goto :close_pack
   }
   /if ( ${InvSlot[${slotID}].Pack} && ${Window[${InvSlot[${slotID}].Pack.Name}].Open} && ( ${Cursor.Name.Equal[${itemName}]} || ${FindItem[${itemName}].ID} ) ) {
      /squelch /nomodkey /itemnotify ${InvSlot[${slotID}].Pack} rightmouseup
      /goto :close_pack
   }
/return

Sub Interrupt
   /if ( ${Me.Mount.ID} ) /dismount
   /if ( !${Me.Ducking} ) {
      /keypress duck
      /keypress duck
   }
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_CANCELLED
/return ${Macro.Return}

Sub ClearReturn
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_SUCCESS
/return

Sub Event_Fizzle
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_FIZZLE
/return

Sub Event_Resisted
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_RESISTED
/return

Sub Event_Interrupt
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_INTERRUPTED
/return

Sub Event_Recover
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_RECOVER
/return

Sub Event_Immune
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_IMMUNE
/return

Sub Event_Stunned
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_STUNNED
/return

Sub Event_NoLOS
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_CANNOTSEE
/return

Sub Event_Standing
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_RESTART
/return

Sub Event_Collapse
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_COLLAPSE
/return

Sub Event_OutOfMana
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_OUTOFMANA
/return

Sub Event_OutOfRange
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_OUTOFRANGE
/return

Sub Event_NoTarget
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_NOTARGET
/return

Sub Event_NotReady
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_NOTREADY
/return

Sub Event_BeginCast
   /if ( ${Defined[castReturn]} ) /varset castReturn CAST_SUCCESS
/return

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Mon Aug 16, 2004 9:17 pm

One thing that might cause the problem is that you call a sub that doesn't exist. MQ2 is case sensitive and the sub you want to call is "Cast" with a capital C and you call "cast". It doesn't normally crash like that when I do stuff like this though, it gives me an error message.

User avatar
Night Hawk
a grimling bloodguard
a grimling bloodguard
Posts: 590
Joined: Fri Aug 13, 2004 4:56 pm

Post by Night Hawk » Mon Aug 16, 2004 10:52 pm

I think it's just cause it doesn't like all those /if's on one line
Just use &&'s and combine them into one /if

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

Post by Chill » Mon Aug 16, 2004 10:55 pm

Code: Select all

First-chance exception in eqgame.exe (MQ2MAIN.DLL): 0xC0000005: Access Violation.
The thread 0x2A8 has exited with code 0 (0x0).
The thread 0x2AC has exited with code 0 (0x0).
The thread 0x1E4 has exited with code 0 (0x0).
The thread 0x574 has exited with code 0 (0x0).
The thread 0xCB8 has exited with code 0 (0x0).
The thread 0xCBC has exited with code 0 (0x0).
The thread 0xD5C has exited with code 0 (0x0).
The thread 0x234 has exited with code 0 (0x0).
The thread 0x2D0 has exited with code 0 (0x0).
The thread 0x39C has exited with code 0 (0x0).
The thread 0x2B4 has exited with code 0 (0x0).
this mean anything to anyone?

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Tue Aug 17, 2004 2:48 am

I think I know what is causing this. I'm not positive, but the include macro that you use calls a data member that actually uses the AltAbility struct.

I've spent about 3 hours now and I think I almost have the altability structs right. I don't know if it will fix all that's wrong with MQ's altability stuff atm; however, it might clear up this crash. We shall see.

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

Post by Rusty~ » Tue Aug 17, 2004 12:12 pm

it shouldn't even go to any of the parts of the include that use altability tho unless you put "alt" in as a parameter. i'm not sure how the include could cause this... i tested it last night with just "/call cast "spellname" and no other parameters, and it worked fine. in my macros i always used all the parameters when casting but just using the name should work too.... is it only crashing with that spell, or any of them?

Gameross
a lesser mummy
a lesser mummy
Posts: 46
Joined: Mon May 03, 2004 10:11 am

Good timing I see...Same issue here. :(

Post by Gameross » Tue Aug 17, 2004 2:13 pm

Ya, I was just about to post about having a crash bug when using Spell_Routine.inc. I hadn't yet as I was going to look over the .inc macro first before I did. I definatley look forward to whatever is causing this to be fixed.

What's strange is it's like totally random. Sometimes is will just keep crashing and sometimes it works and then it starts doing it suddenly.

BlueNinja, the case of the call to Cast makes no difference. Thought of that.

Nighthawk, I've got my call to Cast on a single IFed line. No AND/OR, etc.

Amadeus/Rusty-It's doing it with any spell cast and I hadn't been doing much with AAs and was still doing it.

The issue seemed to get worse as the macro I'm writing got longer. Could be I finally started using it more. I even tried coping the Spell_Routines.Inc into my macro and still had the same issues.


Just some observations.

Mimatas
a hill giant
a hill giant
Posts: 262
Joined: Wed Mar 10, 2004 4:22 pm

Post by Mimatas » Tue Aug 17, 2004 2:27 pm

possibly nesting/stack issues?

A Troll
a lesser mummy
a lesser mummy
Posts: 30
Joined: Fri May 21, 2004 10:04 am

Post by A Troll » Tue Aug 17, 2004 5:33 pm

Crashs with all the spells above.
Sometime it crashes advbot.mac too, when i use it on my 2nd pc with
my shm. Dunno why but sometimes it works , sometimes not.
But in the stick.mac it crashes EVERYTIME...
Hope you guys find a way to fix it :-)
Great Proggie

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

Post by Rusty~ » Tue Aug 17, 2004 5:53 pm

most of the code i have in that include i wrote a logn time ago and some of it isnt exactly the best way of doing things... i'm gonna try pretty much rewritin the whole thing and see how it does.

as a note, i use this in all my macros, and have never had a crash with it, but i also use all the parameters. the error probably has to do with only using one parameter (the spell name). i'll go ahead and work on rewriting it now and see if this fixes the problems.

Gameross
a lesser mummy
a lesser mummy
Posts: 46
Joined: Mon May 03, 2004 10:11 am

Parameters

Post by Gameross » Tue Aug 17, 2004 6:12 pm

Rusty, I'm using both the spell name and the type (gem, item, alt) and still crashing.

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Tue Aug 17, 2004 8:08 pm

Chill wrote:

Code: Select all

First-chance exception in eqgame.exe (MQ2MAIN.DLL): 0xC0000005: Access Violation.
The thread 0x2A8 has exited with code 0 (0x0).
The thread 0x2AC has exited with code 0 (0x0).
The thread 0x1E4 has exited with code 0 (0x0).
The thread 0x574 has exited with code 0 (0x0).
The thread 0xCB8 has exited with code 0 (0x0).
The thread 0xCBC has exited with code 0 (0x0).
The thread 0xD5C has exited with code 0 (0x0).
The thread 0x234 has exited with code 0 (0x0).
The thread 0x2D0 has exited with code 0 (0x0).
The thread 0x39C has exited with code 0 (0x0).
The thread 0x2B4 has exited with code 0 (0x0).
this mean anything to anyone?
Read Reporting CTD Problems in the readme

The above won't help the devs at all.

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Tue Aug 17, 2004 8:53 pm

From the backtrace:

Code: Select all

0012ae8c 012e63d2 06ac62c0 0012b6f7 0012aec8 MQ2Main!MQ2CharacterType::GetMember+0xd7a (FPO: [EBP 0x0012b6ec] [4,2,4]) (CONV: thiscall) [E:\MQ\MQ2Main\MQ2DataTypes.cpp @ 1734] 
If you look at line 1734 in the latest zip, it's in the routine for ${Me.AltAbility...} ....I should have disabled it, but that's probably what's causing your crash.

I'm either going to fix it soon, or disable it completely. Which may temporarily break your macro until you remove references to it. ..I don't use macros, so I don't know. BUT, I can tell you that *everything* related to alt abilities is broken in the latest zip.

I have the structs and some stuff fixed atm. ...so, time will tell if alt abilities stuff will be fixed soon.