Page 1 of 1

Fix: Divide by Zero Errors, and Casting Range notifier

Posted: Tue Jun 22, 2004 3:08 am
by GD
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.

Posted: Tue Jun 22, 2004 6:12 am
by WhiteWolf
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.

Posted: Tue Jun 22, 2004 11:24 am
by fryfrog
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.

Posted: Tue Jun 22, 2004 12:36 pm
by Lax
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.

divide by zero thing

Posted: Wed Jul 07, 2004 1:25 pm
by zoklor
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?

Posted: Wed Jul 07, 2004 1:46 pm
by aChallenged1
May I offer you som flame retardent garments? :wink:

Posted: Wed Jul 07, 2004 1:52 pm
by zoklor
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.

Posted: Wed Jul 07, 2004 1:56 pm
by aChallenged1
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.

Posted: Wed Jul 07, 2004 1:59 pm
by zoklor
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?

Posted: Wed Jul 07, 2004 2:01 pm
by aChallenged1

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.

Posted: Wed Jul 07, 2004 2:05 pm
by aChallenged1
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.

Posted: Wed Jul 07, 2004 3:20 pm
by magictiger
Lax's version also accounts for 0 mana spells such as cannibalize.

Posted: Wed Jul 07, 2004 4:56 pm
by aChallenged1
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!

Posted: Wed Jul 07, 2004 6:00 pm
by zoklor
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?

Posted: Wed Jul 07, 2004 6:23 pm
by zoklor
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!