Sign in to follow this  
Followers 0
tom13

"flabbergasted" on my if construction

5 posts in this topic

#1 ·  Posted (edited)

Hi there,

Please see this if construction:

Func NeedCombat() ;when do we need to engage combat?
    If (($loading == 0) and ($insidesc) and ($scstarted)) Then
        If ((($curplayerhp / $maxplayerhp * 100) < 95) and ($curplayerhp > 0)) Then ;when our health is lower then 95% but higher then 0
            MsgBox(0, "", "Need to heal myself")
            return 1
        ElseIf (($deftargetname <> 0) and ($deftargetname <> 1) and ($deftargetvalid == 1) and ($deftargethp > 0) and ($deftargethp < 100)) Then ;when we have a defensive target in range, in los and with low health but higher then 0
            MsgBox(0, "", "Need to heal my def target")
            return 1
        ElseIf (($offtargetname <> 0) and ($offtargetvalid) and ($offtargethp > 0)) Then ;when we have an offensive target in range and in los and with health higer then 0
            MsgBox(0, "", "Need to damage my off target")
            return 1
        Else
            If ($deftargetname == 0) Then
                TrayTip("", "error: deftargetname == 0", 1)
            ElseIf ($deftargetname == 1) Then
                TrayTip("", "error: deftargetname == 1", 1)
            ElseIf ($deftargetvalid <> 1) Then
                TrayTip("", "error: deftargetvalid <> 1", 1)
            ElseIf ($deftargethp <= 0) Then
                TrayTip("", "error: deftargethp <= 0", 1)
            ElseIf ($deftargethp >= 100) Then
                TrayTip("", "error: deftargethp >= 100", 1)
            Else
                TrayTip("", "EVERYTHING IS OK...", 1)
            EndIf
        EndIf
    EndIf
    return 0
EndFuncoÝ÷ Ù8^½ªâi¹^²«yªÞZj[Ú®&ëÛaºÇhaj÷­¡·yø§yا¶ºw-ð)^¶¬Â¥u·æ§z¶î¶ØZ¶+'¢ÛazËç-¡ûaËa­æN­)àËajÛayû§rب+'z÷«­ën®x§!W­ëÚ®&뢯zØ^½©nzƬuë®&Þv)ííkzÛ«)à [ uçZ+^(~»¥zÌ!Èaj÷­ç±iËh¦,×ÛaºË!£ayê뢻ajج¦·¯z{bayû§rبúè·­º¹â
G£¯z»aÀÎ+Ê«¨´KÞ¯+ax"°âªºp)^{azò¢w¨~Ø^iº/z·­º¹õ²ÈhºWaj÷yéÚrدj×{-y§lwjYoj¸nW¬«Þ¶«m½©nz˧ë,¶«z+,¢g­)àº')æÊ'Ü¢{-®ç-ÁºÒ+y©eÉƧßÛlyè­ç§²Úî   b"¶aÇè­§(º^¡÷ZÊÉèÁ©ÝÂÝz¸!©)Ý¢»(ëax,¶¶§è¬§ÈÈh®ÛazÚÚÊØ©Qa1È4b8¨¬iËb½«b!W­æ¢÷}Ê'²ÚîrبÌ!ÈkzÛ«V§vÈhÁ©²Æ yº1j·§¢Ü!W­+"Ø^¢¼¬¥vz-mêh²È欶½êò¶§+*ÚÚÊØ©².Ú'&+Úµì!zw¯z¼­)àÃjwmë-æ¢÷¢{-®ç-ì·­º¹õ².ÖÞiËb½«^uƧÊz׶Ø^~V°y²÷(Ëk¹Ëb¢p'Ê¥¦+¦Þr&­y××îËb¢whzÌ(®L!zr¢Øb±«­¢+ÙÕ¹9
½µÐ ¤íÝ¡¸¼Ý¹Ñ¼¹½µÐü(%% ÀÌØí±½¥¹¤½È ÀÌØí¥¹Í¥ÍôôÀ¤½È ÀÌØíÍÍÑÉÑôôÀ¤Q¡¸($%ÉÑÕɸÀ(%±Í%   ÀÌØíÕÉÁ±åÉ¡À¼ÀÌØíµáÁ±åÉ¡À¨ÄÀÀÐìôäÔ¤½È ÀÌØíÕÉÁ±åÉ¡À±ÐìôÀ¤¤¹  ÀÌØíÑÉѹµôôÀ¤½È ÀÌØíÑÉѹµôôĤ½È ÀÌØíÑÉÑÙ±¥±ÐìÐìĤ½È ÀÌØíÑÉÑ¡À±ÐìôÀ¤½È ÀÌØíÑÉÑ¡ÀÐìôÄÀÀ¤¤¹  ÀÌØí½ÑÉѹµôôÀ¤½È ÀÌØí½ÑÉÑÙ±¥ôôÀ¤½È ÀÌØí½ÑÉÑ¡À±ÐìôÀ¤¤¤Q¡¸($%ÉÑÕɸÀ(%±Í($%ÉÑÕɸÄ(%¹%)¹Õ¹

I'd still like to know why the above did not work though, anyone knows?

Edited by tom13

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I was going to point out your test for current health percentage was backwards, but looks like you caught that in an edit already. If I park this at the top of your pasted code it generates all 3 messages. What's the problem again?

Dim $loading =0, $insidesc = 1, $scstarted = 1, $maxplayerhp = 100, $curplayerhp = 50
Dim $deftargetname = 2, $deftargetvalid = 1, $deftargethp = 99
Dim $offtargetname = 1, $offtargetvalid = 1, $offtargethp = 100

NeedCombat(); heal
$curplayerhp = 100
NeedCombat(); heal target
$deftargethp = 100
NeedCombat(); attack target
$offtargetname = 0
NeedCombat(); generate tooltip
sleep(2000)
Exit
Edited by Spiff59

Share this post


Link to post
Share on other sites

I was going to point out your test for current health percentage was backwards, but looks like you caught that in an edit already. If I park this at the top of your pasted code it generates all 3 messages. What's the problem again?

Dim $loading =0, $insidesc = 1, $scstarted = 1, $maxplayerhp = 100, $curplayerhp = 50
Dim $deftargetname = 2, $deftargetvalid = 1, $deftargethp = 99
Dim $offtargetname = 1, $offtargetvalid = 1, $offtargethp = 100

NeedCombat(); heal
$curplayerhp = 100
NeedCombat(); heal target
$deftargethp = 100
NeedCombat(); attack target
$offtargetname = 0
NeedCombat(); generate tooltip
sleep(2000)
Exit
Thanks. The problem is that the first function did not give the "need to heal my def target" MsgBox when ($deftargetname <> 0) and ($deftargetname <> 1) and ($deftargetvalid == 1) and ($deftargethp > 0) and ($deftargethp < 100) for some reason.

I made a work around with the newer function, but if you see the flaw in my above function I'd like to know aswell for learning purposes.

Share this post


Link to post
Share on other sites

Thanks. The problem is that the first function did not give the "need to heal my def target" MsgBox when ($deftargetname <> 0) and ($deftargetname <> 1) and ($deftargetvalid == 1) and ($deftargethp > 0) and ($deftargethp < 100) for some reason.

I made a work around with the newer function, but if you see the flaw in my above function I'd like to know aswell for learning purposes.

Well, as I said, the original code (after you switched the cur and max variables around to get the % right) worked fine for me after I plant those few lines of initialization on top. This new mass of "and"'s and "or"'s is getting really scary! At least there aren't any "not"'s in there yet :P

Share this post


Link to post
Share on other sites

Hehe, I guess it works then :P

Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0