Fix: Divide by Zero Errors, and Casting Range notifier

Forum for posting custom UIs, portions of UIs, and HUD stuff using MQ's enhancements.

Moderator: MacroQuest Developers

GD
a snow griffon
a snow griffon
Posts: 353
Joined: Sat Jun 29, 2002 11:57 pm

Fix: Divide by Zero Errors, and Casting Range notifier

Post by GD » Tue Jun 22, 2004 3:08 am

For cast count, use

Code: Select all

${If[${Me.Gem[1].ID},${Int[${Math.Calc[${Me.CurrentMana}/${If[!${Me.Gem[1].ID},1,${Me.Gem[1].Mana}]}]}]},]}
Gives the number if the gem is in use, and leaves it blank if it's not.


To know if target is in casting range, use this:

Code: Select all

${If[${Target.ID},${If[${Me.Gem[1].ID},${If[${Target.Distance}>${Me.Gem[1].Range},${If[${Target.Distance}>${Math.Calc[${Me.Gem[1].Range}*[color=red]1.2[/color]]},N,*]},Y]},]},]}
Gives * if within the 20% ER enhancement range, Y if in normal range, and N if not in range. You can modify the value in red to the value of your own ER enhancement.
Opinions are like assholes, everyone has one, but most of them stink.

WhiteWolf
a ghoul
a ghoul
Posts: 89
Joined: Wed Apr 14, 2004 5:41 am

Post by WhiteWolf » Tue Jun 22, 2004 6:12 am

Works great on normal casters, but unfortunatly it still gives the Divide by zero on bards (songs that cost 0 mana), and i'd assume the Canni spells too, and Elemental.....whatever that mage spell is, 600 DD to the pet for a recourse of 3 mana per tick for the mage. As i've heard, they both have a 0 mana cost.

i'm gonna play around a little with it, though my programming knowledge is pretty poor.

edit: in case it wasn't apparent, i'm talking about the Casts remaining section of code heh.
ive plans for that cast radius one too though.

edit 2: and....my attempt failed miserably. in case anyone wants to take it up, i was trying to alter the first if statement, which as far as i can tell stands for "if a spell is memmed here...." and add an "and" function, thus making it "if a spell is memmed here, and the mana cost for that spell is greater than zero....". my programmng knowledge is too basic though, and i couldn't figure out the proper coding to use.

fryfrog
a hill giant
a hill giant
Posts: 271
Joined: Fri Jun 20, 2003 5:37 am

Post by fryfrog » Tue Jun 22, 2004 11:24 am

If the result is NULL, MQ2 hides it anyway... so a simple "hide it if there is nothing in the gem slot" doesn't change anything except add more code to process.

The divide by 0 bug would be better address by an ${If[!Me.Gem[X]<=0,${True Stuff Here},${False Stuff Here}]} or something along those lines.

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Tue Jun 22, 2004 12:36 pm

The issue at hand is the divide by zero error, which I tried to explain in the announcements how to correctly solve ;)

Also, you can use Math.Calc.Int instead of ${Int}
e.g.:
${Math.Calc[1234.5678].Int} == 1235 (i think it rounds anyway)

Best solution:

Code: Select all

${If[${Me.Gem[1].ID},${Math.Calc[${Me.CurrentMana}/${If[${Me.Gem[1].Mana},${Me.Gem[1].Mana},9999999999]}].Int},]}
The main difference here is the inside check is if CurrentMana. Not all spells have mana (e.g. bard songs)

The issue at hand here for "Divide by zero" is that the calculation is always executed, no matter what. The parser has no idea there's an "if" there that you would want to stop part from being parsed. The only way you can make it realize there's an if, is if the if is INSIDE the calculation.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

zoklor
decaying skeleton
decaying skeleton
Posts: 5
Joined: Wed Jul 07, 2004 1:12 pm

divide by zero thing

Post by zoklor » Wed Jul 07, 2004 1:25 pm

I know alot of you may understand this stuff, but unfortunately I am not a programmer/coder. I currently run SARS UI and have MQ2 running well. I still get the divide by zero. I sorta understand what your saying in that little snippet Lax posted, but it does me no good cause i dont know where to fix/paste the solution.

I havent been able to find a fix for "divide by zero" anywhere, and when i do, Its way over my head. Any help?

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

Post by aChallenged1 » Wed Jul 07, 2004 1:46 pm

May I offer you som flame retardent garments? :wink:

zoklor
decaying skeleton
decaying skeleton
Posts: 5
Joined: Wed Jul 07, 2004 1:12 pm

Post by zoklor » Wed Jul 07, 2004 1:52 pm

Sure, I know I will need them since people cant respond to a genuine question. I may not have posted much, but im no stranger to this site. So a little help would be beneficial pls.

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

Post by aChallenged1 » Wed Jul 07, 2004 1:56 pm

I could probably figure it out if I had all the info. It might take me the day, but I'm sure I could. If no one else does, I may do it, but it won't be today, for no other reason than to learn something.

Learning code isn't horrible, just tedious and sometimes boggling when you aren't familiar with it.

zoklor
decaying skeleton
decaying skeleton
Posts: 5
Joined: Wed Jul 07, 2004 1:12 pm

Post by zoklor » Wed Jul 07, 2004 1:59 pm

actually ok, I found something . This is from my EQUI_CastSpellWind.xml

- <Label item="CS_Times2">
<ScreenID>CS_Times2</ScreenID>
<EQType>9999</EQType>
<TooltipReference>${Math.Calc[(${Me.CurrentMana})/(${Me.Gem[3].Mana})].Int}</TooltipReference>
<Font>1</Font>
<RelativePosition>true</RelativePosition>
- <Location>
<X>74</X>
<Y>80</Y>
</Location>
- <Size>
<CX>30</CX>
<CY>12</CY>
</Size>
<Text />
- <TextColor>
<R>255</R>
<G>255</G>
<B>255</B>
</TextColor>
<NoWrap>true</NoWrap>
<AlignCenter>false</AlignCenter>
<AlignRight>false</AlignRight>
</Label>



I am guessing the "<TooltipReference>${Math.Calc[(${Me.CurrentMana})/(${Me.Gem[3].Mana})].Int}</TooltipReference> " ia the portion your talking about? or are there other files that use the same calculation?

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

Post by aChallenged1 » Wed Jul 07, 2004 2:01 pm

Code: Select all

${Math.Calc[(${Me.CurrentMana})/(${Me.Gem[3].Mana})].Int}
From what Lax posted above, I would say this is exactly where your problem stems from.

If you are playing a pure (read no mana) melee you could just remove that line, I'm sure. Otherwise it needs to be corrected according to what Lax posted.

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

Post by aChallenged1 » Wed Jul 07, 2004 2:05 pm

Ok, now I'm gonna ask a question, this one for Lax or anyone else who can answer it.

looking at the two pieces side by side I get the feeling that Lax's version, with it's IF statements will ignore mana if a pure melee type. Is this correct?

If so then you would simply replace:

Code: Select all

${Math.Calc[(${Me.CurrentMana})/(${Me.Gem[3].Mana})].Int}
with

Code: Select all

${If[${Me.Gem[1].ID},${Math.Calc[${Me.CurrentMana}/${If[${Me.Gem[1].Mana},${Me.Gem[1].Mana},9999999999]}].Int},]}
Correct or no?

What I am seeing is that it looks to see if there is a spell gem, and if there is, then it calculates mana, otherwise it won't touch it.

magictiger
a snow griffon
a snow griffon
Posts: 450
Joined: Sun Mar 21, 2004 2:24 pm

Post by magictiger » Wed Jul 07, 2004 3:20 pm

Lax's version also accounts for 0 mana spells such as cannibalize.

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

Post by aChallenged1 » Wed Jul 07, 2004 4:56 pm

yay, I'ma gonna go git me a cookie, LOL.

Thanks, it does feel good to find out that one's guess, however well founded it was, was correct.

There's your change for the UI!

zoklor
decaying skeleton
decaying skeleton
Posts: 5
Joined: Wed Jul 07, 2004 1:12 pm

Post by zoklor » Wed Jul 07, 2004 6:00 pm

Great!...thanks for helping with that. The only other question is, do i replace every line of --
${Math.Calc[(${Me.CurrentMana})/(${Me.Gem[3].Mana})].Int}

with your fixed one?

and should there be more associated .xml files that need fixing? or just the spellcastwind.xml?

zoklor
decaying skeleton
decaying skeleton
Posts: 5
Joined: Wed Jul 07, 2004 1:12 pm

Post by zoklor » Wed Jul 07, 2004 6:23 pm

Ok, update, I changed all those lines in my castspellwind.xml and set the bracketed numbers according to spell gem. Seem to be working just fine with no divided by number spam. Thanks for the info...BIG HELP!