Gremlin Scream Pet Ability Script

Created by *Taz.*

```
Using "RC_Core.rcm"
;By Tazco
 ;Pet will let out a scream reducing targets Defence.
Function Main()
Player = Actor()
Target = ContextActor()

PName$ = Name(Player)
TName$ = Name(Target)
TargetDef% = Attribute(Target, "Defence") ;get target defence

ScriptLog("Gremlin screem running by " + Pname)
PetID$ = ActorID("Gremlin", "") ;pet id
Petname$ = "Gremlin"  ;Pet Name
PetFound% = 0 ;Used for repeat if = 1 end repeat
PetDeBuffamount% = - 10 ;amount that debuff should be
;--------------------------------------------------------------------------------------------------------

   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 > 40)  ;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.

 		     PetFound = 1
 			 SetActorTarget(PetToFind, Target)
 			 PlaySound(Player, 44, 0)
 			 SetActorAIState(PetToFind, 3) ;set pet attack
 		     AnimateActor(PetToFind, "Scream", .5, 2)
 		     AddActorEffect(Target, "Gremlin DeMark", "Defence", PetDeBuffamount, 120, 213) ; add buff icon should last 2 min
 			 DoEvents(4000)

 		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)

AnimateActor(PetToFind, "Idle3", .5, 2)
End Function

```