mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 15:04:38 +01:00
Compare commits
4 Commits
8f3624d589
...
feature/en
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a8186ae2a | ||
|
|
4a7668549c | ||
|
|
eebb9510e8 | ||
|
|
9ee132eb41 |
@@ -103,7 +103,14 @@
|
||||
"EnableHiganjimaEvent": false,
|
||||
"EnableNierEvent": false,
|
||||
"DisableRoad": false,
|
||||
"SeasonOverride": false
|
||||
"SeasonOverride": false,
|
||||
"EnumerateEvent": {
|
||||
"Enabled":false,
|
||||
"EventID":2,
|
||||
"Duration":172800,
|
||||
"RestartAfter":2977200,
|
||||
"QuestIDs": [20001, 20004, 20005, 20006, 20011, 20012, 20013, 20018, 20019, 20020, 20021, 20022, 20023, 20024, 20025, 20026, 20027, 20028, 20029]
|
||||
}
|
||||
},
|
||||
"Discord": {
|
||||
"Enabled": false,
|
||||
|
||||
@@ -140,6 +140,14 @@ type CapLinkOptions struct {
|
||||
Port int
|
||||
}
|
||||
|
||||
type EnumerateEventOptions struct {
|
||||
QuestIDs []uint16
|
||||
EventID uint16
|
||||
Enabled bool
|
||||
Duration int
|
||||
RestartAfter int
|
||||
}
|
||||
|
||||
// GameplayOptions has various gameplay modifiers
|
||||
type GameplayOptions struct {
|
||||
MinFeatureWeapons int // Minimum number of Active Feature weapons to generate daily
|
||||
@@ -194,6 +202,7 @@ type GameplayOptions struct {
|
||||
EnableNierEvent bool // Enables the Nier event in the Rasta Bar
|
||||
DisableRoad bool // Disables the Hunting Road
|
||||
SeasonOverride bool // Overrides the Quest Season with the current Mezeporta Season
|
||||
EnumerateEvent EnumerateEventOptions
|
||||
}
|
||||
|
||||
// Discord holds the discord integration config.
|
||||
|
||||
5
schemas/patch-schema/event-ancientdragon.sql
Normal file
5
schemas/patch-schema/event-ancientdragon.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TYPE event_type ADD VALUE 'ancientdragon';
|
||||
|
||||
END;
|
||||
@@ -11,22 +11,54 @@ import (
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
EventType uint16
|
||||
EventType uint16 //0 Nothing //1 or 2 "An Acient Dragon has attacked the fort"
|
||||
Unk1 uint16
|
||||
Unk2 uint16
|
||||
Unk3 uint16
|
||||
Unk4 uint16
|
||||
Unk5 uint32
|
||||
Unk6 uint32
|
||||
StartTime uint32
|
||||
EndTime uint32
|
||||
QuestFileIDs []uint16
|
||||
}
|
||||
|
||||
func cleanupEnumEvent(s *Session) {
|
||||
s.server.db.Exec("DELETE FROM events WHERE event_type='ancientdragon'")
|
||||
}
|
||||
func generateEnumEventTimestamps(s *Session, start uint32) []uint32 {
|
||||
timestamps := make([]uint32, 2)
|
||||
midnight := TimeMidnight()
|
||||
//if start is 0 or start is after a duration
|
||||
if start == 0 || TimeAdjusted().Unix() > int64(start)+int64(s.server.erupeConfig.GameplayOptions.EnumerateEvent.RestartAfter) {
|
||||
cleanupEnumEvent(s)
|
||||
// Generate a new diva defense, starting midnight tomorrow
|
||||
start = uint32(midnight.Add(24 * time.Hour).Unix())
|
||||
s.server.db.Exec("INSERT INTO events (event_type, start_time) VALUES ('ancientdragon', to_timestamp($1)::timestamp without time zone)", start)
|
||||
}
|
||||
timestamps[0] = start
|
||||
timestamps[1] = timestamps[0] + uint32(s.server.erupeConfig.GameplayOptions.EnumerateEvent.Duration)
|
||||
return timestamps
|
||||
}
|
||||
|
||||
func handleMsgMhfEnumerateEvent(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfEnumerateEvent)
|
||||
bf := byteframe.NewByteFrame()
|
||||
id, start := uint32(0xCAFEBEEF), uint32(0)
|
||||
|
||||
rows, _ := s.server.db.Queryx("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='ancientdragon'")
|
||||
if !rows.Next() {
|
||||
for rows.Next() {
|
||||
rows.Scan(&id, &start)
|
||||
}
|
||||
}
|
||||
|
||||
var timestamps []uint32
|
||||
events := []Event{}
|
||||
|
||||
if s.server.erupeConfig.GameplayOptions.EnumerateEvent.Enabled {
|
||||
timestamps = generateEnumEventTimestamps(s, start)
|
||||
events = append(events, Event{s.server.erupeConfig.GameplayOptions.EnumerateEvent.EventID, 0, 0, 0, 0, timestamps[0], timestamps[1], s.server.erupeConfig.GameplayOptions.EnumerateEvent.QuestIDs})
|
||||
}
|
||||
|
||||
bf.WriteUint8(uint8(len(events)))
|
||||
for _, event := range events {
|
||||
bf.WriteUint16(event.EventType)
|
||||
@@ -34,8 +66,8 @@ func handleMsgMhfEnumerateEvent(s *Session, p mhfpacket.MHFPacket) {
|
||||
bf.WriteUint16(event.Unk2)
|
||||
bf.WriteUint16(event.Unk3)
|
||||
bf.WriteUint16(event.Unk4)
|
||||
bf.WriteUint32(event.Unk5)
|
||||
bf.WriteUint32(event.Unk6)
|
||||
bf.WriteUint32(event.StartTime)
|
||||
bf.WriteUint32(event.EndTime)
|
||||
if event.EventType == 2 {
|
||||
bf.WriteUint8(uint8(len(event.QuestFileIDs)))
|
||||
for _, qf := range event.QuestFileIDs {
|
||||
|
||||
Reference in New Issue
Block a user