FANDOM


Created by Taz.

Using "RC_Core.rcm"
; By Tazco
 ;Testing a charge ability for RockHead pet

Function Main()
Player = Actor()
Target = ContextActor()


PName$ = Name(Player)
TName$ = Name(Target)


PetID$ = ActorID("RockHead", "") ;pet id
Petname$ = "RockHead"  ;Pet Name
PetFound% = 0 ;Used for repeat if = 1 end repeat

;--------------------------------------------------------------------------------------------------------
   If (Target = 0) ; Check target is valid

  		Output(Player, "Select a target for your pet to attack!")
 		Return
    EndIf
 ;--------------------------------------------------------------------------------------------------------

;--------------------------------Vampire Check----------------------------------------------------------------------------------
 ;If vamp dont tell player they cant use a pet in this form            
                IsVamp% = ActorId("Vampire", "Form")
                PRace$ = Race(Player)     
                PClass$ = Class(Player)
                PlayerID% =ActorID(PRace, PClass)
                
                If(IsVamp = PlayerID) ;if player is a vampire
                    OutPut(Player, "You can not use a human pet in vampire form.", 255, 34, 12)
                    Return
                EndIf
;----------------------------End Vampire Check----------------------------------------------------------------------------------

;Look for actor pet
;Repeat
 
 NewPetToFind$ = FindActor(Petname, 2) ;type 2 search through NPCs
 
 NpcName$ = Name(NewPetToFind) ;found actor name
 
 	If (NpcName = Petname) ;If npc found is a gremlin pet
 		PetOwnerName$ = ActorGlobal(NewPetToFind, 1) ;check for pet owner name.
 		
 		
 					Result% = ActorDistance(NewPetToFind, Target)
 					 If (Result > 140)  ;check distance of target.
 							Output(Player, "Your pet is to far away, from your target!")
 							PetFound = 1
 							Return						
 					 EndIf
 				
 		If (PetOwnerName = PName) ;see if pet found is players pet. Check stored name to player name.
 			 PetSpeed% = Attribute(NewPetToFind, "Speed")
 			 ChargeSpeed% = PetSpeed + 18
 			  SetAttribute(NewPetToFind, "Speed", ChargeSpeed)
 		     
 			 SetActorTarget(NewPetToFind, Target)	
 			
 			 SetActorAIState(NewPetToFind, 3) ;set pet attack
 			 ChargeDone% = 15
 			  	Repeat
 			  		AnimateActor(NewPetToFind, "Run", .5, 2)
 			  		DoEvents(1000)
 			  		ChargeDone% = ChargeDone - 1
 			  		PetFound = 1
 			  	Until (ChargeDone = 0)			 
 			 CreateEmitter(Target, "hitflash", 15, 650)
 		EndIf
 
 
 	EndIf
 DoEvents(10)
 
 	If (PetOwnerName = "")
 		OutPut(Player, "You must have a RockHead pet summoned, to use this ability.")
 		PetFound = 1
 		Return	
 	EndIf
 
 ;Until (PetFound = 1)

OldSpeed% = Attribute(NewPetToFind, "MobSpeed")
SetAttribute(NewPetToFind, "Speed", OldSpeed)

End Function