help with Exp equation or any bug crashing macro + client.

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

Gellenole
orc pawn
orc pawn
Posts: 20
Joined: Wed Oct 29, 2003 10:28 pm

help with Exp equation or any bug crashing macro + client.

Post by Gellenole » Wed Nov 12, 2003 10:58 pm

Though I know it's the whole code...
I need help with the following area:
- Exp displaying

Basically the code will crash not only the code, but the EQ client when it tries to calculate exp from the mob... if you can plz help me fix the code it'll be appreciated. (note... it's not a divide by zero error).

Code: Select all

|Archery Macro v. 1.3a
|Archery Assist Macro.
|Gellenole's Autofire Archery Macro
|Email: drmchaser5@yahoo.com
|
|Forenote:  	This macro was created with a creative purpose.
|		Mod all you want... Just don't distribute and claim it as
|		your own.  
|
|
|HISTORY
|Version 1.3a (11/9/03)
|	- Added support for exp display (If exp divides by zero the client crashes)
|	- Added checks for SoT and SOTP
|	- Added better checks for snare
|	- Fixed a bug that made you do nothing after success of spell cast
|Version 1.2e (11/5/03)
|	- Never forget Snare again (uses Ensnare)
|	- Will do checks for SoE + Eagle Eye + Health + Regrowth + Self haste
|	- Events added to close Macro if player died.
|	- Events will ensure you keep haste on yourself 100% of the time
|Future - Plans to add health checks for whole group and cast until group 
|	  health is full or until mana is depleated.
|Version 1.0d (11/3/03)
|	- Macro will keep running.
|	- Macro Contains enough info in sub routines to identify NPC from PC
|	- Macro also is used to assist the main assist
|	  (restart macro to read just tank)
|	- Macro Contains checks for SoE + Eagle Eye. Will recast if faded.(Buggy)
|Version 1.0c (11/2/03)
|	- Fixed the macro to end when the mob dies. (Turn off macro to stop)
|Version 1.0b (11/1/03)
|	- Fixed having the user to fire 1st arrow for macro to run
|	- Still need to fix how to turn it off once mob is dead
|Version 1.0a (10/31/03)
|	- Need user intervention to Fire 1st arrow for the macro to work
|	- Need user intervention to turn off the macro even after mob is dead
|
|	Usage:  /Macro Archery <tank name>
|
|----------------------------------------------------------------------------|
#Event EAGLEEYE "The avian presence departs."
#Event EAGLESUC "Your eyes sharpen, with an aura of avian presence."
#Event SPIRITOF "The avian spirit departs."
#Event SPIRISUC "Your body pulses with an avian spirit."
#Event REGROWTH	"You have stopped regenerating."
#Event REGROSUC	"You begin to regenerate."
#Event SOTP	"The predator's spirit departs."
#Event SOTPSUC	"The spirit of the predator strengthens your attacks."
#Event SOT	"Tunare's strength ebbs."
#Event SOTSUC	"Tunare's strength flows through your muscles."
#Event HASTE	"The quickening spirit departs."
#Event HASTSUC	"You are filled by the spirit of water."
#Event HASTE_E	"Your restless nature fades."
#Event HASTE_S	"Your speed fades."
#Event HASTE_S2 "Your speed returns to normal."
#Event SLAINBY  "You have been slain by "
|#Event EXP	" experience!!"

#turbo 50

Sub Main
	/ECHO  =+= Gellenole's Autofire Macro Enabled =+=
	/ECHO  =+= Version Realease: 1.3a =+=
	/ECHO  =+= Usage:  /Macro Archery <Tank name> =+=
|-----------------(Tank Declaration Flag=1)---------
	/declare tankname global

|-----------------(Casting Flags=7)-----------------
	/declare CastsoE_Flag global
	/declare Casteagle_Flag global
	/declare Nalot_Flag global
	/declare Castreg_Flag global
	/declare Castsot_Flag global
	/declare Castsotp_Flag global
	/declare Invis_Flag global

|-----------------(Engage Flag=3)-------------------
	/declare engagedistance global
	/declare engagedmob global
	/declare mobhealth global

|-----------------(Experience Flags=12)-------------
	/declare currentexperience global
	/declare currentaaexperience global
	/declare startexperience global
	/declare startaaexperience global
	/declare displayexperience global
	/declare displayaaexperience global
	/declare exptilllevel global
	/declare exptodingaa global
	/declare mobstoding global
	/declare mobstodingaa global
	/declare mobname global
	/declare stable global

|-(Amount of flags have to equal Amount of variable)
|----------------(Current Amount=23)----------------
|----------------(Variable Initialized)-------------
	/varset engagedistance 100   	| How close mob must be to engage 
	/varset mobhealth 98		| Mob health before engage
	/varset tankname @Param0	| Assigns Param0 to variable
	/varset engagedmob 0		| Flag to check if mob is engaged
	/varset mobname 0
	/varset stable 100		|100-x = remaining exp/aaxp to gain
	/varset currentexperience 0
	/varset currentaaexperience 0
	/varset startexperience 0
	/varset startaaexperience 0
	/varset displayexperience 0
	/varset displayaaexperience 0
	/varset exptilllevel 0
	/varset exptodingaa 0
	/varset mobstoding 0
	/varset mobstodingaa 0
	/varset Casteagle_Flag 0
	/varset Castreg_Flag 0
	/varset CastsoE_Flag 0
	/varset Nalot_Flag 0
	/varset Castsot_Flag 0
	/varset Castsotp_Flag 0
	/varset Invis_Flag 0
	:Mainloop 
	/call Combatcheck
	/doevents
	/delay 1s
	/goto :mainloop 
/return

| --> This sub command is a switch to check for mob target
| --> This sub command also checks for your own health
Sub Combatcheck
	/Echo Your Main Assist is @tankname

	/if "@engagedmob==1" {
		/varset Invis_Flag 0
		/assist @tankname
		/call Arrow
	}

	/if "@engagedmob==0" {
		/varset Invis_Flag 1
		/goto :stopfiring
	}

	/if "@Invis_Flag==1" {
		/press num_1
		/varset Invis_Flag 0
	}
	
	/if "@Invis_Flag==0" {
		/goto :stopfiring
	}

	:stopfiring
	/doevents
	/assist @tankname
	/delay 5
	/if "$target(type)"=="NPC" { 
		/Echo $target(name,clean) is at $target(hp,pct)% within the distance of: $target(distance)
		/Echo $target(name) is considered an $target(race)
		/varset mobname $target(name)
		/varset startexperience $char(exp)
		/varset startaaexperience $char(aa,exp)
		/face
		/if n "$target(hp,pct)<=@mobhealth" /if n "$target(distance,nopredict)<@engagedistance" /goto :DoubleCheck

		:DoubleCheck 
		/doevents
		/delay 1s
		/if n "$target(distance)>@engagedistance" /goto :stopfiring
		/if n "$target(hp,pct)<=@mobhealth" /if n "$target(distance)<@engagedistance" /goto :fire

		:fire
		/doevents
		/Echo Autofire Engaged at the distance of: $target(distance)
		/varset engagedmob 1
		/call Arrow
	}
	
	/if "$target(type)"!="NPC" {
		/varset engagedmob 0
		/goto :stopfiring
	}

	/if "$target()"=="FALSE" {
		/varset engagedmob 0
		/goto :stopfiring
	}
	
	:reheal
	/doevents
	/if n $char(mana,pct)>40 {
		/if n $char(hp,pct)<75 { 
			/if $combat!="FALSE" { 
				/if $target()=="FALSE" {
					/press f1
					/cast "Chloroblast"
					/delay 2.4s
					/goto :reheal
	        		}
			} 
		}
	}
/return 

| --> Loop for arrows, and also adjusts for distance of mobs usually
| --> This loop also checks for snaring the mob at 91%
Sub Arrow 
	:arrowloop
	/doevents
	/sendkey up up
	/if "$target()"=="TRUE" { 
		/face fast
		/if n $target(distance)>85 /sendkey down up	|X > 85 move forward	(Max distance)
		/if n $target(distance)<75 /sendkey down down	|X < 75 move back	(Min distance)
		/if n $target(distance)<80 /sendkey up up	|X < 80 stop moving forward	(Var dis max)
		/if n $target(distance)<83 /sendkey up down	|X > 83 stop moving backward	(Var dis min)
		/press num_7		|Change arrow button to your own
	}

	/if "$target(type)"!="NPC" {
		/varset engagedmob 0
		/varset Invis_Flag 1
		/call Combatcheck
	}

	/if "$target()"=="FALSE" {
		/varset engagedmob 0
		/varset Invis_Flag 1
		/call Combatcheck
	}

	:resnare
	/doevents
	/if $target(type)=="NPC" {
		/if $target(hp,pct)>=90 {
			/if $target(hp,pct)<=91 {
				/Echo Ensnared: $target(name)
				/cast "Ensnare"
				/delay 1.8s
				/goto :resnare
			}
		}
	}

	/goto :arrowloop
/return

Sub Spellcast
	:recheck
	/doevents
	/if @Casteagle_Flag=="1" {
		/cast "Eagle Eye"
		/delay 4s
	}

	/if @CastsoE_Flag=="1" {
		/press f1
		/cast "Spirit of Eagle"
		/delay 3.6s
	}

	/if @Castreg_Flag=="1" {
		/press f1
		/cast "Regrowth"
		/delay 4.8s
	}

	/if @Castsot_Flag=="1" {
		/cast "Strength of Tunare"
		/delay 4s
	}

	/if @Castsotp_Flag=="1" {
		/cast "Spirit of the Predator"
		/delay 4s
	}	

	/if @Nalot_Flag=="1" {
		/cast item "Eyepatch of Plunder"
		/delay 3.5s
	}
	/goto :recheck
			
/return

| --> EVENTS DONE by #EVENT

Sub Event_EAGLEEYE
	/Echo (re)casting Eagle Eye
	/varset Casteagle_Flag 1
	/call Spellcast
/return

Sub Event_EAGLESUC
	/Echo Eagle Eye Successfully casted
	/varset Casteagle_Flag 0
	/call Combatcheck
/return

Sub Event_SPIRITOF
	/Echo (re)casting Spirit of Eagle
	/varset CastsoE_Flag 1
	/call Spellcast
/return	

Sub Event_SPIRISUC
	/Echo Spirit of Eagle Successfully casted
	/varset CastsoE_Flag 0
	/call Combatcheck
/return

Sub Event_REGROWTH
	/Echo (re)casting Regrowth
	/varset Castreg_Flag 1
	/call Spellcast
/return

Sub Event_REGROSUC
	/Echo Regrowth Successfully casted
	/varset Castreg_Flag 0
	/call Combatcheck
/return

Sub Event_SOT
	/Echo (re)casting Strength of Tunare
	/varset Castsot_Flag 1
	/call Spellcast
/return

Sub Event_SOTSUC
	/Echo Strength of Tunare Successfully casted
	/varset Castsot_Flag 0
	/call Combatcheck
/return

Sub Event_SOTP
	/Echo (re)casting Spirit of the Predator
	/varset Castsotp_Flag 1
	/call Spellcast
/return

Sub Event_SOTPSUC
	/Echo Spirit of the Predator Successfully casted
	/varset Castsotp_Flag 0
	/call Combatcheck
/return

| -->The 4 haste events is to ensure you to keep haste 100% of the time on yourself.
| -->Only when you begin with selfbuffs
Sub Event_HASTE
	/Echo (re)casting Captain Nalot's Quickening
	/varset Nalot_Flag 1
	/call Spellcast
/return

Sub Event_HASTSUC
	/Echo Captain Nalot's Quickening Successfully casted
	/varset Nalot_Flag 0
	/call Combatcheck
/return

| -->These #Events are described as:  E = Enchanter S = Shaman  S2 = Shaman
| -->When these spells fade, it checks whether you are still targetting an NPC (hopefully while in battle)
| -->When the haste fades during battle it will trigger an event and cast your selfhaste item on you
| -->This minimizes the dramatic loss of DPS during the fight.
Sub Event_HASTE_E
	/if $target(type)=="NPC" {
		/Echo (re)casting Captain Nalot's Quickening
		/varset Nalot_Flag 1
		/call Spellcast
	}

	/if $target(type)!="NPC" {
		/Echo Haste Faded
		/varset Nalot_Flag 0
		/call Combatcheck
	}
	
	/if $target()=="FALSE" {
		/Echo Haste Faded
		/varset Nalot_Flag 0
		/call Combatcheck
	}
/return

Sub Event_HASTE_S
	/if $target(type)=="NPC" {
		/Echo (re)casting Captain Nalot's Quickening
		/varset Nalot_Flag 1
		/call Spellcast
	}

	/if $target(type)!="NPC" {
		/Echo Haste Faded
		/varset Nalot_Flag 0
		/call Combatcheck
	}
	
	/if $target()=="FALSE" {
		/Echo Haste Faded
		/varset Nalot_Flag 0
		/call Combatcheck
	}
/return

Sub Event_HASTE_S2
	/if $target(type)=="NPC" {
		/Echo (re)casting Captain Nalot's Quickening
		/varset Nalot_Flag 1
		/call Spellcast
	}
	
	/if $target(type)!="NPC" {
		/Echo Haste Faded
		/varset Nalot_Flag 0
		/call Combatcheck
	}
	
	/if $target()=="FALSE" {
		/Echo Haste Faded
		/varset Nalot_Flag 0
		/call Combatcheck
	}
/return

Sub Event_EXP
	/delay 1s
	/varset currentexperience $char(exp)
	/varset currentaaexperience $char(aa,exp)

	/varcalc displayexperience @currentexperience-@startexperience
	/varcalc displayaaexperience @currentaaexperience-@startaaexperience
	/varcalc exptilllevel @stable-@currentexperience
	/varcalc exptodingaa @stable-@currentaaexperience
	/varcalc mobstoding @exptilllevel/@displayexperience
	/varcalc mobstodingaa @exptoaading/@displayaaexperience
	
	/if @displayexperience>0.00 {
		/delay 1s
		/ECHO You've gained @displayexperience% Exp, and you have a total $char(exp)% Exp.
		/ECHO You've gained @displayaaexperience% AA Exp, and you have a total of $char(aa,exp)% AA Exp.
		/ECHO You still have @exptilllevel% to level.
		/ECHO You have to kill @mobstoding @mobname to get to the next level.
		/ECHO You still have @exptodingaa% to obtain an AA.
		/ECHO You have to kill @mobstodingaa @mobname to gain another AA.
	}

	/if @displayexperience==@startexperience {
		/delay 1s
		/Echo You have not gained experience by killing @mobname
	}

	/varset mobname 0
	/call Combatcheck
/return

Sub Event_SLAINBY
	/Echo Slained Event Entered
	/endmacro
/return
| --> End of Events
| --> End of Macros

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Thu Nov 13, 2003 4:49 am

Code: Select all

/varcalc mobstodingaa [color=red]@exptoaading[/color]/@displayaaexperience
Doesn't crash on my machine, even with div by zero.

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 » Thu Nov 13, 2003 6:35 am

bah, nm, misread so my fix isn't valid..

Well since I already posted I guess I could point out that when doing numeric comparisons like

Code: Select all

/if @displayexperience>0.00
you should use the 'n' parameter to /if, like this:

Code: Select all

/if n @displayexperience>0.00
won't fix your problem though :(

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 » Thu Nov 13, 2003 9:32 am

Here are some other problems:

Code: Select all

/if n "$target(hp,pct)<=@mobhealth" /if n "$target(distance,[color=cyan]nopredict[/color])<@engagedistance" /goto :DoubleCheck
Remove all instances of nopredict, since nopredict was changed to the default.

Code: Select all

/if n "$target(distance)>@engagedistance" /goto :stopfiring 
/if n "$target(hp,pct)<=@mobhealth" /if n "$target(distance)<@engagedistance" /goto :fire 
What are the quotes in the above line for? You have quite a few lines where you have comparisons inside quotes.

When doing numeric comparisons you need to use

Code: Select all

/if n @displayexperience>0 {
}

I had read awhile ago that putting comments at the end of a line would cause problems.

You have a number of lines like this.

Code: Select all

   /varset engagedistance 100      | How close mob must be to engage 
   /varset mobhealth 98      | Mob health before engage 
   /varset tankname @Param0   | Assigns Param0 to variable 
   /varset engagedmob 0      | Flag to check if mob is engaged 
   /varset mobname 0 
   /varset stable 100      |100-x = remaining exp/aaxp to gain 
This line might be causing some problems:

Code: Select all

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

Gellenole
orc pawn
orc pawn
Posts: 20
Joined: Wed Oct 29, 2003 10:28 pm

Post by Gellenole » Sun Nov 16, 2003 3:19 am

OH MAN YOU'RE SO USEFUL!!!! (NO SARCASM INTENDED!!)
well the quotes have been taken out on further testing... and some lines haven't caused problems because it wasn't read into macroquest as a significant line of code, but rather comments.

anyway i'm going to look into it... there are some 1 line comparisons because they work in a certain aspect =).. but as of now it's working fine. thnx for the input =) i'll look into it! EXTREMELY HELPFUL!