mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-14 01:42:26 +08:00
技能开始耐力消耗
This commit is contained in:
@@ -21,11 +21,13 @@ type StaminaCost struct {
|
||||
SKIFF int32 // 游艇行驶
|
||||
STANDBY int32 // 站立
|
||||
WALK int32 // 走路
|
||||
// 战斗技能
|
||||
// 武器消耗默认值
|
||||
FIGHT_SWORD_ONE_HAND int32 // 单手剑
|
||||
FIGHT_POLE int32 // 长枪
|
||||
FIGHT_CATALYST int32 // 法器
|
||||
FIGHT_CLAYMORE_PER int32 // 双手剑 (每秒消耗)
|
||||
// 技能开始消耗 (目前仅发现绫华与莫娜的冲刺会有开始消耗)
|
||||
SKILL_START map[uint32]int32 // [skillId]消耗值
|
||||
}
|
||||
|
||||
func InitStaminaCostConst() {
|
||||
@@ -51,4 +53,8 @@ func InitStaminaCostConst() {
|
||||
StaminaCostConst.FIGHT_POLE = -2500
|
||||
StaminaCostConst.FIGHT_CATALYST = -5000
|
||||
StaminaCostConst.FIGHT_CLAYMORE_PER = -4000
|
||||
StaminaCostConst.SKILL_START = map[uint32]int32{
|
||||
10013: -1000, // 绫华冲刺(霰步)
|
||||
10413: -1000, // 莫娜冲刺(虚实流动)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ func (t *TickManager) onTick200MilliSecond(now int64) {
|
||||
// 耐力消耗
|
||||
for _, world := range WORLD_MANAGER.worldMap {
|
||||
for _, player := range world.playerMap {
|
||||
GAME_MANAGER.StaminaHandler(player)
|
||||
GAME_MANAGER.SustainStaminaHandler(player)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
|
||||
sceneEntity.lastMoveReliableSeq = entityMoveInfo.ReliableSeq
|
||||
|
||||
// 处理耐力消耗
|
||||
g.HandleStamina(player, motionInfo.State)
|
||||
g.ImmediateStamina(player, motionInfo.State)
|
||||
|
||||
player.CombatInvokeHandler.AddEntry(entry.ForwardType, entry)
|
||||
case proto.CombatTypeArgument_COMBAT_TYPE_ARGUMENT_ANIMATOR_STATE_CHANGED:
|
||||
@@ -280,8 +280,8 @@ func (g *GameManager) EvtDoSkillSuccNotify(player *model.Player, payloadMsg pb.M
|
||||
}
|
||||
logger.LOG.Debug("EvtDoSkillSuccNotify: %v", req)
|
||||
|
||||
// 记录耐力消耗的技能id 技能持续消耗需要这个获取到技能id
|
||||
player.StaminaInfo.SetLastSkill(req.CasterId, req.SkillId)
|
||||
// 处理技能开始的耐力消耗
|
||||
g.SkillStartStamina(player, req.CasterId, req.SkillId)
|
||||
}
|
||||
|
||||
func (g *GameManager) EvtAvatarEnterFocusNotify(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
@@ -24,7 +24,7 @@ func (g *GameManager) HandleAbilityStamina(player *model.Player, entry *proto.Ab
|
||||
return
|
||||
}
|
||||
// 处理持续耐力消耗
|
||||
g.HandleSkillSustainStamina(player)
|
||||
g.SkillSustainStamina(player, costStamina.IsSwim)
|
||||
case proto.AbilityInvokeArgument_ABILITY_INVOKE_ARGUMENT_META_MODIFIER_CHANGE:
|
||||
// 普通角色重击耐力消耗
|
||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||
@@ -37,7 +37,7 @@ func (g *GameManager) HandleAbilityStamina(player *model.Player, entry *proto.Ab
|
||||
abilityNameHashCode := uint32(0)
|
||||
for _, ability := range worldAvatar.abilityList {
|
||||
if ability.InstancedAbilityId == entry.Head.InstancedAbilityId {
|
||||
logger.LOG.Error("%v", ability)
|
||||
//logger.LOG.Error("%v", ability)
|
||||
abilityNameHashCode = ability.AbilityName.GetHash()
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ func (g *GameManager) HandleAbilityStamina(player *model.Player, entry *proto.Ab
|
||||
return
|
||||
}
|
||||
// 重击对应的耐力消耗
|
||||
g.HandleChargedAttackStamina(player, worldAvatar, avatarAbility)
|
||||
g.ChargedAttackStamina(player, worldAvatar, avatarAbility)
|
||||
default:
|
||||
break
|
||||
}
|
||||
@@ -107,8 +107,8 @@ func (g *GameManager) SceneAvatarStaminaStepReq(player *model.Player, payloadMsg
|
||||
g.SendMsg(cmd.SceneAvatarStaminaStepRsp, player.PlayerID, player.ClientSeq, sceneAvatarStaminaStepRsp)
|
||||
}
|
||||
|
||||
// HandleStamina 处理即时耐力消耗
|
||||
func (g *GameManager) HandleStamina(player *model.Player, motionState proto.MotionState) {
|
||||
// ImmediateStamina 处理即时耐力消耗
|
||||
func (g *GameManager) ImmediateStamina(player *model.Player, motionState proto.MotionState) {
|
||||
// 玩家暂停状态不更新耐力
|
||||
if player.Pause {
|
||||
return
|
||||
@@ -144,8 +144,8 @@ func (g *GameManager) HandleStamina(player *model.Player, motionState proto.Moti
|
||||
}
|
||||
}
|
||||
|
||||
// HandleSkillSustainStamina 处理技能持续时的耐力消耗
|
||||
func (g *GameManager) HandleSkillSustainStamina(player *model.Player) {
|
||||
// SkillSustainStamina 处理技能持续时的耐力消耗
|
||||
func (g *GameManager) SkillSustainStamina(player *model.Player, isSwim bool) {
|
||||
staminaInfo := player.StaminaInfo
|
||||
skillId := staminaInfo.LastSkillId
|
||||
|
||||
@@ -186,17 +186,17 @@ func (g *GameManager) HandleSkillSustainStamina(player *model.Player) {
|
||||
pastTime := time.Now().UnixMilli() - staminaInfo.LastSkillTime
|
||||
// 根据配置以及距离上次的时间计算消耗的耐力
|
||||
costStamina = int32(float64(pastTime) / 1000 * float64(costStamina))
|
||||
logger.LOG.Debug("stamina skill sustain, skillId: %v, cost: %v", skillId, costStamina)
|
||||
logger.LOG.Debug("stamina skill sustain, skillId: %v, cost: %v, isSwim: %v", skillId, costStamina, isSwim)
|
||||
|
||||
// 根据配置以及距离上次的时间计算消耗的耐力
|
||||
g.UpdateStamina(player, costStamina)
|
||||
|
||||
// 记录最后释放的技能
|
||||
player.StaminaInfo.SetLastSkill(staminaInfo.LastCasterId, staminaInfo.LastSkillId)
|
||||
// 记录最后释放技能的时间
|
||||
player.StaminaInfo.LastSkillTime = time.Now().UnixMilli()
|
||||
}
|
||||
|
||||
// HandleChargedAttackStamina 处理重击技能即时耐力消耗
|
||||
func (g *GameManager) HandleChargedAttackStamina(player *model.Player, worldAvatar *WorldAvatar, skillData *gdconf.AvatarSkillData) {
|
||||
// ChargedAttackStamina 处理重击技能即时耐力消耗
|
||||
func (g *GameManager) ChargedAttackStamina(player *model.Player, worldAvatar *WorldAvatar, skillData *gdconf.AvatarSkillData) {
|
||||
// 获取现行角色的配置表
|
||||
avatarDataConfig, ok := gdconf.CONF.AvatarDataMap[int32(worldAvatar.avatarId)]
|
||||
if !ok {
|
||||
@@ -229,13 +229,31 @@ func (g *GameManager) HandleChargedAttackStamina(player *model.Player, worldAvat
|
||||
|
||||
// 根据配置消耗耐力
|
||||
g.UpdateStamina(player, costStamina)
|
||||
|
||||
// 记录最后释放的技能
|
||||
player.StaminaInfo.SetLastSkill(worldAvatar.avatarEntityId, uint32(skillData.AvatarSkillId))
|
||||
}
|
||||
|
||||
// StaminaHandler 处理持续耐力消耗
|
||||
func (g *GameManager) StaminaHandler(player *model.Player) {
|
||||
// SkillStartStamina 处理技能开始时的即时耐力消耗
|
||||
func (g *GameManager) SkillStartStamina(player *model.Player, casterId uint32, skillId uint32) {
|
||||
staminaInfo := player.StaminaInfo
|
||||
|
||||
// 获取该技能开始时所需消耗的耐力
|
||||
costStamina := constant.StaminaCostConst.SKILL_START[skillId]
|
||||
logger.LOG.Debug("skill start stamina, skillId: %v, cost: %v", skillId, costStamina)
|
||||
|
||||
// 距离上次处理技能开始耐力消耗过去的时间
|
||||
pastTime := time.Now().UnixMilli() - staminaInfo.LastSkillTime
|
||||
// 上次触发的技能相同则每400ms触发一次消耗
|
||||
if staminaInfo.LastSkillId == skillId && pastTime < 400 {
|
||||
return
|
||||
}
|
||||
// 根据配置消耗耐力
|
||||
g.UpdateStamina(player, costStamina)
|
||||
|
||||
// 记录最后释放的技能
|
||||
player.StaminaInfo.SetLastSkill(casterId, skillId)
|
||||
}
|
||||
|
||||
// SustainStaminaHandler 处理持续耐力消耗
|
||||
func (g *GameManager) SustainStaminaHandler(player *model.Player) {
|
||||
// 玩家暂停状态不更新耐力
|
||||
if player.Pause {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user