ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: The Ghost on July 21, 2016, 05:25:39 PM

Title: main loop optimization
Post by: The Ghost on July 21, 2016, 05:25:39 PM
I have made a rail to help me kill monster.   

 Right now it work like it suppose but sometime  the monster don't die on the first cast.  I add a double cast  but I'm sure their a better way to do this. 


Code: [Select]
repeat
   for %C 1 21
    {
    if #HITS < ( #MAXHITS - 15 )
      {
      Event exmsg #CHARID 3 30 Damage heal!
         if C in #CHARSTATUS
             gosub TM_NewCastSpell 24 SELF -1 20 20 ;  cast A cure until successful
         gosub TM_NewCastSpell 28 self 1 10 10 ; G Heal support Charactere
       }
     gosub pathfind_to_point  %Spotx . %c %Spoty . %c
      Finditem %Castsummon G_8     
       if #findCnt > 0  &&  #FOLLOWERS < 5
         gosub castsummon 57 ;  606 NF _57  EV
      Finditem %Rikktor G_5
         if #findCnt > 0
            gosub wither
       Finditem %Rikktor G_5
         if #findCnt > 0
            gosub wither
      }
until #charghost = yes

Title: Re: main loop optimization
Post by: 12TimesOver on July 22, 2016, 05:31:58 AM
Probably a number of ways to do that...

Maybe use a while?

Code: [Select]
Finditem %Rikktor G_5
while #findCnt > 0
   {
   gosub wither
   Finditem %Rikktor G_5
   }

or another repeat?

Code: [Select]
repeat
   Finditem % Riktor G_5
   if #findcnt > 0
      gosub wither
until #findcnt < 1

Not sure if that is what you're getting at.

X