Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Pet Script


munro
 Share

Recommended Posts

```
dim addattack
dim adddefence
dim petattack
dim petdefence
dim pethp
dim targetattack
dim targetdefence
dim targethp
dim exp

select case npcnumber

    Case 1
owner = FindPlayer(GetVar("pets\pet.ini", "PET" & npcnumber, "owner"))

if npcnumber > 500 then
exit sub
end if

if "" & FindPlayer(GetVar("pets\pet.ini", "PET" & npcnumber, "owner")) = "" then
call ScriptSpawnNpc(mapnpcnum, MapNum, GetNpcX(MapNum, MapNpcNum), GetNpcy(MapNum, MapNpcNum), 0)
exit sub
end if

if isplaying(owner) = "False" or isplaying(owner) = "" then
exit sub
end if

if 0 + GetMapNpcHP(MapNum, mapnpcnum) < 1 then
call ScriptSpawnNpc(mapnpcnum, MapNum, GetNpcX(MapNum, MapNpcNum), GetNpcy(MapNum, MapNpcNum), 0)
call putVar("pets\pet.ini", "PET" & npcnumber, "owner", "")
exit sub

end if

if 0 + GetMapNpcHP(MapNum, mapnpcnum) < 1 then
call ScriptSpawnNpc(mapnpcnum, MapNum, GetNpcX(MapNum, MapNpcNum), GetNpcy(MapNum, MapNpcNum), 0)
call putVar("pets\pet.ini", "PET" & npcnumber, "owner", "")
exit sub

end if

if getplayertarget(owner) > 0 then
if 0 + val(getplayermap(owner)) = 0 + val(getplayermap(getplayertarget(owner))) then
call SetMapNpcTARGET( mapnum, mapnpcnum, getplayertarget(owner))
end if

else
if getplayertargetnpc(owner) <> 0 then
n = 0
if GetNpcX(mapnum, getplayertargetnpc(owner)) < x then
                Call NpcMoving(MapNum, MapNpcNum, 2, 1)
                Exit Sub
end if

if GetNpcX(mapnum, getplayertargetnpc(owner)) > x then
                Call NpcMoving(MapNum, MapNpcNum, 3, 1)
                Exit Sub
end if

if GetNpcY(mapnum, getplayertargetnpc(owner)) < Y - 1 then
                Call NpcMoving(MapNum, MapNpcNum, 0, 1)
                Exit Sub
end if

if GetNpcY(mapnum, getplayertargetnpc(owner)) > Y + 1 then
                Call NpcMoving(MapNum, MapNpcNum, 1, 1)
                Exit Sub
end if

'attacking the oher npc and recieving damage
addattack = 1 + GetVar("pets\pet.ini", "ITEMS", "hatadd" & npcnumber) + GetVar("pets\pet.ini", "ITEMS", "weaponadd" & npcnumber)
adddefence = 1 + GetVar("pets\pet.ini", "ITEMS", "armoradd" & npcnumber)
petattack = GetNpcStrength(npcnumber) + Int((GetNpcStrength(npcnumber) / 6 - addattack + 1) * Rnd) + addattack
petdefence = GetNpcDefence(npcnumber) + Int((GetNpcDefence(npcnumber) / 6 - adddefence + 1) * Rnd) + adddefence
pethp = Int(GetMapNpcHP( MapNum, mapnpcnum))
targetattack = GetNpcStrength(GetMapNPCnumber( MapNum, getplayertargetnpc(owner))) + Int((GetNpcStrength(GetMapNPCnumber( MapNum, getplayertargetnpc(owner))) / 6 - 1 + 1) * Rnd) + 1
targetdefence = GetNpcDefence(GetMapNPCnumber( MapNum, getplayertargetnpc(owner))) + Int((GetNpcDefence(GetMapNPCnumber( MapNum, getplayertargetnpc(owner))) / 6 - 1 + 1) * Rnd) + 1
targethp = Int(GetMapNpcHP( MapNum, getplayertargetnpc(owner)))

if isplaying(owner) = "false" or isplaying(owner) = "" then
exit sub
end if

if pethp - targetattack + petdefence < 1 then
Call battlemsg(owner, "you're pet has been killed in battle.", 14, 0)
call ScriptSpawnNpc(mapnpcnum, MapNum, GetNpcX(MapNum, MapNpcNum), GetNpcy(MapNum, MapNpcNum), 0)
else
Call battlemsg(owner, "Pet hp " & pethp - targetattack + petdefence & "/"  & GetNpcMaxhp(mapnpcnum), 14, 0)
call SetMapNpcHP( MapNum, npcnumber, pethp - targetattack + petdefence)
end if

if targethp - petattack + targetdefence < 1 then
call ScriptSpawnNpc(getplayertargetnpc(owner), MapNum, GetNpcX(MapNum, getplayertargetnpc(owner)), GetNpcy(MapNum, getplayertargetnpc(owner)), 0)
Call battlemsg(owner, "you're pet has killed an enemy.", 14, 1)
else
Call battlemsg(owner, "Npc hp " & targethp - petattack + targetdefence & "/"  & GetNpcMaxhp(GetMapNPCnumber(MapNum, getplayertargetnpc(owner))), 14, 1)
call SetMapNpcHP( MapNum, GetMapNPCnumber(MapNum, getplayertargetnpc(owner)), targethp - petattack + targetdefence)
end if
call playermsg(owner, "test",1)
else
            If GetPlayerX(owner) < x - 1 Then
                Call NpcMoving(MapNum, MapNpcNum, 2, 1)
                Exit Sub
            End If

            If GetPlayerX(owner) - 1 > x Then
                Call NpcMoving(MapNum, MapNpcNum, 3, 1)
                Exit Sub
            End If

            If GetPlayery(owner) < y - 1 Then
                Call NpcMoving(MapNum, MapNpcNum, 0, 1)
                Exit Sub
            End If

            If GetPlayery(owner) - 1 > y Then
                Call NpcMoving(MapNum, MapNpcNum, 1, 1)
                Exit Sub
            End If
end if
end if
end select

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when any player presses the Delete key
Sub HotScript2(index)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

dim npcnumber
i = 1
do while i <= 25
if 0 + GetMapNPCnumber(getplayermap(index), i) = 0 then
npcnumber = 0 + getvar("pets\pet.ini", "PETS", getplayername(index))
Call putvar("pets\pet.ini", "PET" & npcnumber, "owner", "" & trim(getplayername(index)) )
call ScriptSpawnNpc( i, getplayermap(index), getplayerx(index), getplayery(index), npcnumber)
i = 27
else
i = i + 1
end if
loop

if i = 27 then
call playermsg(index, "You summoned your pet.", 1)
else
call playermsg(index, "You can't summon your pet.", 1)
end if
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when players press the End key
Sub HotScript3(index)                                             
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' Telling players the game time
'Call playermsg(index, "The time is " & getservertimehour() & ":" & getservertimeminute() & ":" & getservertimesecond() , 14)

' Loads the shop with new stuff
'call reloadshop(1)

Call CustomMenuShow(index, "Pet equipment", "\GUI\CUSTOM\menustone.gif", 1)
Call CustomMenuLabel(index, 1, "Pet equipment", 45, 15, 8, 15, 0, 400, 40)
call CustomMenuPicture(index, 1, "\GUI\CUSTOM\itembg.jpg", 62, 100)
call CustomMenuPicture(index, 2, "\GUI\CUSTOM\itembg.jpg", 62, 137)
call CustomMenuPicture(index, 3, "\GUI\CUSTOM\itembg.jpg", 100, 100)
petnumber = 0 + getvar("pets\pet.ini", "PETS", getplayername(index))

if 0 + getvar("pets\pet.ini", "PET" & petnumber, "hat") <> 0 then
call CustomMenuPicture(index, 4, "\GUI\CUSTOM\pethat" & getvar("pets\pet.ini", "PET" & petnumber, "hat") & ".jpg", 64, 102)
end if
if 0 + getvar("pets\pet.ini", "PET" & petnumber, "armor") <> 0 then
call CustomMenuPicture(index, 5, "\GUI\CUSTOM\petarmor" & getvar("pets\pet.ini", "PET" & petnumber, "armor") & ".jpg", 64, 139)
end if
if 0 + getvar("pets\pet.ini", "PET" & petnumber, "weapon") <> 0 then
call CustomMenuPicture(index, 6, "\GUI\CUSTOM\petweapon" & getvar("pets\pet.ini", "PET" & petnumber, "weapon") & ".jpg", 102, 102)
end if
End Sub
```
where would i put this script i know where hotscript goes but the stuff before that where does it go?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...