Gremlin Charge Pet Ability Script

*Created by Taz.*

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

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

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

PetID$ = ActorID("Gremlin", "") ;pet id
Petname$ = "Gremlin"  ;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

 PetToFind$ = FindActor(Petname, 2) ;type 2 search through NPCs
 PetTag$ = Tag(PetToFind)
 NpcName$ = Name(PetToFind) ;found actor name
 PetOwnerName$ = ActorGlobal(PetToFind, 1) ;check for pet owner name.
 FirstPet$ = PetTag ;Tag of first pet in zone found.

 ;Look for actor pet
Repeat ;check if player has a pet already

;OutPut(Player, "Stored pet name " + PetOwnerName)
   If (PetOwnerName = Pname)
    EndRepeat% = 1
   Else
 	If Not (PetTag = + PName + "s Pet") ;If npc found is a gremlin pet

             PetToFind$ = NextActorInZone(PetToFind)
            NpcName$ = Name(PetToFind) ;found actor name
            PetTag$ = Tag(PetToFind)
            PetOwnerName$ = ActorGlobal(PetToFind, 1) ;check for pet owner name.

	EndIf
  Endif
 DoEvents(1)

 Until (PetTag = + PName + "s Pet") or (PetTag = FirstPet) or (EndRepeat = 1) ;end if pet is out check

 	If (NpcName = Petname) ;If npc found is a gremlin pet
 		PetOwnerName$ = ActorGlobal(PetToFind, 1) ;check for pet owner name.

 			Result% = ActorDistance(PetToFind, 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(PetToFind, "Speed")
 			 ChargeSpeed% = PetSpeed + 18
 			  SetAttribute(PetToFind, "Speed", ChargeSpeed)

 		     BubbleOutPut(PetToFind, "CHARGE!!")
 			 SetActorTarget(PetToFind, Target)

 			 SetActorAIState(PetToFind, 3) ;set pet attack
 			 ChargeDone% = 15
 			  	Repeat
 			  		AnimateActor(PetToFind, "Charge", .5, 2)
 			  		DoEvents(1000)
 			  		ChargeDone% = ChargeDone - 1
 			  		 PetFound = 1
 			  	Until (ChargeDone = 0)

 		EndIf

 	EndIf
 DoEvents(10)

 	;If (PetOwnerName = "")
 ;		OutPut(Player, "You must have a gremlin pet summoned, to use this ability.")
;		PetFound = 1
 ;		Return
 ;	EndIf

 ;Until (PetFound = 1)

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

End Function

```