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

[EO 2.0] Fixing HP-healing spells increasing NPCs' max health


Guest
 Share

Recommended Posts

There's a bug in EO that causes NPCs' health to increase above their max health. All of this code is serverside.

Replace your Sub SpellNPC_Effect with this:

```
Public Sub SpellNpc_Effect(ByVal Vital As Byte, ByVal increment As Boolean, ByVal index As Long, ByVal Damage As Long, ByVal spellnum As Long, ByVal mapNum As Long)

Dim sSymbol As String * 1

Dim Colour As Long

If Damage > 0 Then

If increment Then

sSymbol = "+"

If Vital = Vitals.HP Then Colour = BrightGreen

If Vital = Vitals.mp Then Colour = BrightBlue

Else

sSymbol = "-"

Colour = Blue

End If

SendAnimation mapNum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_NPC, index

SendActionMsg mapNum, sSymbol & Damage, Colour, ACTIONMSG_SCROLL, MapNpc(mapNum).Npc(index).x * 32, MapNpc(mapNum).Npc(index).y * 32

' send the sound

SendMapSound index, MapNpc(mapNum).Npc(index).x, MapNpc(mapNum).Npc(index).y, SoundEntity.seSpell, spellnum

If increment Then

If MapNpc(mapNum).Npc(index).Vital(Vital) + Damage <= GetNpcMaxVital(index, Vitals.HP) Then

MapNpc(mapNum).Npc(index).Vital(Vital) = MapNpc(mapNum).Npc(index).Vital(Vital) + Damage

Else

MapNpc(mapNum).Npc(index).Vital(Vital) = GetNpcMaxVital(index, Vitals.HP)

End If

If Spell(spellnum).Duration > 0 Then

AddHoT_Npc mapNum, index, spellnum

End If

ElseIf Not increment Then

MapNpc(mapNum).Npc(index).Vital(Vital) = MapNpc(mapNum).Npc(index).Vital(Vital) - Damage

End If

End If

End Sub
```

And your HandleHoT_NPC with this:

```
Public Sub HandleHoT_Npc(ByVal mapNum As Long, ByVal index As Long, ByVal hotNum As Long)

With MapNpc(mapNum).Npc(index).HoT(hotNum)

If .Used And .Spell > 0 Then

' time to tick?

If GetTickCount > .Timer + (Spell(.Spell).Interval * 1000) Then

If Spell(.Spell).Type = SPELL_TYPE_HEALHP Then

SendActionMsg mapNum, "+" & Spell(.Spell).Vital, BrightGreen, ACTIONMSG_SCROLL, MapNpc(mapNum).Npc(index).x * 32, MapNpc(mapNum).Npc(index).y * 32

MapNpc(mapNum).Npc(index).Vital(Vitals.HP) = MapNpc(mapNum).Npc(index).Vital(Vitals.HP) + Spell(.Spell).Vital

If MapNpc(mapNum).Npc(index).Vital(Vitals.HP) > GetNpcMaxVital(index, Vitals.HP) Then

MapNpc(mapNum).Npc(index).Vital(Vitals.HP) = GetNpcMaxVital(index, Vitals.HP)

End If

Else

SendActionMsg mapNum, "+" & Spell(.Spell).Vital, BrightBlue, ACTIONMSG_SCROLL, MapNpc(mapNum).Npc(index).x * 32, MapNpc(mapNum).Npc(index).y * 32

MapNpc(mapNum).Npc(index).Vital(Vitals.mp) = MapNpc(mapNum).Npc(index).Vital(Vitals.mp) + Spell(.Spell).Vital

If MapNpc(mapNum).Npc(index).Vital(Vitals.mp) > GetNpcMaxVital(index, Vitals.mp) Then

MapNpc(mapNum).Npc(index).Vital(Vitals.mp) = GetNpcMaxVital(index, Vitals.mp)

End If

End If

.Timer = GetTickCount

' check if DoT is still active - if NPC died it'll have been purged

If .Used And .Spell > 0 Then

' destroy hoT if finished

If GetTickCount - .StartTime >= (Spell(.Spell).Duration * 1000) Then

.Used = False

.Spell = 0

.Timer = 0

.Caster = 0

.StartTime = 0

End If

End If

End If

End If

End With

End Sub
```
Link to comment
Share on other sites

A better way of doing it is this:

```
If MapNpc(mapNum).Npc(index).Vital(Vital) + Damage > then

MapNpc(mapNum).Npc(index).Vital(Vital) = MapNpc(mapNum).Npc(index).Vital(Vital)

else

MapNpc(mapNum).Npc(index).Vital(Vital) = MapNpc(mapNum).Npc(index).Vital(Vital) + Damage

End If
```

Else it wouldn't heal anything is the full heal will go over the NPC's max health. ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)
Link to comment
Share on other sites

> A better way of doing it is this:
>
> ```
> If MapNpc(mapNum).Npc(index).Vital(Vital) + Damage > then
>
> MapNpc(mapNum).Npc(index).Vital(Vital) = MapNpc(mapNum).Npc(index).Vital(Vital)
>
> else
>
> MapNpc(mapNum).Npc(index).Vital(Vital) = MapNpc(mapNum).Npc(index).Vital(Vital) + Damage
>
> End If
> ```
>
> Else it wouldn't heal anything is the full heal will go over the NPC's max health. ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)

Syntax error on

If MapNpc(mapNum).NPC(index).Vital(Vital) + Damage > then

You meant

> A better way of doing it is this:
>
> ```
> If MapNpc(mapNum).Npc(index).Vital(Vital) + Damage > MapNpc(mapNum).Npc(index).Vital(Vital) then
>
> MapNpc(mapNum).Npc(index).Vital(Vital) = MapNpc(mapNum).Npc(index).Vital(Vital)
>
> else
>
> MapNpc(mapNum).Npc(index).Vital(Vital) = MapNpc(mapNum).Npc(index).Vital(Vital) + Damage
>
> End If
> ```

**EDIT**: Which doesn't work

Trying to figure out how to put GetNpcMaxVital(npcNum, Vitals.HP) in there
Link to comment
Share on other sites

Dangit, sorry for double post. No delete button I can find.

Would this work?

```
MapNpc(mapNum).Npc(index).Vital(Vital) = MapNpc(mapNum).Npc(index).Vital(Vital) + Damage

If MapNpc(mapNum).NPC(index).Vital(Vitals.HP) > GetNpcMaxVital(npcNum, Vitals.HP) Then

MapNpc(mapNum).NPC(index).Vital(Vitals.HP) = GetNpcMaxVital(npcNum, Vitals.HP)
```

Nope…GRRRRR..

**FINAL EDIT IN RAGE.**

Okay, I got tired of ducking around with it, so I edited Case 2 'targetted in CastSpell and did this

> If targetType = TARGET_TYPE_PLAYER Then
>
> x = GetPlayerX(target)
>
> y = GetPlayerY(target)
>
> Else
>
> Exit Sub
>
> End If

So you can't heal NPCs at all.

I also commented out the AoE heal part just above it:

> 'For i = 1 To MAX_MAP_NPCS
>
> ' If MapNpc(mapNum).NPC(i).Num > 0 Then
>
> ' If MapNpc(mapNum).NPC(i).Vital(HP) > 0 Then
>
> ' If isInRange(AoE, x, y, MapNpc(mapNum).NPC(i).x, MapNpc(mapNum).NPC(i).y) Then
>
> ' SpellNpc_Effect VitalType, increment, i, Vital, spellnum, mapNum
>
> ' End If
>
> ' End If
>
> ' End If
>
> 'Next
Link to comment
Share on other sites

```

If MapNpc(mapNum).NPC(index).Vital(Vitals.HP) > GetNpcMaxVital(index, Vitals.HP) Then

```

Would work. I'll edit the post later with a rewritten sub.

EDIT: Updated.
Link to comment
Share on other sites

  • 1 month later...

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