Files
90CNServer/server/internal/services/dnfbridge/dungeon_boss_entrance.go
T
hanfuit 645b64fe21 DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go):
- GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面
- GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新
- 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新)
- 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍
- 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0)
- 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算

启动器(Python/JS):
- 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭
- GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐)
- 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
2026-11-04 14:31:55 +08:00

158 lines
5.3 KiB
Go

package dnfbridge
import (
"strings"
"longheng.io/server/internal/modules/dnf/worldmap"
)
// The current 90CN client registers class-0/op0x0138 independently from the
// class-1 command enum that happens to use the same numeric value. Its exact
// five-byte body is u32(0),u8(0); the client consumes it as
// COMPLETE_CONDITION_PASS_GATE and sets its current-dungeon gate flag.
const currentDungeonCompleteConditionPassGateMsgID uint16 = 0x0138
var currentDungeonCompleteConditionPassGateBody = [...]byte{0, 0, 0, 0, 0}
type currentDungeonBossEntranceHuntProgress struct {
TargetID int64
Required int64
Defeated int64
}
type currentDungeonBossEntranceProgress struct {
Action string
Targets []currentDungeonBossEntranceHuntProgress
Ready bool
}
// currentDungeonBossEntranceConditionProgress evaluates one maze-owned PVF
// gate against every visited room in the current run. Room actors are the
// authority: an op39 replay cannot increment a counter twice, while revisiting
// a cached room preserves the already-defeated state.
func currentDungeonBossEntranceConditionProgress(
runtime *runtimeDungeonState,
) (currentDungeonBossEntranceProgress, bool) {
if runtime == nil || runtime.MazeIndex < 0 || runtime.MazeIndex >= len(runtime.Dungeon.Mazes) {
return currentDungeonBossEntranceProgress{}, false
}
condition := runtime.Dungeon.Mazes[runtime.MazeIndex].BossRoomEntranceCondition
if condition == nil || strings.TrimSpace(strings.ToLower(condition.Action)) != "clear action" ||
len(condition.HuntMonsters) == 0 {
return currentDungeonBossEntranceProgress{}, false
}
progress := currentDungeonBossEntranceProgress{
Action: "clear action",
Targets: make([]currentDungeonBossEntranceHuntProgress, 0, len(condition.HuntMonsters)),
Ready: true,
}
requirements := make(map[int64]int64, len(condition.HuntMonsters))
for _, target := range condition.HuntMonsters {
if target.TargetID <= 0 || target.Count <= 0 {
return currentDungeonBossEntranceProgress{}, false
}
requirements[target.TargetID] += target.Count
}
defeated := make(map[int64]int64, len(requirements))
seenRooms := make(map[*runtimeDungeonRoom]struct{}, len(runtime.Rooms)+1)
countRoom := func(room *runtimeDungeonRoom) {
if room == nil {
return
}
if _, duplicate := seenRooms[room]; duplicate {
return
}
seenRooms[room] = struct{}{}
for _, monster := range room.Snapshot().Monsters {
if monster.State != runtimeDungeonMonsterDefeated {
continue
}
if _, tracked := requirements[monster.Spawn.MonsterID]; tracked {
defeated[monster.Spawn.MonsterID]++
}
}
}
// Include the active room explicitly. It normally shares the pointer held
// in Rooms, but doing so keeps the fourth-tower transition correct during
// the small commit-to-cache interval after op39.
countRoom(runtime.Room)
for _, visit := range runtime.Rooms {
if visit == nil {
continue
}
countRoom(visit.Room)
}
for _, target := range condition.HuntMonsters {
required := requirements[target.TargetID]
// Duplicate target rows are folded into one requirement and one
// projection. The parser rejects them, but this keeps compact/runtime
// callers fail-safe if a future source supplies one.
if required == 0 {
continue
}
progress.Targets = append(progress.Targets, currentDungeonBossEntranceHuntProgress{
TargetID: target.TargetID,
Required: required,
Defeated: defeated[target.TargetID],
})
delete(requirements, target.TargetID)
if defeated[target.TargetID] < required {
progress.Ready = false
}
}
return progress, true
}
func buildCurrentDungeonCompleteConditionPassGateBody() []byte {
return append([]byte(nil), currentDungeonCompleteConditionPassGateBody[:]...)
}
// publishCurrentDungeonBossEntranceGateAfterDeathLocked is called only after
// the native op38 death notification has been written. The room snapshots are
// the idempotent authority, so replayed op39 traffic cannot advance the gate.
// Completion is retained even if the socket write fails, while the sent flag
// advances only after op312 reaches the connection.
func (s *Service) publishCurrentDungeonBossEntranceGateAfterDeathLocked(
session *gameSession,
runtime *runtimeDungeonState,
) error {
progress, found := currentDungeonBossEntranceConditionProgress(runtime)
if !found || !progress.Ready {
return nil
}
runtime.bossEntranceConditionComplete = true
if runtime.bossEntranceGateNotificationSent {
return nil
}
if err := s.sendGameUpperRawClass(
session,
currentDungeonCompleteConditionPassGateMsgID,
buildCurrentDungeonCompleteConditionPassGateBody(),
0,
); err != nil {
return err
}
runtime.bossEntranceGateNotificationSent = true
coordinate := worldmap.RoomCoordinate{}
mapID := int64(0)
if runtime != nil && runtime.Session != nil {
if scene, ok := runtime.Session.Scene(); ok {
coordinate = scene.Coordinate
mapID = scene.Map.Map.ID
}
}
s.logGameEvent(session, "game-dungeon-boss-entrance-condition-complete",
"dungeon_id", runtime.Dungeon.ID,
"maze_index", runtime.MazeIndex,
"room", coordinate.String(),
"map_id", mapID,
"targets", progress.Targets,
"response_opcode", currentDungeonCompleteConditionPassGateMsgID,
"response_body_len", len(currentDungeonCompleteConditionPassGateBody),
"source", "current_exe_complete_condition_pass_gate_after_fourth_target_op38")
return nil
}