The New World Posted March 1, 2011 Author Share Posted March 1, 2011 In this tutorial we'll be replacing the current "commented" system for CanPlayerBlock, by making a new algorithm using the players shields statistics.This modification will take place **Server-Side**, only.In modCombat, find the sub _CanPlayerBlock_.By default (EO 2b) It should look similar to this in a clean download.```Public Function CanPlayerBlock(ByVal index As Long) As BooleanDim rate As LongDim rndNum As Long CanPlayerBlock = False rate = 0 ' TODO : make it based on shield lolEnd Function```We're modifying the enter sub to look like this:```Public Function CanPlayerBlock(ByVal index As Long) As BooleanDim rate As LongDim rndNum As LongDim shieldNum as long CanPlayerBlock = False rate = 0 If GetPlayerEquipment(index, Shield) > 0 Then shieldNum = GetPlayerEquipment(index, Shield) rate = Item(shieldNum).Data2 / 43.3 rndNum = RAND(1, 100) If rndNum <= rate Then CanPlayerBlock = True Else CanPlayerBlock = False End If Else rate = 0.5 rndNum = RAND(1, 100) If rndNum <= rate Then CanPlayerBlock = True Else CanPlayerBlock = False End If End IfEnd Function```Now, to break it down for you. :) (Note: We're only covering the modifications!)```If GetPlayerEquipment(index, Shield) > 0 Then```Here we check IF the player attempting to block is in possession of a shield type item, and if so move on!```shieldNum = GetPlayerEquipment(index, Shield)```At the beginning of the sub, we defined a new variable "shieldNum" as a long data type, and here we give it a numeric value. We're giving the variable "shieldNum" the "Item ID" of the shield the player has equipped at this moment, so we can process that certain items statistical data.```rate = Item(shieldNum).Data2 / 43.3```At the beginning of the sub, the variable rate was defined, here we are giving this variable a value as well. To attain the value we're using the item function to get the Data2, or "damage" statistic of the shield the player has equipped currently, and we're dividing that value by 43.3, then the final value is assigned to the variable "rate".```rndNum = RAND(1, 100)```Here we just assign the variable rndNum a random value between 1 and 100.``` If rndNum <= rate Then```Here we check if the random number value is less than or equal to that of the rate value, and if it is, continue!```CanPlayerBlock = True```Here we tell the server, yes, the Player CAN block, by assigning the Boolean variable, as true.```Else CanPlayerBlock = False```This is just to make damned sure that the variable gets set to false because they algorithm did not come out with the value we wanted for a successful block. :)The next few statements do the same process, for a player whom is not equipped with a shield at that moment to find out if they can block or not. :P Link to comment Share on other sites More sharing options...
Helladen Posted March 1, 2011 Share Posted March 1, 2011 Very good. I will be using this. GetPlayerEquipment should be:```If GetPlayerEquipment(index, Shield) > 0 Then``` Link to comment Share on other sites More sharing options...
The New World Posted March 1, 2011 Author Share Posted March 1, 2011 Yeah, I noticed and had already fixed it in the explanation portion, but not the block of code. >_<Note: This can be easily modified to fit the CanNpcBlock sub. :) Just compare the two and experiment! (Careful not to break anything. o_o) Link to comment Share on other sites More sharing options...
Helladen Posted March 1, 2011 Share Posted March 1, 2011 I'm going to just make a check in npc editor for if they have a shield or not. Then it will compare using that. Link to comment Share on other sites More sharing options...
Xlithan Posted August 9, 2012 Share Posted August 9, 2012 Where does the other armour come into play? Link to comment Share on other sites More sharing options...
Growlith1223 Posted August 9, 2012 Share Posted August 9, 2012 ```Public Function CanPlayerBlock(ByVal index As Long) As BooleanDim rate As LongDim rndNum As LongDim shieldNum as long CanPlayerBlock = False rate = 0 If GetPlayerEquipment(index, Shield) > 0 Then shieldNum = GetPlayerEquipment(index, Shield) rate = Item(shieldNum).Data2 / 43.3 rndNum = RAND(1, 100) If rndNum <= rate Then CanPlayerBlock = True Else CanPlayerBlock = False End If Else rate = 0.5 rndNum = RAND(1, 100) If rndNum <= rate Then CanPlayerBlock = True Else CanPlayerBlock = False End If End IfEnd Function```Look in here. 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