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

[EO] adding REAL defence [SERVER ONLY]


RyokuHasu
 Share

Recommended Posts

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

GetPlayerDef = **0.085** *  GetPlayerStat(index, Endurance) * Def + (GetPlayerLevel(index) / 5)
Link to comment
Share on other sites

@Justn:

> lol awesome man u read my mind i was tryin to get something like this…
>
> Already added it and it was very simple to add my extra equipment slots :cheesy:

=D thats great… >.< but in your case I would either lower the equation like i showed how, or lower defence for each item.

if you have more items with difence you are gona rack up an invincible guy if you dont lower somthing. lol but , good luck with the DEF function glad you like it.
Link to comment
Share on other sites

Thats a great Idea, OR we can follow the guide lines made simple.

@RyokuHasu:

> -If you need to lower the outcome of the defence only lower the bolded number or raise the red number
>
> GetPlayerDef = **0.085** * GetPlayerStat(index, Endurance) * Def + (GetPlayerLevel(index) / 5)

Now im not saying your idea isnt great, but the variables I've given allow for precise control of exactly how much is taken off per attack. It might not be the most "noob-friendly" way but those give great control on fine tuning the defence to everyone's individual needs.

=3 but you free to do any editing to it you wish after instalation ^_^ no credit is needed.
Link to comment
Share on other sites

Like Robin have pointed it out, it is much easier if you just do it with for loop.Like this:

```
Function GetPlayerDefense(ByVal index As Long) As Long
    Dim i As Long

    GetPlayerDefense = 0

    ' Check for subscript out of range
    If IsPlaying(index) = False Or index <= 0 Or index > Player_HighIndex Then
        Exit Function
    End If

    GetPlayerDefense = GetPlayerStat(index, Endurance)

    For i = 2 To 4
        If GetPlayerEquipment(index, i) > 0 Then
            GetPlayerDefense = GetPlayerDefense + Item(GetPlayerEquipment(index, i)).Data2
        End If
    Next

End Function

```
Link to comment
Share on other sites

  • 8 months later...
This is probably a stupid question…And bare in mind I'm still learning this coding thing...But having now implemented this code I've thought of a question lol.

Is this saying that the higher the players Endurance is then the higher the defence...So for example if an NPC was set to do 40 damage and you're shield is set to 10 damage and 10 endurance should it be deducting 20 damage? And is the damage deducting 100% of the time or just every other shot or what not?
Link to comment
Share on other sites

  • 3 weeks later...
Will i still have this?

>! strenght adds to your max melee hit at str/2
adds to your base melee damage reduction from a successful block at str/2
adds to your base parry rate at str *0.25
>! endurance adds to your max health at end*5
>! intelligence adds to your max mana at int*10
>! agillity adds to your base armour rating at agi*2
adds to your base dodge rate at agi/83.3
adds to your base critical rate at agi/52.08
>! willpower adds to yur health regen rate at (will*0.8) +6
adds to your mana regen ratae at (will/4)+12.5
Link to comment
Share on other sites

Lets say I don't want endurance to scale. I just want armor only coming from the actual armor pieces.

```
  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
```
I would change this line
```
        GetPlayerDef = 0.085 * GetPlayerStat(index, Endurance) * Def + (GetPlayerLevel(index) / 5)
```
I would delete GetPlayerStat ect. Or am I misreading this code? I believe this would be the only change with your code correct?
Link to comment
Share on other sites

  • 3 months later...
Ohhh man !!! First time i try it on EO 3.0 and it didn't work. I was so sad ;;( but i didnt give up and i try it on EO 2.0 and it worked i'm so so so happy thanks to you man!!! Thank you for share !!!
Link to comment
Share on other sites

  • 8 months later...
  • 1 year later...
> Seems kinda op. The more the health and endurance you have the less damage you take, the faster you level up, the more health and endurance you have the less damage you take, the faster you level up goto start

when you include needing more exp for each level and needing to kill stronger monsters that do more damage to get that exp it makes more sense
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...