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

Kill Steal & Resource Steal Prevention


Richy420Rich
 Share

Recommended Posts

I have a couple easy tutorials to throw here… First we'll start with Kill Steal Prevention. Using this will only allow Party Members to help you, it's a base that can be expanded upon if you have a guild system or want a toggle system in place, that's up to you to update. Here's the basis:

Server & Client, modTypes, MapNpcRec:

Add this on the bottom above End Type:

```
PreventTimer As Long
PlayerAttacked As Byte

```

Server, modCombat, PlayerAttackNpc:
Add this above (' check for weapon):

```
    If MapNpc(mapNum).Npc(mapNpcNum).PlayerAttacked > 0 Then
        If IsPlaying(MapNpc(mapNum).Npc(mapNpcNum).PlayerAttacked) Then
                If GetPlayerMap(MapNpc(mapNum).Npc(mapNpcNum).PlayerAttacked) = mapNum Then
                        If MapNpc(mapNum).Npc(mapNpcNum).PlayerAttacked <> attacker Then
                                If TempPlayer(attacker).inParty > 0 Then
                                For i = 1 To MAX_PARTY_MEMBERS
                                        If Party(TempPlayer(attacker).inParty).Member(i) = MapNpc(mapNum).Npc(mapNpcNum).PlayerAttacked Then
                                Exit For
                                        Else
                                        PlayerMsg attacker, "Someone else is attacking this.", White
                                        Exit Sub
                                        End If
                                Next
                                Else
                                PlayerMsg attacker, "Someone else is attacking this.", White
                                Exit Sub
                                End If
                        End If
                End If
        End If
End If
MapNpc(mapNum).Npc(mapNpcNum).PlayerAttacked = attacker
MapNpc(mapNum).Npc(mapNpcNum).PreventTimer = GetTickCount

```

Same sub: Add this above: ' Now set HP to 0 so we know to actually kill them in the server loop (this prevents subscript out of range)

```
MapNpc(mapNum).Npc(mapNpcNum).PlayerAttacked = 0
MapNpc(mapNum).Npc(mapNpcNum).PreventTimer = 0

```

Now in Server, modServerLoop, UpdateMapLogic

Add this Above: ' // This is used for ATTACKING ON SIGHT //

```
                If GetTickCount > (MapNpc(mapNum).Npc(x).PreventTimer + 5000) Then
                    MapNpc(mapNum).Npc(x).PlayerAttacked = 0
                    MapNpc(mapNum).Npc(x).PreventTimer = 0
                End If

```

This concludes Kill stealing, now on to Resource stealing…

Client and Server, modTypes, MapResourceRec

Add this: (Make sure client has cur_health As Long)

```
PlayerAttacked As Byte
PreventTimer As Long

```

Server, modPlayer, CheckResource:

Add this above: ' check if damage is more than health

```
If ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked > 0 Then
If IsPlaying(ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked) Then
If GetPlayerMap(ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked) = GetPlayerMap(index) Then
If ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked <> index Then
PlayerMsg index, "Someone else is using this resource.", White
Exit Sub          
End If        
End If    
End If
End If  
ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked = index
ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PreventTimer = GetTickCount

```
Add this under the first IF statement, after (' cut it down! )

```
ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked = 0
ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PreventTimer = 0

```
Now in modServerloop, UpdateMapLogic:

Right under this line: If Resource_index > 0 Then

Add this:

```
If GetTickCount > (ResourceCache(mapNum).ResourceData(i).PreventTimer + 5000) Then
ResourceCache(mapNum).ResourceData(i).PlayerAttacked = 0
ResourceCache(mapNum).ResourceData(i).PreventTimer = 0
End If

```

I hadn't tested it yet, I'm about to: So I will update if I find any bugs with it, but this should now reset timer and attacker if left idle for 5 seconds.
Link to comment
Share on other sites

Looks good, i have the same system except it allows for 5 attackers, and at death of said npc, the attacker who has dealt the most damage of all attackers, gets the exp. If the damage is within a certain amount proportional to the npcs total health and the two players closely dealt damages, it scales the experience between that amount of players
Link to comment
Share on other sites

Thanks. Yeah that's cool, I just dropped the base incase new people decide they need it and can always expand on it when they get to learning. Personally, I like the resource steal prevention better. It would be a potential problem with limited resources in a game.

Everyone would be sitting there trying to get the last cut on the "rare" tree, perse lol.

I just realised this poses exploits, as a player could still sit on that map and screw up the content, I'll have to fix this and add a timer to reset the variables.
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...