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

[EO] Pet System: combat Upgrade


RyokuHasu
 Share

Recommended Posts

** This Is my 2nd Mod to Lightning's pet system, enjoy.

This tut Is to help fill in the blanks of the pet system combat. It adds all the basic checks of PVP combat.

it adds these to fighting with pets

-owner level 10 check (cant fight with players under level 10)
-cant fight aginst admins using a pet
-cant attack an admin's pet
-cant attack an admin's pet with a pet
-admins cant attack players with a pet
-admins cant attack a player's pet
-admins can attack a player's pet using  a pet
-pets follow map moral when fighting players and other pets
-can not accidently attack your own pet

**Prerequired TUT - Lightning's pet system**
http://www.touchofdeathforums.com/smf/index.php/topic,69521.0.html

**Highly suggested Pet Mod, Summoning with items**
http://www.touchofdeathforums.com/smf/index.php/topic,69925.0.html

**SERVER**

in modCombat Find "Public Function CanPlayerAttackNpc"

above
```
CanPlayerAttackNpc = True

```add
```
Dim petowner As Long

```

above
```
' attack speed from weapon

```add
```

    If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(mapNpcNum).PetData.Owner
        If attacker = petowner Then
            Call PlayerMsg(attacker, "You can not attack your own pet.", BrightRed)
            Exit Function
        End If
    End If

If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        If Not Map(GetPlayerMap(attacker)).Moral = MAP_MORAL_NONE Then
            Call PlayerMsg(attacker, "This is a safe zone! You can not attack another player's pet.", BrightRed)
            Exit Function
        End If
    End If

    If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(mapNpcNum).PetData.Owner
        If GetPlayerAccess(petowner) > ADMIN_MONITOR Then
            Call PlayerMsg(attacker, "You cannot attack " & GetPlayerName(petowner) & "'s pet!", BrightRed)
            Exit Function
        End If
    End If

    If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        If GetPlayerAccess(attacker) > ADMIN_MONITOR Then
            Call PlayerMsg(attacker, "Admins cannot attack another player's pet.", BrightBlue)
            Exit Function
        End If
    End If

    If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(mapNpcNum).PetData.Owner
        If GetPlayerLevel(petowner) < 10 Then
            Call PlayerMsg(attacker, GetPlayerName(petowner) & " is below level 10, you cannot attack this player's pet yet!", BrightRed)
            Exit Function
        End If
    End If

    If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        If GetPlayerLevel(attacker) < 10 Then
            Call PlayerMsg(attacker, "You are below level 10, you cannot attack another player with a pet yet!", BrightRed)
            Exit Function
        End If
    End If

```
Find "Function CanNpcAttackPlayer"

Under
```
Dim npcNum As Long

```add
```
Dim petowner As Long

```
above
```
' Make sure they are on the same map

```add
```
If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(mapNpcNum).PetData.Owner
        If Not Map(GetPlayerMap(petowner)).Moral = MAP_MORAL_NONE Then
            Call PlayerMsg(petowner, "This is a safe zone! You can not attack players with a pet.", BrightRed)
            Exit Function
        End If
    End If

    If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(mapNpcNum).PetData.Owner
        If GetPlayerAccess(petowner) > ADMIN_MONITOR Then
            Call PlayerMsg(petowner, "Admins cannot use pet to attack other players.", BrightBlue)
            Exit Function
        End If
    End If

    If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(mapNpcNum).PetData.Owner
        If GetPlayerAccess(Index) > ADMIN_MONITOR Then
            Call PlayerMsg(petowner, "You cannot attack " & GetPlayerName(Index) & " with a pet!", BrightRed)
            Exit Function
        End If
    End If

    If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(mapNpcNum).PetData.Owner
        If GetPlayerLevel(petowner) < 10 Then
            Call PlayerMsg(petowner, "You are below level 10, you cannot attack another player with a pet yet!", BrightRed)
            Exit Function
        End If
    End If

    If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(mapNpcNum).PetData.Owner
        If GetPlayerLevel(Index) < 10 Then
            Call PlayerMsg(petowner, GetPlayerName(petowner) & " is below level 10, you can not attack this player with a pet yet!", BrightRed)
            Exit Function
        End If
    End If

```
find "Function CanNpcAttackNpc"

under
```
Dim AttackerY As Long

```add
```
Dim petowner As Long

```
above
```
' Make sure the npcs arent already dead

```add
```
If MapNpc(MapNum).NPC(attacker).IsPet = YES Then
    If MapNpc(MapNum).NPC(Victim).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(attacker).PetData.Owner
        If Not Map(GetPlayerMap(petowner)).Moral = MAP_MORAL_NONE Then
            Call PlayerMsg(petowner, "This is a safe zone! You can not attack another player's pet with a pet.", BrightRed)
            Exit Function
        End If
    End If
    End If

    If MapNpc(MapNum).NPC(attacker).IsPet = YES Then
    If MapNpc(MapNum).NPC(Victim).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(attacker).PetData.Owner
        If GetPlayerAccess(petowner) > ADMIN_MONITOR Then
            Call PlayerMsg(petowner, "Admins cannot use a pet to attack another player's pet.", BrightBlue)
            Exit Function
        End If
    End If
    End If

    If MapNpc(MapNum).NPC(attacker).IsPet = YES Then
    If MapNpc(MapNum).NPC(Victim).IsPet = YES Then
    petowner = MapNpc(MapNum).NPC(Victim).PetData.Owner
        If GetPlayerAccess(petowner) > ADMIN_MONITOR Then
            Call PlayerMsg(petowner, "You cannot use a pet to attack " & GetPlayerName(petowner) & "'s pet.", BrightBlue)
            Exit Function
        End If
    End If
    End If

    If MapNpc(MapNum).NPC(attacker).IsPet = YES Then
    If MapNpc(MapNum).NPC(Victim).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(attacker).PetData.Owner
        If GetPlayerLevel(petowner) < 10 Then
            Call PlayerMsg(petowner, "You are below level 10, you cannot attack another player's pet with a pet yet!", BrightRed)
            Exit Function
        End If
    End If
    End If

    If MapNpc(MapNum).NPC(attacker).IsPet = YES Then
    If MapNpc(MapNum).NPC(Victim).IsPet = YES Then
        petowner = MapNpc(MapNum).NPC(Victim).PetData.Owner
        If GetPlayerLevel(petowner) < 10 Then
            Call PlayerMsg(petowner, GetPlayerName(petowner) & " is below level 10, you cannot attack this player's pet with a pet yet!", BrightRed)
            Exit Function
        End If
    End If
    End If

```
**DONE**
Link to comment
Share on other sites

  • 1 year later...
Hm Pets can still attacks non pet npcs? Did I mess something up? If not how would I add a check to see if the target of the pet is a friendly,guard, or shopkeeper?

My fix, it seems to work, but not really sure how well. Most likely you will need to fix this. I am using it as a temp until I figure out how to properly do it. The text does not display at all.
```
    'pet stuff
If MapNpc(MapNum).NPC(Attacker).IsPet = YES Then
If NPC(vNpcNum).Behaviour = NPC_BEHAVIOUR_FRIENDLY Or NPC(vNpcNum).Behaviour = NPC_BEHAVIOUR_SHOPKEEPER Or NPC(vNpcNum).Behaviour = NPC_BEHAVIOUR_GUARD Then
Call PlayerMsg(petowner, "Can't attack friendly allies.", BrightRed)
Exit Function

```
Link to comment
Share on other sites

Some of the If statements seem a bit pointless, like checking MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES every time. As an example of what I mean, here's how I would do it (pretty much the exact same code except i deleted things :P)

```
petowner = MapNpc(MapNum).NPC(mapNpcNum).PetData.Owner

If MapNpc(MapNum).NPC(mapNpcNum).IsPet = YES Then
    If attacker = petowner Then
        Call PlayerMsg(attacker, "You can not attack your own pet.", BrightRed)
        Exit Function
    End If

    If Not Map(GetPlayerMap(attacker)).Moral = MAP_MORAL_NONE Then
        Call PlayerMsg(attacker, "This is a safe zone! You can not attack another player's pet.", BrightRed)
        Exit Function
    End If

    If GetPlayerAccess(petowner) > ADMIN_MONITOR Then
        Call PlayerMsg(attacker, "You cannot attack " & GetPlayerName(petowner) & "'s pet!", BrightRed)
        Exit Function
    End If

    If GetPlayerAccess(attacker) > ADMIN_MONITOR Then
        Call PlayerMsg(attacker, "Admins cannot attack another player's pet.", BrightBlue)
        Exit Function
    End If

    If GetPlayerLevel(petowner) < 10 Then
        Call PlayerMsg(attacker, GetPlayerName(petowner) & " is below level 10, you cannot attack this player's pet yet!", BrightRed)
        Exit Function
    End If

    If GetPlayerLevel(attacker) < 10 Then
        Call PlayerMsg(attacker, "You are below level 10, you cannot attack another player with a pet yet!", BrightRed)
        Exit Function
    End If
End If

```
Link to comment
Share on other sites

  • 6 months later...

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...