大世界ability相关交互完善第二弹
This commit is contained in:
1 parent
0750f2a984
commit
7f2fa99a82
25 files changed
+323
-342
No files matched your search
+60
-53
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"hk4e/pkg/endec"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"hk4e/gdconf"
|
||||
@@ -257,8 +258,8 @@ func (s *Scene) CreateEntityGadgetClient(pos, rot *model.Vector, entityId, confi
|
||||
},
|
||||
entityType: constant.ENTITY_TYPE_GADGET,
|
||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||
configId: configId,
|
||||
},
|
||||
gadgetId: configId,
|
||||
},
|
||||
campId: campId,
|
||||
campType: campType,
|
||||
@@ -274,9 +275,14 @@ func (s *Scene) CreateEntityGadgetClient(pos, rot *model.Vector, entityId, confi
|
||||
|
||||
func (s *Scene) CreateEntityGadgetVehicle(ownerUid uint32, pos, rot *model.Vector, vehicleId uint32) uint32 {
|
||||
// 获取载具配置表
|
||||
vehicleDataConfig := gdconf.GetVehicleDataById(int32(vehicleId))
|
||||
if vehicleDataConfig == nil {
|
||||
logger.Error("vehicle config error, vehicleId: %v", vehicleId)
|
||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(vehicleId))
|
||||
if gadgetDataConfig == nil {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", vehicleId)
|
||||
return 0
|
||||
}
|
||||
gadgetJsonConfig := gdconf.GetGadgetJsonConfigByName(gadgetDataConfig.JsonName)
|
||||
if gadgetJsonConfig == nil {
|
||||
logger.Error("get gadget json config is nil, name: %v", gadgetDataConfig.JsonName)
|
||||
return 0
|
||||
}
|
||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_GADGET)
|
||||
@@ -292,20 +298,19 @@ func (s *Scene) CreateEntityGadgetVehicle(ownerUid uint32, pos, rot *model.Vecto
|
||||
lastMoveSceneTimeMs: 0,
|
||||
lastMoveReliableSeq: 0,
|
||||
fightProp: map[uint32]float32{
|
||||
constant.FIGHT_PROP_BASE_DEFENSE: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.DefenseBase,
|
||||
constant.FIGHT_PROP_CUR_HP: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.HP,
|
||||
constant.FIGHT_PROP_MAX_HP: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.HP,
|
||||
constant.FIGHT_PROP_CUR_ATTACK: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.Attack,
|
||||
constant.FIGHT_PROP_BASE_DEFENSE: gadgetJsonConfig.Combat.Property.DefenseBase,
|
||||
constant.FIGHT_PROP_CUR_HP: gadgetJsonConfig.Combat.Property.HP,
|
||||
constant.FIGHT_PROP_MAX_HP: gadgetJsonConfig.Combat.Property.HP,
|
||||
constant.FIGHT_PROP_CUR_ATTACK: gadgetJsonConfig.Combat.Property.Attack,
|
||||
},
|
||||
entityType: constant.ENTITY_TYPE_GADGET,
|
||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||
},
|
||||
gadgetId: vehicleId,
|
||||
},
|
||||
vehicleId: vehicleId,
|
||||
worldId: s.world.id,
|
||||
ownerUid: ownerUid,
|
||||
maxStamina: vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaUpperLimit,
|
||||
curStamina: vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaUpperLimit,
|
||||
maxStamina: gadgetJsonConfig.Vehicle.Stamina.StaminaUpperLimit,
|
||||
curStamina: gadgetJsonConfig.Vehicle.Stamina.StaminaUpperLimit,
|
||||
restoreDelay: 0,
|
||||
memberMap: make(map[uint32]uint32),
|
||||
}
|
||||
@@ -615,7 +620,7 @@ func (e *Entity) InitAbility() {
|
||||
}
|
||||
|
||||
func (e *Entity) AddAbility(abilityName string, instancedAbilityId uint32) {
|
||||
logger.Debug("[AddAbility] abilityName: %v, instancedAbilityId: %v, entityId: %v", abilityName, instancedAbilityId, e.GetId())
|
||||
// logger.Debug("[AddAbility] abilityName: %v, instancedAbilityId: %v, entityId: %v", abilityName, instancedAbilityId, e.GetId())
|
||||
_, exist := e.abilityMap[instancedAbilityId]
|
||||
if exist {
|
||||
logger.Error("ability already exist, abilityName: %v, entityId: %v", abilityName, e.GetId())
|
||||
@@ -627,11 +632,6 @@ func (e *Entity) AddAbility(abilityName string, instancedAbilityId uint32) {
|
||||
instancedAbilityId: instancedAbilityId,
|
||||
abilitySpecialOverrideMap: make(map[uint32]float32),
|
||||
}
|
||||
abilityDataConfig := gdconf.GetAbilityDataByName(abilityName)
|
||||
if abilityDataConfig == nil {
|
||||
logger.Error("get ability data config is nil, abilityName: %v", abilityName)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Entity) GetAbility(instancedAbilityId uint32) *Ability {
|
||||
@@ -647,8 +647,8 @@ func (e *Entity) GetAllAbility() []*Ability {
|
||||
}
|
||||
|
||||
func (e *Entity) AddModifier(ability *Ability, instancedModifierId uint32, modifierLocalId uint32) {
|
||||
logger.Debug("[AddModifier] abilityName: %v, instancedModifierId: %v, modifierLocalId: %v, entityId: %v",
|
||||
ability.abilityName, instancedModifierId, modifierLocalId, e.GetId())
|
||||
// logger.Debug("[AddModifier] abilityName: %v, instancedModifierId: %v, modifierLocalId: %v, entityId: %v",
|
||||
// ability.abilityName, instancedModifierId, modifierLocalId, e.GetId())
|
||||
_, exist := e.modifierMap[instancedModifierId]
|
||||
if exist {
|
||||
logger.Error("modifier already exist, abilityName: %v, modifierLocalId: %v, entityId: %v", ability.abilityName, modifierLocalId, e.GetId())
|
||||
@@ -661,16 +661,6 @@ func (e *Entity) AddModifier(ability *Ability, instancedModifierId uint32, modif
|
||||
instancedAbilityId: ability.instancedAbilityId,
|
||||
instancedModifierId: instancedModifierId,
|
||||
}
|
||||
abilityDataConfig := gdconf.GetAbilityDataByName(ability.abilityName)
|
||||
if abilityDataConfig == nil {
|
||||
logger.Error("get ability data config is nil, abilityName: %v", ability.abilityName)
|
||||
return
|
||||
}
|
||||
modifierDataConfig := abilityDataConfig.Modifiers.GetByLocalId(modifierLocalId)
|
||||
if modifierDataConfig == nil {
|
||||
logger.Error("get modifier data config is nil, modifierLocalId: %v", modifierLocalId)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Entity) GetAllModifier() []*Modifier {
|
||||
@@ -687,18 +677,8 @@ func (e *Entity) RemoveModifier(instancedModifierId uint32) {
|
||||
logger.Error("modifier not exist, instancedModifierId: %v, entityId: %v", instancedModifierId, e.GetId())
|
||||
return
|
||||
}
|
||||
logger.Debug("[RemoveModifier] abilityName: %v, modifierLocalId: %v, entityId: %v", modifier.parentAbilityName, modifier.modifierLocalId, e.GetId())
|
||||
delete(e.modifierMap, instancedModifierId)
|
||||
abilityDataConfig := gdconf.GetAbilityDataByName(modifier.parentAbilityName)
|
||||
if abilityDataConfig == nil {
|
||||
logger.Error("get ability data config is nil, abilityName: %v", modifier.parentAbilityName)
|
||||
return
|
||||
}
|
||||
modifierDataConfig := abilityDataConfig.Modifiers.GetByLocalId(modifier.modifierLocalId)
|
||||
if modifierDataConfig == nil {
|
||||
logger.Error("get modifier data config is nil, modifierLocalId: %v", modifier.modifierLocalId)
|
||||
return
|
||||
}
|
||||
// logger.Debug("[RemoveModifier] abilityName: %v, modifierLocalId: %v, entityId: %v", modifier.parentAbilityName, modifier.modifierLocalId, e.GetId())
|
||||
delete(e.modifierMap, modifier.instancedModifierId)
|
||||
}
|
||||
|
||||
func (a *Ability) GetDynamicFloat(abilityData *gdconf.AbilityData, dynamicFloat gdconf.DynamicFloat) float32 {
|
||||
@@ -791,6 +771,43 @@ func (e *Entity) AbilityAction(ability *Ability, action *gdconf.ActionData, enti
|
||||
}
|
||||
staminaCost := ability.GetDynamicFloat(abilityDataConfig, action.CostStaminaRatio)
|
||||
GAME.UpdatePlayerStamina(owner, int32(staminaCost)*-100)
|
||||
GAME.TriggerQuest(owner, constant.QUEST_FINISH_COND_TYPE_SKILL, "", action.SkillID)
|
||||
case "CreateGadget":
|
||||
if !action.ByServer {
|
||||
return
|
||||
}
|
||||
GAME.CreateGadget(owner, entity.GetPos(), uint32(action.GadgetID), false, 0, 0)
|
||||
case "GenerateElemBall":
|
||||
itemDataConfig := gdconf.GetItemDataById(action.ConfigID)
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("get item data config is nil, itemId: %v", action.ConfigID)
|
||||
return
|
||||
}
|
||||
if itemDataConfig.GadgetId == 0 {
|
||||
return
|
||||
}
|
||||
abilityDataConfig := gdconf.GetAbilityDataByName(ability.abilityName)
|
||||
if abilityDataConfig == nil {
|
||||
logger.Error("get ability data config is nil, abilityName: %v", ability.abilityName)
|
||||
return
|
||||
}
|
||||
baseEnergy := ability.GetDynamicFloat(abilityDataConfig, action.BaseEnergy)
|
||||
ratio := ability.GetDynamicFloat(abilityDataConfig, action.Ratio)
|
||||
totalEnergy := baseEnergy * ratio
|
||||
for _, itemUse := range itemDataConfig.ItemUseList {
|
||||
if itemUse.UseOption != constant.ITEM_USE_ADD_ELEM_ENERGY {
|
||||
continue
|
||||
}
|
||||
if len(itemUse.UseParam) != 3 {
|
||||
continue
|
||||
}
|
||||
sameEnergy, err := strconv.Atoi(itemUse.UseParam[1])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
count := math.Ceil(float64(totalEnergy) / float64(sameEnergy))
|
||||
GAME.CreateDropGadget(owner, entity.GetPos(), uint32(itemDataConfig.GadgetId), uint32(action.ConfigID), uint32(count))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -941,7 +958,7 @@ func (g *GadgetEntity) InitAbility() {
|
||||
for configAbilityIndex, configAbility := range gadgetJsonConfig.Abilities {
|
||||
abilityDataConfig := gdconf.GetAbilityDataByName(configAbility.AbilityName)
|
||||
if abilityDataConfig == nil {
|
||||
logger.Error("get ability data config is nil, abilityName: %v", gadgetDataConfig.JsonName)
|
||||
logger.Error("get ability data config is nil, abilityName: %v", configAbility.AbilityName)
|
||||
continue
|
||||
}
|
||||
instancedAbilityId := uint32(configAbilityIndex + 1)
|
||||
@@ -999,8 +1016,6 @@ func (g *GadgetClientEntity) GetPropOwnerEntityId() uint32 {
|
||||
|
||||
type GadgetVehicleEntity struct {
|
||||
*GadgetEntity
|
||||
vehicleId uint32
|
||||
worldId uint64
|
||||
ownerUid uint32
|
||||
maxStamina float32
|
||||
curStamina float32
|
||||
@@ -1008,14 +1023,6 @@ type GadgetVehicleEntity struct {
|
||||
memberMap map[uint32]uint32 // key:pos value:uid
|
||||
}
|
||||
|
||||
func (g *GadgetVehicleEntity) GetVehicleId() uint32 {
|
||||
return g.vehicleId
|
||||
}
|
||||
|
||||
func (g *GadgetVehicleEntity) GetWorldId() uint64 {
|
||||
return g.worldId
|
||||
}
|
||||
|
||||
func (g *GadgetVehicleEntity) GetOwnerUid() uint32 {
|
||||
return g.ownerUid
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ func (g *Game) ScenePlayerLocationNotify(world *World) {
|
||||
Z: float32(entity.GetPos().Z),
|
||||
},
|
||||
UidList: make([]uint32, 0, len(gadgetVehicleEntity.GetMemberMap())),
|
||||
GadgetId: gadgetVehicleEntity.GetVehicleId(),
|
||||
GadgetId: gadgetVehicleEntity.GetGadgetId(),
|
||||
MaxHp: entity.GetFightProp()[constant.FIGHT_PROP_MAX_HP],
|
||||
}
|
||||
for _, uid := range gadgetVehicleEntity.GetMemberMap() {
|
||||
|
||||
@@ -232,7 +232,7 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", iGadgetEntity.GetGadgetId())
|
||||
return
|
||||
}
|
||||
logger.Debug("[EvtBeingHit] GadgetData: %+v, EntityId: %v, uid: %v", gadgetDataConfig, defEntity.GetId(), player.PlayerId)
|
||||
logger.Debug("[EvtBeingHit] GadgetData: %+v, entityId: %v, uid: %v", gadgetDataConfig, defEntity.GetId(), player.PlayerId)
|
||||
if gadgetDataConfig.ServerLuaScript != "" {
|
||||
gadgetLuaConfig := gdconf.GetGadgetLuaConfigByName(gadgetDataConfig.ServerLuaScript)
|
||||
if gadgetLuaConfig == nil {
|
||||
@@ -962,7 +962,7 @@ func (g *Game) handleAbilityInvoke(player *model.Player, entry *proto.AbilityInv
|
||||
if entity == nil {
|
||||
return
|
||||
}
|
||||
logger.Debug("[LocalAbilityInvoke] type: %v, localId: %v, entityId: %v, uid: %v", entry.ArgumentType, entry.Head.LocalId, entity.GetId(), player.PlayerId)
|
||||
// logger.Debug("[LocalAbilityInvoke] type: %v, localId: %v, entityId: %v, uid: %v", entry.ArgumentType, entry.Head.LocalId, entity.GetId(), player.PlayerId)
|
||||
if strings.Contains(entry.ArgumentType.String(), "ACTION") || entry.ArgumentType == proto.AbilityInvokeArgument_ABILITY_NONE {
|
||||
ability := entity.GetAbility(entry.Head.InstancedAbilityId)
|
||||
if ability == nil {
|
||||
|
||||
@@ -523,11 +523,6 @@ func (g *Game) TriggerQuest(player *model.Player, cond int32, complexParam strin
|
||||
dbQuest.ForceFinishQuest(quest.QuestId)
|
||||
updateQuestIdList = append(updateQuestIdList, quest.QuestId)
|
||||
case constant.QUEST_FINISH_COND_TYPE_SKILL:
|
||||
// TODO 实在不知道客户端要在怎样的情况下 才会发长按10006这个技能 这里先临时改表解决了
|
||||
// 是走ability体系计算出来的 操了
|
||||
if quest.QuestId == 35303 {
|
||||
questCond.Param[0] = 10067
|
||||
}
|
||||
// 使用技能 参数1:技能id
|
||||
ok := matchParamEqual(questCond.Param, param, 1)
|
||||
if !ok {
|
||||
|
||||
@@ -2119,7 +2119,7 @@ func (g *Game) PacketSceneGadgetInfoNormal(player *model.Player, entity IEntity)
|
||||
|
||||
func (g *Game) PacketSceneGadgetInfoClient(gadgetClientEntity *GadgetClientEntity) *proto.SceneGadgetInfo {
|
||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||
GadgetId: gadgetClientEntity.GetConfigId(),
|
||||
GadgetId: gadgetClientEntity.GetGadgetId(),
|
||||
OwnerEntityId: gadgetClientEntity.GetOwnerEntityId(),
|
||||
AuthorityPeerId: 1,
|
||||
IsEnableInteract: true,
|
||||
@@ -2143,8 +2143,8 @@ func (g *Game) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVehicleEn
|
||||
return new(proto.SceneGadgetInfo)
|
||||
}
|
||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||
GadgetId: gadgetVehicleEntity.GetVehicleId(),
|
||||
AuthorityPeerId: WORLD_MANAGER.GetWorldById(gadgetVehicleEntity.GetWorldId()).GetPlayerPeerId(player),
|
||||
GadgetId: gadgetVehicleEntity.GetGadgetId(),
|
||||
AuthorityPeerId: gadgetVehicleEntity.GetScene().GetWorld().GetPlayerPeerId(player),
|
||||
IsEnableInteract: true,
|
||||
Content: &proto.SceneGadgetInfo_VehicleInfo{
|
||||
VehicleInfo: &proto.VehicleInfo{
|
||||
|
||||
@@ -114,14 +114,19 @@ func (g *Game) RestoreCountStaminaHandler(player *model.Player) {
|
||||
continue
|
||||
}
|
||||
// 获取载具配置表
|
||||
vehicleDataConfig := gdconf.GetVehicleDataById(int32(gadgetVehicleEntity.GetVehicleId()))
|
||||
if vehicleDataConfig == nil {
|
||||
logger.Error("vehicle config error, vehicleId: %v", gadgetVehicleEntity.GetVehicleId())
|
||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetVehicleEntity.GetGadgetId()))
|
||||
if gadgetDataConfig == nil {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", gadgetVehicleEntity.GetGadgetId())
|
||||
continue
|
||||
}
|
||||
gadgetJsonConfig := gdconf.GetGadgetJsonConfigByName(gadgetDataConfig.JsonName)
|
||||
if gadgetJsonConfig == nil {
|
||||
logger.Error("get gadget json config is nil, name: %v", gadgetDataConfig.JsonName)
|
||||
continue
|
||||
}
|
||||
restoreDelay := gadgetVehicleEntity.GetRestoreDelay()
|
||||
// 做个限制不然一直加就panic了
|
||||
if restoreDelay < uint8(vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaRecoverWaitTime*10) {
|
||||
if restoreDelay < uint8(gadgetJsonConfig.Vehicle.Stamina.StaminaRecoverWaitTime*10) {
|
||||
gadgetVehicleEntity.SetRestoreDelay(restoreDelay + 1)
|
||||
}
|
||||
}
|
||||
@@ -219,16 +224,21 @@ func (g *Game) UpdateVehicleStamina(player *model.Player, entity IEntity, stamin
|
||||
return
|
||||
}
|
||||
// 获取载具配置表
|
||||
vehicleDataConfig := gdconf.GetVehicleDataById(int32(gadgetVehicleEntity.GetVehicleId()))
|
||||
if vehicleDataConfig == nil {
|
||||
logger.Error("vehicle config error, vehicleId: %v", gadgetVehicleEntity.GetVehicleId())
|
||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetVehicleEntity.GetGadgetId()))
|
||||
if gadgetDataConfig == nil {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", gadgetVehicleEntity.GetGadgetId())
|
||||
return
|
||||
}
|
||||
gadgetJsonConfig := gdconf.GetGadgetJsonConfigByName(gadgetDataConfig.JsonName)
|
||||
if gadgetJsonConfig == nil {
|
||||
logger.Error("get gadget json config is nil, name: %v", gadgetDataConfig.JsonName)
|
||||
return
|
||||
}
|
||||
// 添加的耐力大于0为恢复
|
||||
if staminaCost > 0 {
|
||||
// 耐力延迟1.5s(15 ticks)恢复 动作状态为加速将立刻恢复耐力
|
||||
restoreDelay := gadgetVehicleEntity.GetRestoreDelay()
|
||||
if restoreDelay < uint8(vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaRecoverWaitTime*10) && staminaInfo.State != proto.MotionState_MOTION_SKIFF_POWERED_DASH {
|
||||
if restoreDelay < uint8(gadgetJsonConfig.Vehicle.Stamina.StaminaRecoverWaitTime*10) && staminaInfo.State != proto.MotionState_MOTION_SKIFF_POWERED_DASH {
|
||||
return // 不恢复耐力
|
||||
}
|
||||
} else {
|
||||
|
||||
+33
-10
@@ -459,15 +459,35 @@ func (g *Game) PacketAvatarAbilityControlBlock(avatarId uint32, skillDepotId uin
|
||||
}
|
||||
abilityId := 0
|
||||
// 默认ability
|
||||
for _, abilityHashCode := range constant.DEFAULT_ABILITY_HASH_CODE {
|
||||
for _, defaultAbilityName := range gdconf.GetDefaultAbilityNameList() {
|
||||
abilityId++
|
||||
ae := &proto.AbilityEmbryo{
|
||||
AbilityId: uint32(abilityId),
|
||||
AbilityNameHash: uint32(abilityHashCode),
|
||||
AbilityNameHash: uint32(endec.Hk4eAbilityHashCode(defaultAbilityName)),
|
||||
AbilityOverrideNameHash: uint32(endec.Hk4eAbilityHashCode("Default")),
|
||||
}
|
||||
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, ae)
|
||||
}
|
||||
if SELF != nil && SELF.ClientVersion >= 400 {
|
||||
defaultAbilityNameList := []string{
|
||||
"Avatar_PlayerBoy_DiveStamina_Reduction",
|
||||
"Ability_Avatar_Dive_SealEcho",
|
||||
"Absorb_SealEcho_Bullet_01",
|
||||
"Absorb_SealEcho_Bullet_02",
|
||||
"Ability_Avatar_Dive_CrabShield",
|
||||
"ActivityAbility_Absorb_Shoot",
|
||||
"SceneAbility_DiveVolume",
|
||||
}
|
||||
for _, defaultAbilityName := range defaultAbilityNameList {
|
||||
abilityId++
|
||||
ae := &proto.AbilityEmbryo{
|
||||
AbilityId: uint32(abilityId),
|
||||
AbilityNameHash: uint32(endec.Hk4eAbilityHashCode(defaultAbilityName)),
|
||||
AbilityOverrideNameHash: uint32(endec.Hk4eAbilityHashCode("Default")),
|
||||
}
|
||||
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, ae)
|
||||
}
|
||||
}
|
||||
// 角色ability
|
||||
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatarId))
|
||||
if avatarDataConfig != nil && avatarDataConfig.ConfigAbility != nil {
|
||||
@@ -504,15 +524,18 @@ func (g *Game) PacketTeamAbilityControlBlock() *proto.AbilityControlBlock {
|
||||
AbilityEmbryoList: make([]*proto.AbilityEmbryo, 0),
|
||||
}
|
||||
abilityId := 0
|
||||
// 默认ability
|
||||
for _, abilityHashCode := range constant.DEFAULT_TEAM_ABILITY_HASH_CODE {
|
||||
abilityId++
|
||||
ae := &proto.AbilityEmbryo{
|
||||
AbilityId: uint32(abilityId),
|
||||
AbilityNameHash: uint32(abilityHashCode),
|
||||
AbilityOverrideNameHash: uint32(endec.Hk4eAbilityHashCode("Default")),
|
||||
if SELF != nil && SELF.ClientVersion >= 400 {
|
||||
// 默认ability
|
||||
defaultTeamAbilityNameList := []string{"Ability_Avatar_Dive_Team"}
|
||||
for _, defaultTeamAbilityName := range defaultTeamAbilityNameList {
|
||||
abilityId++
|
||||
ae := &proto.AbilityEmbryo{
|
||||
AbilityId: uint32(abilityId),
|
||||
AbilityNameHash: uint32(endec.Hk4eAbilityHashCode(defaultTeamAbilityName)),
|
||||
AbilityOverrideNameHash: uint32(endec.Hk4eAbilityHashCode("Default")),
|
||||
}
|
||||
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, ae)
|
||||
}
|
||||
acb.AbilityEmbryoList = append(acb.AbilityEmbryoList, ae)
|
||||
}
|
||||
return acb
|
||||
}
|
||||
@@ -86,7 +86,7 @@ func (g *Game) VehicleInteractReq(player *model.Player, payloadMsg pb.Message) {
|
||||
}
|
||||
// 判断实体类型是否为载具
|
||||
_, ok := entity.(*GadgetVehicleEntity)
|
||||
if ok {
|
||||
if !ok {
|
||||
logger.Error("vehicle entity error, entity: %v", entity)
|
||||
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_GADGET_NOT_VEHICLE)
|
||||
return
|
||||
@@ -120,7 +120,7 @@ func (g *Game) VehicleDestroyMotion(player *model.Player, entity IEntity, state
|
||||
// 状态等于 MOTION_STATE_DESTROY_VEHICLE 代表请求销毁
|
||||
if state == proto.MotionState_MOTION_DESTROY_VEHICLE {
|
||||
gadgetVehicleEntity := entity.(*GadgetVehicleEntity)
|
||||
g.DestroyVehicleEntity(player, scene, gadgetVehicleEntity.GetVehicleId(), entity.GetId())
|
||||
g.DestroyVehicleEntity(player, scene, gadgetVehicleEntity.GetGadgetId(), entity.GetId())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (g *Game) IsPlayerInVehicle(player *model.Player, entity IEntity) bool {
|
||||
}
|
||||
|
||||
// DestroyVehicleEntity 删除载具实体
|
||||
func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleId uint32, entityId uint32) {
|
||||
func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, gadgetId uint32, entityId uint32) {
|
||||
entity := scene.GetEntity(entityId)
|
||||
if entity == nil {
|
||||
return
|
||||
@@ -151,7 +151,7 @@ func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleI
|
||||
}
|
||||
// 目前原神仅有一种载具 多载具目前理论上是兼容了 到时候有问题再改
|
||||
// 确保载具Id为将要创建的 (每种载具允许存在1个)
|
||||
if gadgetVehicleEntity.GetVehicleId() != vehicleId {
|
||||
if gadgetVehicleEntity.GetGadgetId() != gadgetId {
|
||||
return
|
||||
}
|
||||
// 该载具是否为此玩家的
|
||||
@@ -169,7 +169,7 @@ func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleI
|
||||
scene.DestroyEntity(entity.GetId())
|
||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{entity.GetId()}, 0)
|
||||
// 删除玩家载具在线数据
|
||||
delete(player.VehicleInfo.CreateEntityIdMap, vehicleId)
|
||||
delete(player.VehicleInfo.CreateEntityIdMap, gadgetId)
|
||||
}
|
||||
|
||||
// EnterVehicle 进入载具
|
||||
@@ -179,12 +179,17 @@ func (g *Game) EnterVehicle(player *model.Player, entity IEntity, avatarGuid uin
|
||||
return
|
||||
}
|
||||
// 获取载具配置表
|
||||
vehicleDataConfig := gdconf.GetVehicleDataById(int32(gadgetVehicleEntity.GetVehicleId()))
|
||||
if vehicleDataConfig == nil {
|
||||
logger.Error("vehicle config error, vehicleId: %v", gadgetVehicleEntity.GetVehicleId())
|
||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetVehicleEntity.GetGadgetId()))
|
||||
if gadgetDataConfig == nil {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", gadgetVehicleEntity.GetGadgetId())
|
||||
return
|
||||
}
|
||||
maxSlot := int(vehicleDataConfig.ConfigGadgetVehicle.Vehicle.MaxSeatCount)
|
||||
gadgetJsonConfig := gdconf.GetGadgetJsonConfigByName(gadgetDataConfig.JsonName)
|
||||
if gadgetJsonConfig == nil {
|
||||
logger.Error("get gadget json config is nil, name: %v", gadgetDataConfig.JsonName)
|
||||
return
|
||||
}
|
||||
maxSlot := int(gadgetJsonConfig.Vehicle.MaxSeatCount)
|
||||
// 判断载具是否已满
|
||||
if len(gadgetVehicleEntity.GetMemberMap()) >= maxSlot {
|
||||
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_VEHICLE_SLOT_OCCUPIED)
|
||||
|
||||
@@ -420,7 +420,7 @@ func (g *Game) GadgetInteractReq(player *model.Player, payloadMsg pb.Message) {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v, uid: %v", entity.(IGadgetEntity).GetGadgetId(), player.PlayerId)
|
||||
return
|
||||
}
|
||||
logger.Debug("[GadgetInteractReq] GadgetData: %+v, EntityId: %v, uid: %v", gadgetDataConfig, entity.GetId(), player.PlayerId)
|
||||
logger.Debug("[GadgetInteractReq] GadgetData: %+v, entityId: %v, uid: %v", gadgetDataConfig, entity.GetId(), player.PlayerId)
|
||||
switch gadgetDataConfig.Type {
|
||||
case constant.GADGET_TYPE_GADGET, constant.GADGET_TYPE_EQUIP, constant.GADGET_TYPE_ENERGY_BALL:
|
||||
// 掉落物捡起
|
||||
|
||||
Reference in new issue
Block a user