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

"Adding Real Defense Tut - not found"


troglodite
 Share

Recommended Posts

Can somebody post again this tutorial named Adding Real Defense??

[This was the link](http://www.touchofdeathforums.com/smf/index.php/topic,73579.0.html) but does not exist anymore ![:(](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/sad.png)
Link to comment
Share on other sites

[EO] adding REAL defence [SERVER ONLY]

« on: July 14, 2011, 12:27:35 PM »

• Quote

Ok the armor, sheild, and helmet all have the same problem… none of them have any real defence. Robin said to just give it "damage" and that will give it defence. This was not entirely true, it is stored but never calculated. There is no defence calc function.

To add defence follow the simple steps bellow.

SERVER

In modCombat

Find "Function GetNpcMaxVital" and add above it

```
Function GetPlayerDef(ByVal index As Long) As Long

Dim DefNum As Long

Dim Def As Long

GetPlayerDef = 0

Def = 0

' Check for subscript out of range

If IsPlaying(index) = False Or index <= 0 Or index > MAX_PLAYERS Then

Exit Function

End If

If GetPlayerEquipment(index, Armor) > 0 Then

DefNum = GetPlayerEquipment(index, Armor)

Def = Def + Item(DefNum).Data2

End If

If GetPlayerEquipment(index, Helmet) > 0 Then

DefNum = GetPlayerEquipment(index, Helmet)

Def = Def + Item(DefNum).Data2

End If

If GetPlayerEquipment(index, Shield) > 0 Then

DefNum = GetPlayerEquipment(index, Shield)

Def = Def + Item(DefNum).Data2

End If

If Not GetPlayerEquipment(index, Armor) > 0 And Not GetPlayerEquipment(index, Helmet) > 0 And Not GetPlayerEquipment(index, Shield) > 0 Then

GetPlayerDef = 0.085 * GetPlayerStat(index, Endurance) + (GetPlayerLevel(index) / 5)

Else

GetPlayerDef = 0.085 * GetPlayerStat(index, Endurance) * Def + (GetPlayerLevel(index) / 5)

End If

End Function
```

now find "Public Sub TryNpcAttackPlayer"

above

```
If Damage > 0 Then

Call NpcAttackPlayer(mapNpcNum, index, Damage)

End If
```
add

```
Damage = Damage - GetPlayerDef(index)
```

find "TryPlayerAttackPlayer"

above

```
If Damage > 0 Then

Call PlayerAttackPlayer(attacker, Victim, Damage)

Else

Call PlayerMsg(attacker, "Your attack does nothing.", BrightRed)

End If
```
add

```
Damage = Damage - GetPlayerDef(Victim)
```

DONE

________________________________________

**Just like a weapon change the Damage value on defence equipment to set the defence value.*

Tips

-Player Defence is pretty much calculated the same way as attack, EXCEPT its adding up 3 diffrent values for the defence. (and its using END instead of STR)

-Keep the defence values of each item about 4-5 times lower than the matching weapon.

-Make sure NPCs and Players can still attack when the defending player is at the generaly the same level.

-If you need to lower the outcome of the defence only lower the bolded number or raise the red number

–-------------------------------------------------------------------------------------------------------------------------

i have saved this tutorial in world FROM 2011 xD

Hope it help you
Link to comment
Share on other sites

Thank you so much!! ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

I will try to make an inteligence defense for damage spells with the help of this code

Solved ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
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...