RealmCrafter Wiki
Advertisement

Created by UUICEO.

Using "RC_Core.rcm" 
; Aftermath!
; Date/Time: 11:20:32 PM on 3/24/2009
; By UUICEO on RealityCrafters
;
; Spell Template for Standard Projectile type spells
; This is the base script used in SCW for the damage spells tab
;

Dim Reagent$(9, 1)
Dim HasReagent$(9)

Function Main()

   Attacker% = Actor()
   Target% = ContextActor()


;
;==================================[Spell Template Variables]=======================
;
;===================================================================================
;         Adjust Attacker Attributes                    =
;===================================================================================

   ReduceAttackerSpeed# = .25 ;Set this to the % you want the attackers Speed
;               Attribute to be while casting, (zero to disable)
;-----------------------------------------------------------------------------------
   ManaCost% = 15 ;           Set this # to the amount of MANA the spell will
;               Cost to Successfully cast

;===================================================================================
;         Movement Modifiers and requirements             =
;===================================================================================

   RequireStop% = 0 ;      Set this to 1 to force the caster to stop while
;            casting this spell
;-----------------------------------------------------------------------------------
   NoMovement% = 1 ;      If set to 1 this option will cancel a spell being
;            cast if casters location changes durring casting

;===================================================================================
;         Multi-Projectile Spell                   =
;===================================================================================

;   Set this to something other than 1 to have the spell fire additional projectiles
   MultiShot% = 5
;-----------------------------------------------------------------------------------
;   Set this value to the delay time (in Milliseconds) between shots for a multi-shot spell
   MultiShotDelay% = 350

;===================================================================================
;         Chain Spell                         =
;===================================================================================

;   Set this to 1 too allow the cast projectile to hit multiple targets after the initial hit
   IsChain% = 0

;===================================================================================
;         Spell Reagents needed to case spell             =
;===================================================================================

;   Set this to the total # of different items the caster is required to have to case this spell, zero to disable
   ReagentsTotal% = 0
;-----------------------------------------------------------------------------------
;   Set these next values to the items the caster must have in their inventory to cast this spell
;   Note that these should be items that are expendable like roots or other such items (up to 10 items per spell)
;   Also Note that you can also specify a Quantity of each item. leave at zero to just make sure the caster has the item
;   but the item will not be removed from the casters inventory.

;=-=-=-=-=-[Items]-=-=-=-=-=-=-=
   Reagent$(0, 0) = ""
   Reagent$(1, 0) = ""
   Reagent$(2, 0) = ""
   Reagent$(3, 0) = ""
   Reagent$(4, 0) = ""
   Reagent$(5, 0) = ""
   Reagent$(6, 0) = ""
   Reagent$(7, 0) = ""
   Reagent$(8, 0) = ""
   Reagent$(9, 0) = ""

;=-=-=-=-=-[Item QTY]-=-=-=-=-=
   Reagent$(0, 1) = "0"
   Reagent$(1, 1) = "0"
   Reagent$(2, 1) = "0"
   Reagent$(3, 1) = "0"
   Reagent$(4, 1) = "0"
   Reagent$(5, 1) = "0"
   Reagent$(6, 1) = "0"
   Reagent$(7, 1) = "0"
   Reagent$(8, 1) = "0"
   Reagent$(9, 1) = "0"

;===================================================================================
;         Casting Animation and Animation Speed             =
;===================================================================================

;   Set this to the Animation to use for casting the Spell, 'NONE' to disable
   CastingAnimation$ = "Default attack"
;-----------------------------------------------------------------------------------
;             Set this to the speed at which the animation should run (0.5 = half speed)
   CastingAnimationSpeed# = 0.4

;===================================================================================
;           Set Casting Time (Delay)                   =
;===================================================================================

    CastingTime% = 2000 ;   Set this to = the amount of time you want the
;               spell to take to cast (1000 = 1 second)
   
;===================================================================================
;            Set Min/Max distances and Range Modifications          =
;===================================================================================

   MinDistance# = 0.0 ;      Set this to the minimum distance a target must be
;                  from the player to be able to use the spell
;-----------------------------------------------------------------------------------
   MaxDistance# = 80.0 ;   Set this to the maximum distance a target can be
;                  away from the attacker to be able to use the spell
;-----------------------------------------------------------------------------------
   UseRangeMod = 1.1 ;      Set this to a value you want to use as a modifyer
;               multiplied against ability level, ZERO Disables
;-----------------------------------------------------------------------------------
   UseDamageMod = .75 ;      Set this to a value you want to use as a modifyer
;               multiplied against ability level, ZERO Disables

;===================================================================================
;         Set Spell Damage Type                    =
;===================================================================================

   SpellDamageType% = 2 ;   Set the damage type so our output knows what info
;               to display to the target and what resistances to
;               to use when checking resistance.
;===================================================================================
;         Set Spell, Emitter and Projectile Names                 =
;===================================================================================

;    Change this to the name of the spell ability that is needed for this spell
   SpellAbilityName$ = "FireBall"
;-----------------------------------------------------------------------------------
;   Change this to the name you want to be displayed for all output messages, Leave Blank to use SpellAbilityName$
   SpellDisplayName$ = ""
;-----------------------------------------------------------------------------------
;   This is the Emitter to Attach to the Attacker while Casting the spell, Leave Blank for NONE
   AttackerEmitterName$ = "MMCast"
;-----------------------------------------------------------------------------------
;      This is the emitter to attach to the target if the projectile hits the Target, Leave Blank for NONE
   TargetEmitterName$ = "Explode"
;-----------------------------------------------------------------------------------
;   This is the name of the Projectile to use
   ProjectileName$ = "Fireball"
;-----------------------------------------------------------------------------------
;     This is the ID of the texture to use for the AttackerEmitter (Casting Spell Emitter Prior to Projectile Fireing)
   AttackerEmitterTextureID = 15
;-----------------------------------------------------------------------------------
;   This is the ID of the texture to use for the TargetEmitter (Projectile HIT Target emitter)
   TargetEmitterTextureID = 109

;===================================================================================
;              Set Sound options                      =
;===================================================================================

;    Set this to 1 to allow for Casting and Hit sounds for this spell, zero to disables
   UseSpellSounds% = 1
;-----------------------------------------------------------------------------------
;        Set this to the sounds GUE ID # that you want to use for the CASTING sound, zero to disable
   CastingSoundID% = 3
;-----------------------------------------------------------------------------------
;                  Set this to the sounds GUE ID # that you want to use for the PROJECTILE sound, zero to disable
   ProjectileSoundID% = 30
;   -----------------------------------------------------------------------------------
;          Set this to the sounds GUE ID # that you want to use for the Spell HITTING Target sound, zero to disable
   SpellHitSoundID% = 4

;===================================================================================
;         Set Screen Flash Options                   =
;===================================================================================

   FlashScreenAttacker% = 1 ;   Set this to 1 to flash the casters screen when
;               the spell is cast, zero to disable the flash
;-----------------------------------------------------------------------------------
   FlashScreenTarget% = 1 ;   Set this to 1 to flash the targets screen if the
;                spell makes a successfull hit
;-----------------------------------------------------------------------------------
   AttackerFlashTime% = 750 ;   Set the length of time the screen flash will last
;               for the Attacker
;-----------------------------------------------------------------------------------
   TargetFlashTime% = 1000 ;   Set the length of time the screen flash will last
;               for the Target
;-----------------------------------------------------------------------------------
   AttackerRED% = 255 ;      Set this to the RED value for the screen flash
;                        color of the Attacker
;-----------------------------------------------------------------------------------
   AttackerGREEN% = 20 ;   Set this to the GREEN value for the screen flash
;                  color of the Attacker
;-----------------------------------------------------------------------------------
   AttackerBLUE% = 10 ;      Set this to the BLUE value for the screen flash
;                         color of the Attacker
;-----------------------------------------------------------------------------------
   TargetRED% = 255 ;      Set this to the RED value for the screen flash
;               color of the Target
;-----------------------------------------------------------------------------------
   TargetGREEN% = 20 ;      Set this to the GREEN value for the screen flash
;               color of the Target
;-----------------------------------------------------------------------------------
   TargetBLUE% = 10 ;      Set this to the BLUE value for the screen flash
;                   color of the Target

;===================================================================================
;         Set Min/Max Damage of spell                   =
;===================================================================================

   MinDamage% = 10 ;      This is the minimum amount of (BASE) damage the
;               spell will do on a successfull hit
;-----------------------------------------------------------------------------------
   MaxDamage% = 25 ;      This is the maximum amount of (BASE) damage the
;               spell will do on a successfull hit

;===================================================================================
;            BEGIN MAIN SPELL SCRIPT                 =
;===================================================================================

   If SpellDisplayName$ = "" Then SpellDisplayName$ = SpellAbilityName$
   If UseRangeMod <> 0 Then
      RangeMod = Int(AbilityLevel(Attacker, SpellName$) * RangeMod)
      MaxDistance = MaxDistance + (MaxDistance * RangeMod)
   Else
      RangeMod = 0
   EndIf
   If UseDamageMod <> 0 Then
      DamageMod = AbilityLevel(Attacker, SpellName$) * 1.25
      MaxDamage = MaxDamage + (MaxDamage * DamageMod)
   Else
      DamageMod = 0
   EndIf
   TargetDistance# = ActorDistance(Attacker, Target)
   AttackerNormalSpeed% = Attribute(Attacker, "Speed")

;   Check for correct distance between attacker and target
   If MinDistance > TargetDistance Then
      OutPut(Attacker, "Your target is too close to use that spell.", 255, 255, 255)
          Return
   ElseIf TargetDistance > MaxDistance Then
      OutPut(Attacker, "Your target is too far away to use that spell.", 255, 255, 255)
      Return
   EndIf

;   Check for needed Reagents in Attackers Backpack

   If ReagentsTotal <> 0
      For i = 0 to ReagentsTotal
         If Reagent$(i, 0) <> ""
            If Int(Reagent$(i,1)) = 0 And HasItem(Attacker, Reagent$(i, 0), 1) Then
               HasReagent$(i) = Reagent$(i, 0)
               Reagent$(i, 0) = ""
            ElseIf HasItem(Attacker, Reagent$(i, 0), Int(Reagent$(i, 1))) Then
               HasReagent$(i) = Reagent$(i, 0)
               Reagent$(i, 0) = ""
            Else
               OutPut(Attacker, "You are missing Reagents to be able to cast this spell.")
               Return
               
            EndIf
         EndIf
      Next
      For i = 0 to ReagentsTotal
         If HasReagent$(i) <> "" Then
            If Reagent$(i, 1) <> 0 Then
               GiveItem(Attacker, HasReagent$(i), -(Int(Reagent$(i, 1))))
            EndIf
         EndIf
      Next
   EndIf

;   Reset attackers speed if applicable

   If ReduceAttackerSpeed# <> 0 And RequireStop = 0 Then
      AttackerSpeed# = AttackerNormalSpeed * ReduceAttackerSpeed#
      SetAttribute(Attacker, "Speed", Int(AttackerSpeed))
   ElseIf RequireStop = 1 Then
      SetAttribute(Attacker, "Speed", 0)
   EndIf
   CasterX# = ActorX(Attacker)
   CasterY# = ActorY(Attacker)
   CasterZ# = ActorZ(Attacker)

;   Give some game enhancing output
   Output(Attacker, "You begin casting " + SpellDisplayName$, 127, 255, 20)

;   Turn on Casting Emitter if applicable

   StartMS = Millisecs()
   If AttackerEmitterName$ <> "" Then
      CreateEmitter(Attacker, AttackerEmitterName$, AttackerEmitterTextureID, 1000)
   EndIf

;   Turn on the casting sound if applicable

   If UseSpellSounds <> 0 Then
      If CastingSoundID <> 0 Then
         PlaySound(Attacker, CastingSoundID, 1)
      EndIf
   EndIf
 

;      Start Casting Animation

   If Upper(CastingAnimation$) <> "NONE" or CastingAnimation$ <> "" Then
      AnimateActor(Attacker, CastingAnimation$, CastingAnimationSpeed#)
   EndIf

;   Create the Casting time Progress Bar

   Pbar% = CreateProgressBar(Attacker, 250, 175, 0, 0.39, 0.35, 0.2, 0.04, 100, 1, "Gathering Magic Power")
   Clicks = 0
   DelayPeriod# = CastingTime / 100
   KillSpell = 0

;   Do our casting delay prior to shooting the projectile(s)

   Repeat
      KillSpell = Checkmovement%(Attacker%, CasterX#, CasterY#, CasterZ#, NoMovement%)
      If KillSpell = 1 Then
            DeleteProgressBar(Attacker, Pbar)
            OutPut(Attacker, "Your Movement caused your spell to fail.")
            SetAttribute(Attacker, "Speed", AttackerNormalSpeed)
            Return
      EndIf
      If AttackerEmitterName$ <> "" Then
         CheckMS = Millisecs()
         If CheckMS > (StartMS + 1000) Then
            StartMS = CheckMS
            CheckMS = Millisecs()
            CreateEmitter(Attacker, AttackerEmitterName$, AttackerEmitterTextureID, 1000)
         EndIf
      EndIf
      Clicks = Clicks + 1
      DoEvents(DelayPeriod#)
      UpdateProgressBar(Attacker, Pbar, Clicks)
   Until Clicks = 100
   DeleteProgressBar(Attacker, Pbar)

;   Fire the projectile(s)

   Repeat

;   Flash the attackers Screen if applicable

      If FlashScreenAttacker And ActorIsHuman(Attacker) Then
         ScreenFlash(Attacker, AttackerRED, AttackerGREEN, AttackerBLUE, 200, AttackerFlashTime, 65535)
      EndIf

      TargetDistance# = ActorDistance(Attacker, Target)

;   Check for movement of attacker

      KillSpell = Checkmovement%(Attacker%, CasterX#, CasterY#, CasterZ#, NoMovement%)
      If KillSpell = 1 Then
            DeleteProgressBar(Attacker, Pbar)
            OutPut(Attacker, "Your Movement caused your spell to end Early.")
            SetAttribute(Attacker, "Speed", AttackerNormalSpeed)
            Return
      EndIf

;   Turn on projectile being fired sound

      If  UseSpellSounds <> 0 Then
         If  ProjectileSoundID% <> 0 Then
            PlaySound(Attacker,  ProjectileSoundID, 1)
         EndIf
      EndIf

      FireProjectile(Attacker, Target, ProjectileName$)

;   Track our projectile via a function (Shoot and forget function)

      TrackProjectile(Attacker%, Target%, MultiShot%, MaxDamage%, MinDamage%, TargetDistance#, DamageType%, FlashScreenTarget%, TargetEmitterName$, TargetEmitterTextureID%, SpellHitSoundID%, UseSpellSounds%, TargetRED%, TargetGREEN%, TargetBLUE%, TargetFlashTime%, AttackerNormalSpeed)

;   If this is a multiple projectile spell then do our delay before repeating the process

      DoEvents(MultiShotDelay + 1)
      MultiShot = MultiShot - 1
   Until MultiShot < 1

;   Reset the attackers speed to Normal

   SetAttribute(Attacker, "Speed", AttackerNormalSpeed)

   Output(Attacker, "Exiting From Script")
   Output(Attacker, "Current Speed = " + Attribute(Attacker, "Speed"))

   Return
End Function


Function TrackProjectile(fAttacker%, fTarget%, fMultiShot%, fMaxDamage%, fMinDamage%, fTargetDistance#, fDamageType%, fFlashScreenTarget%, fTargetEmitterName$, fTargetEmitterTextureID, fSpellHitSoundID, fUseSpellSounds, fTargetRED, fTargetGREEN, fTargetBLUE, fTargetFlashTime, fAttackerNormalSpeed)

;   Add in a delay before we check to see if we successfully hit our target and
;   Turn on the Target hit Emitter
   If fMultiShot = 1 Then
      SetAttribute(fAttacker, "Speed", fAttackerNormalSpeed)
   EndIf
   ProjectileDistanceTraveled = fTargetDistance
   While ProjectileDistanceTraveled > 0
      DoEvents(100)
      ProjectileDistanceTraveled = ProjectileDistanceTraveled - 4
   Wend

;   Flash the Targets Screen if applicable
   If fFlashScreenTarget And ActorIsHuman(fTarget) Then
      ScreenFlash(fTarget, fTargetRED, fTargetGREEN, fTargetBLUE, 200, fTargetFlashTime, 65535)
   EndIf

;    Add Target Emitter if applicable
   If fTargetEmitterName$ <> "" Then
      CreateEmitter(fTarget, fTargetEmitterName$, fTargetEmitterTextureID, 1000)
   EndIf

;   Add Target Hit Sound
   If fUseSpellSounds <> 0 Then
      If fSpellHitSoundID <> 0 Then
         PlaySound(fTarget, fSpellHitSoundID, 1)
      EndIf
   EndIf

   ToHit% = 0
   ApplyDamage(fAttacker%, fTarget%, fDamageType%, fMinDamage, fMaxDamage)
Return

End Function



Function ApplyDamage(fAttacker%, fTarget%, fDamageType%, fMinDamage, fMaxDamage)

   If fDamageType% = 1 Then

      DMGType$ = "NORMALFIRE"
      DMGOutput$ = "Fire"

   ElseIf fDamageType% = 2 Then

      DMGType$ = "MAGICFIRE"
      DMGOutput$ = "Magical Fire"

   ElseIf fDamageType% = 3 Then

      DMGType$ = "OTHERFIRE"
      DMGOutput$ = "Fire"

   ElseIf fDamageType% = 4 Then

      DMGType$ = "NORMALELECTRIC"
      DMGOutput$ = "Electrical"

   ElseIf fDamageType% = 5 Then

      DMGType$ = "MAGICELECTRIC"
      DMGOutput$ = "Magical Electric"

   ElseIf fDamageType% = 6 Then

      DMGType$ = "OTHERELECTRIC"
      DMGOutput$ = "Electrical"

   ElseIf fDamageType% = 7 Then

      DMGType$ = "NORMALWIND"
      DMGOutput$ = "Wind"

   ElseIf fDamageType% = 8 Then

      DMGType$ = "MAGICWIND"
      DMGOutput$ = "Magical Wind"

   ElseIf fDamageType% = 9 Then

      DMGType$ = "OTHERWIND"
      DMGOutput$ = "Wind"

   ElseIf fDamageType% = 10 Then

      DMGType$ = "NORMALIMPACT"
      DMGOutput$ = "Impact"

   ElseIf fDamageType% = 11 Then

      DMGType$ = "MAGICIMPACT"
      DMGOutput$ = "Magical Impact"

   ElseIf fDamageType% = 12 Then

      DMGType$ = "OTHERIMPACT"
      DMGOutput$ = "Impact"

   ElseIf fDamageType% = 13 Then

      DMGType$ = "NORMALHOLY"
      DMGOutput$ = "Holy"

   ElseIf fDamageType% = 14 Then

      DMGType$ = "DIVINEHOLY"
      DMGOutput$ = "Divine Holy"

   ElseIf fDamageType% = 15 Then

      DMGType$ = "OTHERHOLY"
      DMGOutput$ = "Holy"

   ElseIf fDamageType% = 16 Then

      DMGType$ = "NORMALUNHOLY"
      DMGOutput$ = "UnHoly"

   ElseIf fDamageType% = 17 Then

      DMGType$ = "DIVINEUNHOLY"
      DMGOutput$ = "Divine UnHoly"

   ElseIf fDamageType% = 18 Then

      DMGType$ = "OTHERUNHOLY"
      DMGOutput$ = "UnHoly"

   ElseIf fDamageType% = 19 Then

      DMGType$ = "NONE"
      DMGOutput$ = "Other"

   ElseIf fDamageType% = 20 Then

      DMGType$ = "NONE"
      DMGOutput$ = "Other"

   EndIf

   If  SpecialMOD% < 0 Then

;      SpecialDMG$ = SpecialMOD%

   ElseIf fSpecialMOD% = 1 Then

   ElseIf fSpecialMOD% = 2 Then

   ElseIf fSpecialMOD% = 3 Then

   ElseIf fSpecialMOD% = 4 Then

   ElseIf fSpecialMOD% = 5 Then

   ElseIf fSpecialMOD% = 6 Then

   ElseIf fSpecialMOD% = 7 Then

   ElseIf fSpecialMOD% = 8 Then

   ElseIf fSpecialMOD% = 9 Then

   ElseIf fSpecialMOD% = 10 Then

   Else

      SpecialDMG$ = "NONE"

   EndIf

   TotalDamage% = Rand(1, (fMaxDamage - fMinDamage)) + (fMinDamage - 1)
;               MyString$ = DMGType$$ + "," + DMGOutput$+ "," + SpecialDMG$ + "," + fMinDamage% + "," + fMaxDamage%
;         ThreadExecute("SpellDamage", "Main", fAttacker,  fTarget, MyString$)
   If Attribute(fTarget, "Health") < TotalDamage Then
      DeadMob = 1
      GiveXP(fAttacker, ActorLevel(fTarget) + MaxAttribute(fTarget, "Health"))
;                        SetAttribute(fTarget, "Health", 0)
      KillActor(fTarget, fAttacker)
   Else
      SetAttribute(fTarget, "Health", Attribute(fTarget, "Health") - TotalDamage)
   
   EndIf

;   SetResistance(Actor, DamageType, Value)
;           Use this commands help to create resistance script.

   Return

End Function

Function Checkmovement%(fAttacker%, fCasterX#, fCasterY#, fCasterZ#, fNoMovement%)

   If fNoMovement <> 1 Then Return
   If ActorX(fAttacker) <> fCasterX Then Return(1)
   If ActorY(fAttacker) <> fCasterY Then Return(1)
   If ActorZ(fAttacker) <> fCasterZ Then Return(1)
   Return

End Function
Advertisement