ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: vanzelus on January 04, 2014, 05:28:02 PM

Title: Please help with an "OR" action code line.
Post by: vanzelus on January 04, 2014, 05:28:02 PM
Hi,

Am trying to implement the chivalry cure poison spell into a script that I currently run for my sampire; I only want to use this spell when my character is not in combat and is poisoned.  Is this the correct way to write it?

Code: [Select]
IF ( G Notin #charstatus ) && ( C In #charstatus ) && ( #mana >= 10) && ( %cast_wait_timer <= #scnt2 )
{
    Event Macro 15 201
    Target 5s
    Event Macro 23 0
    Set %cast_wait_timer #scnt2 + 20
    Repeat
    Until C Notin #charstatus Or G in #charstatus
}
Return

Thanks for the inputs.
Title: Re: Please help with an "OR" action code line.
Post by: 12TimesOver on January 04, 2014, 08:19:20 PM
You don't need the parens () unless you're grouping multiple criteria together:

for example
Code: [Select]
IF G Notin #charstatus && C In #charstatus && ( #mana >= 10 || %cast_wait_timer <= #scnt2 )
This treats whatever is within the () as a single qualifier for IF.

X
Title: Re: Please help with an "OR" action code line.
Post by: vanzelus on January 04, 2014, 10:02:55 PM
You don't need the parens () unless you're grouping multiple criteria together:

for example
Code: [Select]
IF G Notin #charstatus && C In #charstatus && ( #mana >= 10 || %cast_wait_timer <= #scnt2 )
This treats whatever is within the () as a single qualifier for IF.

X

That || symbol you used, can that be used to change the last line in my snippet

Code: [Select]
Until C Notin #charstatus Or G In #charstatus

to

Code: [Select]
Until C Notin #charstatus || G In #charstatus

Does that still accomplish the purpose that the char only casts cure when out of combat and if a new mob spawns, he'll stop casting even if still poisoned and attack the mob?  The char has protection on so am not accounting for failure due to poison interruption.
Title: Re: Please help with an "OR" action code line.
Post by: Alpha on January 04, 2014, 10:32:05 PM
Something like this is how I'd go about it...   The Repeat loop only loops what's BETWEEN the Repeat / Until  which is nada.


Code: [Select]
Sub Cast_Cure
set %Cast_wait_timer #Scnt2 + 20
CAST:
If G Notin #charstatus && C In #charstatus && #mana >= 10 && %cast_wait_timer <= #scnt2
{
    Event Macro 15 201
    Target 5s
    Event Macro 23 0
    wait 10  ;--- Clean by Fire actually takes time to cure AFTER Targetting Adjust as needed....
    goto CAST
 
}
Return
Title: Re: Please help with an "OR" action code line.
Post by: dxrom on January 05, 2014, 02:14:11 AM
Let's not forget parenthesis influence in order of operations... Caution should be executed when throwing them around :>
Title: Re: Please help with an "OR" action code line.
Post by: Endless Night on January 05, 2014, 06:28:59 AM
That || symbol you used, can that be used to change the last line in my snippet

Code: [Select]
Until C Notin #charstatus Or G In #charstatus

to

Code: [Select]
Until C Notin #charstatus || G In #charstatus


Their is no command "OR" in easyuo.  The command for 'or' in easyuo is "||".  

Therefor you have to do it your revised way .. Until C Notin #charstatus || G In #charstatus


but be carefull with your repeat loop your code WILL get stuck looping and doing nothing if your spell fails so instead of
Repeat
Until C Notin #charstatus || G in #charstatus

Maybe you should change your code to a structure such as this
Repeat
    if blabla
       caste spell
 Until C Notin #charstatus || G in #charstatus
Title: Re: Please help with an "OR" action code line.
Post by: vanzelus on January 05, 2014, 07:43:08 AM
Thank you guys for your inputs  :), it's clearer now what the code should be