FANDOM


Created by Taz.

Using "RC_Core.rcm"
; Define entry function 'Main'

Function Main()
;using mana cost for spell xp.
Player = Actor()
Target = ContextActor()
Result% = ActorDistance(Actor(), ContextActor())
plvl% = ActorLevel(Player)
staffequip% = ItemAttribute(ActorWeapon(Player), "Magic")
Spellxp% = ActorGlobal(Player, 2)
	
VampBlood% = Attribute(Player, "Blood")
AbilityCost% = 35

TotBloodCost% = VampBlood - AbilityCost

    If (VampBlood < AbilityCost)
        OutPut(Player, "You do not have enough blood for that.", 255, 0, 0)
        Return
     Endif
 
     
 
 AbleToAtt% = ActorGlobal(Target, 0) ;if actor spawns with 5 then they are noncombat or should not be targeted by abilitys
 
 If (AbleToAtt >= 55)
 	OutPut(Player, "You can not attack that target", 255, 0, 0)
 Return
 EndIf
 
 If ActorHasEffect(Player,"Casting")
 OutPut(Player, "You are already casting a spell", 155, 255, 0)
 Return
 EndIf
 
 
    ; Check to see if target is in range					
	If (Result > 100)
		Output(Player, "You are to far away!")
		Return
	
	EndIf

	   ; Check target is valid
	If (Target = 0)
  		Output(Player, "select a target for the spell!")
 		Return
 
  	EndIf
     
 
     
     
 ;----------------------------------------------------
;Mana Cost    
   ;new spell cost will base cost on amount of mana player has.
  
   MagicLvl% = Attribute(Player, "Magic")
  
   If (MagicLvl >= 30)
    CostCalc% = Attribute(Player, "Magic") * AbilityLevel(Player, "Hold Target") + MaxAttribute(Player, "Mana") + Rand(350, 360) ;spell cost calculation
    SpellCost% = CostCalc / 17 + Rand(15, 20)
  Else
     CostCalc% = Attribute(Player, "Magic") * AbilityLevel(Player, "Hold Target") + MaxAttribute(Player, "Mana") + Rand(250, 260) ;spell cost calculation
    SpellCost% = CostCalc / 29 + Rand(15, 20)
  EndIf
 ;--------------------------------------------------------------------------  
givespellXp% = Spellxp + Rnd(18, 22) + plvl
;--------------------------------------------------------------------------		 
    OutPut(Player, "Spell cost is " + Spellcost, 55, 134, 234)
;Mana check
  	ManaLevel% = Attribute(Player, "Mana")
 	If (ManaLevel < Spellcost)
        	Output(Player, "insufficient mana - spell failed!")
	 	Return

      EndIf
 AddActorEffect(Player, "Casting", "Speed", - 9, 2, 3) 
 
 CreateEmitter(Target, "Holdenemy", 10, 1000) ; casting emitter
 SetAttribute(Player, "Mana", ManaLevel - Spellcost)     ;Remove mana for spell
 SetAttribute(Target, "Speed", 0)
 AnimateActor(Player, "Magic", .5, 2) ;Particles and casting animation
 SetActorGlobal(Player, 2, givespellXp)
 OutPut(Player, "You have casted Stunning eyes on your target", 200, 103, 120)
 DoEvents(1000)
 Ticks% = 10
 
 
 
 Repeat
 Ticks% = Ticks - 1				;take 1 tick per half a sec
 DoEvents(1000)
 CreateEmitter(Target, "Hold", 10, 500)
 Until(Ticks = 0) 
        SetActorTarget(Target, Player)
       SetActorAIState(Target, 3)
OutPut(Player, "Your Target has been freed.", 200, 103, 120)
SetAttribute(Target, "Speed", Attribute(Target, "Mobspeed"))
;----------------------------------------------------------------------------------------------------------------
              Maglvl% = Attribute(Player, "Magic")
              Spellxp% = ActorGlobal(Player, 2)
         
              If (Spellxp >= Maglvl * 750) ;if player has amount of xp need to level send them to level up 
                SetActorGlobal(Player, 2, 0)
                ThreadExecute("LevelUp", "Main", Player, Target, 3)	                 
              EndIf
;----------------------------------------------------------------------------------------------------------------  
SetAttribute(Player, "Blood", TotBloodCost) ;take blood cost

Return
End Function