fix(pet): 优化宠物面板计算逻辑,限制非首次生成时等级不超过100并简化特性生成
This commit is contained in:
@@ -39,7 +39,7 @@ func (h Controller) PetEVdiy(data *pet.PetEV, c *player.Player) (result *pet.S2C
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
onpet.Ev = data.EVs
|
||||
onpet.CalculatePetPane()
|
||||
onpet.CalculatePetPane(false)
|
||||
c.Info.EVPool -= USEEV1
|
||||
|
||||
result = &pet.S2C_50001{}
|
||||
|
||||
@@ -65,7 +65,7 @@ func (h Controller) ItemUsePet(data *item.C2S_USE_PET_ITEM_OUT_OF_FIGHT, c *play
|
||||
|
||||
c.Service.Item.SubItem(data.ItemID, 1)
|
||||
result = &item.S2C_USE_PET_ITEM_OUT_OF_FIGHT{}
|
||||
onpet.CalculatePetPane()
|
||||
onpet.CalculatePetPane(false)
|
||||
copier.Copy(&result, onpet)
|
||||
|
||||
return result, 0
|
||||
@@ -81,7 +81,7 @@ func (h Controller) ResetNature(data *item.C2S_PET_RESET_NATURE, c *player.Playe
|
||||
}
|
||||
|
||||
onpet.Nature = data.Nature
|
||||
onpet.CalculatePetPane()
|
||||
onpet.CalculatePetPane(false)
|
||||
c.Service.Item.SubItem(data.ItemId, 1)
|
||||
return result, 0
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ func (h *Controller) PetFirst(
|
||||
|
||||
func (h Controller) SetPetExp(data *pet.PetSetExpInboundInfo, c *player.Player) (result *pet.PetSetExpOutboundInfo, err errorcode.ErrorCode) {
|
||||
_, onpet, ok := c.FindPet(data.CatchTime)
|
||||
if ok {
|
||||
if ok && onpet.Level < 100 {
|
||||
|
||||
defer c.AddPetExp(onpet, data.Exp)
|
||||
}
|
||||
|
||||
@@ -38,9 +38,7 @@ func (p *Player) AddPetExp(petinfo *model.PetInfo, addExp uint32) {
|
||||
petinfo.Exp = Exp
|
||||
// 重新计算面板
|
||||
if originalLevel != petinfo.Level {
|
||||
if petinfo.Level <= 100 {
|
||||
petinfo.CalculatePetPane()
|
||||
}
|
||||
petinfo.CalculatePetPane(false)
|
||||
|
||||
petinfo.Cure()
|
||||
}
|
||||
|
||||
@@ -454,22 +454,17 @@ func GenPetInfo(
|
||||
})
|
||||
}
|
||||
case abilityTypeEnum == -1:
|
||||
// 随机特性
|
||||
randomIndex := grand.Intn(len(xmlres.PlayerEffectMAP))
|
||||
|
||||
var i int
|
||||
for _, v := range xmlres.PlayerEffectMAP {
|
||||
|
||||
if i == randomIndex {
|
||||
p.EffectInfo = append(p.EffectInfo, PetEffectInfo{
|
||||
Idx: uint16(gconv.Int16(v.Idx)),
|
||||
Status: 1,
|
||||
EID: uint16(gconv.Int16(v.Eid)),
|
||||
Args: v.ArgsS,
|
||||
})
|
||||
break
|
||||
}
|
||||
i++
|
||||
p.EffectInfo = append(p.EffectInfo, PetEffectInfo{
|
||||
Idx: uint16(gconv.Int16(v.Idx)),
|
||||
Status: 1,
|
||||
EID: uint16(gconv.Int16(v.Eid)),
|
||||
Args: v.ArgsS,
|
||||
})
|
||||
break
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +483,7 @@ func GenPetInfo(
|
||||
}
|
||||
|
||||
// ---- 属性计算 ----
|
||||
p.CalculatePetPane()
|
||||
p.CalculatePetPane(true)
|
||||
|
||||
p.Update_EXP()
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package model
|
||||
|
||||
import "blazing/common/data/xmlres"
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/common/utils"
|
||||
)
|
||||
|
||||
// 实现获取等级范围内可学习的技能
|
||||
func (p *PetInfo) GetLevelRangeCanLearningSkills(from, to uint32) []uint32 {
|
||||
@@ -23,14 +26,17 @@ func (c *PetInfo) calculatePetHPPanelSize(base, dv, level, ev uint32) uint32 {
|
||||
}
|
||||
|
||||
// 计算其他属性面板值(带性格修正)
|
||||
func (c *PetInfo) calculatePetPanelSize(base, dv, level, ev uint32, natureCorrect float64) uint32 {
|
||||
func (c *PetInfo) calculatePetPanelSize(base, ev uint32, natureCorrect float64) uint32 {
|
||||
|
||||
base1 := float64((float64(base)*2+float64(ev)/4.0+float64(dv))*(float64(level)/100.0) + 5)
|
||||
base1 := float64((float64(base)*2+float64(ev)/4.0+float64(c.Dv))*(float64(c.Level)/100.0) + 5)
|
||||
return uint32(float64(base1) * natureCorrect)
|
||||
}
|
||||
|
||||
// 计算生成面板
|
||||
func (p *PetInfo) CalculatePetPane() {
|
||||
// 计算生成面板,只允许第一次生成超过100,比如boss,不允许额外超过
|
||||
func (p *PetInfo) CalculatePetPane(frist bool) {
|
||||
if !frist {
|
||||
p.Level = utils.Min(p.Level, 100)
|
||||
}
|
||||
naxml := xmlres.NatureRootMap[int(p.Nature)]
|
||||
petxml := xmlres.PetMAP[int(p.ID)]
|
||||
// 计算各项属性
|
||||
@@ -44,40 +50,35 @@ func (p *PetInfo) CalculatePetPane() {
|
||||
// * battle_lv: atk(0), def(1), sp_atk(2), sp_def(3), spd(4), accuracy(5)
|
||||
p.Prop[0] = p.calculatePetPanelSize(
|
||||
uint32(petxml.Atk),
|
||||
p.Dv,
|
||||
p.Level,
|
||||
|
||||
p.Ev[1],
|
||||
naxml.AttackCorrect,
|
||||
)
|
||||
|
||||
p.Prop[1] = p.calculatePetPanelSize(
|
||||
uint32(petxml.Def),
|
||||
p.Dv,
|
||||
p.Level,
|
||||
|
||||
p.Ev[2],
|
||||
naxml.DefenseCorrect,
|
||||
)
|
||||
|
||||
p.Prop[2] = p.calculatePetPanelSize(
|
||||
uint32(petxml.SpAtk),
|
||||
p.Dv,
|
||||
p.Level,
|
||||
|
||||
p.Ev[3],
|
||||
naxml.SaCorrect,
|
||||
)
|
||||
|
||||
p.Prop[3] = p.calculatePetPanelSize(
|
||||
uint32(petxml.SpDef),
|
||||
p.Dv,
|
||||
p.Level,
|
||||
|
||||
p.Ev[4],
|
||||
naxml.SdCorrect,
|
||||
)
|
||||
|
||||
p.Prop[4] = p.calculatePetPanelSize(
|
||||
uint32(petxml.Spd),
|
||||
p.Dv,
|
||||
p.Level,
|
||||
|
||||
p.Ev[5],
|
||||
naxml.SpeedCorrect,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user