Skip to content

Commit 5f6743e

Browse files
authored
Merge pull request #177 from ao-libre/happyhour
Added happy hour experience functionality
2 parents 28faa83 + 3b6f932 commit 5f6743e

File tree

5 files changed

+101
-1
lines changed

5 files changed

+101
-1
lines changed

Codigo/Declares.bas

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,18 @@ Public EnPausa As Boolean
19791979

19801980
Public EnTesting As Boolean
19811981

1982+
' Sistema de Happy Hour (adaptado de 0.13.5)
1983+
Public iniHappyHourActivado As Boolean ' GSZAO
1984+
Public HappyHour As Single ' 0.13.5
1985+
Public HappyHourActivated As Boolean ' 0.13.5
1986+
1987+
Public Type tHappyHour ' GSZAO
1988+
Multi As Single ' Multi
1989+
Hour As Integer ' Hora
1990+
End Type
1991+
1992+
Public HappyHourDays(1 To 7) As tHappyHour ' 0.13.5
1993+
19821994
'*****************ARRAYS PUBLICOS*************************
19831995
Public UserList() As User 'USUARIOS
19841996

Codigo/FileIO.bas

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1825,9 +1825,22 @@ Sub LoadSini()
18251825

18261826
RECORDusuarios = val(Lector.GetValue("INIT", "Record"))
18271827

1828+
' HappyHour
1829+
Dim lDayNumberTemp As Long
1830+
Dim sDayName As String
1831+
1832+
iniHappyHourActivado = IIf(Lector.GetValue("HAPPYHOUR", "Activado") = 1, True, False)
1833+
For lDayNumberTemp = 1 To 7
1834+
sDayName = Lector.GetValue("HAPPYHOUR", "Dia" & lDayNumberTemp)
1835+
HappyHourDays(lDayNumberTemp).Hour = val(ReadField(1, sDayName, 45)) ' GSZAO
1836+
HappyHourDays(lDayNumberTemp).Multi = val(ReadField(2, sDayName, 45)) ' 0.13.5
1837+
If HappyHourDays(lDayNumberTemp).Hour < 0 Or HappyHourDays(lDayNumberTemp).Hour > 23 Then HappyHourDays(lDayNumberTemp).Hour = 20 ' Hora de 0 a 23.
1838+
If HappyHourDays(lDayNumberTemp).Multi < 0 Then HappyHourDays(lDayNumberTemp).Multi = 0
1839+
Next
1840+
18281841
'Conexion con la API hecha en Node.js
18291842
'Mas info aqui: https://github.com/ao-libre/ao-api-server/
1830-
ConexionAPI = CBool(GetVar(IniPath & "Server.ini", "CONEXIONAPI", "Activado"))
1843+
ConexionAPI = CBool(Lector.GetValue("CONEXIONAPI", "Activado"))
18311844

18321845
'CHOTS | Database
18331846
Database_Enabled = CBool(val(Lector.GetValue("DATABASE", "Enabled")))

Codigo/MODULO_NPCs.bas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,7 @@ Public Function OpenNPC(ByVal NpcNumber As Integer, _
11471147
.flags.OldHostil = .Hostile
11481148

11491149
.GiveEXP = val(Leer.GetValue("NPC" & NpcNumber, "GiveEXP")) * ExpMultiplier
1150+
If HappyHourActivated And (HappyHour <> 0) Then .GiveEXP = .GiveEXP * HappyHour
11501151

11511152
.flags.ExpCount = .GiveEXP
11521153

Codigo/frmMain.frm

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,67 @@ Sub CheckIdleUser()
366366

367367
End Sub
368368

369+
Public Sub UpdateNpcsExp(ByVal Multiplicador As Single) ' 0.13.5
370+
Dim NpcIndex As Long
371+
For NpcIndex = 1 To LastNPC
372+
With Npclist(NpcIndex)
373+
.GiveEXP = .GiveEXP * Multiplicador
374+
.flags.ExpCount = .flags.ExpCount * Multiplicador
375+
End With
376+
Next NpcIndex
377+
End Sub
378+
379+
Private Sub HappyHourManager
380+
If iniHappyHourActivado = True Then
381+
Dim tmpHappyHour As Double
382+
383+
' HappyHour
384+
Dim iDay As Integer ' 0.13.5
385+
386+
iDay = Weekday(Date)
387+
tmpHappyHour = HappyHourDays(iDay).Multi
388+
389+
If tmpHappyHour <> HappyHour Then ' 0.13.5
390+
If HappyHourActivated Then
391+
' Reestablece la exp de los npcs
392+
If HappyHour <> 0 Then Call UpdateNpcsExp(1 / HappyHour)
393+
End If
394+
395+
If tmpHappyHour = 1 Then ' Desactiva
396+
Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Ha concluido la Happy Hour!", FontTypeNames.FONTTYPE_DIOS))
397+
HappyHourActivated = False
398+
399+
Else ' Activa?
400+
If HappyHourDays(iDay).Hour = Hour(Now) And tmpHappyHour > 0 Then ' GSZAO - Es la hora pautada?
401+
UpdateNpcsExp tmpHappyHour
402+
403+
If HappyHour <> 1 Then
404+
Call SendData(SendTarget.ToAll, 0, _
405+
PrepareMessageConsoleMsg("Se ha modificado la Happy Hour, a partir de ahora las criaturas aumentan su experiencia en un " & Round((tmpHappyHour - 1) * 100, 2) & "%", FontTypeNames.FONTTYPE_DIOS))
406+
Else
407+
Call SendData(SendTarget.ToAll, 0, _
408+
PrepareMessageConsoleMsg("Ha comenzado la Happy Hour! Las criaturas aumentan su experiencia en un " & Round((tmpHappyHour - 1) * 100, 2) & "%!", FontTypeNames.FONTTYPE_DIOS))
409+
End If
410+
411+
HappyHourActivated = True
412+
Else
413+
HappyHourActivated = False ' GSZAO
414+
End If
415+
End If
416+
417+
HappyHour = tmpHappyHour
418+
End If
419+
Else
420+
' Si estaba activado, lo deshabilitamos
421+
If HappyHour <> 0 Then
422+
Call UpdateNpcsExp(1 / HappyHour)
423+
Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Ha concluido la Happy Hour!", FontTypeNames.FONTTYPE_DIOS))
424+
HappyHourActivated = False
425+
HappyHour = 0
426+
End If
427+
End If
428+
End Sub
429+
369430
Private Sub AutoSave_Timer()
370431

371432
On Error GoTo ErrHandler
@@ -380,6 +441,8 @@ Private Sub AutoSave_Timer()
380441
Minutos = Minutos + 1
381442
MinsPjesSave = MinsPjesSave + 1
382443

444+
Call HappyHourManager
445+
383446
'??????????
384447
Call ModAreas.AreasOptimizacion
385448
'??????????

Server.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,14 @@ Host=argentumonlinefree.cjq47ruczip9.sa-east-1.rds.amazonaws.com
163163
Name=argentumonline
164164
Username=argentumonline
165165
Password=CHANGEME
166+
167+
[HAPPYHOUR]
168+
Activado=1
169+
## Formato: Hora-% (la hora es de 0 a 23hs) (el % es convertido x100, 1 el doble de exp)
170+
Dia1=22-1 ## Lunes
171+
Dia2=20-1
172+
Dia3=21-1
173+
Dia4=22-1
174+
Dia5=22-2
175+
Dia6=22-2
176+
Dia7=21-2 ## Domingo

0 commit comments

Comments
 (0)