Skip to content

Commit

Permalink
Merge pull request #365 from ao-org/fix-factions-info
Browse files Browse the repository at this point in the history
update faction score system
  • Loading branch information
RecoX authored Sep 1, 2023
2 parents e07d08c + eae7e66 commit 927da79
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 deletions.
1 change: 1 addition & 0 deletions Codigo/Admin.bas
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Public MRSkillNpcProtectionModifier As Single
Public AssistDamageValidTime As Long 'valid time for damage to count as assit
Public AssistHelpValidTime As Long 'valid time for helpful spell to count as assist
Public HideAfterHitTime As Long 'required time to hide again after a hit remove us from this state
Public FactionReKillTime As Long 'required time between killing the same user to get factions points

Public Puerto As Long

Expand Down
12 changes: 9 additions & 3 deletions Codigo/Declares.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,7 @@ Public Type t_ObjData
MagicDamageBonus As Integer
MagicPenetration As Integer
ResistenciaMagica As Integer
MagicAbsoluteBonus As Integer
Revive As Boolean

Invernal As Boolean
Expand Down Expand Up @@ -1738,12 +1739,18 @@ End Enum

Public Const MaxRecentKillToStore = 5

Public Type t_RecentKiller
UserId As Long
KillTime As Long
End Type

Public Type t_RecentKillRecord
UserId As Long
RecentKillers(MaxRecentKillToStore) As Long
RecentKillers(MaxRecentKillToStore) As t_RecentKiller
RecentKillersIndex As Long
End Type


'keep record from alst 50 dc users in memory to prevent relog abuse that dont belong to the db
Public Type t_RecentKillCache
LastDisconnectionInfo(50) As t_RecentKillRecord 'Use a circular buffer for this
Expand Down Expand Up @@ -1837,7 +1844,6 @@ Public Enum e_InventorySlotMask
eTool = 64
End Enum


'Flags
Public Type t_UserFlags
Nadando As Byte
Expand Down Expand Up @@ -1975,7 +1981,7 @@ Public Type t_UserFlags

ValCoDe As Integer

RecentKillers(MaxRecentKillToStore) As Long 'Circular buffer to store recent killers to this user
RecentKillers(MaxRecentKillToStore) As t_RecentKiller 'Circular buffer to store recent killers to this user
LastKillerIndex As Integer 'Last killer index of the circular buffer

OldBody As Integer
Expand Down
3 changes: 3 additions & 0 deletions Codigo/FileIO.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@ Sub LoadBalance()
AssistDamageValidTime = val(BalanceIni.GetValue("EXTRA", "AssistDamageValidTime"))
AssistHelpValidTime = val(BalanceIni.GetValue("EXTRA", "AssistHelpValidTime"))
HideAfterHitTime = val(BalanceIni.GetValue("EXTRA", "HideAfterHitTime"))
FactionReKillTime = val(BalanceIni.GetValue("EXTRA", "FactionReKillTime"))
'stun
PlayerStunTime = val(BalanceIni.GetValue("STUN", "PlayerStunTime"))
NpcStunTime = val(BalanceIni.GetValue("STUN", "NpcStunTime"))
Expand Down Expand Up @@ -1336,6 +1337,7 @@ Sub LoadOBJData()
218 .Municion = val(Leer.GetValue(ObjKey, "Municiones"))
220 .Power = val(Leer.GetValue(ObjKey, "StaffPower"))
222 .MagicDamageBonus = val(Leer.GetValue(ObjKey, "MagicDamageBonus"))
224 .MagicAbsoluteBonus = val(Leer.GetValue(ObjKey, "MagicAbsoluteBonus"))
226 .Real = val(Leer.GetValue(ObjKey, "Real"))
228 .Caos = val(Leer.GetValue(ObjKey, "Caos"))
230 .EfectoMagico = val(Leer.GetValue(ObjKey, "efectomagico"))
Expand Down Expand Up @@ -1481,6 +1483,7 @@ Sub LoadOBJData()

422 Case e_OBJType.otDañoMagico
424 .MagicDamageBonus = val(Leer.GetValue(ObjKey, "MagicDamageBonus"))
425 .MagicAbsoluteBonus = val(Leer.GetValue(ObjKey, "MagicAbsoluteBonus"))
426 .Revive = val(Leer.GetValue(ObjKey, "Revive")) <> 0

428 Case e_OBJType.otResistencia
Expand Down
1 change: 1 addition & 0 deletions Codigo/LocaleDef.bas
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Public Const MsgCCInunity = 475
Public Const MsgRequiredSkill = 473
Public Const MsgCantUseBowTransformed = 476
Public Const MsgBindableHotkeysOnly = 477
Public Const MsgFactionScore = 478


Public Function GetRequiredWeaponLocaleId(ByVal WeaponType As e_WeaponType) As Integer
Expand Down
19 changes: 5 additions & 14 deletions Codigo/Modulo_UsUaRiOs.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,6 @@ Sub SendUserStatsTxt(ByVal sendIndex As Integer, ByVal UserIndex As Integer)
100 Call WriteConsoleMsg(sendIndex, "Estadisticas de: " & UserList(UserIndex).Name, e_FontTypeNames.FONTTYPE_INFO)
102 Call WriteConsoleMsg(sendIndex, "Nivel: " & UserList(UserIndex).Stats.ELV & " EXP: " & UserList(UserIndex).Stats.Exp & "/" & ExpLevelUp(UserList(UserIndex).Stats.ELV), e_FontTypeNames.FONTTYPE_INFO)
104 Call WriteConsoleMsg(sendIndex, "Salud: " & UserList(UserIndex).Stats.MinHp & "/" & UserList(UserIndex).Stats.MaxHp & " Mana: " & UserList(UserIndex).Stats.MinMAN & "/" & UserList(UserIndex).Stats.MaxMAN & " Vitalidad: " & UserList(UserIndex).Stats.MinSta & "/" & UserList(UserIndex).Stats.MaxSta, e_FontTypeNames.FONTTYPE_INFO)

106 If UserList(UserIndex).Invent.WeaponEqpObjIndex > 0 Then
108 Call WriteConsoleMsg(sendIndex, "Menor Golpe/Mayor Golpe: " & UserList(UserIndex).Stats.MinHIT & "/" & UserList(UserIndex).Stats.MaxHit & " (" & ObjData(UserList(UserIndex).Invent.WeaponEqpObjIndex).MinHIT & "/" & ObjData(UserList(UserIndex).Invent.WeaponEqpObjIndex).MaxHit & ")", e_FontTypeNames.FONTTYPE_INFO)
Else
Expand Down Expand Up @@ -1703,11 +1702,11 @@ Sub SendUserStatsTxt(ByVal sendIndex As Integer, ByVal UserIndex As Integer)
148 Call WriteConsoleMsg(sendIndex, "Oro: " & UserList(UserIndex).Stats.GLD & " Posicion: " & UserList(UserIndex).Pos.X & "," & UserList(UserIndex).Pos.Y & " en mapa " & UserList(UserIndex).Pos.Map, e_FontTypeNames.FONTTYPE_INFO)
150 Call WriteConsoleMsg(sendIndex, "Dados: " & UserList(UserIndex).Stats.UserAtributos(e_Atributos.Fuerza) & ", " & UserList(UserIndex).Stats.UserAtributos(e_Atributos.Agilidad) & ", " & UserList(UserIndex).Stats.UserAtributos(e_Atributos.Inteligencia) & ", " & UserList(UserIndex).Stats.UserAtributos(e_Atributos.Constitucion) & ", " & UserList(UserIndex).Stats.UserAtributos(e_Atributos.Carisma), e_FontTypeNames.FONTTYPE_INFO)
152 Call WriteConsoleMsg(sendIndex, "Veces que Moriste: " & UserList(UserIndex).flags.VecesQueMoriste, e_FontTypeNames.FONTTYPE_INFO)

154 Call WriteLocaleMsg(sendIndex, MsgFactionScore, e_FontTypeNames.FONTTYPE_INFO, UserList(UserIndex).Faccion.FactionScore)
Exit Sub

SendUserStatsTxt_Err:
154 Call TraceError(Err.Number, Err.Description, "UsUaRiOs.SendUserStatsTxt", Erl)
156 Call TraceError(Err.Number, Err.Description, "UsUaRiOs.SendUserStatsTxt", Erl)


End Sub
Expand Down Expand Up @@ -2030,19 +2029,12 @@ Sub UserDie(ByVal UserIndex As Integer)
162 If .flags.PendienteDelSacrificio = 0 Then
164 Call TirarTodosLosItems(UserIndex)
Else

Dim MiObj As t_Obj

166 MiObj.amount = 1
168 MiObj.ObjIndex = PENDIENTE
170 Call QuitarObjetos(PENDIENTE, 1, UserIndex)
172 Call MakeObj(MiObj, .Pos.Map, .Pos.X, .Pos.Y)
174 Call WriteConsoleMsg(UserIndex, "Has perdido tu pendiente del sacrificio.", e_FontTypeNames.FONTTYPE_INFO)

End If

End If

End If

Call Desequipar(UserIndex, .Invent.ArmourEqpSlot)
Expand Down Expand Up @@ -2203,7 +2195,7 @@ Public Function AlreadyKilledBy(ByVal TargetIndex As Integer, ByVal KillerIndex
TargetPos = Min(.flags.LastKillerIndex, MaxRecentKillToStore)
Dim i As Integer
For i = 0 To TargetPos
If .flags.RecentKillers(i) = UserList(KillerIndex).id Then
If .flags.RecentKillers(i).UserId = UserList(killerIndex).id And (GlobalFrameTime - .flags.RecentKillers(i).KillTime) < FactionReKillTime Then
AlreadyKilledBy = True
Exit Function
End If
Expand All @@ -2216,7 +2208,8 @@ Public Sub RegisterRecentKiller(ByVal TargetIndex As Integer, ByVal KillerIndex
Dim InsertIndex As Integer
With UserList(TargetIndex)
InsertIndex = .flags.LastKillerIndex Mod MaxRecentKillToStore
.flags.RecentKillers(InsertIndex) = UserList(KillerIndex).id
.flags.RecentKillers(InsertIndex).UserId = UserList(killerIndex).id
.flags.RecentKillers(InsertIndex).KillTime = GlobalFrameTime
.flags.LastKillerIndex = .flags.LastKillerIndex + 1
If .flags.LastKillerIndex > MaxRecentKillToStore * 10 Then 'prevent overflow
.flags.LastKillerIndex = .flags.LastKillerIndex \ 10
Expand Down Expand Up @@ -2268,14 +2261,12 @@ Sub HandleFactionScoreForKill(ByVal UserIndex As Integer, ByVal TargetIndex As I
Score = Score - 1
Call HandleFactionScoreForAssist(.flags.LastHelpUser.ArrayIndex, TargetIndex)
End If

End If
If GlobalFrameTime - UserList(TargetIndex).flags.LastAttackedByUserTime < AssistDamageValidTime Then
If IsValidUserRef(UserList(TargetIndex).flags.LastAttacker) And UserList(TargetIndex).flags.LastAttacker.ArrayIndex <> UserIndex Then
Score = Score - 1
Call HandleFactionScoreForAssist(UserList(TargetIndex).flags.LastAttacker.ArrayIndex, TargetIndex)
End If
Score = Score - 1
End If
.Faccion.FactionScore = .Faccion.FactionScore + Score
End With
Expand Down
29 changes: 25 additions & 4 deletions Codigo/modHechizos.bas
Original file line number Diff line number Diff line change
Expand Up @@ -2771,10 +2771,13 @@ Sub HechizoPropNPC(ByVal hIndex As Integer, ByVal npcIndex As Integer, ByVal Use
148 If UserList(UserIndex).invent.WeaponEqpObjIndex > 0 Then
150 Damage = Damage + Porcentaje(Damage, ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicDamageBonus)
MagicPenetration = ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicPenetration
Damage = Damage + ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicAbsoluteBonus
End If
' Magic Damage ring
152 If UserList(UserIndex).invent.DañoMagicoEqpObjIndex > 0 Then
154 Damage = Damage + Porcentaje(Damage, ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicDamageBonus)
Damage = Damage + ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicAbsoluteBonus
MagicPenetration = MagicPenetration + ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicPenetration
End If
156 b = True
158 If NpcList(NpcIndex).flags.Snd2 > 0 Then
Expand Down Expand Up @@ -3332,9 +3335,11 @@ Sub HechizoPropUsuario(ByVal UserIndex As Integer, ByRef b As Boolean, ByRef IsA
If UserList(UserIndex).invent.WeaponEqpObjIndex > 0 Then
Damage = Damage + Porcentaje(Damage, ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicDamageBonus)
PorcentajeRM = PorcentajeRM - ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicPenetration
Damage = Damage + ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicAbsoluteBonus
End If
418 If UserList(UserIndex).invent.DañoMagicoEqpObjIndex > 0 Then
420 Damage = Damage + Porcentaje(Damage, ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicDamageBonus)
Damage = Damage + ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicAbsoluteBonus
PorcentajeRM = PorcentajeRM - ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicPenetration
End If

Expand Down Expand Up @@ -3645,12 +3650,15 @@ Sub HechizoCombinados(ByVal UserIndex As Integer, ByRef b As Boolean, ByRef IsAl
' Weapon Magic bonus
280 If UserList(UserIndex).Invent.WeaponEqpObjIndex > 0 Then
282 Damage = Damage + Porcentaje(Damage, ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicDamageBonus)
Damage = Damage + ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicAbsoluteBonus
MR = MR - ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicPenetration
End If

' Magic ring bonus
284 If UserList(UserIndex).invent.DañoMagicoEqpObjIndex > 0 Then
286 Damage = Damage + Porcentaje(Damage, ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicDamageBonus)
Damage = Damage + ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicAbsoluteBonus
MR = MR - ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicPenetration
End If
' Si el hechizo no ignora la RM
288 If Hechizos(h).AntiRm = 0 Then
Expand Down Expand Up @@ -4546,18 +4554,31 @@ End Sub
Private Sub AdjustNpcStatWithCasterLevel(ByVal UserIndex As Integer, ByVal NpcIndex As Integer)
Dim BaseHit As Integer
Dim BonusDamage As Single
Dim BonusFromItem As Integer
'get natural skill for user lvl and apply hit chance for a cleric of that level with agility buff to 36
BaseHit = UserList(UserIndex).Stats.ELV * 2.5
BaseHit = ((BaseHit + ((3 * BaseHit / 100) * 36))) * ModClase(e_Class.Cleric).AtaqueArmas
BaseHit = (BaseHit + (2.5 * max(CInt(UserList(UserIndex).Stats.ELV) - 12, 0)))
If UserList(UserIndex).invent.WeaponEqpObjIndex > 0 Then
BonusDamage = ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicDamageBonus / 100
BonusFromItem = ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicDamageBonus
If BonusFromItem = 0 Then
BonusFromItem = ObjData(UserList(UserIndex).invent.WeaponEqpObjIndex).MagicAbsoluteBonus \ 2
End If
End If

If BonusFromItem = 0 And UserList(UserIndex).invent.DañoMagicoEqpObjIndex Then
BonusFromItem = ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicDamageBonus
If BonusFromItem = 0 Then
BonusFromItem = ObjData(UserList(UserIndex).invent.DañoMagicoEqpObjIndex).MagicAbsoluteBonus \ 3
End If
End If
BonusDamage = BonusFromItem / 100
With NpcList(NpcIndex)
.PoderAtaque = BaseHit
.Stats.MinHIT = .Stats.MinHIT + .Stats.MinHIT * BonusDamage
.Stats.MaxHit = .Stats.MaxHit + .Stats.MaxHit * BonusDamage
Dim HitBonus As Integer
HitBonus = .Stats.MaxHit * BonusDamage
HitBonus = max(HitBonus, BonusFromItem / 2)
.Stats.MinHIT = .Stats.MinHIT + HitBonus
.Stats.MaxHit = .Stats.MaxHit + HitBonus
End With
End Sub

Expand Down

0 comments on commit 927da79

Please sign in to comment.