mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:42:26 +08:00
耐力模块技能耐力消耗初步
This commit is contained in:
@@ -19,4 +19,5 @@ func InitConstant() {
|
||||
InitSceneTypeConst()
|
||||
InitEntityTypeConst()
|
||||
InitStaminaCostConst()
|
||||
InitWeaponTypeConst()
|
||||
}
|
||||
|
||||
@@ -4,25 +4,23 @@ var StaminaCostConst *StaminaCost
|
||||
|
||||
type StaminaCost struct {
|
||||
// 消耗耐力
|
||||
CLIMBING_BASE int32
|
||||
CLIMB_START int32
|
||||
CLIMB_JUMP int32
|
||||
DASH int32
|
||||
FLY int32
|
||||
SKIFF_DASH int32
|
||||
SPRINT int32
|
||||
SWIM_DASH_START int32
|
||||
SWIM_DASH int32
|
||||
SWIMMING int32
|
||||
TALENT_DASH int32
|
||||
TALENT_DASH_START int32
|
||||
CLIMBING_BASE int32 // 缓慢攀爬基数
|
||||
CLIMB_START int32 // 攀爬开始
|
||||
CLIMB_JUMP int32 // 攀爬跳跃
|
||||
DASH int32 // 快速跑步
|
||||
FLY int32 // 滑翔
|
||||
SKIFF_DASH int32 // 浪船加速
|
||||
SPRINT int32 // 冲刺
|
||||
SWIM_DASH_START int32 // 快速游泳开始
|
||||
SWIM_DASH int32 // 快速游泳
|
||||
SWIMMING int32 // 缓慢游泳
|
||||
// 恢复耐力
|
||||
POWERED_FLY int32
|
||||
POWERED_SKIFF int32
|
||||
RUN int32
|
||||
SKIFF int32
|
||||
STANDBY int32
|
||||
WALK int32
|
||||
POWERED_FLY int32 // 滑翔加速(风圈等)
|
||||
POWERED_SKIFF int32 // 浪船加速(风圈等)
|
||||
RUN int32 // 正常跑步
|
||||
SKIFF int32 // 游艇行驶
|
||||
STANDBY int32 // 站立
|
||||
WALK int32 // 走路
|
||||
}
|
||||
|
||||
func InitStaminaCostConst() {
|
||||
@@ -38,8 +36,6 @@ func InitStaminaCostConst() {
|
||||
StaminaCostConst.SWIM_DASH_START = -2000
|
||||
StaminaCostConst.SWIM_DASH = -204
|
||||
StaminaCostConst.SWIMMING = -400
|
||||
StaminaCostConst.TALENT_DASH = -300
|
||||
StaminaCostConst.TALENT_DASH_START = -1000
|
||||
StaminaCostConst.POWERED_FLY = 500
|
||||
StaminaCostConst.POWERED_SKIFF = 500
|
||||
StaminaCostConst.RUN = 500
|
||||
|
||||
39
gs/constant/weapon_type.go
Normal file
39
gs/constant/weapon_type.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package constant
|
||||
|
||||
var WeaponTypeConst *WeaponType
|
||||
|
||||
type WeaponType struct {
|
||||
WEAPON_NONE int32
|
||||
WEAPON_SWORD_ONE_HAND int32 // 单手剑
|
||||
WEAPON_CROSSBOW int32 // 弩
|
||||
WEAPON_STAFF int32 // 权杖
|
||||
WEAPON_DOUBLE_DAGGER int32 // 双刀
|
||||
WEAPON_KATANA int32 // 武士刀
|
||||
WEAPON_SHURIKEN int32 // 手里剑
|
||||
WEAPON_STICK int32 // 棍
|
||||
WEAPON_SPEAR int32 // 矛
|
||||
WEAPON_SHIELD_SMALL int32 // 小盾牌
|
||||
WEAPON_CATALYST int32 // 法器
|
||||
WEAPON_CLAYMORE int32 // 双手剑
|
||||
WEAPON_BOW int32 // 弓
|
||||
WEAPON_POLE int32 // 长枪
|
||||
}
|
||||
|
||||
func InitWeaponTypeConst() {
|
||||
WeaponTypeConst = new(WeaponType)
|
||||
|
||||
WeaponTypeConst.WEAPON_NONE = 0
|
||||
WeaponTypeConst.WEAPON_SWORD_ONE_HAND = 1
|
||||
WeaponTypeConst.WEAPON_CROSSBOW = 2
|
||||
WeaponTypeConst.WEAPON_STAFF = 3
|
||||
WeaponTypeConst.WEAPON_DOUBLE_DAGGER = 4
|
||||
WeaponTypeConst.WEAPON_KATANA = 5
|
||||
WeaponTypeConst.WEAPON_SHURIKEN = 6
|
||||
WeaponTypeConst.WEAPON_STICK = 7
|
||||
WeaponTypeConst.WEAPON_SPEAR = 8
|
||||
WeaponTypeConst.WEAPON_SHIELD_SMALL = 9
|
||||
WeaponTypeConst.WEAPON_CATALYST = 10
|
||||
WeaponTypeConst.WEAPON_CLAYMORE = 11
|
||||
WeaponTypeConst.WEAPON_BOW = 12
|
||||
WeaponTypeConst.WEAPON_POLE = 13
|
||||
}
|
||||
27
gs/game/user_ability.go
Normal file
27
gs/game/user_ability.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"hk4e/gs/model"
|
||||
"hk4e/protocol/proto"
|
||||
)
|
||||
|
||||
// HandleAbilityInvoke 处理能力调用
|
||||
func (g *GameManager) HandleAbilityInvoke(player *model.Player, entry *proto.AbilityInvokeEntry) {
|
||||
//logger.LOG.Debug("ability invoke handle, entry: %v", entry.ArgumentType)
|
||||
|
||||
switch entry.ArgumentType {
|
||||
case proto.AbilityInvokeArgument_ABILITY_INVOKE_ARGUMENT_MIXIN_COST_STAMINA:
|
||||
// 消耗耐力
|
||||
|
||||
//costStamina := new(proto.AbilityMixinCostStamina)
|
||||
//err := pb.Unmarshal(entry.AbilityData, costStamina)
|
||||
//if err != nil {
|
||||
// logger.LOG.Error("unmarshal ability data err: %v", err)
|
||||
// return
|
||||
//}
|
||||
|
||||
// 处理技能持续时的耐力消耗
|
||||
g.HandleSkillSustainStamina(player)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -262,6 +262,10 @@ func (g *GameManager) AbilityInvocationsNotify(player *model.Player, payloadMsg
|
||||
invokeHandler := NewInvokeHandler[proto.AbilityInvokeEntry]()
|
||||
for _, entry := range req.Invokes {
|
||||
//logger.LOG.Debug("AT: %v, FT: %v, UID: %v", entry.ArgumentType, entry.ForwardType, player.PlayerID)
|
||||
|
||||
// 处理能力调用
|
||||
g.HandleAbilityInvoke(player, entry)
|
||||
|
||||
invokeHandler.addEntry(entry.ForwardType, entry)
|
||||
}
|
||||
|
||||
@@ -316,6 +320,10 @@ func (g *GameManager) ClientAbilityInitFinishNotify(player *model.Player, payloa
|
||||
invokeHandler := NewInvokeHandler[proto.AbilityInvokeEntry]()
|
||||
for _, entry := range req.Invokes {
|
||||
//logger.LOG.Debug("AT: %v, FT: %v, UID: %v", entry.ArgumentType, entry.ForwardType, player.PlayerID)
|
||||
|
||||
// 处理能力调用
|
||||
g.HandleAbilityInvoke(player, entry)
|
||||
|
||||
invokeHandler.addEntry(entry.ForwardType, entry)
|
||||
}
|
||||
|
||||
@@ -363,6 +371,9 @@ func (g *GameManager) EvtDoSkillSuccNotify(player *model.Player, payloadMsg pb.M
|
||||
logger.LOG.Debug("user event do skill success, uid: %v", player.PlayerID)
|
||||
req := payloadMsg.(*proto.EvtDoSkillSuccNotify)
|
||||
logger.LOG.Debug("EvtDoSkillSuccNotify: %v", req)
|
||||
|
||||
// 处理技能开始时的耐力消耗
|
||||
g.HandleSkillStartStamina(player, req.SkillId)
|
||||
}
|
||||
|
||||
func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
@@ -2,10 +2,13 @@ package game
|
||||
|
||||
import (
|
||||
pb "google.golang.org/protobuf/proto"
|
||||
"hk4e/gdconf"
|
||||
"hk4e/gs/constant"
|
||||
"hk4e/gs/model"
|
||||
"hk4e/pkg/logger"
|
||||
"hk4e/protocol/cmd"
|
||||
"hk4e/protocol/proto"
|
||||
"time"
|
||||
)
|
||||
|
||||
// SceneAvatarStaminaStepReq 缓慢游泳或缓慢攀爬时消耗耐力
|
||||
@@ -85,17 +88,43 @@ func (g *GameManager) HandleStamina(player *model.Player, motionState proto.Moti
|
||||
// 攀爬跳跃
|
||||
g.UpdateStamina(player, constant.StaminaCostConst.CLIMB_JUMP)
|
||||
case proto.MotionState_MOTION_STATE_SWIM_DASH:
|
||||
// 游泳冲刺开始
|
||||
// 快速游泳开始
|
||||
g.UpdateStamina(player, constant.StaminaCostConst.SWIM_DASH_START)
|
||||
}
|
||||
}
|
||||
|
||||
// SetStaminaLastSkill 记录最后释放的技能
|
||||
func (g *GameManager) SetStaminaLastSkill(player *model.Player, casterId uint32, skillId uint32) {
|
||||
// TODO 有些角色的重击消耗不同
|
||||
switch skillId {
|
||||
|
||||
// HandleSkillSustainStamina 处理技能持续时的耐力消耗
|
||||
func (g *GameManager) HandleSkillSustainStamina(player *model.Player) {
|
||||
skillId := player.StaminaInfo.LastSkillId
|
||||
logger.LOG.Error("stamina skill sustain, skillId: %v", skillId)
|
||||
avatarSkillConfig, ok := gdconf.CONF.AvatarSkillDataMap[int32(skillId)]
|
||||
if !ok {
|
||||
logger.LOG.Error("avatarSkillConfig error, skillId: %v", skillId)
|
||||
return
|
||||
}
|
||||
// 距离上次执行过去的时间
|
||||
pastTime := time.Now().UnixMilli() - player.StaminaInfo.LastSkillTime
|
||||
// 根据配置以及距离上次的时间计算消耗的耐力
|
||||
g.UpdateStamina(player, -(int32(pastTime/1000)*avatarSkillConfig.CostStamina)*100)
|
||||
|
||||
// 记录最后释放技能时间
|
||||
player.StaminaInfo.LastSkillTime = time.Now().UnixMilli()
|
||||
}
|
||||
|
||||
// HandleSkillStartStamina 处理技能开始时即时耐力消耗
|
||||
func (g *GameManager) HandleSkillStartStamina(player *model.Player, skillId uint32) {
|
||||
logger.LOG.Error("stamina skill start, skillId: %v", skillId)
|
||||
avatarSkillConfig, ok := gdconf.CONF.AvatarSkillDataMap[int32(skillId)]
|
||||
if !ok {
|
||||
logger.LOG.Error("avatarSkillConfig error, skillId: %v", skillId)
|
||||
return
|
||||
}
|
||||
// 根据配置消耗耐力
|
||||
g.UpdateStamina(player, -avatarSkillConfig.CostStamina*100)
|
||||
|
||||
// 记录最后释放的技能
|
||||
player.StaminaInfo.LastSkillId = skillId
|
||||
player.StaminaInfo.LastSkillTime = time.Now().UnixMilli()
|
||||
}
|
||||
|
||||
// StaminaHandler 处理持续耐力消耗
|
||||
@@ -103,9 +132,9 @@ func (g *GameManager) StaminaHandler(player *model.Player) {
|
||||
staminaInfo := player.StaminaInfo
|
||||
|
||||
// 添加的耐力大于0为恢复
|
||||
if staminaInfo.Cost > 0 {
|
||||
if staminaInfo.CostStamina > 0 {
|
||||
// 耐力延迟1s(5 ticks)恢复 动作状态为加速将立刻恢复耐力
|
||||
if staminaInfo.RestoreDelay < 5 && staminaInfo.State != proto.MotionState_MOTION_STATE_POWERED_FLY && staminaInfo.State != proto.MotionState_MOTION_STATE_SKIFF_POWERED_DASH {
|
||||
if staminaInfo.RestoreDelay < 5 && (staminaInfo.State != proto.MotionState_MOTION_STATE_POWERED_FLY && staminaInfo.State != proto.MotionState_MOTION_STATE_SKIFF_POWERED_DASH) {
|
||||
//logger.LOG.Debug("stamina delay add, restoreDelay: %v", staminaInfo.RestoreDelay)
|
||||
staminaInfo.RestoreDelay++
|
||||
return // 不恢复耐力
|
||||
@@ -113,7 +142,7 @@ func (g *GameManager) StaminaHandler(player *model.Player) {
|
||||
}
|
||||
|
||||
// 更新玩家耐力
|
||||
g.UpdateStamina(player, staminaInfo.Cost)
|
||||
g.UpdateStamina(player, staminaInfo.CostStamina)
|
||||
}
|
||||
|
||||
// SetStaminaCost 设置动作需要消耗的耐力
|
||||
@@ -125,38 +154,38 @@ func (g *GameManager) SetStaminaCost(player *model.Player, state proto.MotionSta
|
||||
switch state {
|
||||
// 消耗耐力
|
||||
case proto.MotionState_MOTION_STATE_DASH:
|
||||
// 疾跑
|
||||
staminaInfo.Cost = constant.StaminaCostConst.DASH
|
||||
// 快速跑步
|
||||
staminaInfo.CostStamina = constant.StaminaCostConst.DASH
|
||||
case proto.MotionState_MOTION_STATE_FLY, proto.MotionState_MOTION_STATE_FLY_FAST, proto.MotionState_MOTION_STATE_FLY_SLOW:
|
||||
// 飞行
|
||||
staminaInfo.Cost = constant.StaminaCostConst.FLY
|
||||
// 滑翔
|
||||
staminaInfo.CostStamina = constant.StaminaCostConst.FLY
|
||||
case proto.MotionState_MOTION_STATE_SWIM_DASH:
|
||||
// 游泳加速
|
||||
staminaInfo.Cost = constant.StaminaCostConst.SWIM_DASH
|
||||
// 快速游泳
|
||||
staminaInfo.CostStamina = constant.StaminaCostConst.SWIM_DASH
|
||||
case proto.MotionState_MOTION_STATE_SKIFF_DASH:
|
||||
// 小艇加速移动
|
||||
// 浪船加速
|
||||
// TODO 玩家使用载具时需要用载具的协议发送prop
|
||||
staminaInfo.Cost = constant.StaminaCostConst.SKIFF_DASH
|
||||
staminaInfo.CostStamina = constant.StaminaCostConst.SKIFF_DASH
|
||||
// 恢复耐力
|
||||
case proto.MotionState_MOTION_STATE_DANGER_RUN, proto.MotionState_MOTION_STATE_RUN:
|
||||
// 跑步
|
||||
staminaInfo.Cost = constant.StaminaCostConst.RUN
|
||||
// 正常跑步
|
||||
staminaInfo.CostStamina = constant.StaminaCostConst.RUN
|
||||
case proto.MotionState_MOTION_STATE_DANGER_STANDBY_MOVE, proto.MotionState_MOTION_STATE_DANGER_STANDBY, proto.MotionState_MOTION_STATE_LADDER_TO_STANDBY, proto.MotionState_MOTION_STATE_STANDBY_MOVE, proto.MotionState_MOTION_STATE_STANDBY:
|
||||
// 站立
|
||||
staminaInfo.Cost = constant.StaminaCostConst.STANDBY
|
||||
staminaInfo.CostStamina = constant.StaminaCostConst.STANDBY
|
||||
case proto.MotionState_MOTION_STATE_DANGER_WALK, proto.MotionState_MOTION_STATE_WALK:
|
||||
// 走路
|
||||
staminaInfo.Cost = constant.StaminaCostConst.WALK
|
||||
staminaInfo.CostStamina = constant.StaminaCostConst.WALK
|
||||
case proto.MotionState_MOTION_STATE_POWERED_FLY:
|
||||
// 飞行加速 (风圈等)
|
||||
staminaInfo.Cost = constant.StaminaCostConst.POWERED_FLY
|
||||
// 滑翔加速 (风圈等)
|
||||
staminaInfo.CostStamina = constant.StaminaCostConst.POWERED_FLY
|
||||
case proto.MotionState_MOTION_STATE_SKIFF_POWERED_DASH:
|
||||
// 小艇加速 (风圈等)
|
||||
staminaInfo.Cost = constant.StaminaCostConst.POWERED_SKIFF
|
||||
// 浪船加速 (风圈等)
|
||||
staminaInfo.CostStamina = constant.StaminaCostConst.POWERED_SKIFF
|
||||
// 缓慢动作将在客户端发送消息后消耗
|
||||
case proto.MotionState_MOTION_STATE_CLIMB, proto.MotionState_MOTION_STATE_SWIM_MOVE:
|
||||
// 缓慢攀爬 或 缓慢游泳
|
||||
staminaInfo.Cost = 0
|
||||
staminaInfo.CostStamina = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,11 @@ func (p *Player) InitAvatar(avatar *Avatar) {
|
||||
}
|
||||
|
||||
func (p *Player) AddAvatar(avatarId uint32) {
|
||||
avatarDataConfig := gdc.CONF.AvatarDataMap[int32(avatarId)]
|
||||
avatarDataConfig, ok := gdc.CONF.AvatarDataMap[int32(avatarId)]
|
||||
if !ok {
|
||||
logger.LOG.Error("avatarDataConfig error, avatarId: %v", avatarId)
|
||||
return
|
||||
}
|
||||
skillDepotId := int32(0)
|
||||
// 主角要单独设置
|
||||
if avatarId == 10000005 {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package model
|
||||
|
||||
import "hk4e/protocol/proto"
|
||||
import (
|
||||
"hk4e/protocol/proto"
|
||||
)
|
||||
|
||||
type StaminaInfo struct {
|
||||
State proto.MotionState // 动作状态
|
||||
Cost int32 // 消耗或恢复的耐力
|
||||
RestoreDelay uint8 // 恢复延迟
|
||||
LastCasterId uint32 // 最后技能释放者
|
||||
LastSkillId uint32 // 最后释放的技能
|
||||
State proto.MotionState // 动作状态
|
||||
CostStamina int32 // 消耗或恢复的耐力
|
||||
RestoreDelay uint8 // 恢复延迟
|
||||
LastSkillId uint32 // 最后释放的技能Id
|
||||
LastSkillTime int64 // 最后释放技能的时间
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user