Skip to content

Commit

Permalink
Merge pull request #364 from ao-org/fix-bonus-damage-bug
Browse files Browse the repository at this point in the history
fix bonus damage apply multiple times when cast from multiple user on…
  • Loading branch information
RecoX authored Aug 30, 2023
2 parents 5525b58 + 48b3188 commit e07d08c
Show file tree
Hide file tree
Showing 25 changed files with 154 additions and 34 deletions.
4 changes: 4 additions & 0 deletions Codigo/ApplyEffectOnHit.cls
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Public Property Get IBaseEffectOverTime_TypeId() As Integer
IBaseEffectOverTime_TypeId = e_EffectOverTimeType.eApplyEffectOnHit
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(DotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = DotInfo.UniqueId
End Property
Expand Down
32 changes: 24 additions & 8 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 All @@ -91,6 +93,10 @@ Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = DotInfo.UniqueId
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(DotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_CasterIsValid() As Boolean
IBaseEffectOverTime_CasterIsValid = IsValidRef(Source)
End Property
Expand Down Expand Up @@ -152,6 +158,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 +181,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 +261,30 @@ 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)
ElseIf EffectOverTime(DotInfo.EotId).Override Then
Call Effect.Reset(DotInfo.TargetRef.ArrayIndex, DotInfo.TargetRef.RefType, ApplyEffectId)
Call CreateEffect(DotInfo.TargetRef.ArrayIndex, DotInfo.TargetRef.RefType, TargetId, TargetType, EffectIdToApply)
ElseIf EffectOverTime(EffectIdToApply).Override And _
(Effect.EotId = EffectIdToApply Or EffectIdToApply = ApplyEffectId) Then
'either we don't override personal buff with other bard buff or we override anohter bard buff with ours on ourself
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
18 changes: 16 additions & 2 deletions Codigo/Declares.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1138,10 +1138,11 @@ End Enum

Public Type t_EffectOverTime
Type As e_EffectOverTimeType
SharedTypeId As e_EotTypeId
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 +1168,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 Expand Up @@ -2966,11 +2968,23 @@ Public Enum e_EffectOverTimeType
[EffectTypeCount]
End Enum

Public Enum e_EotTypeId
eNone = 0
eHealingDot = 1
eManaSong = 2
eSpeedSong = 3
eHitSing = 4
eEvasionSong = 5
eDivineProtection = 6
[EotTypeIdCount]
End Enum

Public Enum e_EOTTargetLimit
eSingle = 1 'Only one on target for this type
eSingleByCaster 'The target can have more than 1 effect of this type but only 1 for every caster
eAny 'No limits
eSingleByType 'can only have one effect of given type active at the time (like weapon poison)
eSingleByTypeId 'only one by TypeId (so we can have different buff that share the same id and can't stack like different lvls of the same buff)
End Enum

Public Type t_BaseDotInfo
Expand Down
4 changes: 4 additions & 0 deletions Codigo/DrunkEffect.cls
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = DotInfo.UniqueId
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(DotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_CasterIsValid() As Boolean
IBaseEffectOverTime_CasterIsValid = IsValidRef(DotInfo.TargetRef)
End Property
Expand Down
4 changes: 4 additions & 0 deletions Codigo/EffectOverTime/AttrackEffect.cls
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = DotInfo.UniqueId
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(DotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_CasterIsValid() As Boolean
IBaseEffectOverTime_CasterIsValid = IsValidRef(Source)
End Property
Expand Down
7 changes: 5 additions & 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,13 +65,16 @@ 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
IBaseEffectOverTime_TypeId = e_EffectOverTimeType.eBonusDamage
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(EffectInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = EffectInfo.UniqueId
End Property
Expand Down Expand Up @@ -142,7 +146,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
4 changes: 4 additions & 0 deletions Codigo/EffectOverTime/DelayedBlast.cls
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Public Property Get IBaseEffectOverTime_TypeId() As Integer
IBaseEffectOverTime_TypeId = e_EffectOverTimeType.eDelayedBlast
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(DotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = DotInfo.UniqueId
End Property
Expand Down
4 changes: 4 additions & 0 deletions Codigo/EffectOverTime/MultipleAttacks.cls
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = mDotInfo.UniqueId
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(mDotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_CasterIsValid() As Boolean
IBaseEffectOverTime_CasterIsValid = IsValidRef(mDotInfo.TargetRef)
End Property
Expand Down
4 changes: 4 additions & 0 deletions Codigo/EffectOverTime/ProtectEffect.cls
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ Public Property Get IBaseEffectOverTime_TypeId() As Integer
IBaseEffectOverTime_TypeId = e_EffectOverTimeType.eProtection
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(DotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = DotInfo.UniqueId
End Property
Expand Down
4 changes: 4 additions & 0 deletions Codigo/EffectOverTime/TransformEffect.cls
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ Public Property Get IBaseEffectOverTime_TypeId() As Integer
IBaseEffectOverTime_TypeId = e_EffectOverTimeType.eTransform
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(DotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = DotInfo.UniqueId
End Property
Expand Down
4 changes: 4 additions & 0 deletions Codigo/EffectOverTime/UnequipItem.cls
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Public Property Get IBaseEffectOverTime_TypeId() As Integer
IBaseEffectOverTime_TypeId = e_EffectOverTimeType.eUnequip
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(mDotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = mDotInfo.UniqueId
End Property
Expand Down
4 changes: 4 additions & 0 deletions Codigo/EffectProvoke.cls
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = DotInfo.UniqueId
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(DotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_CasterIsValid() As Boolean
IBaseEffectOverTime_CasterIsValid = IsValidRef(Source)
End Property
Expand Down
4 changes: 4 additions & 0 deletions Codigo/EffectProvoked.cls
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ Public Property Get IBaseEffectOverTime_TypeId() As Integer
IBaseEffectOverTime_TypeId = e_EffectOverTimeType.eProvoked
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(DotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = DotInfo.UniqueId
End Property
Expand Down
5 changes: 5 additions & 0 deletions Codigo/EffectsOverTime.bas
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,11 @@ On Error GoTo FindEffectOnTarget_Err
Set FindEffectOnTarget = EffectList.EffectList(i)
Exit Function
End If
ElseIf EffectLimit = eSingleByTypeId Then
If EffectList.EffectList(i).SharedTypeId = EffectOverTime(EffectId).SharedTypeId Then
Set FindEffectOnTarget = EffectList.EffectList(i)
Exit Function
End If
End If
Next i
Exit Function
Expand Down
3 changes: 3 additions & 0 deletions Codigo/FileIO.bas
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ On Error GoTo ErrHandler
114 For i = 1 To EffectCount
EffectOverTime(i).Type = val(Leer.GetValue("EOT" & i, "Type"))
EffectOverTime(i).SubType = val(Leer.GetValue("EOT" & i, "SubType"))
EffectOverTime(i).SharedTypeId = val(Leer.GetValue("EOT" & i, "SharedTypeId"))
EffectOverTime(i).TickPowerMin = val(Leer.GetValue("EOT" & i, "TickPowerMin"))
EffectOverTime(i).TickPowerMax = val(Leer.GetValue("EOT" & i, "TickPowerMax"))
EffectOverTime(i).Ticks = val(Leer.GetValue("EOT" & i, "Ticks"))
Expand Down Expand Up @@ -843,6 +844,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
3 changes: 3 additions & 0 deletions Codigo/IBaseEffectOverTime.cls
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ End Property
Public Property Get TypeId() As Integer
End Property

Public Property Get SharedTypeId() As Integer
End Property

Public Property Get EotId() As Integer
End Property

Expand Down
8 changes: 7 additions & 1 deletion Codigo/InvUsuario.bas
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,15 @@ Function MeterItemEnInventario(ByVal UserIndex As Integer, ByRef MiObj As t_Obj)
Dim Y As Integer

Dim Slot As Integer

If MiObj.ObjIndex = 12 Then
UserList(UserIndex).Stats.GLD = UserList(UserIndex).Stats.GLD + MiObj.amount
MeterItemEnInventario = True
Call WriteUpdateGold(UserIndex)
Exit Function
End If
'¿el user ya tiene un objeto del mismo tipo? ?????
100 Slot = GetSlotForItemInInvetory(UserIndex, MiObj)

If Slot <= 0 Then
118 Call WriteLocaleMsg(UserIndex, MsgInventoryIsFull, e_FontTypeNames.FONTTYPE_FIGHT)
120 MeterItemEnInventario = False
Expand Down
9 changes: 9 additions & 0 deletions Codigo/Matematicas.bas
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ RandomNumber_Err:
102 Call TraceError(Err.Number, Err.Description, "Matematicas.RandomNumber", Erl)
End Function

Public Function RandomRange(ByVal LowerBound As Single, ByVal UpperBound As Single) As Single
On Error GoTo RandomNumber_Err
100 RandomRange = Rnd
RandomRange = RandomRange * (UpperBound - LowerBound) + LowerBound
Exit Function
RandomNumber_Err:
102 Call TraceError(Err.Number, Err.Description, "Matematicas.RandomNumber", Erl)
End Function

Public Sub SetMask(ByRef mask As Long, ByVal value As Long)
mask = mask Or value
End Sub
Expand Down
10 changes: 0 additions & 10 deletions Codigo/Modulo_InventANDobj.bas
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,6 @@ Public Sub NpcDropeo(ByRef npc As t_Npc, ByRef UserIndex As Integer)

End If

110 If UserList(UserIndex).Invent.MagicoObjIndex = 383 Then
112 If npc.QuizaProb = 0 Then
114 Probabilidad = RandomNumber(1, DropMult / 2) 'Tiro Item?
Else
116 Probabilidad = RandomNumber(1, npc.QuizaProb / 2) 'Tiro Item?

End If

End If

118 If Probabilidad <> 1 Then Exit Sub

120 objRandom = RandomNumber(1, npc.NumQuiza) 'Que item puede ser que tire?
Expand Down
2 changes: 0 additions & 2 deletions Codigo/Modulo_UsUaRiOs.bas
Original file line number Diff line number Diff line change
Expand Up @@ -3526,8 +3526,6 @@ Public Sub RemoveUserInvisibility(ByVal UserIndex As Integer)
Dim RemoveHiddenState As Boolean
If IsFeatureEnabled("remove-inv-on-attack") And Not MapInfo(.pos.Map).KeepInviOnAttack Then
RemoveHiddenState = .flags.Oculto > 0 Or .flags.invisible > 0
Else
RemoveHiddenState = .flags.Oculto > 0
End If
'I see you...
If RemoveHiddenState And .flags.AdminInvisible = 0 Then
Expand Down
4 changes: 4 additions & 0 deletions Codigo/StatModifier.cls
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Public Property Get IBaseEffectOverTime_TypeId() As Integer
IBaseEffectOverTime_TypeId = e_EffectOverTimeType.eApplyModifiers
End Property

Public Property Get IBaseEffectOverTime_SharedTypeId() As Integer
IBaseEffectOverTime_SharedTypeId = EffectOverTime(DotInfo.EotId).SharedTypeId
End Property

Public Property Get IBaseEffectOverTime_UniqueId() As Long
IBaseEffectOverTime_UniqueId = DotInfo.UniqueId
End Property
Expand Down
Loading

0 comments on commit e07d08c

Please sign in to comment.