mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-03-01 00:35:36 +08:00
技能开始耐力消耗异常解决
This commit is contained in:
@@ -242,18 +242,23 @@ func (g *GameManager) SkillStartStamina(player *model.Player, casterId uint32, s
|
|||||||
staminaInfo := player.StaminaInfo
|
staminaInfo := player.StaminaInfo
|
||||||
|
|
||||||
// 获取该技能开始时所需消耗的耐力
|
// 获取该技能开始时所需消耗的耐力
|
||||||
costStamina := constant.StaminaCostConst.SKILL_START[skillId]
|
costStamina, ok := constant.StaminaCostConst.SKILL_START[skillId]
|
||||||
|
|
||||||
// 距离上次处理技能开始耐力消耗过去的时间
|
// 配置表确保存在技能开始对应的耐力消耗
|
||||||
pastTime := time.Now().UnixMilli() - staminaInfo.LastSkillTime
|
if ok {
|
||||||
// 上次触发的技能相同则每400ms触发一次消耗
|
// 距离上次处理技能开始耐力消耗过去的时间
|
||||||
if staminaInfo.LastSkillId == skillId && pastTime > 400 {
|
pastTime := time.Now().UnixMilli() - staminaInfo.LastSkillStartTime
|
||||||
// 根据配置消耗耐力
|
// 上次触发的技能相同则每400ms触发一次消耗
|
||||||
g.UpdatePlayerStamina(player, costStamina)
|
if staminaInfo.LastSkillId != skillId || pastTime > 400 {
|
||||||
|
logger.LOG.Debug("skill start stamina, skillId: %v, cost: %v", skillId, costStamina)
|
||||||
|
// 根据配置消耗耐力
|
||||||
|
g.UpdatePlayerStamina(player, costStamina)
|
||||||
|
staminaInfo.LastSkillStartTime = time.Now().UnixMilli()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//logger.LOG.Debug("skill start cost error, cost: %v", costStamina)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LOG.Debug("skill start stamina, skillId: %v, cost: %v", skillId, costStamina)
|
|
||||||
|
|
||||||
// 记录最后释放的技能
|
// 记录最后释放的技能
|
||||||
staminaInfo.LastCasterId = casterId
|
staminaInfo.LastCasterId = casterId
|
||||||
staminaInfo.LastSkillId = skillId
|
staminaInfo.LastSkillId = skillId
|
||||||
@@ -410,7 +415,7 @@ func (g *GameManager) UpdatePlayerStamina(player *model.Player, staminaCost int3
|
|||||||
func (g *GameManager) SetVehicleStamina(player *model.Player, vehicleEntity *Entity, stamina float32) {
|
func (g *GameManager) SetVehicleStamina(player *model.Player, vehicleEntity *Entity, stamina float32) {
|
||||||
// 设置载具的耐力
|
// 设置载具的耐力
|
||||||
vehicleEntity.gadgetEntity.gadgetVehicleEntity.curStamina = stamina
|
vehicleEntity.gadgetEntity.gadgetVehicleEntity.curStamina = stamina
|
||||||
logger.LOG.Debug("vehicle stamina set, stamina: %v", stamina)
|
//logger.LOG.Debug("vehicle stamina set, stamina: %v", stamina)
|
||||||
|
|
||||||
// PacketVehicleStaminaNotify
|
// PacketVehicleStaminaNotify
|
||||||
vehicleStaminaNotify := new(proto.VehicleStaminaNotify)
|
vehicleStaminaNotify := new(proto.VehicleStaminaNotify)
|
||||||
@@ -424,7 +429,7 @@ func (g *GameManager) SetPlayerStamina(player *model.Player, stamina uint32) {
|
|||||||
// 设置玩家的耐力
|
// 设置玩家的耐力
|
||||||
prop := constant.PlayerPropertyConst.PROP_CUR_PERSIST_STAMINA
|
prop := constant.PlayerPropertyConst.PROP_CUR_PERSIST_STAMINA
|
||||||
player.PropertiesMap[prop] = stamina
|
player.PropertiesMap[prop] = stamina
|
||||||
logger.LOG.Debug("player stamina set, stamina: %v", stamina)
|
//logger.LOG.Debug("player stamina set, stamina: %v", stamina)
|
||||||
|
|
||||||
// PacketPlayerPropNotify
|
// PacketPlayerPropNotify
|
||||||
playerPropNotify := new(proto.PlayerPropNotify)
|
playerPropNotify := new(proto.PlayerPropNotify)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ type StaminaInfo struct {
|
|||||||
LastCasterId uint32 // 最后释放技能者的Id
|
LastCasterId uint32 // 最后释放技能者的Id
|
||||||
LastSkillId uint32 // 最后释放的技能Id
|
LastSkillId uint32 // 最后释放的技能Id
|
||||||
LastSkillTime int64 // 最后释放技能的时间
|
LastSkillTime int64 // 最后释放技能的时间
|
||||||
|
LastSkillStartTime int64 // 最后执行开始技能耐力消耗的时间
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetStaminaCost 设置动作需要消耗的耐力
|
// SetStaminaCost 设置动作需要消耗的耐力
|
||||||
|
|||||||
Reference in New Issue
Block a user