FANDOM


This tutorial was created by scoterr on the RealmCrafter: Community Edition forums.

To create casting time bar we will use ProgressBar function. Default fireball script:

Using "RC_Core.rcm"


Function Main()

    Player = Actor()
    Target = ContextActor()

    ;Check if the target is correct?
    If(Target = 0)
        Output(Player, "Target not correct")
        Return
    EndIf

    ;Check the mana
    ManaLevel = Attribute(Player, "Mana")
    If(ManaLevel < 1)
        Output(Player, "Not enough Mana")
        Return
    EndIf
        SetAttribute(Player, "Mana", ManaLevel -1)


    ;Particles and casting animation
    AnimateActor(Player, "Pray", 0.05, 1)
    FireProjectile(Player, Target, "Fireball")

    DoEvents(2000)
 CreateEmitter(Target, "Waterfall", 10, 100)
    hp = Attribute(Target, "Health")
    damage = Rand(30,60)
    SetAttribute(Target, "Health", hp-damage)

   ;If (hp-Damage)<1
   ;KillActor(Target, Player)
   ;Endif

    Return

End Function

This part is used for firing the projectile. 

;Particles and casting animation
AnimateActor(Player, "Pray", 0.05, 1)
FireProjectile(Player, Target, "Fireball")
We need to create casting bar before firing the particle. 

Whole code for casting bar

Casting_Bar = CreateProgressBar(Player,255,0,0,0.01,0.48,0.2,0.04,100,0,"Casting")
Casting_Time = 1
Repeat
    Casting_Time = Casting_Time + 1
    UpdateProgressBar(Player,Casting_Bar,Casting_Time)
    DoEvents(25)
Until Casting_Time > 100
DeleteProgressBar(Player,Casting_Bar)
Creating new ProgressBar called Casting_Bar for actor player, colored red, with max value of 100 and starting on 1.
Casting_Bar = CreateProgressBar(Player,255,0,0,0.01,0.48,0.2,0.04,100,1,"Casting")
Declaring variable for value of the ProgressBar
Casting_Time = 1
Repeat loop adding 1 to the Casting_Time, updating ProgressBar called Casting_Bar for actor Player with value of Casting_Time, waiting 25ms and repeating everything until Casting_Time (the value of our ProgressBar) is 100.
Repeat
    Casting_Time = Casting_Time + 1
    UpdateProgressBar(Player,Casting_Bar,Casting_Time)
    DoEvents(25)
Until Casting_Time > 100
Deleting ProgressBar after use
DeleteProgressBar(Player,Casting_Bar)
And now we can fire our projectile.

Whole script:

Using "RC_Core.rcm"
Function Main()

    Player = Actor()
    Target = ContextActor()

    ;Check if the target is correct?
    If(Target = 0)
        Output(Player, "Target not correct")
        Return
    EndIf

    ;Check the mana
    ManaLevel = Attribute(Player, "Mana")
    If(ManaLevel < 1)
        Output(Player, "Not enough Mana")
        Return
    EndIf
        SetAttribute(Player, "Mana", ManaLevel -1)


    ;Particles and casting animation
    AnimateActor(Player, "Pray", 0.05, 1)
    Casting_Bar = CreateProgressBar(Player,255,0,0,0.01,0.48,0.2,0.04,100,0,"Casting")
    Casting_Time = 1
    Repeat
       Casting_Time = Casting_Time + 1
       UpdateProgressBar(Player,Casting_Bar,Casting_Time)
       DoEvents(25)
    Until Casting_Time > 100
    DeleteProgressBar(Player,Casting_Bar)
    FireProjectile(Player, Target, "Fireball")

    DoEvents(2000)
 CreateEmitter(Target, "Waterfall", 10, 100)
    hp = Attribute(Target, "Health")
    damage = Rand(30,60)
    SetAttribute(Target, "Health", hp-damage)

   ;If (hp-Damage)<1
   ;KillActor(Target, Player)
   ;Endif

    Return

End Function
Have fun!