FANDOM


Created by Taz.

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

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
 
 Result% = ActorDistance(PetToFind, Target)
  If (Result > 130)  ;check distance of target.
		Output(Player, "Your pet is to far away!")
		PetFound = 1
		Return
	
 EndIf
 
 
 	If (NpcName = Petname) ;If npc found is a gremlin pet
 		PetOwnerName$ = ActorGlobal(PetToFind, 1) ;check for pet owner name.
 
 		If (PetOwnerName = PName) ;see if pet found is players pet. Check stored name to player name.
 		
 
 			 AnimateActor(PetToFind, "Magic", .5, 2)
 			 CreateEmitter(PetToFind, "Ice", 15, 650) ; Attack effect emitter
 			 DoEvents(5000)
 			 	 
 			 SetActorTarget(Target, PetToFind)	;set pet as npcs target
 			 FireProjectile(PetToFind, Target, "FrostBall")
 			 SetActorAIState(Target, 3) ;set mob attack					
 			 CreateEmitter(Target, "Ice", 15, 650) ; Attack effect emitter
 		EndIf
 
 
 	EndIf
 	
 	
 	;If (PetOwnerName = "")
 ;		OutPut(Player, "You must have a gremlin pet summoned, to use this ability.")
;		PetFound = 1
 ;		Return	
 ;	EndIf
 	
 	
 DoEvents(10)
 
 ;Until (PetFound = 1)


End Function