Author Topic: main loop optimization  (Read 3019 times)

0 Members and 1 Guest are viewing this topic.

Offline The GhostTopic starter

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
main loop optimization
« on: July 21, 2016, 05:25:39 PM »
0
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


Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: main loop optimization
« Reply #1 on: July 22, 2016, 05:31:58 AM »
0
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
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Tags: