Update GaCy-GO
This commit is contained in:
1 parent
da8a32f60d
commit
0cbe460e49
345 files changed
+98202
-77559
No files matched your search
@@ -15,40 +15,42 @@ import (
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// loadChallengeScene is the Go port of scene.rs load_challenge_scene.
|
||||
func loadChallengeScene(s *Session, entryID, targetGroupID, monsterID, eventID uint32, avatarIDs []uint32) (*goproto.SceneInfo, *goproto.MotionInfo, error) {
|
||||
func loadChallengeScene(s *Session, entryID, targetGroupID, monsterID, eventID uint32, avatarIDs []uint32) (*goproto.SceneInfo, *goproto.MotionInfo, bool, error) {
|
||||
player := s.JSON()
|
||||
if player == nil {
|
||||
return nil, nil, errors.New("data is not set!")
|
||||
return nil, nil, false, errors.New("data is not set!")
|
||||
}
|
||||
res, err := common.GameRes()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, nil, false, err
|
||||
}
|
||||
|
||||
name, scene, ok := firstSceneOfEntry(res, entryID)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("Challenge Map Entrance Not Found %d", entryID)
|
||||
return nil, nil, false, fmt.Errorf("Challenge Map Entrance Not Found %d", entryID)
|
||||
}
|
||||
planeID, floorID, err := parsePlaneFloor(name)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, nil, false, err
|
||||
}
|
||||
|
||||
// Use the selected group's resource placement, with no guessed arena
|
||||
// height or offset towards world origin (arena floors need not be there).
|
||||
group, ok := scene.Scenes[targetGroupID]
|
||||
if !ok || len(group.Monsters) == 0 {
|
||||
return nil, nil, fmt.Errorf("challenge entrance %d group %d has no monster placement", entryID, targetGroupID)
|
||||
return nil, nil, false, fmt.Errorf("challenge entrance %d group %d has no monster placement", entryID, targetGroupID)
|
||||
}
|
||||
placement := group.Monsters[0]
|
||||
monsPos := common.Position{X: placement.Pos.X, Y: placement.Pos.Y, Z: placement.Pos.Z, RotY: placement.Rot.Y}
|
||||
instID := placement.InstID
|
||||
playerMotion := monsPos.ToMotionInfo()
|
||||
spawnSource := "monster-placement"
|
||||
hasAnchor := false
|
||||
if anchors := res.SceneAnchors[entryID]; len(anchors) > 0 {
|
||||
anchor := anchors[0] // PearlSR scene_mgr.zig getAnchorMotion.
|
||||
playerMotion = (&common.Position{X: anchor.Pos.X, Y: anchor.Pos.Y, Z: anchor.Pos.Z, RotY: anchor.Rot.Y}).ToMotionInfo()
|
||||
spawnSource = "anchor"
|
||||
hasAnchor = true
|
||||
}
|
||||
SceneDebugLog("[CHALLENGE] spawn entry=%d floor=%d source=%s player=%v monster=%v", entryID, floorID, spawnSource, playerMotion, monsPos)
|
||||
|
||||
@@ -144,7 +146,7 @@ func loadChallengeScene(s *Session, entryID, targetGroupID, monsterID, eventID u
|
||||
|
||||
// NOTE: do not overwrite the saved scene so the player returns to the
|
||||
// open world on logout/battle end
|
||||
return sceneInfo, playerMotion, nil
|
||||
return sceneInfo, playerMotion, hasAnchor, nil
|
||||
}
|
||||
|
||||
// handleStartChallengePeak ports on_start_challenge_peak_cs_req (cmd 8948):
|
||||
@@ -157,6 +159,12 @@ func handleStartChallengePeak(s *Session, req *goproto.StartChallengePeakCsReq,
|
||||
stage, ok := getChallengeData().Peak[itoa(int(peakID))]
|
||||
if !ok {
|
||||
Log("[PEAK] peak_id=" + itoa(int(peakID)) + " not found in challenge_data!")
|
||||
rsp.Retcode = uint32(goproto.Retcode_RET_CHALLENGE_NOT_EXIST)
|
||||
return nil
|
||||
}
|
||||
if stage.SceneResourceError != "" {
|
||||
SceneDebugLog("[PEAK] scene resource rejected peak=%d: %s", peakID, stage.SceneResourceError)
|
||||
rsp.Retcode = uint32(goproto.Retcode_RET_CHALLENGE_NOT_EXIST)
|
||||
return nil
|
||||
}
|
||||
eventID := stage.EventID
|
||||
@@ -176,7 +184,7 @@ func handleStartChallengePeak(s *Session, req *goproto.StartChallengePeakCsReq,
|
||||
if req.BossBuffId != 0 {
|
||||
buffs = append(buffs, req.BossBuffId)
|
||||
}
|
||||
if stage.Entrance == 0 || stage.Group == 0 || eventID == 0 || len(avatars) == 0 {
|
||||
if stage.Entrance == 0 || stage.Group == 0 || monsterID == 0 || eventID == 0 || len(avatars) == 0 {
|
||||
rsp.Retcode = uint32(goproto.Retcode_RET_CHALLENGE_NOT_EXIST)
|
||||
return nil
|
||||
}
|
||||
@@ -186,7 +194,7 @@ func handleStartChallengePeak(s *Session, req *goproto.StartChallengePeakCsReq,
|
||||
rsp.Retcode = uint32(goproto.Retcode_RET_CHALLENGE_NOT_EXIST)
|
||||
return nil
|
||||
}
|
||||
sceneInfo, _, err := loadChallengeScene(s, stage.Entrance, stage.Group, monsterID, eventID, avatars)
|
||||
sceneInfo, playerMotion, hasAnchor, err := loadChallengeScene(s, stage.Entrance, stage.Group, monsterID, eventID, avatars)
|
||||
if err != nil {
|
||||
s.ChallengeBattleConfig = previousConfig
|
||||
SceneDebugLog("[PEAK] scene rejected: %v", err)
|
||||
@@ -197,10 +205,36 @@ func handleStartChallengePeak(s *Session, req *goproto.StartChallengePeakCsReq,
|
||||
|
||||
lineupInfo := lineupInfoFromAvatars(avatars, sceneInfo.PlaneId, goproto.ExtraLineupType_ExtraLineupType_LineupChallenge, 0)
|
||||
|
||||
return s.Send(&goproto.EnterSceneByServerScNotify{
|
||||
// Match the Client-tested PearlSR AA transition: send the arena scene,
|
||||
// move each actor to the scene anchor when present, then let the typed
|
||||
// dispatcher send StartChallengePeakScRsp last. The lineup is included in
|
||||
// EnterSceneByServerScNotify, so a separate SyncLineupNotify is unnecessary.
|
||||
if err := s.Send(&goproto.EnterSceneByServerScNotify{
|
||||
Scene: sceneInfo,
|
||||
Lineup: lineupInfo,
|
||||
})
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
anchorMoves := 0
|
||||
if hasAnchor {
|
||||
for _, group := range sceneInfo.EntityGroupList {
|
||||
for _, entity := range group.EntityList {
|
||||
if entity.GetActor() == nil {
|
||||
continue
|
||||
}
|
||||
if err := s.Send(&goproto.SceneEntityMoveScNotify{
|
||||
EntityId: entity.EntityId,
|
||||
EntryId: sceneInfo.EntryId,
|
||||
Motion: playerMotion,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
anchorMoves++
|
||||
}
|
||||
}
|
||||
}
|
||||
SceneDebugLog("[PEAK] transition peak=%d entry=%d anchor_moves=%d", peakID, sceneInfo.EntryId, anchorMoves)
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ = proto.Marshal
|
||||
Reference in new issue
Block a user