forked from Ayin-a/hkrpg-go
/
player_battle.go
826 lines (756 loc) · 24.9 KB
/
player_battle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
package Game
import (
"strconv"
"time"
"github.com/Eichs/hkrpg-go/gdconf"
"github.com/Eichs/hkrpg-go/protocol/cmd"
"github.com/Eichs/hkrpg-go/protocol/proto"
)
/***********************************大世界攻击事件处理***********************************/
func (g *Game) SceneCastSkillCsReq(payloadMsg []byte) {
msg := g.DecodePayloadToProto(cmd.SceneCastSkillCsReq, payloadMsg)
req := msg.(*proto.SceneCastSkillCsReq)
var targetIndex uint32 = 0
var stageConfig *gdconf.StageConfig
var stageID *gdconf.PlaneEvent
if req.SkillIndex == 1 {
avatarId := g.Player.EntityList[req.CasterId].Entity
skillId := (avatarId * 100) + req.SkillIndex
if gdconf.GetMazeBuffById(skillId, req.SkillIndex) != nil {
g.Player.DbAvatar.Avatar[avatarId].BuffList = skillId
} else {
// 技能处理,有的技能并不会增加buff而是回复生命等功能
}
}
if len(req.HitTargetEntityIdList) == 0 {
rsp := &proto.SceneCastSkillScRsp{
AttackedGroupId: req.AttackedGroupId,
}
g.Send(cmd.SceneCastSkillScRsp, rsp)
return
}
if g.Player.EntityList[req.HitTargetEntityIdList[0]] == nil {
rsp := &proto.SceneCastSkillScRsp{
AttackedGroupId: req.AttackedGroupId,
}
g.Send(cmd.SceneCastSkillScRsp, rsp)
return
}
entity := g.Player.EntityList[req.HitTargetEntityIdList[0]]
stageID = gdconf.GetPlaneEventById(entity.Entity, g.Player.WorldLevel)
if stageID == nil {
newEntity := g.Player.EntityList[req.CasterId]
stageID = gdconf.GetPlaneEventById(newEntity.Entity, g.Player.WorldLevel)
stageConfig = gdconf.GetStageConfigById(stageID.StageID)
} else {
stageConfig = gdconf.GetStageConfigById(stageID.StageID)
}
// 构造回复包
rsp := &proto.SceneCastSkillScRsp{
AttackedGroupId: req.AttackedGroupId,
BattleInfo: &proto.SceneBattleInfo{
BuffList: make([]*proto.BattleBuff, 0), // Buff列表
LogicRandomSeed: gdconf.GetLoadingDesc(), // 逻辑随机种子
StageId: stageID.StageID, // 阶段id
//TurnSnapshotList: nil, // 打开快照列表?
WorldLevel: g.Player.WorldLevel,
RoundsLimit: 0, // 回合限制
BattleId: g.GetBattleIdGuid(), // 战斗Id
BattleAvatarList: make([]*proto.BattleAvatar, 0), // 战斗角色列表
},
}
// 怪物波列表
for id, monsterListMap := range stageConfig.MonsterList {
monsterWaveList := &proto.SceneMonsterWave{
StageId: stageID.StageID,
WaveId: uint32(id + 1),
}
for _, monsterList := range monsterListMap {
sceneMonster := &proto.SceneMonster{
MonsterId: monsterList,
}
monsterWaveList.MonsterList = append(monsterWaveList.MonsterList, sceneMonster)
}
rsp.BattleInfo.MonsterWaveList = append(rsp.BattleInfo.MonsterWaveList, monsterWaveList)
}
// 添加角色
for id, Lineup := range g.Player.DbLineUp.LineUpList[g.Player.DbLineUp.MainLineUp].AvatarIdList {
if Lineup == 0 {
continue
}
avatar := g.Player.DbAvatar.Avatar[Lineup]
battleAvatar := &proto.BattleAvatar{
AvatarType: proto.AvatarType_AVATAR_FORMAL_TYPE,
Id: Lineup,
Level: avatar.Level,
Rank: avatar.Rank,
Index: uint32(id),
SkilltreeList: g.GetSkilltree(avatar.AvatarId),
Hp: avatar.Hp,
Promotion: avatar.Promotion,
RelicList: make([]*proto.BattleRelic, 0),
WorldLevel: g.Player.WorldLevel,
SpBar: &proto.SpBarInfo{
CurSp: avatar.SpBar.CurSp,
MaxSp: avatar.SpBar.MaxSp,
},
}
// 获取角色装备的光锥
if avatar.EquipmentUniqueId != 0 {
equipment := g.Player.DbItem.EquipmentMap[avatar.EquipmentUniqueId]
equipmentList := &proto.BattleEquipment{
Id: equipment.Tid,
Level: equipment.Level,
Promotion: equipment.Promotion,
Rank: equipment.Rank,
}
battleAvatar.EquipmentList = append(battleAvatar.EquipmentList, equipmentList)
}
rsp.BattleInfo.BattleAvatarList = append(rsp.BattleInfo.BattleAvatarList, battleAvatar)
// 检查是否有提前释放的技能,添加到buff里
if avatar.BuffList != 0 {
buffList := &proto.BattleBuff{
Id: avatar.BuffList,
Level: 1,
OwnerId: targetIndex,
TargetIndexList: []uint32{targetIndex},
WaveFlag: 4294967295, // 失效时间
}
rsp.BattleInfo.BuffList = append(rsp.BattleInfo.BuffList, buffList)
targetIndex++
g.Player.DbAvatar.Avatar[Lineup].BuffList = 0
}
}
// 储存战斗信息
g.Player.Battle = make(map[uint32]*Battle)
battle := &Battle{
BattleId: rsp.BattleInfo.BattleId,
EventID: req.HitTargetEntityIdList[0],
LogicRandomSeed: rsp.BattleInfo.LogicRandomSeed,
RoundsLimit: rsp.BattleInfo.RoundsLimit,
BuffList: rsp.BattleInfo.BuffList,
BattleAvatarList: rsp.BattleInfo.BattleAvatarList,
}
g.Player.Battle[rsp.BattleInfo.BattleId] = battle
g.Send(cmd.SceneCastSkillScRsp, rsp)
}
/***********************************战斗结算***********************************/
func (g *Game) PVEBattleResultCsReq(payloadMsg []byte) {
msg := g.DecodePayloadToProto(cmd.PVEBattleResultCsReq, payloadMsg)
req := msg.(*proto.PVEBattleResultCsReq)
rsp := new(proto.PVEBattleResultScRsp)
// 要记得扣体力,和回复奖励
rsp.BattleId = req.BattleId
rsp.StageId = req.StageId
rsp.EndStatus = req.EndStatus // 战斗结算状态
rsp.CheckIdentical = true // 反作弊验证
rsp.BinVersion = ""
rsp.ResVersion = strconv.Itoa(int(req.ClientResVersion)) // 版本验证
// 撤退
if req.EndStatus == proto.BattleEndStatus_BATTLE_END_QUIT {
// 删除储存的战斗信息
delete(g.Player.Battle, req.BattleId)
g.Send(cmd.PVEBattleResultScRsp, rsp)
return
}
// 更新角色状态
for _, avatar := range req.Stt.BattleAvatarList {
g.Player.DbAvatar.Avatar[avatar.Id].Type = avatar.AvatarType
g.Player.DbAvatar.Avatar[avatar.Id].SpBar.CurSp = uint32((avatar.AvatarStatus.LeftSp / avatar.AvatarStatus.MaxSp) * 10000)
if avatar.AvatarStatus.LeftHp == float64(0) {
g.Player.DbAvatar.Avatar[avatar.Id].Hp = 2000
g.Player.DbAvatar.Avatar[avatar.Id].Type = proto.AvatarType_AVATAR_FORMAL_TYPE
} else {
g.Player.DbAvatar.Avatar[avatar.Id].Hp = uint32((avatar.AvatarStatus.LeftHp / avatar.AvatarStatus.MaxHp) * 10000)
}
}
// 更新队伍状态
g.BattleSyncLineupNotify(g.Player.DbLineUp.MainLineUp)
// 账号状态改变通知
g.PlayerPlayerSyncScNotify()
// 胜利时获取奖励
if req.EndStatus == proto.BattleEndStatus_BATTLE_END_WIN {
battle := g.Player.Battle[req.BattleId]
entity := g.Player.EntityList[battle.EventID]
if entity != nil {
// 删除实体
nitify := new(proto.SceneGroupRefreshScNotify)
nitify.GroupRefreshInfo = []*proto.SceneGroupRefreshInfo{
{
GroupId: entity.GroupId,
RefreshEntity: []*proto.SceneEntityRefreshInfo{
{
//UpdateType: &proto.SceneEntityRefreshInfo_DelEntity{
DelEntity: battle.EventID,
},
},
},
}
g.Send(cmd.SceneGroupRefreshScNotify, nitify)
delete(g.Player.EntityList, battle.EventID)
}
g.Player.DbItem.MaterialMap[11].Num -= battle.StaminaCost * battle.Wave // 扣除体力
// 获取奖励
rsp.DropData = &proto.ItemList{ItemList: make([]*proto.Item, 0)}
for _, drop := range battle.DisplayItemList {
item := &proto.Item{
ItemId: drop.Tid,
Level: 0,
Num: drop.Num * battle.Wave,
MainAffixId: 0,
Rank: 0,
Promotion: 0,
UniqueId: 0,
}
rsp.DropData.ItemList = append(rsp.DropData.ItemList, item)
g.AddMaterial(drop.Tid, drop.Num*battle.Wave)
}
}
// 当前坐标通知(失败情况应该是移动到最近锚点)
g.SceneEntityMoveScNotify()
// 体力改变通知
g.StaminaInfoScNotify()
// 删除储存的战斗信息
delete(g.Player.Battle, req.BattleId)
g.Send(cmd.PVEBattleResultScRsp, rsp)
}
// 队伍更新通知
func (g *Game) BattleSyncLineupNotify(index uint32) {
rsq := new(proto.SyncLineupNotify)
lineUp := g.Player.DbLineUp.LineUpList[index]
lineupList := &proto.LineupInfo{
IsVirtual: false,
LeaderSlot: 0,
AvatarList: make([]*proto.LineupAvatar, 0),
Index: index,
ExtraLineupType: proto.ExtraLineupType_LINEUP_NONE,
MaxMp: 5,
Mp: 5,
Name: lineUp.Name,
PlaneId: 0,
}
for slot, avatarId := range lineUp.AvatarIdList {
if avatarId == 0 {
continue
}
avatar := g.Player.DbAvatar.Avatar[avatarId]
lineupAvatar := &proto.LineupAvatar{
AvatarType: avatar.Type,
Slot: uint32(slot),
Satiety: 0,
Hp: avatar.Hp,
Id: avatarId,
SpBar: &proto.SpBarInfo{
CurSp: avatar.SpBar.CurSp,
MaxSp: avatar.SpBar.MaxSp,
},
}
lineupList.AvatarList = append(lineupList.AvatarList, lineupAvatar)
}
rsq.Lineup = lineupList
g.Send(cmd.SyncLineupNotify, rsq)
}
/***********************************模拟宇宙***********************************/
func (g *Game) GetRogueInfoCsReq(payloadMsg []byte) {
beginTime := time.Now().AddDate(0, 0, -1).Unix()
endTime := beginTime + int64(time.Hour.Seconds()*24*8)
rsp := new(proto.GetRogueInfoScRsp)
rogueInfo := &proto.RogueInfo{
BeginTime: beginTime,
EndTime: endTime,
SeasonId: 77,
RogueVirtualItemInfo: &proto.RogueVirtualItemInfo{
RogueAbilityPoint: 0,
},
RogueScoreInfo: &proto.RogueScoreRewardInfo{
PoolId: 20 + g.Player.WorldLevel,
HasTakenInitialScore: true,
PoolRefreshed: true,
},
RogueData: &proto.RogueInfoData{
RogueSeasonInfo: &proto.RogueSeasonInfo{
BeginTime: beginTime,
SeasonId: 77,
EndTime: endTime,
},
RogueScoreInfo: &proto.RogueScoreRewardInfo{
PoolId: 20 + g.Player.WorldLevel,
HasTakenInitialScore: true,
PoolRefreshed: true,
},
},
RogueAreaList: make([]*proto.RogueArea, 0),
}
for _, rogueArea := range gdconf.GetRogueAreaMap() {
RogueArea := &proto.RogueArea{
AreaId: rogueArea.RogueAreaID,
RogueAreaStatus: proto.RogueAreaStatus_ROGUE_AREA_STATUS_FIRST_PASS,
}
rogueInfo.RogueAreaList = append(rogueInfo.RogueAreaList, RogueArea)
}
rsp.RogueInfo = rogueInfo
g.Send(cmd.GetRogueInfoScRsp, rsp)
}
func (g *Game) StartRogueCsReq(payloadMsg []byte) {
msg := g.DecodePayloadToProto(cmd.StartRogueCsReq, payloadMsg)
req := msg.(*proto.StartRogueCsReq)
if req.BaseAvatarIdList == nil {
req.BaseAvatarIdList = g.Player.DbLineUp.LineUpList[g.Player.DbLineUp.MainLineUp].AvatarIdList
}
entityMap := make(map[uint32]*EntityList) // [实体id]怪物群id
leaderEntityId := uint32(g.GetNextGameObjectGuid())
// 获取地图
rogueAreaConfig := gdconf.GetRogueAreaConfigById(strconv.Itoa(int(req.AreaId)))
if rogueAreaConfig == nil {
rsp := &proto.StartRogueScRsp{
Retcode: uint32(proto.Retcode_RET_FIGHT_ACTIVITY_STAGE_NOT_OPEN),
}
g.Send(cmd.StartRogueScRsp, rsp)
return
}
rogueMapID := (rogueAreaConfig.AreaProgress * 100) + rogueAreaConfig.Difficulty
rogueMapStart := gdconf.GetRogueMapStartById(strconv.Itoa(int(rogueMapID)))
if rogueMapStart == nil {
rsp := &proto.StartRogueScRsp{
Retcode: uint32(proto.Retcode_RET_FIGHT_ACTIVITY_STAGE_NOT_OPEN),
}
g.Send(cmd.StartRogueScRsp, rsp)
return
}
// 获取映射信息
rogueMap := gdconf.GetRogueRoomIDBySiteID()
beginTime := time.Now().AddDate(0, 0, -1).Unix()
endTime := beginTime + int64(time.Hour.Seconds()*24*8)
// 可独立成单独的方法
rogueScoreInfo := &proto.RogueScoreRewardInfo{
HasTakenInitialScore: true, // 已取得初始积分?
//RogueImmersifier: 0,
Score: 0,
PoolRefreshed: true, // 刷新?
TakenScoreRewardList: nil,
PoolId: 20 + g.Player.WorldLevel,
}
// 可独立成单独的方法
roomMap := &proto.RogueMapInfo{
MapId: rogueMapID,
AreaId: req.AreaId,
CurSiteId: rogueMapStart.SiteID,
CurRoomId: rogueMap[1],
RoomList: make([]*proto.RogueRoom, 0),
}
for id, rogue := range rogueMap {
roomList := &proto.RogueRoom{
SiteId: id,
RoomId: rogue,
}
if id == rogueMapStart.SiteID {
roomList.RoomStatus = proto.RogueRoomStatus_ROGUE_ROOM_STATUS_PLAY
} else {
roomList.RoomStatus = proto.RogueRoomStatus_ROGUE_ROOM_STATUS_NONE
}
roomMap.RoomList = append(roomMap.RoomList, roomList)
}
// 可独立成单独的方法
rogueAreaList := make([]*proto.RogueArea, 0)
for _, rogueArea := range gdconf.GetRogueAreaMap() {
RogueArea := &proto.RogueArea{
AreaId: rogueArea.RogueAreaID,
RogueAreaStatus: proto.RogueAreaStatus_ROGUE_AREA_STATUS_FIRST_PASS,
}
rogueAreaList = append(rogueAreaList, RogueArea)
}
// 可独立成单独的方法
rogueRoom := gdconf.GetRogueRoomById(strconv.Itoa(int(rogueMap[rogueMapStart.SiteID])))
if rogueRoom == nil {
rsp := &proto.StartRogueScRsp{
Retcode: uint32(proto.Retcode_RET_FIGHT_ACTIVITY_STAGE_NOT_OPEN),
}
g.Send(cmd.StartRogueScRsp, rsp)
return
}
mapEntrance := gdconf.GetMapEntranceById(strconv.Itoa(int(rogueRoom.MapEntrance)))
if mapEntrance == nil {
rsp := &proto.StartRogueScRsp{
Retcode: uint32(proto.Retcode_RET_FIGHT_ACTIVITY_STAGE_NOT_OPEN),
}
g.Send(cmd.StartRogueScRsp, rsp)
return
}
scene := &proto.SceneInfo{
ClientPosVersion: 0,
PlaneId: mapEntrance.PlaneID,
FloorId: mapEntrance.FloorID,
LeaderEntityId: leaderEntityId,
WorldId: gdconf.GetMazePlaneById(strconv.Itoa(int(mapEntrance.PlaneID))).WorldID,
EntryId: rogueRoom.MapEntrance,
GameModeType: gdconf.GetPlaneType(gdconf.GetMazePlaneById(strconv.Itoa(int(mapEntrance.PlaneID))).PlaneType),
EntityGroupList: make([]*proto.SceneEntityGroupInfo, 0),
GroupIdList: nil,
LightenSectionList: nil,
EntityList: nil,
GroupStateList: nil,
}
entityGroupList := &proto.SceneEntityGroupInfo{
EntityList: make([]*proto.SceneEntityInfo, 0),
}
// 添加角色信息
startGroup := gdconf.GetNGroupById(mapEntrance.PlaneID, mapEntrance.FloorID, rogueRoom.GroupID)
anchor := startGroup.AnchorList[0]
for id, avatarId := range req.BaseAvatarIdList {
if avatarId == 0 {
continue
}
entityId := uint32(g.GetNextGameObjectGuid())
entityList := &proto.SceneEntityInfo{
Actor: &proto.SceneActorInfo{
AvatarType: proto.AvatarType_AVATAR_FORMAL_TYPE,
BaseAvatarId: avatarId,
},
Motion: &proto.MotionInfo{
Pos: &proto.Vector{
X: int32(anchor.PosX * 1000),
Y: int32(anchor.PosY * 1000),
Z: int32(anchor.PosZ * 1000),
},
Rot: &proto.Vector{
X: int32(anchor.RotX * 1000),
Y: int32(anchor.RotY * 1000),
Z: int32(anchor.RotZ * 1000),
},
},
}
// 为进入场景的角色设置与上面相同的实体id
if id == 0 {
entityList.EntityId = leaderEntityId
entityMap[leaderEntityId] = &EntityList{
Entity: avatarId,
GroupId: rogueRoom.GroupID,
}
} else {
entityList.EntityId = entityId
entityMap[entityId] = &EntityList{
Entity: avatarId,
GroupId: rogueRoom.GroupID,
}
}
entityGroupList.EntityList = append(entityGroupList.EntityList, entityList)
}
scene.EntityGroupList = append(scene.EntityGroupList, entityGroupList)
// 获取场景实体
for groupID, _ := range rogueRoom.GroupWithContent {
sceneGroup := gdconf.GetNGroupById(mapEntrance.PlaneID, mapEntrance.FloorID, stou32(groupID))
if sceneGroup == nil {
continue
}
scene.GroupIdList = append(scene.GroupIdList, stou32(groupID))
sceneGroupState := &proto.SceneGroupState{
GroupId: stou32(groupID),
IsDefault: true,
}
scene.GroupStateList = append(scene.GroupStateList, sceneGroupState)
entityGroupLists := &proto.SceneEntityGroupInfo{
GroupId: stou32(groupID),
EntityList: make([]*proto.SceneEntityInfo, 0),
}
// 添加物品实体
for _, propList := range sceneGroup.PropList {
entityList := &proto.SceneEntityInfo{
GroupId: stou32(groupID), // 文件名后那个G
InstId: propList.ID, // ID
EntityId: uint32(g.GetNextGameObjectGuid()),
Motion: &proto.MotionInfo{
Pos: &proto.Vector{
X: int32(propList.PosX * 1000),
Y: int32(propList.PosY * 1000),
Z: int32(propList.PosZ * 1000),
},
Rot: &proto.Vector{
X: 0,
Y: int32(propList.RotY * 1000),
Z: 0,
},
},
Prop: &proto.ScenePropInfo{
PropId: propList.PropID, // PropID
PropState: gdconf.GetStateValue(propList.State),
},
}
entityGroupLists.EntityList = append(entityGroupLists.EntityList, entityList)
}
// 添加怪物实体
for _, monsterList := range sceneGroup.MonsterList {
entityId := uint32(g.GetNextGameObjectGuid())
entityList := &proto.SceneEntityInfo{
GroupId: stou32(groupID),
InstId: monsterList.ID,
EntityId: entityId,
Motion: &proto.MotionInfo{
Pos: &proto.Vector{
X: int32(monsterList.PosX * 1000),
Y: int32(monsterList.PosY * 1000),
Z: int32(monsterList.PosZ * 1000),
},
Rot: &proto.Vector{
X: 0,
Y: int32(monsterList.RotY * 1000),
Z: 0,
},
},
NpcMonster: &proto.SceneNpcMonsterInfo{
WorldLevel: g.Player.WorldLevel,
MonsterId: monsterList.NPCMonsterID,
EventId: monsterList.EventID,
},
}
entityMap[entityId] = &EntityList{
Entity: monsterList.EventID,
GroupId: stou32(groupID),
}
entityGroupLists.EntityList = append(entityGroupLists.EntityList, entityList)
}
// 添加NPC实体
for _, npcList := range sceneGroup.NPCList {
entityList := &proto.SceneEntityInfo{
GroupId: stou32(groupID),
InstId: npcList.ID,
EntityId: uint32(g.GetNextGameObjectGuid()),
Motion: &proto.MotionInfo{
Pos: &proto.Vector{
X: int32(npcList.PosX * 1000),
Y: int32(npcList.PosY * 1000),
Z: int32(npcList.PosZ * 1000),
},
Rot: &proto.Vector{
X: 0,
Y: int32(npcList.RotY * 1000),
Z: 0,
},
},
Npc: &proto.SceneNpcInfo{
NpcId: npcList.NPCID,
},
}
entityGroupLists.EntityList = append(entityGroupLists.EntityList, entityList)
}
if len(entityGroupLists.EntityList) == 0 {
continue
}
scene.EntityGroupList = append(scene.EntityGroupList, entityGroupLists)
}
// 先更新队伍
for id, avatarid := range req.BaseAvatarIdList {
g.Player.DbLineUp.LineUpList[g.Player.DbLineUp.MainLineUp].AvatarIdList[id] = avatarid
}
g.Player.DbLineUp.MainAvatarId = 0
// 队伍更新通知
g.SyncLineupNotify(g.Player.DbLineUp.MainLineUp)
rsp := &proto.StartRogueScRsp{
Scene: scene,
Lineup: &proto.LineupInfo{
AvatarList: make([]*proto.LineupAvatar, 0),
ExtraLineupType: proto.ExtraLineupType_LINEUP_ROGUE,
MaxMp: 5,
Mp: 5,
},
RogueInfo: &proto.RogueInfo{
RogueData: &proto.RogueInfoData{
RogueScoreInfo: rogueScoreInfo,
RogueSeasonInfo: &proto.RogueSeasonInfo{
BeginTime: beginTime,
SeasonId: 77,
EndTime: endTime,
},
},
RogueVirtualItemInfo: &proto.RogueVirtualItemInfo{
RoguePumanCoupon: 0,
RogueCoin: 0,
RogueImmersifier: 0,
RogueAbilityPoint: 0,
},
RogueScoreInfo: rogueScoreInfo,
RoomMap: roomMap,
RogueAreaList: rogueAreaList,
Status: proto.RogueStatus_ROGUE_STATUS_DOING,
SeasonId: 77,
RogueProgress: &proto.RogueCurrentInfo{
RogueAvatarInfo: &proto.RogueAvatarInfo{
BaseAvatarIdList: req.BaseAvatarIdList,
},
RoomMap: roomMap,
Status: proto.RogueStatus_ROGUE_STATUS_DOING,
RogueBuffInfo: &proto.RogueBuffInfo{
BuffSelectInfo: nil,
MazeBuffList: nil,
},
RogueMiracleInfo: &proto.RogueMiracleInfo{
MiracleSelectInfo: nil,
RogueMiracleInfo: nil,
},
},
RogueAeonInfo: &proto.RogueAeonInfo{
UnlockAeonEnhanceNum: 0,
UnlockAeonNum: 0,
SelectedAeonId: 0,
AeonIdList: nil,
},
EndTime: endTime,
BaseAvatarIdList: req.BaseAvatarIdList,
BeginTime: beginTime,
RogueCoin: 0,
},
}
for slot, avatarId := range req.BaseAvatarIdList {
if avatarId == 0 {
continue
}
avatar := g.Player.DbAvatar.Avatar[avatarId]
lineupAvatar := &proto.LineupAvatar{
AvatarType: avatar.Type,
Slot: uint32(slot),
Hp: avatar.Hp,
Id: avatarId,
SpBar: &proto.SpBarInfo{
CurSp: avatar.SpBar.CurSp,
MaxSp: avatar.SpBar.MaxSp,
},
}
rsp.Lineup.AvatarList = append(rsp.Lineup.AvatarList, lineupAvatar)
}
g.Player.EntityList = entityMap
g.Player.IsRogue = true
g.Send(cmd.StartRogueScRsp, rsp)
}
func (g *Game) GetRogueTalentInfoCsReq() {
rsp := &proto.GetRogueTalentInfoScRsp{
TalentInfo: &proto.RogueTalentInfo{
RogueTalent: make([]*proto.RogueTalent, 0),
},
}
for _, talent := range gdconf.GetTalentIDList() {
rogueTalent := &proto.RogueTalent{
Status: proto.RogueTalentStatus_ROGUE_TALENT_STATUS_UNLOCK,
// UnlockProgressList: nil,
TalentId: talent,
}
rsp.TalentInfo.RogueTalent = append(rsp.TalentInfo.RogueTalent, rogueTalent)
}
g.Send(cmd.GetRogueTalentInfoScRsp, rsp)
}
func (g *Game) LeaveRogueCsReq(payloadMsg []byte) {
}
func (g *Game) QuitRogueCsReq(payloadMsg []byte) {
}
/***********************************关卡/副本***********************************/
func (g *Game) StartCocoonStageCsReq(payloadMsg []byte) {
msg := g.DecodePayloadToProto(cmd.StartCocoonStageCsReq, payloadMsg)
req := msg.(*proto.StartCocoonStageCsReq)
var targetIndex uint32 = 0
rsp := new(proto.StartCocoonStageScRsp)
rsp.PropEntityId = req.PropEntityId
rsp.CocoonId = req.CocoonId
rsp.Wave = req.Wave
cocoonConfig := gdconf.GetCocoonConfigById(req.CocoonId, req.WorldLevel)
if len(cocoonConfig.DropList) == 0 {
rsp.Retcode = uint32(proto.Retcode_RET_FIGHT_ACTIVITY_STAGE_NOT_OPEN)
g.Send(cmd.StartCocoonStageScRsp, rsp)
return
}
rsp.BattleInfo = new(proto.SceneBattleInfo)
rsp.BattleInfo.LogicRandomSeed = gdconf.GetLoadingDesc()
rsp.BattleInfo.BattleId = g.GetBattleIdGuid() // 战斗Id
rsp.BattleInfo.StageId = cocoonConfig.StageID
rsp.BattleInfo.WorldLevel = g.Player.WorldLevel
if rsp.BattleInfo.StageId == 0 {
rsp.BattleInfo.StageId = cocoonConfig.StageIDList[0]
}
for id, StageList := range cocoonConfig.StageIDList {
stageConfig := gdconf.GetStageConfigById(StageList)
// 怪物波列表
for _, monsterListMap := range stageConfig.MonsterList {
monsterWaveList := &proto.SceneMonsterWave{
StageId: StageList,
WaveId: uint32(id + 1),
}
for _, monsterList := range monsterListMap {
sceneMonster := &proto.SceneMonster{
MonsterId: monsterList,
}
monsterWaveList.MonsterList = append(monsterWaveList.MonsterList, sceneMonster)
}
rsp.BattleInfo.MonsterWaveList = append(rsp.BattleInfo.MonsterWaveList, monsterWaveList)
}
}
// 添加角色
for id, Lineup := range g.Player.DbLineUp.LineUpList[g.Player.DbLineUp.MainLineUp].AvatarIdList {
if Lineup == 0 {
continue
}
avatar := g.Player.DbAvatar.Avatar[Lineup]
battleAvatar := &proto.BattleAvatar{
AvatarType: proto.AvatarType_AVATAR_FORMAL_TYPE,
Id: Lineup,
Level: avatar.Level,
Rank: avatar.Rank,
Index: uint32(id),
SkilltreeList: g.GetSkilltree(avatar.AvatarId),
Hp: avatar.Hp,
Promotion: avatar.Promotion,
RelicList: make([]*proto.BattleRelic, 0),
WorldLevel: g.Player.WorldLevel,
SpBar: &proto.SpBarInfo{
CurSp: avatar.SpBar.CurSp,
MaxSp: avatar.SpBar.MaxSp,
},
}
// 获取角色装备的光锥
if avatar.EquipmentUniqueId != 0 {
equipment := g.Player.DbItem.EquipmentMap[avatar.EquipmentUniqueId]
equipmentList := &proto.BattleEquipment{
Id: equipment.Tid,
Level: equipment.Level,
Promotion: equipment.Promotion,
Rank: equipment.Rank,
}
battleAvatar.EquipmentList = append(battleAvatar.EquipmentList, equipmentList)
}
rsp.BattleInfo.BattleAvatarList = append(rsp.BattleInfo.BattleAvatarList, battleAvatar)
// 检查是否有提前释放的技能,添加到buff里
if avatar.BuffList != 0 {
buffList := &proto.BattleBuff{
Id: avatar.BuffList,
Level: 1,
OwnerId: targetIndex,
TargetIndexList: []uint32{targetIndex},
WaveFlag: 4294967295, // 失效时间
}
rsp.BattleInfo.BuffList = append(rsp.BattleInfo.BuffList, buffList)
targetIndex++
g.Player.DbAvatar.Avatar[Lineup].BuffList = 0
}
}
// 储存战斗信息
g.Player.Battle = make(map[uint32]*Battle)
battle := &Battle{
BattleId: rsp.BattleInfo.BattleId,
Wave: req.Wave,
EventID: req.CocoonId,
LogicRandomSeed: rsp.BattleInfo.LogicRandomSeed,
RoundsLimit: rsp.BattleInfo.RoundsLimit,
StaminaCost: cocoonConfig.StaminaCost,
BuffList: rsp.BattleInfo.BuffList,
BattleAvatarList: rsp.BattleInfo.BattleAvatarList,
}
// 添加奖励
for _, displayItem := range gdconf.GetMappingInfoById(req.CocoonId, g.Player.WorldLevel).DisplayItemList {
material := &Material{
Tid: displayItem.ItemID,
Num: displayItem.ItemNum,
}
if material.Num == 0 {
material.Num += 1
}
battle.DisplayItemList = append(battle.DisplayItemList, material)
}
g.Player.Battle[rsp.BattleInfo.BattleId] = battle
g.Send(cmd.StartCocoonStageScRsp, rsp)
}