ScriptUO

Official ScriptUO EasyUO Scripts => Script Snippets => Topic started by: rana70 on October 12, 2009, 09:43:20 AM

Title: How to: Gain Mana with Meditation Skill
Post by: rana70 on October 12, 2009, 09:43:20 AM
Hi,

this is just a small example how to use :

- Use the Meditation Skill
- Read out a Journal
- auto disable the use of Meditation Skill if wrong armor is worn
- cast magery Spells

I added a lot of comments to give an idea how it works,
the Journal Scan is a basic solution and as soon as you
have got the idea I would recommend to check out
TM JournalScan SUB.
His Journal Scanner is far more advanced and fail safe.

Code: [Select]
;==============================================================================
; Script Name: Rana's SUB Mediatation
; Author: Rana
;==============================================================================

; Wait Timer feel free to adjust if you have timing related Error Msg.
Set %DelayEvent 20     ; Waittime for Event Macro Function
Set %DelaySkillUse 10  ; Waittime in sec between Skill uses

; #true  = use Mediation Skill for faster Mana Regneration
; #false = Skip this option, if you run out of mana script will just wait
Set %Medi_UseSkill #TRUE

; Set the Mana Level to start using the Meditation Skill to gain MANA
Set %Medi_StartLvl ( #MAXMANA / 2 )

; Internal Vars to check status and  failsafe
Set %Medi_Activ #FALSE       ; This will report when the Medi Skill is activ
Set %NextTimeforSkill #SCNT  ; Marker when you can use the skill next Time



; MainScriptLoop
;------------------------ Main Script -------------------------
Repeat
 {
 ; Check Mana and if needed use Meditation SUB to regain
 if #MANA < %Medi_StartLvl
  GoSUB Meditation

 ; Do what ever you like to do in your Main Loop
 ; In this case I simply Cast a Magery Spell

 Event Macro 15 43 ; Cast Spell Invis
  Wait %DelayEvent
 Target
 Event Macro 23 ; Target Self
  Wait %DelayEvent

 Wait 3s ; just wait for next Spell
}
Until #CHARGHOST = YES
; End of Script
HALT

; SUB's Area
; =================================================



; Re Gain Mana with or without the Help of MEDI Skill
;------------------------ Routine -----------------------------
SUB Meditation
  While %Medi_UseSkill = #TRUE && %Medi_Activ = #FALSE
   {
    ; Call the SUB for the Meditation Skill
    GoSUB UseSkill_Meditation

    ; Check if the Medi Skill became active
    ; RESULT is TRUE if Medi Skill is active
    ; Medi active means, basicly stop
    ; "use skill Medi" and start to gain Mana
    GoSUB JournalScan You_enter_a_meditative_trance
    if #RESULT = #TRUE
     Set %Medi_Activ #TRUE

    ; Failsafe routine if the Char wears any wrong
    ; armor, to prevent script from trying to use Medi Skill
    ; RESULT is TRUE will auto deactivate the Mediation part
    GoSUB JournalScan penetrate
    if #RESULT = #TRUE
     Set %Medi_UseSkill #FALSE
   }

   ; Wait for Mana gain
   While #MANA < #MAXMANA
    {
     ;Simply Wait until #Mana reached #Maxmana
    }

   ; Reset Medi_Activ flag for next cylcle
   Set %Medi_Activ #FALSE
RETURN

; Use Meditation Skill
;------------------------ Routine -----------------------------
SUB UseSkill_Meditation
  ; just wait before use the Skill to prevent error Msg
  ; if you do not wait you will have error Msg on screen
  While #SCNT < %NextTimeforSkill
   {
   }
   ; Use Medi Skill
   Event Macro 13 46 ; Use Meditation Skill
    Wait %DelayEvent
   ; Timer for next possible skill use
   Set %NextTimeforSkill ( #SCNT + %DelaySkillUse )
RETURN

; Scan the Journal Log for Keywords
;------------------------ Routine -----------------------------
SUB JournalScan %1
  ; %1 Text to Scan for
  Set %JournalStart #jIndex
  Set %ScanMessage %1

  For %tmp %JournalStart #jIndex
   {
    Scanjournal %tmp
    if %ScanMessage in #journal
     RETURN #TRUE
   }
RETURN #FALSE


cu
Title: Re: How to: Gain Mana with Meditation Skill
Post by: Endless Night on October 12, 2009, 11:27:21 AM
Might want to bung a wait 1 in thier to give the OS a chance to do something elese while its waiting.

Code: [Select]
   ; Wait for Mana gain
   While #MANA < #MAXMANA
    {
     ;Simply Wait until #Mana reached #Maxmana
    }
Title: Re: How to: Gain Mana with Meditation Skill
Post by: Wakiza on October 12, 2009, 04:00:34 PM
Hi Rana70, this is very nice. It basically does exactly what i was trying to do. I really like how everything is laid out, seems very organized compared to other scripts i been trying to decipher. Now that you have taken the time to help, hopefully i can learn from it! I must admit i feel a bit overwhelmed, but i think it will just take some time.

Thanks for your help with this problem.





Title: Re: How to: Gain Mana with Meditation Skill
Post by: Hoby on November 18, 2009, 02:20:21 PM
thx rana was looking for this exactly.  Now need to figure out to implement it into my script. :)