Richy420Rich Posted August 15, 2013 Author Share Posted August 15, 2013 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 LongPlayerAttacked 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 IfEnd IfMapNpc(mapNum).Npc(mapNpcNum).PlayerAttacked = attackerMapNpc(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 = 0MapNpc(mapNum).Npc(mapNpcNum).PreventTimer = 0```Now in Server, modServerLoop, UpdateMapLogicAdd 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, MapResourceRecAdd this: (Make sure client has cur_health As Long)```PlayerAttacked As BytePreventTimer As Long```Server, modPlayer, CheckResource:Add this above: ' check if damage is more than health```If ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked > 0 ThenIf IsPlaying(ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked) ThenIf GetPlayerMap(ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked) = GetPlayerMap(index) ThenIf ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked <> index ThenPlayerMsg index, "Someone else is using this resource.", WhiteExit Sub End If End If End IfEnd If ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PlayerAttacked = indexResourceCache(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 = 0ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).PreventTimer = 0```Now in modServerloop, UpdateMapLogic:Right under this line: If Resource_index > 0 ThenAdd this:```If GetTickCount > (ResourceCache(mapNum).ResourceData(i).PreventTimer + 5000) ThenResourceCache(mapNum).ResourceData(i).PlayerAttacked = 0ResourceCache(mapNum).ResourceData(i).PreventTimer = 0End 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 More sharing options...
Whackeddie99 Posted August 16, 2013 Share Posted August 16, 2013 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 More sharing options...
Richy420Rich Posted August 16, 2013 Author Share Posted August 16, 2013 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 More sharing options...
SkywardRiver Posted August 16, 2013 Share Posted August 16, 2013 Looks good, and it will be even better if you add the things that you mentioned above. Good luck! Link to comment Share on other sites More sharing options...
Richy420Rich Posted August 16, 2013 Author Share Posted August 16, 2013 Yeah I just fixed it, I messed up using NpcRec, when I was supposed to use MapNpcRec:Now the server loop removes lock after idle for 5 seconds (Resources and MapNpcs) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now