"Adding Real Defense Tut - not found"

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

This was the link but does not exist anymore :(

Well as clearly as possible, explain what you want to know and I’ll see if I can’t just make you a quick tutorial. I’m afraid the one you’re requesting is gone forever.

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


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)


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

	End If

End Function

now find “Public Sub TryNpcAttackPlayer”


 If Damage > 0 Then

			Call NpcAttackPlayer(mapNpcNum, index, Damage)

		End If


Damage = Damage - GetPlayerDef(index)

find “TryPlayerAttackPlayer”


 If Damage > 0 Then

			Call PlayerAttackPlayer(attacker, Victim, Damage)


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

		End If


Damage = Damage - GetPlayerDef(Victim)


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


-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

Way to go Zopto. You’re the man.

Thank you so much!! :)

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

Solved :)

np any time

Log in to reply