Author Topic: Dissecting/Understanding a Mana Check/Meditate Sub  (Read 1574 times)

0 Members and 1 Guest are viewing this topic.

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3016
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Dissecting/Understanding a Mana Check/Meditate Sub
« on: April 14, 2015, 06:44:51 PM »
0
I am trying to understand this sub and make sure that it is correct.
Code: [Select]
sub CheckMana
  gosub newstatus lime black Checking Mana
  set %_test ( 100 * #mana ) / #maxmana
  if ( %_test < 20 ) || ( #mana < %mana )
  {

If I am correct, it is setting the amount of mana at 100% I.E. if the character has 138 mana, it sets 138 as 100% mana and then it sets 20% mana so it can do something when mana falls below the 20% threshold.

    
Code: [Select]
gosub newstatus lime black 10 Meditating
    while #systime < %_lastskillt
    {
      sleep 10
    }

Checks the system time compared to when the last skill was used, if it is less than what time will be set, sit idle for 10 (not sure if it is like a wait 10 or wait 10s)?

Code: [Select]
   event macro 13 46 ; meditate
    set %_lastskillt #systime + 10200
    while #mana < ( 95 * #maxmana / 100 )
    {
      wait 20
      if %_lastskillt < #systime
      

ok, this uses the skill meditate and then sets that time as the last skill time and ads a timer of 10.2 seconds? Then says keep going as long as mana is less than 95%? Then has a short wait then starts comparing the time to the time of the last skill used?

    
Code: [Select]
{
        event macro 13 46 ; meditate
        set %_lastskillt #systime + 10200
      }
    };

Does the same thing again?

  
Code: [Select]
set %_diff #systime - %_lastskillt - 9000
    if %_diff > 0
    {
      set %_diff ( %_diff / 50 ) + 1
    }
  }

This part loses me, sets a difference between the system time and the last skill time - 9 seconds and then halfs that difference and adds 1 second? I am stumped for sure on this part.

Code: [Select]
menu delete scriptstatus
return

Deletes the menu status message and a return


So, how far off am I, is this code solid as a mana check/med sub?

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Dissecting/Understanding a Mana Check/Meditate Sub
« Reply #1 on: April 15, 2015, 05:32:23 AM »
0

Tags: