Skip to content

Commit

Permalink
fix bonus damage apply multiple times when cast from multiple user on…
Browse files Browse the repository at this point in the history
… the same target
  • Loading branch information
matiascalegaris committed Aug 30, 2023
1 parent 5525b58 commit 8bb5255
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
24 changes: 17 additions & 7 deletions Codigo/ApplyEffectOnParty.cls
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Dim ApplyEffectId As Integer
Dim AreaOfEffect As Integer
Dim TickManaConsumption As Integer
Dim TickStaminaConsumption As Integer
Dim SecondaryEffect As Integer

Private DotInfo As t_BaseDotInfo
Private Source As t_AnyReference
Expand All @@ -61,7 +62,6 @@ Public Sub Setup(ByVal SourceIndex As Integer, ByVal SourceType As e_ReferenceTy
Call SetBaseDot(DotInfo, TargetIndex, TargetType, ID, EffectId)
Call SetRef(Source, SourceIndex, SourceType)
Call SetActiveEffect

End Sub

Private Sub SetActiveEffect()
Expand All @@ -73,12 +73,14 @@ Private Sub SetActiveEffect()
TickManaConsumption = .TickManaConsumption
TickStaminaConsumption = .TickStaminaConsumption
ApplyEffectId = .ApplyEffectId
SecondaryEffect = .SecondaryEffectId
If DotInfo.TargetRef.RefType = eUser And EffectOverTime(DotInfo.EotId).ClientEffectTypeId > 0 Then
Call WriteSendSkillCdUpdate(DotInfo.TargetRef.ArrayIndex, .ClientEffectTypeId, DotInfo.UniqueId, .TickTime * TargetTicks, .TickTime * TargetTicks, .buffType)
End If
If DotInfo.TargetRef.RefType = eUser And TickStaminaConsumption > 0 Then
Call SetMask(UserList(DotInfo.TargetRef.ArrayIndex).flags.StatusMask, ePreventEnergyRestore)
End If
Call EffectsOverTime.ApplyEotModifier(DotInfo.TargetRef, EffectOverTime(DotInfo.EotId))
End With
Call PerformAction
End Sub
Expand Down Expand Up @@ -152,6 +154,7 @@ Public Function IBaseEffectOverTime_Reset(ByVal SourceUserId As Integer, ByVal S
TickCount = 0
IBaseEffectOverTime_Reset = True
If NewEffectId <> DotInfo.EotId Then
Call EffectsOverTime.RemoveEotModifier(DotInfo.TargetRef, EffectOverTime(DotInfo.EotId), 0)
If DotInfo.TargetRef.RefType = eUser And EffectOverTime(DotInfo.EotId).ClientEffectTypeId > 0 Then
Call WriteSendSkillCdUpdate(DotInfo.TargetRef.ArrayIndex, EffectOverTime(DotInfo.EotId).ClientEffectTypeId, DotInfo.UniqueId, 0, 0, EffectOverTime(DotInfo.EotId).buffType)
End If
Expand All @@ -174,6 +177,7 @@ Public Sub IBaseEffectOverTime_OnRemove()
If DotInfo.Removed Then Exit Sub
DotInfo.Removed = True
DotInfo.RemoveEffect = True
Call EffectsOverTime.RemoveEotModifier(DotInfo.TargetRef, EffectOverTime(DotInfo.EotId), 0)
If DotInfo.TargetRef.RefType = eUser And EffectOverTime(DotInfo.EotId).ClientEffectTypeId > 0 Then
Call WriteSendSkillCdUpdate(DotInfo.TargetRef.ArrayIndex, EffectOverTime(DotInfo.EotId).ClientEffectTypeId, DotInfo.UniqueId, 0, 0, EffectOverTime(DotInfo.EotId).buffType)
End If
Expand Down Expand Up @@ -253,22 +257,28 @@ End Sub

Private Sub ApplyEffectTo(ByVal TargetId As Integer, ByVal TargetType As e_ReferenceType)
Dim Effect As IBaseEffectOverTime
Dim EffectIdToApply As Integer
If TargetId = DotInfo.TargetRef.ArrayIndex And TargetType = DotInfo.TargetRef.RefType Then
EffectIdToApply = ApplyEffectId
Else
EffectIdToApply = SecondaryEffect
End If
If TargetType = eUser Then
If UserList(TargetId).Stats.MinHp > 0 Then
Set Effect = FindEffectOnTarget(DotInfo.TargetRef.ArrayIndex, UserList(TargetId).EffectOverTime, ApplyEffectId)
Set Effect = FindEffectOnTarget(DotInfo.TargetRef.ArrayIndex, UserList(TargetId).EffectOverTime, EffectIdToApply)
If Effect Is Nothing Then
Call CreateEffect(DotInfo.TargetRef.ArrayIndex, DotInfo.TargetRef.RefType, TargetId, TargetType, ApplyEffectId)
Call CreateEffect(DotInfo.TargetRef.ArrayIndex, DotInfo.TargetRef.RefType, TargetId, TargetType, EffectIdToApply)
ElseIf EffectOverTime(DotInfo.EotId).Override Then
Call Effect.Reset(DotInfo.TargetRef.ArrayIndex, DotInfo.TargetRef.RefType, ApplyEffectId)
Call Effect.Reset(DotInfo.TargetRef.ArrayIndex, DotInfo.TargetRef.RefType, EffectIdToApply)
End If
Call RegisterNewHelp(TargetId, DotInfo.TargetRef.ArrayIndex)
End If
Else
Set Effect = FindEffectOnTarget(DotInfo.TargetRef.ArrayIndex, NpcList(TargetId).EffectOverTime, ApplyEffectId)
Set Effect = FindEffectOnTarget(DotInfo.TargetRef.ArrayIndex, NpcList(TargetId).EffectOverTime, EffectIdToApply)
If Effect Is Nothing Then
Call CreateEffect(DotInfo.TargetRef.ArrayIndex, DotInfo.TargetRef.RefType, TargetId, TargetType, ApplyEffectId)
Call CreateEffect(DotInfo.TargetRef.ArrayIndex, DotInfo.TargetRef.RefType, TargetId, TargetType, EffectIdToApply)
ElseIf EffectOverTime(DotInfo.EotId).Override Then
Call Effect.Reset(DotInfo.TargetRef.ArrayIndex, DotInfo.TargetRef.RefType, ApplyEffectId)
Call Effect.Reset(DotInfo.TargetRef.ArrayIndex, DotInfo.TargetRef.RefType, EffectIdToApply)
End If
End If
End Sub
Expand Down
5 changes: 3 additions & 2 deletions Codigo/Declares.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1140,8 +1140,8 @@ Public Type t_EffectOverTime
Type As e_EffectOverTimeType
Limit As e_EOTTargetLimit
SubType As Integer
TickPowerMin As Integer
TickPowerMax As Integer
TickPowerMin As Single
TickPowerMax As Single
Ticks As Integer
TickTime As Long
TickManaConsumption As Integer
Expand All @@ -1167,6 +1167,7 @@ Public Type t_EffectOverTime
Area As Integer
Aura As String
ApplyeffectID As Integer
SecondaryEffectId As Integer
SpellRequirementMask As Long
RequireWeaponType As Integer
npcId As Integer
Expand Down
3 changes: 1 addition & 2 deletions Codigo/EffectOverTime/BonusDamageEffect.cls
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Public Sub Setup(ByVal SourceIndex As Integer, ByVal SourceType As e_ReferenceTy
Call SetBaseDot(EffectInfo, TargetIndex, TargetType, ID, EffectId)
Call SetRef(Source, SourceIndex, SourceType)
Call SetEotEffect
Call EffectsOverTime.ApplyEotModifier(EffectInfo.TargetRef, EffectOverTime(EffectInfo.EotId))
End Sub

Private Sub SetEotEffect()
Expand All @@ -64,7 +65,6 @@ Private Sub SetEotEffect()
If .ClientEffectTypeId > 0 Then Call WriteSendSkillCdUpdate(EffectInfo.TargetRef.ArrayIndex, .ClientEffectTypeId, EffectInfo.UniqueId, .TickTime, .buffType, TickCount)
End If
End With
Call EffectsOverTime.ApplyEotModifier(EffectInfo.TargetRef, EffectOverTime(EffectInfo.EotId))
End Sub

Public Property Get IBaseEffectOverTime_TypeId() As Integer
Expand Down Expand Up @@ -142,7 +142,6 @@ Public Function IBaseEffectOverTime_Reset(ByVal SourceUserId As Integer, ByVal S
End If
End If
EffectInfo.EotId = NewEffectId
Call EffectsOverTime.ApplyEotModifier(EffectInfo.TargetRef, EffectOverTime(EffectInfo.EotId))
Call SetEotEffect
IBaseEffectOverTime_Reset = True
End Function
Expand Down
2 changes: 2 additions & 0 deletions Codigo/FileIO.bas
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,8 @@ On Error GoTo ErrHandler
EffectOverTime(i).Area = val(Leer.GetValue("EOT" & i, "Area"))
EffectOverTime(i).Aura = Leer.GetValue("EOT" & i, "Aura")
EffectOverTime(i).ApplyeffectID = val(Leer.GetValue("EOT" & i, "ApplyeffectID"))
EffectOverTime(i).SecondaryEffectId = val(Leer.GetValue("EOT" & i, "SecondaryEffectId"))

If val(Leer.GetValue("EOT" & i, "AffectedByMagicBonus")) > 0 Then
Call SetMask(EffectOverTime(i).EffectModifiers, e_ModifierTypes.MagicBonus)
End If
Expand Down
4 changes: 2 additions & 2 deletions Codigo/UpdateManaOverTime.cls
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Option Explicit
Implements IBaseEffectOverTime


Dim DotManaMin As Integer
Dim DotManaMax As Integer
Dim DotManaMin As Single
Dim DotManaMax As Single
Dim TargetTicks As Integer
Dim TickCount As Integer
Dim TickTime As Long
Expand Down

0 comments on commit 8bb5255

Please sign in to comment.