diff --git a/go.mod b/go.mod index 3354fe47c..6be685a41 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/gin-gonic/gin v1.8.1 github.com/go-playground/validator/v10 v10.10.1 github.com/go-redis/redis/v8 v8.11.5 - github.com/go-vgo/robotgo v0.100.10 github.com/golang-jwt/jwt v3.2.2+incompatible github.com/golang/protobuf v1.5.2 github.com/gorilla/websocket v1.4.2 @@ -45,7 +44,6 @@ require ( require ( github.com/BurntSushi/toml v1.2.0 // indirect - github.com/StackExchange/wmi v1.2.1 // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect github.com/kr/fs v0.1.0 // indirect github.com/onsi/gomega v1.20.0 // indirect diff --git a/go.sum b/go.sum index 47be83864..9046999a0 100644 --- a/go.sum +++ b/go.sum @@ -582,9 +582,6 @@ github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5h github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= -github.com/otiai10/gosseract v2.2.1+incompatible h1:Ry5ltVdpdp4LAa2bMjsSJH34XHVOV7XMi41HtzL8X2I= -github.com/otiai10/gosseract v2.2.1+incompatible/go.mod h1:XrzWItCzCpFRZ35n3YtVTgq5bLAhFIkascoRo8G32QE= -github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= diff --git a/modules/battle/fight/attribute/attributenumeric.go b/modules/battle/fight/attribute/attributenumeric.go index 84ea13c14..c5425bbd9 100644 --- a/modules/battle/fight/attribute/attributenumeric.go +++ b/modules/battle/fight/attribute/attributenumeric.go @@ -13,6 +13,9 @@ func NewAttributeNumeric(pData float32) *AttributeNumeric { return attribute } +/// +/// 属性数值 +/// type AttributeNumeric struct { fixedValue FixedPoint /// @@ -47,92 +50,92 @@ func (this *AttributeNumeric) Value() float32 { ///基础数值 func (this *AttributeNumeric) SetBase(value float32) float32 { this.BaseValue.SetFloat(value) - this.onChange() + this.OnChange() return this.BaseValue.Value() } func (this *AttributeNumeric) AddBase(value float32) float32 { this.BaseValue.Add(value) - this.onChange() + this.OnChange() return this.BaseValue.Value() } func (this *AttributeNumeric) MinusBase(value float32) float32 { this.BaseValue.Minus(value) - this.onChange() + this.OnChange() return this.BaseValue.Value() } ///附加数值 func (this *AttributeNumeric) SetAppend(value float32) float32 { this.AppendValue.SetFloat(value) - this.onChange() + this.OnChange() return this.AppendValue.Value() } func (this *AttributeNumeric) AddAppend(value float32) float32 { this.AppendValue.Add(value) - this.onChange() + this.OnChange() return this.AppendValue.Value() } func (this *AttributeNumeric) MinusAppend(value float32) float32 { this.AppendValue.Minus(value) - this.onChange() + this.OnChange() return this.AppendValue.Value() } ///附加百分比数值 func (this *AttributeNumeric) SetPro(value float32) float32 { this.ProValue.SetFloat(value) - this.onChange() + this.OnChange() return this.ProValue.Value() } func (this *AttributeNumeric) AddPro(value float32) float32 { this.ProValue.Add(value) - this.onChange() + this.OnChange() return this.ProValue.Value() } func (this *AttributeNumeric) MinusPro(value float32) float32 { this.ProValue.Minus(value) - this.onChange() + this.OnChange() return this.ProValue.Value() } /// Buff附加数值 func (this *AttributeNumeric) SetBuff(value float32) float32 { this.BuffValue.SetFloat(value) - this.onChange() + this.OnChange() return this.BuffValue.Value() } func (this *AttributeNumeric) AddBuff(value float32) float32 { this.BuffValue.Add(value) - this.onChange() + this.OnChange() return this.BuffValue.Value() } func (this *AttributeNumeric) MinusBuff(value float32) float32 { this.BuffValue.Minus(value) - this.onChange() + this.OnChange() return this.BuffValue.Value() } /// Buff附加百分比数值 func (this *AttributeNumeric) SetBuffPro(value float32) float32 { this.BuffProValue.SetFloat(value) - this.onChange() + this.OnChange() return this.BuffProValue.Value() } func (this *AttributeNumeric) AddBuffPro(value float32) float32 { this.BuffProValue.Add(value) - this.onChange() + this.OnChange() return this.BuffProValue.Value() } func (this *AttributeNumeric) MinusBuffPro(value float32) float32 { this.BuffProValue.Minus(value) - this.onChange() + this.OnChange() return this.BuffProValue.Value() } -func (this *AttributeNumeric) onChange() { +func (this *AttributeNumeric) OnChange() { this.fixedValue = (FixedPoint_Multiply(this.BaseValue.Fixed(), (NewFixedPoint(1)+this.ProValue.Fixed())) + FixedPoint_Multiply(this.AppendValue.Fixed(), (NewFixedPoint(1)+this.BuffProValue.Fixed())) + this.BuffValue.Fixed()) } diff --git a/modules/battle/fight/attribute/fixednumeric.go b/modules/battle/fight/attribute/fixednumeric.go index c327e3101..af7ba0cce 100644 --- a/modules/battle/fight/attribute/fixednumeric.go +++ b/modules/battle/fight/attribute/fixednumeric.go @@ -6,6 +6,9 @@ func NewFixedNumeric(pData float32) FixedNumeric { return fixed } +/// +/// 浮点型数值 +/// type FixedNumeric struct { baseValue FixedPoint } diff --git a/modules/battle/fight/attribute/healthpoint.go b/modules/battle/fight/attribute/healthpoint.go index 5dc622103..c9fcb237b 100644 --- a/modules/battle/fight/attribute/healthpoint.go +++ b/modules/battle/fight/attribute/healthpoint.go @@ -36,12 +36,6 @@ type HealthPoint struct { CurrMaxHpAppend *AttributeNumeric } -/// -/// 重置当前生命值为最大值 -/// -func (this *HealthPoint) Reset() { - this.Hp.SetFloat(this.CurrMaxHp.Value()) -} func (this *HealthPoint) Value() int32 { return int32(this.Hp.Value()) } @@ -61,6 +55,13 @@ func (this *HealthPoint) OnChange() { //FightDebug.Log($"增加后属性{(MaxHp.Fixed)}----- {(1 + CurrMaxHpPro.Fixed)}----- {CurrMaxHpAppend.Fixed}"); } +/// +/// 重置当前生命值为最大值 +/// +func (this *HealthPoint) Reset() { + this.Hp.SetFloat(this.CurrMaxHp.Value()) +} + /// /// 扣血 /// diff --git a/modules/battle/fight/buff/fightbuff.go b/modules/battle/fight/buff/fightbuff.go index c4e696a3e..27ca656b3 100644 --- a/modules/battle/fight/buff/fightbuff.go +++ b/modules/battle/fight/buff/fightbuff.go @@ -1,9 +1,73 @@ package buff +import ( + "go_dreamfactory/modules/battle/fight/core" + cfg "go_dreamfactory/sys/configure/structs" +) + +var id int64 = 0 + func NewFightBuff() *FightBuff { - return &FightBuff{} + id++ + return &FightBuff{ + GId: id, + } } type FightBuff struct { FightBuffBase + BuffConf *cfg.GameSkillBuffData + GId int64 +} + +func (this FightBuff) GetBuffConf() *cfg.GameSkillBuffData { + return this.BuffConf +} + +func (this FightBuff) Activate(param float32) { + this.FightBuffBase.Activate(param) +} + +func (this FightBuff) OnEnd(skill core.IAfterSkill) { + this.FromRole.GetFightBase().Debugf("%d 准备移除Buff:%d 类型=%d ", this.OwnerRole.GetData().UniqueId, this.BuffConf.Id, this.BuffConf.BuffType) + if this.BuffConf.BuffIcon != "" { + var com = new(core.ComMondifyBuff) + com.To = this.OwnerRole.GetData().Rid + com.Gid = this.GId + com.BuffId = this.BuffConf.Id + com.Operate = 0 + if skill != nil { + skill.AddLog(com) + } else { + this.OwnerRole.GetFightBase().GetFightLog().AddCommand(com) + } + if this.NeedHpSync() { + var hpCmd = new(core.ComModifyHealth) + hpCmd.To = this.OwnerRole.GetData().Rid + hpCmd.Nhp = this.OwnerRole.GetCurrentHealth().Value() + hpCmd.Mhp = this.OwnerRole.GetCurrentHealth().MaxValue() + hpCmd.HideDmg = true + if skill != nil { + skill.AddLog(hpCmd) + } else { + this.OwnerRole.GetFightBase().GetFightLog().AddCommand(hpCmd) + } + } + } + this.OwnerRole.GetData().BuffStore.RemoveBuff(this) +} + +/// +/// 当前buff效果是否需要同步血量 +/// +/// +func (this FightBuff) NeedHpSync() bool { + return false +} + +/// +/// 回合开始开始需要触发效果的 +/// +func (this FightBuff) OnRoundStart() { + } diff --git a/modules/battle/fight/buff/fightbuffbase.go b/modules/battle/fight/buff/fightbuffbase.go index 0001c8e87..20483f2b6 100644 --- a/modules/battle/fight/buff/fightbuffbase.go +++ b/modules/battle/fight/buff/fightbuffbase.go @@ -1,41 +1,125 @@ package buff +import "go_dreamfactory/modules/battle/fight/core" + type FightBuffBase struct { + /// + /// 所属子技能ID + /// + AfterSkillId int + /// + /// Buff投放者 + /// + FromRole core.IFightRole + /// + /// Buff持有者 + /// + OwnerRole core.IFightRole + /// + /// 剩余持续回合数 + /// + duration int + /// + /// 叠加层数 [叠加Buff不立即叠加效果, 受BufParNum影响] + /// + OverlapNum int + /// + /// 叠加Buff当前效果次数 + /// + EffectNum int + /// + /// 是否无限回合 + /// + AlwaysExist bool + BufParNum int +} + +/// +/// cd 回合数 +/// +/// +/// -1 无限回合,0 回合结束后移除 +/// +func (this FightBuffBase) GetRound() int { + return this.duration +} + +/// +/// cd 回合数 +/// +/// +/// -1 无限回合,0 回合结束后移除 +/// +func (this FightBuffBase) SetRound(value int) { + this.AlwaysExist = value == -1 + this.duration = value } /// 激活Buff -func (this FightBuffBase) Activate() { +func (this FightBuffBase) Activate(param float32) { + this.Restore() + this.EffectNum = this.OverlapNum / this.BufParNum + this.OnActivate(param) +} + +func (this FightBuffBase) OnActivate(param float32) { } /// 结束Buff -func (this FightBuffBase) End() { +func (this FightBuffBase) Restore() { } +func (this FightBuffBase) OnEnd(skill core.IAfterSkill) { -/// 增加CD回合数 -func (this FightBuffBase) AddCD(pVal int32) int32 { - return 0 -} - -/// 减少CD回合数 -func (this FightBuffBase) MinusCD(pVal int32) int32 { - return 0 -} - -/// 设置CD回合数为新的值 -func (this FightBuffBase) SetCD(newVal int32) int32 { - return 0 } /// -/// 是否存在指定Tag +/// 结束Buff /// -func (this FightBuffBase) HasTag(pTag string) bool { - return false +func (this FightBuffBase) End(skill core.IAfterSkill) { + this.Restore() + this.OnEnd(skill) + this.Clear() } /// 战斗结束时的清理 func (this FightBuffBase) Clear() { } + +//CD 处理-------------------------------------------------------------------------------------------------------------------- + +/// +/// 增加剩余回合数 v 默认:1 +/// +/// 新的回合数 +func (this FightBuffBase) AddDuration(v int) int { + this.duration += v + return this.duration +} + +/// +/// 减少剩余回合数 v 默认:1 +/// +/// 新的回合数 +func (this FightBuffBase) MinusDuration(v int) int { + this.duration -= v + if this.duration < 0 { + this.duration = 0 + } + this.SetDuration(this.duration) + return this.duration +} + +/// +/// 设置剩余回合数为新的值 +/// +/// +func (this FightBuffBase) SetDuration(newVal int) int { + this.duration = newVal + if this.duration == 0 && !this.AlwaysExist { + this.End(nil) + } + return this.duration +} diff --git a/modules/battle/fight/buff/fightpoisonbuff.go b/modules/battle/fight/buff/fightpoisonbuff.go index 6f9bf931b..0df8e3b6d 100644 --- a/modules/battle/fight/buff/fightpoisonbuff.go +++ b/modules/battle/fight/buff/fightpoisonbuff.go @@ -1,5 +1,7 @@ package buff +import "go_dreamfactory/modules/battle/fight/core" + func NewFightPoisonBuff() *FightPoisonBuff { return &FightPoisonBuff{} } @@ -7,3 +9,17 @@ func NewFightPoisonBuff() *FightPoisonBuff { type FightPoisonBuff struct { FightBuff } + +func (this FightPoisonBuff) OnRoundStart() { + this.FromRole.GetFightBase().Debugf("{%d}中毒buff触发", this.OwnerRole.GetData().Rid) + num := this.OwnerRole.GetCurrentHealth().CurrMaxHp.Value() * (float32(this.BuffConf.EffectArgu[0]) / 1000.0) + this.OwnerRole.ReceiveDamage(this.FromRole, num, nil) + var com = new(core.ComModifyHealth) + com.From = this.FromRole.GetData().Rid + com.To = this.OwnerRole.GetData().Rid + com.Num = num * -1 + com.Nhp = this.OwnerRole.GetCurrentHealth().Value() + com.Mhp = this.OwnerRole.GetCurrentHealth().MaxValue() + com.Baoji = false + this.OwnerRole.GetFightBase().GetFightLog().AddCommand(com) +} diff --git a/modules/battle/fight/buff/fightpropercentbuff.go b/modules/battle/fight/buff/fightpropercentbuff.go index 8d5a02fbd..accdae1d9 100644 --- a/modules/battle/fight/buff/fightpropercentbuff.go +++ b/modules/battle/fight/buff/fightpropercentbuff.go @@ -1,9 +1,46 @@ package buff +import ( + "go_dreamfactory/modules/battle/fight/core" +) + func NewFightProPercentBuff(proType int, quaType bool) *FightProPercentBuff { return &FightProPercentBuff{} } +/// +/// 修改属性buff (百分比数值) +/// + /// 属性类型 + /// + ProType int + /// + /// 是否减法 + /// + BufQuaType bool + BuffValue float32 +} + +func (this FightProPercentBuff) OnActivate(param float32) { + var effectArgu = this.BuffConf.EffectArgu + if len(effectArgu) < 1 { // 参数列属性值 + this.FromRole.GetFightBase().Errorf("buff效果参数配置错误 ID={%d},参数[ 属性值]", this.BuffConf.Id) + return + } + value := effectArgu[0] + perc := float32(value) / 1000.0 + this.BuffValue = perc * float32(this.EffectNum) + core.TrySetValue(this.OwnerRole, this.ProType, this.BuffValue, !this.BufQuaType) +} + +func (this FightProPercentBuff) Restore() { + core.TrySetValue(this.OwnerRole, this.ProType, this.BuffValue, this.BufQuaType) + this.BuffValue = 0 +} + +func (this FightProPercentBuff) NeedHpSync() bool { + return this.ProType == int(core.PropertyType_Add_Per_Hp) || this.ProType == int(core.PropertyType_Add_Hp) } diff --git a/modules/battle/fight/buff/fightshieldbuff.go b/modules/battle/fight/buff/fightshieldbuff.go index 833d99244..3326b78c3 100644 --- a/modules/battle/fight/buff/fightshieldbuff.go +++ b/modules/battle/fight/buff/fightshieldbuff.go @@ -1,9 +1,43 @@ package buff +import ( + "go_dreamfactory/modules/battle/fight/attribute" + "go_dreamfactory/modules/battle/fight/core" +) + func NewFightShieldBuff() *FightShieldBuff { return &FightShieldBuff{} } type FightShieldBuff struct { FightBuff + ShieldValue attribute.FixedNumeric + tmepDamage attribute.FixedNumeric +} + +func (this FightShieldBuff) OnActivate(param float32) { + var val float32 = 0 + if param > 0 { + val = param + } else { + args := this.BuffConf.EffectArgu + var pValue float32 = 0 + for i := 0; i < len(args); i += 3 { + source := args[i] //[属性来源] + proType := args[i+1] //[属性类型] + proValue := args[i+2] //[属性值] + var target core.IFightRole + if source == 1 { + target = this.OwnerRole + } else { + target = this.FromRole + } + // var target = source == 1 ? OwnerRole : FromRole; // 1 取自身属性 2 取目标属性 + if !core.TryGetValue(target, int(proType), &pValue) { + continue + } + val += pValue * float32(proValue) / 1000.0 + } + } + this.ShieldValue.Add(val) } diff --git a/modules/battle/fight/component/buffstore.go b/modules/battle/fight/component/buffstore.go new file mode 100644 index 000000000..389697962 --- /dev/null +++ b/modules/battle/fight/component/buffstore.go @@ -0,0 +1,224 @@ +package component + +import ( + "go_dreamfactory/modules/battle/fight/buff" + "go_dreamfactory/modules/battle/fight/core" +) + +type BuffStore struct { + /// + /// 已经添加的buff类型 + /// + HasBuffTypes []int + /// + /// Buff列表 [BuffId, FightBuff] + /// + Buffs map[int][]core.IBuff + temp []int +} + +/// +/// 查找相同 BuffId 的Buff +/// +func (this *BuffStore) GetBuffList(pBuffId int) []core.IBuff { + if v, ok := this.Buffs[pBuffId]; ok { + return v + } + return nil +} + +func (this *BuffStore) TryGetBuffList(pBuffId int, pBuffList *[]core.IBuff) bool { + if v, ok := this.Buffs[pBuffId]; ok { + *pBuffList = v + return true + } + *pBuffList = nil + return false +} + +/// +/// 查找不是指定 BuffId 的Buff +/// +func (this *BuffStore) GetBuffListNon(pBuffId int) []core.IBuff { + tResult := make([]core.IBuff, 0) + iskeep := false + for k, v := range this.Buffs { + if k != pBuffId { + for _, v1 := range v { + iskeep = false + for _, v2 := range tResult { + if v1 == v2 { + iskeep = true + } + } + if !iskeep { + tResult = append(tResult, v1) + } + } + } + } + return tResult +} + +/// 获取指定buff列表 +func (this *BuffStore) GetBuffListByFilter(filter func(buff core.IBuff) bool) []core.IBuff { + tResult := make([]core.IBuff, 0) + iskeep := false + this.ForEach(func(buff core.IBuff) { + if filter(buff) { + iskeep = false + for _, v2 := range tResult { + if buff == v2 { + iskeep = true + } + } + if !iskeep { + tResult = append(tResult, buff) + } + } + }) + return tResult +} + +func (this *BuffStore) GetBuffListByTypes(pType []core.BuffType) []core.IBuff { + tResult := make([]core.IBuff, 0) + iskeep := false + this.ForEach(func(buff core.IBuff) { + for _, tTag := range pType { + if buff.GetBuffConf().BuffType == int32(tTag) { + iskeep = false + for _, v2 := range tResult { + if buff == v2 { + iskeep = true + } + } + if !iskeep { + tResult = append(tResult, buff) + } + break + } + } + }) + return tResult +} + +func (this *BuffStore) ForEach(action func(core.IBuff)) { + this.temp = this.temp[:0] + for k, _ := range this.Buffs { + this.temp = append(this.temp, k) + } + for _, v := range this.temp { + list := this.Buffs[v] + for _, v1 := range list { + action(v1) + } + } +} + +/// +/// 附加Buff +/// 默认参数 param=0;shift=false +/// +func (this *BuffStore) Attach(pSkill core.IAfterSkill, id int, randVal int, numVal int, round int, param float32, shift bool) bool { + + return true +} + +func (this *BuffStore) HasBuff(judge func(core.IBuff) bool) bool { + for _, v := range this.Buffs { + for _, buff := range v { + if judge(buff) { + return true + } + } + } + return false +} + +func (this *BuffStore) Clear() { + this.Buffs = make(map[int][]core.IBuff) +} + +func (this *BuffStore) CreateBuff(pType core.BuffType) core.IBuff { + switch pType { + case core.BuffType_NONE: + break + case core.BuffType_ATKUP: + return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Atk), false) + case core.BuffType_DEFUP: + return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Def), false) + case core.BuffType_SPDUP: + return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Agi), false) + case core.BuffType_CRATEUP: + return buff.NewFightProPercentBuff(int(core.PropertyType_Add_Cri), false) + case core.BuffType_CRITRESIST: + break + case core.BuffType_ATKDOWN: + return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Atk), true) + case core.BuffType_DEFDOWN: + return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Def), true) + case core.BuffType_SPDDOWN: + return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Agi), true) + case core.BuffType_CRATEDOWN: + return buff.NewFightProPercentBuff(int(core.PropertyType_Add_Cri), true) + case core.BuffType_MISSRATEUP: + return buff.NewFightProPercentBuff(int(core.PropertyType_LostHold_per), false) + case core.BuffType_SEAR: + break + case core.BuffType_INVINCIBILITY: + return buff.NewFightBuff() + case core.BuffType_STANDOFF: + break + case core.BuffType_STUN: + return buff.NewFightBuff() + case core.BuffType_FREEZE: + return buff.NewFightBuff() + case core.BuffType_DISEASED: + return buff.NewFightBuff() + case core.BuffType_PETRIFICATION: + return buff.NewFightBuff() + case core.BuffType_SILENCE: + return buff.NewFightBuff() + case core.BuffType_TAUNT: + break + case core.BuffType_IMMUNITY: + return buff.NewFightBuff() + case core.BuffType_SHIELD: + return buff.NewFightShieldBuff() + case core.BuffType_NOTSPEED: + return buff.NewFightBuff() + case core.BuffType_DAMREUP: + return buff.NewFightProPercentBuff(int(core.PropertyType_DamRe_Per), true) + case core.BuffType_HPUP: + return buff.NewFightProPercentBuff(int(core.PropertyType_Add_Per_Hp), false) + case core.BuffType_EFFHITUP: + return buff.NewFightProPercentBuff(int(core.PropertyType_Add_EffHit), false) + case core.BuffType_EFFREUP: + return buff.NewFightProPercentBuff(int(core.PropertyType_Add_EffRe), false) + case core.BuffType_HPDOWN: + break + case core.BuffType_EFFHITDOWN: + return buff.NewFightProPercentBuff(int(core.PropertyType_Add_EffHit), true) + case core.BuffType_EFFREDOWN: + return buff.NewFightProPercentBuff(int(core.PropertyType_Add_EffRe), true) + case core.BuffType_CAUSEDAMUP: + return buff.NewFightProPercentBuff(int(core.PropertyType_CauseDam_Per), false) + case core.BuffType_POISON: + return buff.NewFightPoisonBuff() + case core.BuffType_ATTRTRANS: + break + case core.BuffType_UNDEAD: + break + case core.BuffType_DEVOUR: + break + case core.BuffType_DONTMISS: + break + case core.BuffType_NOTGAIN: + break + case core.BuffType_NOTCONTROL: + break + case core.BuffType_SLEEP: + break + } + return buff.NewFightBuff() +} diff --git a/modules/battle/fight/core/passivestore.go b/modules/battle/fight/component/passivestore.go similarity index 52% rename from modules/battle/fight/core/passivestore.go rename to modules/battle/fight/component/passivestore.go index a5a9c2f57..af0592aed 100644 --- a/modules/battle/fight/core/passivestore.go +++ b/modules/battle/fight/component/passivestore.go @@ -1,20 +1,23 @@ -package core +package component -import "go_dreamfactory/modules/battle/fight/passive" +import ( + "go_dreamfactory/modules/battle/fight/core" + "go_dreamfactory/modules/battle/fight/passive" +) type PassiveStore struct { - Passives map[int]passive.IFightPassive + Passives map[int]core.IFightPassive temp []int } -func (this *PassiveStore) CreatePassive(pType string) passive.IFightPassive { +func (this *PassiveStore) CreatePassive(pType string) core.IFightPassive { switch pType { case "CallSkillPas": return passive.NewFightCallSkillPas() } return nil } -func (this *PassiveStore) ForEach(action func(fp passive.IFightPassive)) { +func (this *PassiveStore) ForEach(action func(fp core.IFightPassive)) { this.temp = make([]int, 0) for k, _ := range this.Passives { this.temp = append(this.temp, k) @@ -27,5 +30,5 @@ func (this *PassiveStore) RemovePassive(id int) { } func (this *PassiveStore) Clear() { - this.Passives = make(map[int]passive.IFightPassive) + this.Passives = make(map[int]core.IFightPassive) } diff --git a/modules/battle/fight/core/buffstore.go b/modules/battle/fight/core/buffstore.go deleted file mode 100644 index 80590e5b4..000000000 --- a/modules/battle/fight/core/buffstore.go +++ /dev/null @@ -1,125 +0,0 @@ -package core - -import "go_dreamfactory/modules/battle/fight/buff" - -type BuffStore struct { - /// - /// 已经添加的buff类型 - /// - HasBuffTypes []int - /// - /// Buff列表 [BuffId, FightBuff] - /// - Buffs map[int][]IBuff - temp []int -} - -func (this *BuffStore) CreateBuff(pType BuffType) IBuff { - switch pType { - case BuffType_NONE: - break - case BuffType_ATKUP: - return buff.NewFightProPercentBuff(PropertyType_Buff_Per_Atk, false) - case BuffType_DEFUP: - return buff.NewFightProPercentBuff(PropertyType_Buff_Per_Def, false) - case BuffType_SPDUP: - return buff.NewFightProPercentBuff(PropertyType_Buff_Per_Agi, false) - case BuffType_CRATEUP: - return buff.NewFightProPercentBuff(PropertyType_Add_Cri, false) - case BuffType_CRITRESIST: - break - case BuffType_ATKDOWN: - return buff.NewFightProPercentBuff(PropertyType_Buff_Per_Atk, true) - case BuffType_DEFDOWN: - return buff.NewFightProPercentBuff(PropertyType_Buff_Per_Def, true) - case BuffType_SPDDOWN: - return buff.NewFightProPercentBuff(PropertyType_Buff_Per_Agi, true) - case BuffType_CRATEDOWN: - return buff.NewFightProPercentBuff(PropertyType_Add_Cri, true) - case BuffType_MISSRATEUP: - return buff.NewFightProPercentBuff(PropertyType_LostHold_per, false) - case BuffType_SEAR: - break - case BuffType_INVINCIBILITY: - return buff.NewFightBuff() - case BuffType_STANDOFF: - break - case BuffType_STUN: - return buff.NewFightBuff() - case BuffType_FREEZE: - return buff.NewFightBuff() - case BuffType_DISEASED: - return buff.NewFightBuff() - case BuffType_PETRIFICATION: - return buff.NewFightBuff() - case BuffType_SILENCE: - return buff.NewFightBuff() - case BuffType_TAUNT: - break - case BuffType_IMMUNITY: - return buff.NewFightBuff() - case BuffType_SHIELD: - return buff.NewFightShieldBuff() - case BuffType_NOTSPEED: - return buff.NewFightBuff() - case BuffType_DAMREUP: - return buff.NewFightProPercentBuff(PropertyType_DamRe_Per, true) - case BuffType_HPUP: - return buff.NewFightProPercentBuff(PropertyType_Add_Per_Hp, false) - case BuffType_EFFHITUP: - return buff.NewFightProPercentBuff(PropertyType_Add_EffHit, false) - case BuffType_EFFREUP: - return buff.NewFightProPercentBuff(PropertyType_Add_EffRe, false) - case BuffType_HPDOWN: - break - case BuffType_EFFHITDOWN: - return buff.NewFightProPercentBuff(PropertyType_Add_EffHit, true) - case BuffType_EFFREDOWN: - return buff.NewFightProPercentBuff(PropertyType_Add_EffRe, true) - case BuffType_CAUSEDAMUP: - return buff.NewFightProPercentBuff(PropertyType_CauseDam_Per, false) - case BuffType_POISON: - return buff.NewFightPoisonBuff() - case BuffType_ATTRTRANS: - break - case BuffType_UNDEAD: - break - case BuffType_DEVOUR: - break - case BuffType_DONTMISS: - break - case BuffType_NOTGAIN: - break - case BuffType_NOTCONTROL: - break - case BuffType_SLEEP: - break - } - return buff.NewFightBuff() -} -func (this *BuffStore) ForEach(action func(IBuff)) { - this.temp = this.temp[:0] - for k, _ := range this.Buffs { - this.temp = append(this.temp, k) - } - for _, v := range this.temp { - list := this.Buffs[v] - for _, v1 := range list { - action(v1) - } - } -} -func (this *BuffStore) HasBuff(judge func(IBuff) bool) bool { - for _, v := range this.Buffs { - for _, buff := range v { - if judge(buff) { - return true - } - } - } - return false -} - -func (this *BuffStore) Clear() { - this.Buffs = make(map[int][]IBuff) -} diff --git a/modules/battle/fight/core/core.go b/modules/battle/fight/core/core.go index 9bb1255b0..cfa1649a4 100644 --- a/modules/battle/fight/core/core.go +++ b/modules/battle/fight/core/core.go @@ -1,11 +1,19 @@ package core -import cfg "go_dreamfactory/sys/configure/structs" +import ( + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/modules/battle/fight/attribute" + cfg "go_dreamfactory/sys/configure/structs" +) type ( ///战斗控制器 IFight interface { + log.ILogger GetRoles() []IFightRole + GetFightLog() IFightLog + GetFightEvent() IFightEvent + GetSkillConfig(SkillId int, skillLv int) interface{} /// 战前逻辑 BeforeStart() ///开始战斗 @@ -32,6 +40,17 @@ type ( /// 技能ID /// 选择的目标rid EmitSkill(skillId int32, targetRid []int32) + /// + /// 触发的释放主技能添加到这边(出手角色主技能执行完了,再执行) + /// + AddPassiveMainSkill(role IFightRole, skillId int32) + /// + /// 生成随机数 + /// + /// 最小值(含) + /// 最大值(含) + /// + Rand(min, max int) int } //战斗角色 IFightRole interface { @@ -42,7 +61,8 @@ type ( /// /// 角色数据 /// - GetData() FightRoleData + GetData() *FightRoleData + GetCurrentHealth() *attribute.HealthPoint /// /// 增加一个主技能 /// @@ -56,7 +76,7 @@ type ( /// 修改行动值 ModifyOperateValue(newNum float32) ///接收伤害 - ReceiveDamage(damageValue float32) int + ReceiveDamage(from IFightRole, DamageValue float32, skill IAfterSkill) /// 是否致死伤害 WillDead(damageValue float32) bool /// 接收治疗 @@ -71,7 +91,7 @@ type ( /// 获取下一个技能id GetNextSkillId() int32 /// 获取后续子技能 - GetAfterAtk(skillId int) ISkill + GetAfterAtk(skillId int32) ISkill /// 触发SkillId技能,选择的目标是TargetRid EmitSkill(skillId int32, targetRid []int32) /// 自身的 Buff 和 被动 是否有指定标签 @@ -90,11 +110,14 @@ type ( /// 获取技能配置信息 /// GetSkillConf() *cfg.GameSkillAtkData + GetSourceSkillId() int32 + SetSourceSkillId(skillid int32) + GetSkillLog() *ComSkillAfterAtk /// /// 触发 /// 遍历所有ChildSkills,生成对应的实例,并Emit触发 /// - Emit() + Emit() bool /// /// 减少CD回合数 /// @@ -121,6 +144,12 @@ type ( SendSkillLog() } IAfterSkill interface { + GetOwnerRole() IFightRole + GetAfterSkillConf() cfg.GameSkillAfteratkData + GetSkillArgs() []int + GetSourceSkillId() int + AddLog(pCom IComEffectSkill) + AddSkillLog(afterAtk *ComSkillAfterAtk) /// /// 战斗结束时的清理 /// @@ -128,24 +157,37 @@ type ( } //Buff对象 IBuff interface { + GetBuffConf() *cfg.GameSkillBuffData /// 激活Buff - Activate() + Activate(param float32) /// 结束Buff - End() - /// 增加CD回合数 - AddCD(pVal int32) int32 - /// 减少CD回合数 - MinusCD(pVal int32) int32 - /// 设置CD回合数为新的值 - SetCD(newVal int32) int32 + OnEnd(skill IAfterSkill) /// - /// 是否存在指定Tag - /// - HasTag(pTag string) bool - /// 战斗结束时的清理 + /// Clear() } + //buff集合 + IBuffStore interface { + GetHasBuffTypes() []int + ForEach(action func(buff IBuff)) + RemoveBuff(buff IBuff) + Clear() + } + //被动技集合 + IPassiveStore interface { + TryGetPassive(pPassId int) (v IFightPassive, ok bool) + ForEach(action func(fp IFightPassive)) + Clear() + } + IFightPassive interface { + GetTriggerPassiveRole() IFightRole + Clear() + } + //战报 + IFightLog interface { + AddCommand(log interface{}) + } IFightEvent interface { //发送事件 EmitForInt(eventNumber int, args ...interface{}) diff --git a/modules/battle/fight/core/enum.go b/modules/battle/fight/core/enum.go index 8f61c94ca..0e2f6eafc 100644 --- a/modules/battle/fight/core/enum.go +++ b/modules/battle/fight/core/enum.go @@ -98,6 +98,27 @@ const ( /// 除选定目标外的其他友方 /// AferSkillFromType_FriendExceptChoose AferSkillFromType = 7 + /// + /// 触发被动的角色(发起者) + /// + AferSkillFromType_TriggerPassiveFrom = 8 + /// + /// 继承上一个技能选敌 + /// + AferSkillFromType_SourceSkillTarget = 9 + /// + /// 除去上一个技能选敌之后友方 + /// + AferSkillFromType_ExceptSourceSkillTargetFriend = 10 + /// + /// 除去上一个技能选敌之后敌方 + /// + AferSkillFromType_ExceptSourceSkillTargetEnemy = 11 + + /// + /// 触发被动的角色(目标) + /// + AferSkillFromType_TriggerPassiveTarget = 12 ) type EventType int8 @@ -106,27 +127,27 @@ const ( /// /// 空 /// - EventType_None EventType = -1 + EventType_None = -1 /// /// 开始战斗时 /// EventType_OnFightStart EventType = iota /// - /// 回合行动前 + /// 回合开始 /// EventType_OnRoundStart /// - /// 回合结束后 + /// 回合结束 /// EventType_OnRoundEnd /// - /// 行动结束前 + /// 技能开始 /// - EventType_OnPreActionEnd + EventType_OnSkillStart /// - /// 行动结束后 + /// 技能结束 /// - EventType_OnPostActionEnd + EventType_OnSkillEnd /// /// 效果执行前 /// @@ -155,10 +176,59 @@ const ( /// 被暴击 /// EventType_OnPostReceiveCriCal + /// + /// 击破护盾时 + /// + EventType_OnPostGiveLostShield + /// + /// 护盾被击破时 + /// + EventType_OnPostReceiveLostShield + /// /// 回合行动后 /// EventType_OnStopAction + /// + /// 受到致死伤害时 + /// + EventType_OnDeathDmg + /// + /// 造成伤害 + /// + EventType_OnDamage + /// + /// 受到伤害 + /// + EventType_OnBeDamage + /// + /// 造成击杀 + /// + EventType_OnKill + /// + /// 治疗前 + /// + EventType_OnPreTre + /// + /// 治疗后 + /// + EventType_OnTreEnd + /// + /// 被治疗前 + /// + EventType_OnPreBeTre + /// + /// 被治疗后 + /// + EventType_OnBeTreEnd + /// + /// 移除buff后 + /// + EventType_OnRemoveBuffEnd + /// + /// 添加buff + /// + EventType_OnAddBuff ) type EOrderType int8 @@ -184,7 +254,7 @@ func (this *ComModifyOperate) ToString() string { } type ComSetSkillCD struct { - From byte + From int Skillid int32 Nv byte } @@ -270,14 +340,21 @@ type ComSkillAfterAtk struct { ComList []*ComEffectSkill } +//技能指令 +type IComEffectSkill interface { +} + type ComEffectSkill struct { - To byte + To int } type ComMondifyBuff struct { ComEffectSkill - BuffId int - Append bool + Gid int64 //唯一实体id + BuffId int32 //配置id + OverlapNum int //叠加层数 + Param float32 //参数 - 护盾量 + Operate byte // 0 移除 1 添加 2 修改 } /// @@ -285,11 +362,19 @@ type ComMondifyBuff struct { /// func (this *ComMondifyBuff) Recycle() { this.BuffId = 0 - this.Append = false + this.Operate = 0 this.To = 0 } func (this *ComMondifyBuff) ToString() string { - var str = fmt.Sprintf("Buff变化 to={%d} buffId={%d} append={%t}", this.To, this.BuffId, this.Append) + var operateStr string + if this.Operate == 0 { + operateStr = "移除" + } else if this.Operate == 1 { + operateStr = "添加" + } else { + operateStr = "修改" + } + var str = fmt.Sprintf("Buff变化 to={%d}gid={%d} buffId={%d} overlapNum={%d} operate={%s}", this.To, this.Gid, this.BuffId, this.OverlapNum, operateStr) return str } @@ -298,11 +383,13 @@ func (this *ComMondifyBuff) ToString() string { /// type ComModifyHealth struct { ComEffectSkill - Baoji bool - Miss bool - Num float32 - Nhp int - Mhp int + HideDmg bool + From int + Baoji bool + Miss bool + Num float32 + Nhp int32 + Mhp int32 } /// diff --git a/modules/battle/fight/core/fightargu.go b/modules/battle/fight/core/fightargu.go new file mode 100644 index 000000000..368dff6b3 --- /dev/null +++ b/modules/battle/fight/core/fightargu.go @@ -0,0 +1,12 @@ +package core + +const StepNum int = 10 + +/// +/// 效果触发概率判断 +/// +func Exec_Pr(pSkill IAfterSkill, pr int) bool { + randVal := pSkill.GetOwnerRole().GetFightBase().Rand(1, 1000) + // FightDebug.Log($"子技能 {pSkill.AfterSkillConf.Id} 效果触发概率判断:{randVal}, Bool: {randVal <= pr}"); + return randVal <= pr +} diff --git a/modules/battle/fight/core/fightproperty.go b/modules/battle/fight/core/fightproperty.go new file mode 100644 index 000000000..4a802042c --- /dev/null +++ b/modules/battle/fight/core/fightproperty.go @@ -0,0 +1,260 @@ +package core + +import "go_dreamfactory/modules/battle/fight/attribute" + +func Get(role IFightRole, attributeType int) *attribute.FixedNumeric { + switch PropertyType(attributeType) { + case PropertyType_Add_Hp: // 附加生命 + return &role.GetCurrentHealth().CurrMaxHpAppend.BaseValue + case PropertyType_Add_Per_Hp: // 附加百分比生命 + return &role.GetCurrentHealth().CurrMaxHpPro.BaseValue + case PropertyType_Add_Atk: // 附加攻击 + return &role.GetData().Atk.AppendValue + case PropertyType_Add_Per_Atk: // 附加百分比攻击 + return &role.GetData().Atk.ProValue + case PropertyType_Buff_Atk: // BUFF附加攻击 + return &role.GetData().Atk.BuffValue + case PropertyType_Buff_Per_Atk: // BUFF附加百分比攻击 + return &role.GetData().Atk.BuffProValue + + case PropertyType_Add_Def: // 附加防御 + return &role.GetData().Def.AppendValue + case PropertyType_Add_Per_Def: // 附加百分比防御 + return &role.GetData().Def.ProValue + case PropertyType_Buff_Def: // BUFF附加防御 + return &role.GetData().Def.BuffValue + case PropertyType_Buff_Per_Def: // BUFF附加百分比防御 + return &role.GetData().Def.BuffProValue + case PropertyType_Add_Agi: // 附加速度 + return &role.GetData().Speed.AppendValue + case PropertyType_Add_Per_Agi: // 附加百分比速度 + return &role.GetData().Speed.ProValue + case PropertyType_Buff_Agi: // BUFF附加速度 + return &role.GetData().Speed.BuffValue + case PropertyType_Buff_Per_Agi: // BUFF附加百分比速度 + return &role.GetData().Speed.BuffProValue + case PropertyType_Add_Cri: // 附加暴击率 + return &role.GetData().Critical.BuffProValue + case PropertyType_Add_CriDam: // 附加暴击伤害 + return &role.GetData().CriticalPower.BuffProValue + case PropertyType_Add_EffHit: // 附加效果命中 + return &role.GetData().EffectHit.BuffProValue + case PropertyType_Add_EffRe: // 附加效果抵抗 + return &role.GetData().EfectResist.BuffProValue + case PropertyType_ActValue: // 行动值 + return &role.GetData().Operate.BaseValue + case PropertyType_DamRe: // 伤害减免 + return &role.GetData().DamRe.BaseValue + //30 DamRe 伤害减免 + //31 CauseDam 造成伤害参数 + //32 SufferDam 受到伤害参数 + //33 MissPr 失手率 + //34 KnowPr 会心率 + //35 KnowPrDam 会心伤害 + //36 AddEffPr 附加效果触发概率 + //37 HpShield 生命护盾 + //38 CauseHpShieldPer 护盾量百分比加成 + //39 SufferHpShieldPer 受到护盾量百分比加成 + //40 CauseAddHp 治疗量百分比加成 + //41 SufferAddHp 受到治疗量百分比加成 + //42 IgnoreDefPer 无视防御百分比 + //43 SucHp 吸血百分比 + //44 Add_SufCri 附加暴击抵抗 + } + role.GetFightBase().Debugf("属性暂未绑定:%d", attributeType) + return nil +} + +/// +/// 获取真实属性值 +/// +func TryGetValue(role IFightRole, attributeType int, pValue *float32) bool { + var ( + numeric *attribute.FixedNumeric + ) + switch PropertyType(attributeType) { + case PropertyType_Total_Hp: // 总生命 + *pValue = role.GetCurrentHealth().MaxHp.Value() + return true + case PropertyType_NowTotal_Hp: // 当前总生命 + *pValue = role.GetCurrentHealth().CurrMaxHp.Value() + return true + case PropertyType_NowHp: // 当前生命 + *pValue = role.GetCurrentHealth().Hp.Value() + return true + case PropertyType_Total_Atk: // 总攻击 + *pValue = role.GetData().Atk.Value() + return true + case PropertyType_Total_Def: // 总防御 + *pValue = role.GetData().Def.Value() + return true + case PropertyType_Total_Agi: // 总速度 + *pValue = role.GetData().Speed.Value() + return true + case PropertyType_Total_Cri: // 总暴击率 + *pValue = role.GetData().Critical.Value() + return true + case PropertyType_Total_CriDam: // 总暴击伤害 + *pValue = role.GetData().CriticalPower.Value() + return true + case PropertyType_Total_EffHit: // 总效果命中 + *pValue = role.GetData().EffectHit.Value() + return true + case PropertyType_Total_EffRe: // 总效果抵抗 + *pValue = role.GetData().EfectResist.Value() + return true + case PropertyType_LostHp: // 已损失生命值 + *pValue = role.GetCurrentHealth().Deduct() + return true + case PropertyType_LostPerHp: // 已损失生命值百分比 + *pValue = role.GetCurrentHealth().LostPercent() * 1000 + return true + case PropertyType_NowHp_Per: // 当前生命百分比 + *pValue = role.GetCurrentHealth().Percent() * 1000 + return true + } + + numeric = Get(role, attributeType) + if numeric != nil { + *pValue = numeric.Value() + return true + } + + *pValue = 0 + return false +} + +/// 尝试设置属性 +func TrySetValue(role IFightRole, attributeType int, pValue float32, add bool) bool { + var ( + numeric *attribute.AttributeNumeric + attr attribute.FixedNumeric + value float32 + f float32 + ) + switch PropertyType(attributeType) { + case PropertyType_Add_Hp: // 附加生命 + var attri = role.GetCurrentHealth().CurrMaxHpAppend.BaseValue + if add { + value = attri.Add(pValue) + } else { + value = attri.Minus(pValue) + } + role.GetCurrentHealth().CurrMaxHpAppend.OnChange() + role.GetCurrentHealth().OnChange() + return true + case PropertyType_Add_Per_Hp: // 附加百分比生命 + var attri = role.GetCurrentHealth().CurrMaxHpPro.BaseValue + if add { + value = attri.Add(pValue) + } else { + value = attri.Minus(pValue) + } + role.GetCurrentHealth().CurrMaxHpPro.OnChange() + role.GetCurrentHealth().OnChange() + return true + case PropertyType_Add_Atk: // 附加攻击 + numeric = role.GetData().Atk + attr = role.GetData().Atk.AppendValue + break + case PropertyType_Add_Per_Atk: // 附加百分比攻击 + numeric = role.GetData().Atk + attr = role.GetData().Atk.ProValue + break + case PropertyType_Buff_Atk: // BUFF附加攻击 + numeric = role.GetData().Atk + attr = role.GetData().Atk.BuffValue + break + case PropertyType_Buff_Per_Atk: // BUFF附加百分比攻击 + numeric = role.GetData().Atk + attr = role.GetData().Atk.BuffProValue + break + case PropertyType_Add_Def: // 附加防御 + numeric = role.GetData().Def + attr = role.GetData().Def.AppendValue + break + case PropertyType_Add_Per_Def: // 附加百分比防御 + numeric = role.GetData().Def + attr = role.GetData().Def.ProValue + break + case PropertyType_Buff_Def: // BUFF附加防御 + numeric = role.GetData().Def + attr = role.GetData().Def.BuffValue + break + case PropertyType_Buff_Per_Def: // BUFF附加百分比防御 + numeric = role.GetData().Def + attr = role.GetData().Def.BuffProValue + break + case PropertyType_Add_Agi: // 附加速度 + numeric = role.GetData().Speed + attr = role.GetData().Speed.AppendValue + break + case PropertyType_Add_Per_Agi: // 附加百分比速度 + numeric = role.GetData().Speed + attr = role.GetData().Speed.ProValue + break + case PropertyType_Buff_Agi: // BUFF附加速度 + numeric = role.GetData().Speed + attr = role.GetData().Speed.BuffValue + break + case PropertyType_Buff_Per_Agi: // BUFF附加百分比速度 + numeric = role.GetData().Speed + attr = role.GetData().Speed.BuffProValue + break + case PropertyType_Add_Cri: // 附加暴击率 + numeric = role.GetData().Critical + attr = role.GetData().Critical.BuffProValue + break + case PropertyType_Add_CriDam: // 附加暴击伤害 + numeric = role.GetData().CriticalPower + attr = role.GetData().CriticalPower.BuffProValue + break + case PropertyType_Add_EffHit: // 附加效果命中 + numeric = role.GetData().EffectHit + attr = role.GetData().EffectHit.BuffProValue + break + case PropertyType_Add_EffRe: // 附加效果抵抗 + numeric = role.GetData().EfectResist + attr = role.GetData().EfectResist.BuffProValue + break + case PropertyType_ActValue: // 行动值 + numeric = role.GetData().Operate + attr = role.GetData().Operate.BaseValue + break + case PropertyType_DamRe: // 伤害减免 + numeric = role.GetData().DamRe + attr = role.GetData().DamRe.BuffValue + break + case PropertyType_DamRe_Per: // 伤害减免(百分比) + numeric = role.GetData().DamRe + attr = role.GetData().DamRe.BuffProValue + break + case PropertyType_CauseDam: // 伤害提升 + numeric = role.GetData().CauseDam + attr = role.GetData().DamRe.BuffValue + break + case PropertyType_CauseDam_Per: // 伤害提升(百分比) + numeric = role.GetData().CauseDam + attr = role.GetData().CauseDam.BuffProValue + break + case PropertyType_LostHold_per: // 失手率(百分比) + numeric = role.GetData().LostHold + attr = role.GetData().LostHold.BuffProValue + break + case PropertyType_UnderStand_per: // 会心率(百分比) + numeric = role.GetData().UnderStand + attr = role.GetData().UnderStand.BuffProValue + break + } + if numeric == nil { + role.GetFightBase().Debugf("属性暂未绑定:%d value:%f f:%f", attributeType, value, f) + return false + } + if add { + f = attr.Add(pValue) + } else { + f = attr.Minus(pValue) + } + numeric.OnChange() + return true +} diff --git a/modules/battle/fight/core/fightroledata.go b/modules/battle/fight/core/fightroledata.go index d94190f13..4e90a3fba 100644 --- a/modules/battle/fight/core/fightroledata.go +++ b/modules/battle/fight/core/fightroledata.go @@ -24,7 +24,7 @@ type FightRoleData struct { /// /// 唯一标记,同时也是List FightBase.Roles的索引 /// - Rid byte + Rid int /// /// 唯一id, 用于调试打日志 /// @@ -101,6 +101,24 @@ type FightRoleData struct { /// 会心率 /// UnderStand *attribute.AttributeNumeric + /// + /// 伤害减免 + /// + DamRe *attribute.AttributeNumeric + /// + /// 伤害提升 + /// + CauseDam *attribute.AttributeNumeric + + /// + /// 治疗加成 + /// + TreAdd *attribute.AttributeNumeric + + /// + /// 受疗加成 + /// + BeTreAdd *attribute.AttributeNumeric ///region 技能相关----------------------------------------------------------------------- /// @@ -114,7 +132,7 @@ type FightRoleData struct { /// /// 最后一次skillAtk技能选择的目标 /// - LastChooseTarget []byte + LastChooseTarget []int /// /// 可执行技能列表 /// @@ -130,10 +148,10 @@ type FightRoleData struct { /// /// BUFF集合 /// - BuffStore *BuffStore + BuffStore IBuffStore /// /// 被动技能集合 /// - PassiveStore PassiveStore + PassiveStore IPassiveStore } diff --git a/modules/battle/fight/core/map.go b/modules/battle/fight/core/map.go new file mode 100644 index 000000000..52b16d290 --- /dev/null +++ b/modules/battle/fight/core/map.go @@ -0,0 +1,33 @@ +package core + +import "strconv" + +type MapString map[string]string + +func (this MapString) TryGetInt(pKey string) (result int, ok bool) { + var ( + err error + v string + ) + if v, ok = this[pKey]; ok { + if result, err = strconv.Atoi(v); err == nil { + return + } + } + result = 0 + return +} +func (this MapString) TryGetFloat(pKey string, pResult *float32) bool { + var err error + var value float64 + if v, ok := this[pKey]; ok { + if value, err = strconv.ParseFloat(v, 32); err == nil { + *pResult = 0 + return false + } else { + *pResult = float32(value) + return true + } + } + return false +} diff --git a/modules/battle/fight/core/propertytype.go b/modules/battle/fight/core/propertytype.go index dc471786a..bfd613562 100644 --- a/modules/battle/fight/core/propertytype.go +++ b/modules/battle/fight/core/propertytype.go @@ -6,169 +6,169 @@ const ( /// /// 总生命 /// - PropertyType_Total_Hp = 1 + PropertyType_Total_Hp PropertyType = 1 /// /// 当前总生命 /// - PropertyType_NowTotal_Hp = 2 + PropertyType_NowTotal_Hp PropertyType = 2 /// /// 当前生命 /// - PropertyType_NowHp = 3 + PropertyType_NowHp PropertyType = 3 /// /// 总攻击 /// - PropertyType_Total_Atk = 4 + PropertyType_Total_Atk PropertyType = 4 /// /// 总防御 /// - PropertyType_Total_Def = 5 + PropertyType_Total_Def PropertyType = 5 /// /// 总速度 /// - PropertyType_Total_Agi = 6 + PropertyType_Total_Agi PropertyType = 6 /// /// 总暴击率 /// - PropertyType_Total_Cri = 7 + PropertyType_Total_Cri PropertyType = 7 /// /// 总暴击伤害 /// - PropertyType_Total_CriDam = 8 + PropertyType_Total_CriDam PropertyType = 8 /// /// 总效果命中 /// - PropertyType_Total_EffHit = 9 + PropertyType_Total_EffHit PropertyType = 9 /// /// 总效果抵抗 /// - PropertyType_Total_EffRe = 10 + PropertyType_Total_EffRe PropertyType = 10 /// /// 已损失生命值 /// - PropertyType_LostHp = 11 + PropertyType_LostHp PropertyType = 11 /// /// 已损失生命值百分比 /// - PropertyType_LostPerHp = 12 + PropertyType_LostPerHp PropertyType = 12 /// /// 当前生命百分比 /// - PropertyType_NowHp_Per = 13 + PropertyType_NowHp_Per PropertyType = 13 /// /// 附加生命(修改属性类型从这里开始) /// - PropertyType_Add_Hp = 14 + PropertyType_Add_Hp PropertyType = 14 /// /// 附加百分比生命 /// - PropertyType_Add_Per_Hp = 15 + PropertyType_Add_Per_Hp PropertyType = 15 /// /// BUFF附加生命 /// - PropertyType_Buff_Hp = 16 + PropertyType_Buff_Hp PropertyType = 16 /// /// BUFF附加百分比生命 /// - PropertyType_Buff_Per_Hp = 17 + PropertyType_Buff_Per_Hp PropertyType = 17 /// /// 附加攻击 /// - PropertyType_Add_Atk = 18 + PropertyType_Add_Atk PropertyType = 18 /// /// 附加百分比攻击 /// - PropertyType_Add_Per_Atk = 19 + PropertyType_Add_Per_Atk PropertyType = 19 /// /// BUFF附加攻击 /// - PropertyType_Buff_Atk = 20 + PropertyType_Buff_Atk PropertyType = 20 /// /// BUFF附加百分比攻击 /// - PropertyType_Buff_Per_Atk = 21 + PropertyType_Buff_Per_Atk PropertyType = 21 /// /// 附加防御 /// - PropertyType_Add_Def = 22 + PropertyType_Add_Def PropertyType = 22 /// /// 附加百分比防御 /// - PropertyType_Add_Per_Def = 23 + PropertyType_Add_Per_Def PropertyType = 23 /// /// BUFF附加防御 /// - PropertyType_Buff_Def = 24 + PropertyType_Buff_Def PropertyType = 24 /// /// BUFF附加百分比防御 /// - PropertyType_Buff_Per_Def = 25 + PropertyType_Buff_Per_Def PropertyType = 25 /// /// 附加速度 /// - PropertyType_Add_Agi = 26 + PropertyType_Add_Agi PropertyType = 26 /// /// 附加百分比速度 /// - PropertyType_Add_Per_Agi = 27 + PropertyType_Add_Per_Agi PropertyType = 27 /// /// BUFF附加速度 /// - PropertyType_Buff_Agi = 28 + PropertyType_Buff_Agi PropertyType = 28 /// /// BUFF附加百分比速度 /// - PropertyType_Buff_Per_Agi = 29 + PropertyType_Buff_Per_Agi PropertyType = 29 /// /// 附加暴击率 /// - PropertyType_Add_Cri = 30 + PropertyType_Add_Cri PropertyType = 30 /// /// 附加暴击伤害 /// - PropertyType_Add_CriDam = 31 + PropertyType_Add_CriDam PropertyType = 31 /// /// 附加效果命中 /// - PropertyType_Add_EffHit = 32 + PropertyType_Add_EffHit PropertyType = 32 /// /// 附加效果抵抗 /// - PropertyType_Add_EffRe = 33 + PropertyType_Add_EffRe PropertyType = 33 /// /// 行动值 /// - PropertyType_ActValue = 34 + PropertyType_ActValue PropertyType = 34 /// /// 伤害减免(buff附加百分比) /// - PropertyType_DamRe_Per = 35 + PropertyType_DamRe_Per PropertyType = 35 /// /// 伤害提升(buff附加百分比) /// - PropertyType_CauseDam_Per = 36 + PropertyType_CauseDam_Per PropertyType = 36 /// /// 伤害减免(固定值) /// - PropertyType_DamRe = 37 + PropertyType_DamRe PropertyType = 37 /// /// 伤害提升(固定值) /// - PropertyType_CauseDam = 38 + PropertyType_CauseDam PropertyType = 38 /// /// 失手率buff增加百分比 /// - PropertyType_LostHold_per = 39 + PropertyType_LostHold_per PropertyType = 39 /// /// 会心率buff增加百分比 /// - PropertyType_UnderStand_per = 40 + PropertyType_UnderStand_per PropertyType = 40 /// /// 治疗加成 /// - PropertyType_TreAdd = 41 + PropertyType_TreAdd PropertyType = 41 /// /// 受疗加成 /// - PropertyType_BeTreAdd = 42 + PropertyType_BeTreAdd PropertyType = 42 ) diff --git a/modules/battle/fight/fightbase.go b/modules/battle/fight/fightbase.go index 8c7926234..939f3c934 100644 --- a/modules/battle/fight/fightbase.go +++ b/modules/battle/fight/fightbase.go @@ -2,6 +2,7 @@ package fight import ( "go_dreamfactory/modules/battle/fight/core" + "math" ) type FightBase struct { @@ -24,9 +25,17 @@ type FightBase struct { LastActionRole core.IFightRole /// 战斗AI FightAI core.IFightAI + /// + /// 随机数种子 + /// + RandSeed int64 ///事件系统 FightEvent core.IFightEvent /// + /// 战报 + /// + FightLog core.IFightLog + /// /// 触发释放主技能,需要在当前出手角色技能释放完成之后再执行 /// readyEmitSkills map[core.IFightRole]int32 @@ -166,11 +175,11 @@ func (this *FightBase) GetActionRole() core.IFightRole { /// 选择的目标rid func (this *FightBase) EmitSkill(skillId int32, targetRid []int32, toNextRound bool) { // FightDebug.Log($">>>>>>>> {LastActionRole.Data.UniqueId} 使用技能 skillid={skillId} 选择了Rid: {targetRid[0].ToString()}"); + this.FightEvent.EmitForInt(int(skillId), this.LastActionRole) this.LastActionRole.EmitSkill(skillId, targetRid) + this.FightEvent.EmitForInt(int(core.EventType_OnRoundEnd), this.LastActionRole) //主动技能触发所有带动作的子技能需要在主动技能释放完成之后执行 this.EmitPassiveMainSkill() - this.FightEvent.EmitForInt(int(core.EventType_OnRoundEnd), this.LastActionRole) - this.FightEvent.EmitForInt(int(core.EventType_OnPreActionEnd), this.LastActionRole) this.OnLastActionRoleActionStop() } @@ -194,3 +203,15 @@ func (this *FightBase) OnLastActionRoleActionStop() { //检测战斗是否结束 this.CheckFightEnd() } + +/// +/// 生成随机数 +/// +/// 最小值(含) +/// 最大值(含) +/// +func (this *FightBase) Rand(min, max int) int { + RandSeed := (this.RandSeed*9301 + 49297) % 233280 + num := int(math.Floor(float64(RandSeed/233280.0)*float64(max-min+1) + float64(min))) + return num +} diff --git a/modules/battle/fight/fightevent.go b/modules/battle/fight/fightevent.go index 34bb5c0c5..6518dfbb2 100644 --- a/modules/battle/fight/fightevent.go +++ b/modules/battle/fight/fightevent.go @@ -1,5 +1,65 @@ package fight +import "reflect" + +func NewFightEvent() *FightEvent { + return &FightEvent{ + events: make(map[string][]reflect.Value), + } +} + type FightEvent struct { - -} \ No newline at end of file + events map[string][]reflect.Value + onceevents map[string][]reflect.Value +} + +/// +/// 发送消息 +/// +/// +/// +func (this *FightEvent) Emit(key string, params ...interface{}) { + +} + +/// +/// 监听消息 +/// +/// +/// +func (this *FightEvent) On(key string, f interface{}) { + +} + +/// +/// 监听一次消息 +/// +/// +/// +func (this *FightEvent) Once(key string, f interface{}) { + +} + +/// +/// 移除监听消息 +/// +/// +/// +func (this *FightEvent) Off(key string, f interface{}) { + +} + +/// +/// 移除监听消息 +/// +/// +func (this *FightEvent) OffKey(key string) { + +} + +/// +/// 重置事件中心 +/// +func (this *FightEvent) Clear() { + +} diff --git a/modules/battle/fight/fightlog.go b/modules/battle/fight/fightlog.go new file mode 100644 index 000000000..9f066928c --- /dev/null +++ b/modules/battle/fight/fightlog.go @@ -0,0 +1,17 @@ +package fight + +import "go_dreamfactory/modules/battle/fight/core" + +//战报 +type FightLog struct { + FightBase core.IFight + Commands []interface{} +} + +/// +/// 增加战报日志 +/// +/// +func (this *FightLog) AddCommand(object interface{}) { + this.Commands = append(this.Commands, object) +} diff --git a/modules/battle/fight/fightrole.go b/modules/battle/fight/fightrole.go index 8da6fd579..305897dad 100644 --- a/modules/battle/fight/fightrole.go +++ b/modules/battle/fight/fightrole.go @@ -4,7 +4,6 @@ import ( "fmt" "go_dreamfactory/modules/battle/fight/attribute" "go_dreamfactory/modules/battle/fight/core" - "go_dreamfactory/modules/battle/fight/passive" cfg "go_dreamfactory/sys/configure/structs" ) @@ -18,13 +17,17 @@ type FightRole struct { /// 角色数据 /// data core.FightRoleData - CurrentHealth *attribute.HealthPoint + currentHealth *attribute.HealthPoint +} + +func (this *FightRole) GetCurrentHealth() *attribute.HealthPoint { + return this.currentHealth } func (this *FightRole) Initialize(pData core.FightRoleData) { // this.data = pData - // this.CurrentHealth = attribute.NewHealthPoint(this.data.Hp) - // this.CurrentHealth.Reset() + // this.currentHealth = attribute.NewHealthPoint(this.data.Hp) + // this.currentHealth.Reset() // this.data.BuffStore.OwnerRole = this // this.data.PassiveStore.OwnerRole = this } @@ -33,13 +36,13 @@ func (this *FightRole) Initialize(pData core.FightRoleData) { /// 接收伤害 /// func (this *FightRole) ReceiveDamage(DamageValue float32) { - this.CurrentHealth.Minus(DamageValue) - // FightDebug.Log($"========接收伤害:{Data.UniqueId} 变化值={DamageValue} 当前血量={CurrentHealth.Value}"); + this.currentHealth.Minus(DamageValue) + // FightDebug.Log($"========接收伤害:{Data.UniqueId} 变化值={DamageValue} 当前血量={currentHealth.Value}"); if this.IsDead() { //有不死buff生命值设置为1 - for _, v := range this.data.BuffStore.HasBuffTypes { + for _, v := range this.data.BuffStore.GetHasBuffTypes() { if v == cfg.GameBuffType_UNDEAD { - this.CurrentHealth.Hp.SetFloat(1) + this.currentHealth.Hp.SetFloat(1) break } } @@ -49,7 +52,7 @@ func (this *FightRole) ReceiveDamage(DamageValue float32) { } func (this *FightRole) IsDead() bool { - return this.CurrentHealth.Value() <= 0 + return this.currentHealth.Value() <= 0 } func (this *FightRole) Dead() { this.data.ALive = false @@ -74,7 +77,7 @@ func (this *FightRole) Clear() { buff.Clear() }) // //清理所有被动就能 - this.data.PassiveStore.ForEach(func(fp passive.IFightPassive) { + this.data.PassiveStore.ForEach(func(fp core.IFightPassive) { fp.Clear() }) diff --git a/modules/battle/fight/fighttarget.go b/modules/battle/fight/fighttarget.go index ad3701a59..66412fb20 100644 --- a/modules/battle/fight/fighttarget.go +++ b/modules/battle/fight/fighttarget.go @@ -2,6 +2,117 @@ package fight import "go_dreamfactory/modules/battle/fight/core" +//From------------------------------------------------------------------------------------------------------- +/// +/// 从roles里,过滤出符合From设定的对象List +/// +/// 筛选前List +/// 用哪个技能来筛选 +/// 筛选后List +func From(roles []core.IFightRole, skill core.IAfterSkill) []core.IFightRole { + from := skill.GetAfterSkillConf().From + if from == int32(core.AferSkillFromType_TriggerPassiveFrom) { + if source, ok := skill.GetOwnerRole().GetData().PassiveStore.TryGetPassive(skill.GetSourceSkillId()); ok && source.GetTriggerPassiveRole() != nil { + return []core.IFightRole{source.GetTriggerPassiveRole()} + } else { + // FightDebug.Error("没有找到该子技能的SourceSkill 或者 该被动的触发者为null") + } + return []core.IFightRole{} + } + return nil +} + +/// +/// 从roles里,过滤出符合设定的对象List +/// +/// 筛选前List +/// 当前行动role +/// afterSkill里设置的From +/// +func FromByType(roles []core.IFightRole, actionRole core.IFightRole, from int) []core.IFightRole { + switch core.AferSkillFromType(from) { + case core.AferSkillFromType_All: + // 选所有 + return roles + case core.AferSkillFromType_Friend: // 只选友方 + result := make([]core.IFightRole, 0) + for _, role := range roles { + if role.GetData().ALive && role.GetData().Side == actionRole.GetData().Side { + result = append(result, role) + } + } + return result + case core.AferSkillFromType_Enemy: // 只选敌方 + result := make([]core.IFightRole, 0) + for _, role := range roles { + if role.GetData().ALive && role.GetData().Side != actionRole.GetData().Side { + result = append(result, role) + } + } + return result + case core.AferSkillFromType_Self: // 只选自己 + return []core.IFightRole{actionRole} + case core.AferSkillFromType_PlayerChoose: + // 只选skillAtk里选择的目标 + if actionRole.GetData().LastChooseTarget == nil { + // 如果主技能是个被动, 则此值会为空 + actionRole.GetData().LastChooseTarget = make([]int, 0) + } + result := make([]core.IFightRole, 0) + for _, role := range roles { + if role.GetData().ALive { + for _, v := range actionRole.GetData().LastChooseTarget { + if v == role.GetData().Rid { + result = append(result, role) + } + } + } + } + return result + case core.AferSkillFromType_FriendExceptSelf: + result := make([]core.IFightRole, 0) + for _, role := range roles { + if role.GetData().ALive && role.GetData().Side == actionRole.GetData().Side && role != actionRole { + result = append(result, role) + } + } + return result + case core.AferSkillFromType_EnemyExceptChoose: // 除选定目标外的其他敌方 + result := make([]core.IFightRole, 0) + for _, role := range roles { + if role.GetData().ALive && role.GetData().Side != actionRole.GetData().Side { + iskeep := false + for _, v := range actionRole.GetData().LastChooseTarget { + if v == role.GetData().Rid { + iskeep = true + } + } + if iskeep { + result = append(result, role) + } + } + } + return result + case core.AferSkillFromType_FriendExceptChoose: // 除选定目标外的其他友方 + result := make([]core.IFightRole, 0) + for _, role := range roles { + if role.GetData().ALive && role.GetData().Side == actionRole.GetData().Side { + iskeep := false + for _, v := range actionRole.GetData().LastChooseTarget { + if v == role.GetData().Rid { + iskeep = true + } + } + if iskeep { + result = append(result, role) + } + } + } + return result + } + return []core.IFightRole{} +} + /// /// 从roles里,过滤出符合设定的对象List /// diff --git a/modules/battle/fight/passive/fightcallskillpas.go b/modules/battle/fight/passive/fightcallskillpas.go index b860cdfec..af8b981ac 100644 --- a/modules/battle/fight/passive/fightcallskillpas.go +++ b/modules/battle/fight/passive/fightcallskillpas.go @@ -1,6 +1,11 @@ package passive -func NewFightCallSkillPas() IFightPassive { +import ( + "fmt" + "go_dreamfactory/modules/battle/fight/core" +) + +func NewFightCallSkillPas() core.IFightPassive { return &FightCallSkillPas{} } @@ -10,3 +15,36 @@ func NewFightCallSkillPas() IFightPassive { type FightCallSkillPas struct { FightPassive } + +func (this *FightCallSkillPas) OnEvent(argu []interface{}) { + this.FightPassive.OnEvent(argu) + this.ApplyAfterAtk() +} + +/// +/// 执行子技能 +/// +func (this *FightCallSkillPas) ApplyAfterAtk() { + // FightDebug.Log("触发被动执行子技能") + for _, skillId := range this.PassiveConf.Callback { + if fmt.Sprintf("%d", skillId)[0] == '1' { + this.OwnerRole.GetFightBase().AddPassiveMainSkill(this.OwnerRole, skillId) + } else { + afterSkill := this.OwnerRole.GetAfterAtk(skillId) + if afterSkill == nil { + continue + } + // 当前子技能的技能来源为当前被动 + afterSkill.SetSourceSkillId(this.PassiveConf.Id) + //直接执行(执行成功才写入日志) + if afterSkill.Emit() { + //如果是其他子技能触发的就把日志写入该子技能中 不是就直接发送日志 + if this.EmitAfterSkill != nil { + this.EmitAfterSkill.AddSkillLog(afterSkill.GetSkillLog()) + return + } + afterSkill.SendSkillLog() + } + } + } +} diff --git a/modules/battle/fight/passive/fightpassive.go b/modules/battle/fight/passive/fightpassive.go index 29d7ab04e..0a0a7a2a0 100644 --- a/modules/battle/fight/passive/fightpassive.go +++ b/modules/battle/fight/passive/fightpassive.go @@ -1,10 +1,422 @@ package passive -type IFightPassive interface { - Clear() -} +import ( + "fmt" + "go_dreamfactory/modules/battle/fight" + "go_dreamfactory/modules/battle/fight/buff" + "go_dreamfactory/modules/battle/fight/core" + cfg "go_dreamfactory/sys/configure/structs" + "strconv" +) type FightPassive struct { + buff.FightBuffBase + /// + /// skillPassive 配置 + /// + PassiveConf cfg.GameSkillPassiveData + /// + /// 这个被动是哪个角色给我施加的 + /// + FromRole core.IFightRole + /// + /// 被动持有者 + /// + OwnerRole core.IFightRole + /// + /// 触发被动的发起者(该角色触发了被动执行此子技能) + /// + TriggerPassiveRole core.IFightRole + /// + /// 触发被动的角色目标(该角色触发了被动执行此子技能) + /// + TriggerPassiveTarget core.IFightRole + /// + /// 条件检测参数 + /// + AddConArgs core.MapString + /// + /// 触发此被动的子技能Id + /// + EmitAfterSkillId int32 + EventType core.EventType + /// + /// 触发此被动的子技能(需要把战报输入到这个子技能中) + /// + EmitAfterSkill core.IAfterSkill + /// + /// 被动CD + /// + CD int + /// + /// 当前CD =0 才能触发 + /// + CurrentCD int + /// + /// 每回合累计触发次数 + /// + TotalEmitTimes int +} + +func (this *FightPassive) GetTriggerPassiveRole() core.IFightRole { + return this.TriggerPassiveRole +} + +func (this *FightPassive) OnActivate(param float32) { + this.EventType = this.CurEvent() + this.InitEvent() +} + +//绑定被动------------------------- +/// +/// 初始化事件 +/// +func (this *FightPassive) InitEvent() { + eventIndex := int(this.EventType) + if eventIndex != -1 { + this.OwnerRole.GetFightBase().GetFightEvent().OnForInt( + eventIndex, + this.OnReceiveEvent, + ) + } +} +func (this *FightPassive) OnReceiveEvent(argu []interface{}) { + if !this.CheckEmit() { + return + } + if !this.CheckWhere(argu) { + return + } + this.FromRole.GetFightBase().Debugf("角色 %d 被动技能 %d 执行, 触发子技能: %d", this.OwnerRole.GetData().UniqueId, this.PassiveConf.Id, this.EmitAfterSkillId) + this.OnEvent(argu) + this.TotalEmitTimes++ + this.EmitAfterSkill = nil + this.EmitAfterSkillId = 0 + this.TriggerPassiveRole = nil + this.TriggerPassiveTarget = nil +} + +/// +/// 接收到事件 +/// +func (this *FightPassive) OnEvent(argu []interface{}) { +} + +//触发被动--------------------------------------------------------------------------- +func (this *FightPassive) CheckEmit() bool { + //需要先检查cd 再判断当前回合是否触发达上限 + // FightDebug.Log($"{OwnerRole.Data.Rid}被动{PassiveConf.Id}当前CD={CurrentCD}TotalEmitTimes ={TotalEmitTimes},触发事件={EventType}"); + if this.CurrentCD != 0 || int32(this.TotalEmitTimes) >= this.PassiveConf.MaxEmitTimes { + return false + } + randVal := int32(this.OwnerRole.GetFightBase().Rand(1, 1000)) + // FightDebug.Log($"{OwnerRole.Data.Rid}被动技能 {PassiveConf.Id} 触发几率判断:{randVal}"); + return randVal <= this.PassiveConf.PasPr +} + +//检测逻辑---------------------------------------------------------------------------- +func (this *FightPassive) CheckWhere(argu []interface{}) bool { + switch this.EventType { + case core.EventType_OnRoundStart: // 角色回合行动前 + case core.EventType_OnRoundEnd: // 角色回合结束后 + case core.EventType_OnSkillStart: // 行动结束前 + case core.EventType_OnSkillEnd: // 行动结束后 + // 参数 [发起者, ] + if !this.CheckTarget(argu[0].(core.IFightRole)) { + return false + } + break + case core.EventType_OnPreEffect: // 准备执行效果前 + // 参数 [发起者, afterSkill] + if !this.CheckTarget(argu[0].(core.IFightRole)) { + return false + } + if !this.CheckCondition(argu[1].(core.IAfterSkill)) { + return false + } + this.EmitAfterSkill = argu[1].(core.IAfterSkill) + this.EmitAfterSkillId = this.EmitAfterSkill.GetAfterSkillConf().Id + break + case core.EventType_OnPostGiveEffect: // 施加效果时 + case core.EventType_OnPreReceiveEffect: // 受到效果执行前 + case core.EventType_OnPostReceiveEffect: // 受到效果时 + case core.EventType_OnPostGiveLostShield: // 击破护盾时 + case core.EventType_OnPostReceiveLostShield: // 护盾被击破时 + case core.EventType_OnDamage: // 造成伤害 + case core.EventType_OnBeDamage: // 受到伤害 + case core.EventType_OnPreTre: // 造成治疗前 + case core.EventType_OnTreEnd: // 造成治疗后 + case core.EventType_OnPreBeTre: // 受到治疗前 + case core.EventType_OnBeTreEnd: // 受到治疗后 + // 参数 [发起者, 目标者, afterSkill] + if !this.CheckTarget(argu[0].(core.IFightRole)) { + return false // , argu[1] as FightRole + } + if !this.CheckCondition(argu[2].(core.IAfterSkill)) { + return false + } + this.EmitAfterSkill = argu[2].(core.IAfterSkill) + this.EmitAfterSkillId = this.EmitAfterSkill.GetAfterSkillConf().Id + this.TriggerPassiveTarget = argu[1].(core.IFightRole) + break + case core.EventType_OnPostGiveCriCal: // 暴击时 + case core.EventType_OnPostReceiveCriCal: // 被暴击时 + // 参数 [发起者, 目标者, 是否暴击, afterSkill] + if !this.CheckTarget(argu[0].(core.IFightRole)) { + return false // , argu[1] as FightRole + } + if !this.CheckCriCal(argu[2].(int)) { + return false + } + this.EmitAfterSkill = argu[3].(core.IAfterSkill) + this.EmitAfterSkillId = this.EmitAfterSkill.GetAfterSkillConf().Id + this.TriggerPassiveTarget = argu[1].(core.IFightRole) + break + case core.EventType_OnCalcDmgEffect: // 受到伤害计算后 + // 参数 [发起者, 目标者, 是否致死, afterSkill] + if !this.CheckTarget(argu[0].(core.IFightRole)) { + return false // , argu[1] as FightRole + } + if !this.CheckDeadDmg(argu[2].(int)) { + return false + } + this.EmitAfterSkill = argu[3].(core.IAfterSkill) + this.EmitAfterSkillId = this.EmitAfterSkill.GetAfterSkillConf().Id + this.TriggerPassiveTarget = argu[1].(core.IFightRole) + break + case core.EventType_OnDeathDmg: // 受致死伤害后 + // 参数 [发起者, 目标者] + if !this.CheckTarget(argu[0].(core.IFightRole)) { + return false // , argu[1] as FightRole + } + if !this.CheckDeadDmg(argu[2].(int)) { + return false + } + this.TriggerPassiveTarget = argu[1].(core.IFightRole) + break + case core.EventType_OnKill: + // 参数 [发起者, 目标者, afterSkill] + if !this.CheckTarget(argu[0].(core.IFightRole)) { + return false // , argu[1] as FightRole + } + if !this.CheckKillCondition(argu[2].(core.IAfterSkill)) { + return false + } + this.TriggerPassiveTarget = argu[1].(core.IFightRole) + break + case core.EventType_OnRemoveBuffEnd: + case core.EventType_OnAddBuff: + // 参数 [发起者, 目标者, buff效果类型,是否成功,afterSkill] + if !this.CheckTarget(argu[0].(core.IFightRole)) { + return false // , argu[1] as FightRole + } + if !this.CheckBuffCondition(argu[2].(int), argu[3].(bool)) { + return false + } + this.TriggerPassiveTarget = argu[1].(core.IFightRole) + break + } + this.TriggerPassiveRole = argu[0].(core.IFightRole) + return true +} + +func (this *FightPassive) CheckKillCondition(skill core.IAfterSkill) bool { + for key, vlaue := range this.AddConArgs { + switch key { + case "SkillID": //死于某技能 + if skill == nil { + return false + } + return fmt.Sprintf("%d", skill.GetAfterSkillConf().Id) == vlaue + } + } + return true +} + +func (this *FightPassive) CheckBuffCondition(effect int, succ bool) bool { + for key, vlaue := range this.AddConArgs { + switch key { + case "EffType": //buff效果类型 + if fmt.Sprintf("%d", effect) != vlaue { + return false + } + if result, ok := this.AddConArgs.TryGetInt("Result"); !ok { + // FightDebug.Error($"{PassiveConf.Id}参数配置错误EffType后面必须指定目标Result"); + return false + } else { + if succ { + return result == 1 + } else { + return result == 0 + } + } + } + } + return true +} + +/// +/// 检测目标 +/// +/// 发起者 +/// 目标者 +func (this *FightPassive) CheckTarget(pLaunch core.IFightRole) bool { + // FightDebug.Log("开始目标检测-++++++++++++"); + switch this.PassiveConf.TargetCheck { + case 0: // 全体 + return true + case 1: // 友方 + // 检测所有友军身上有没有目标为友军,施加效果时检测,并且效果标签为治疗的被动 + return this.OwnerRole.GetData().Side == pLaunch.GetData().Side + case 2: // 敌方 + // 检测敌方所有角色身上有没有目标为敌军,施加效果时检测,并且效果标签为治疗的被动 + return pLaunch.GetData().Side != this.OwnerRole.GetData().Side + case 3: // 自身 + // 检测自身身上有没有目标为自身,施加效果时检测,并且效果标签为治疗的被动 + return this.OwnerRole.GetData().Rid == pLaunch.GetData().Rid + case 4: // 不包含自身的友方 + // 不包含自身友军 + return this.OwnerRole.GetData().Side == pLaunch.GetData().Side && this.OwnerRole.GetData().Rid != pLaunch.GetData().Rid + } + // FightDebug.Log("目标检测不通过-++++++++++++"); + return false +} + +/// +/// 检测暴击 +/// +func (this *FightPassive) CheckCriCal(pCriCal int) bool { + if CriRely, ok := this.AddConArgs.TryGetInt("CriRely"); !ok { + return true + } else { + return CriRely == pCriCal + } +} + +/// +/// 检测是否致死伤害 +/// +func (this *FightPassive) CheckDeadDmg(pDead int) bool { + if LetDmg, ok := this.AddConArgs.TryGetInt("LetDmg"); !ok { + return true + } else { + return LetDmg == pDead + } +} + +/// +/// 条件检测 +/// +/// 发起者 +/// 目标者 +/// afterSkill +/// +func (this *FightPassive) CheckCondition(afterSkill core.IAfterSkill) bool { + // FightDebug.Log("开始条件检测-++++++++++++"); + for key, vlaue := range this.AddConArgs { + vint, _ := strconv.Atoi(vlaue) + switch key { + case "Hpproless": //目标血量低于多少 + if target, ok := this.AddConArgs.TryGetInt("Target"); !ok { + // FightDebug.Error($"{PassiveConf.Id}参数配置错误Hpproless后面必须指定目标Target"); + return false + } else { + var list = fight.FromByType(this.OwnerRole.GetFightBase().GetRoles(), this.OwnerRole, target) + conform := false + for _, v := range list { + var pre float32 = 0 + if core.TryGetValue(v, int(core.PropertyType_NowHp_Per), &pre) && pre < float32(vint) { + conform = true + } + } + if !conform { + return false + } + } + break + case "EffID": + if afterSkill.GetAfterSkillConf().Type != cfg.GameSkillEffectType_AddBuff { + return false + } + if afterSkill.GetSkillArgs()[0] != vint { + return false + } + break + case "EffType": + if afterSkill.GetAfterSkillConf().Type != cfg.GameSkillEffectType_AddBuff { + return false + } + var buffId = afterSkill.GetSkillArgs()[0] + var buffConf = this.OwnerRole.GetFightBase().GetSkillConfig(buffId, 1).(*cfg.GameSkillBuffData) + if buffConf == nil { + // FightDebug.Error($"子技能{afterSkill.AfterSkillConf.Id}参数配置添加buffID={buffId}没有配置"); + return false + } + if int(buffConf.BuffType) != vint { + return false + } + break + } + } + // FightDebug.Log("条件检测通过-++++++++++++"); + return true +} + +func (this *FightPassive) CurEvent() core.EventType { + switch this.PassiveConf.When { + // 全局事件 + case "RouFro": + return core.EventType_OnRoundStart + case "RouEnd": + return core.EventType_OnRoundEnd + + // 角色事件 + case "EffFro": + return core.EventType_OnPreEffect + case "ImpEff": + return core.EventType_OnPostGiveEffect + case "SufEffFro": + return core.EventType_OnPreReceiveEffect + case "SufDmg": + return core.EventType_OnCalcDmgEffect + case "SufEff": + return core.EventType_OnPostReceiveEffect + case "CriCal": + return core.EventType_OnPostGiveCriCal + case "CovCriCal": + return core.EventType_OnPostReceiveCriCal + case "ActEndFro": + case "SkillStart": + return core.EventType_OnSkillStart + case "ActEnd": + return core.EventType_OnSkillEnd + case "ShieldBro": + return core.EventType_OnPostReceiveLostShield + case "BreShield": + return core.EventType_OnPostGiveLostShield + case "Damage": + return core.EventType_OnDamage + case "BeDamage": + return core.EventType_OnBeDamage + + case "Kill": + return core.EventType_OnKill + case "TreStart": + return core.EventType_OnPreTre + case "TreEnd": + return core.EventType_OnTreEnd + case "PreBeTre": + return core.EventType_OnPreBeTre + case "BeTreEnd": + return core.EventType_OnBeTreEnd + case "RemoveBuffEnd": + return core.EventType_OnRemoveBuffEnd + case "AddBuff": + return core.EventType_OnAddBuff + } + + // FightDebug.Log($"被动技能触发时机{PassiveConf.When}配置错误"); + return core.EventType_None } func (this *FightPassive) Clear() { diff --git a/modules/battle/fight/skill/afteratk/fightaddactvalueskill.go b/modules/battle/fight/skill/afteratk/fightaddactvalueskill.go new file mode 100644 index 000000000..564c9c792 --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightaddactvalueskill.go @@ -0,0 +1,10 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +/// +/// 修改目标行动值 +/// +type FightAddActValueSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightaddbuffskill.go b/modules/battle/fight/skill/afteratk/fightaddbuffskill.go new file mode 100644 index 000000000..f68bbe181 --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightaddbuffskill.go @@ -0,0 +1,10 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +/// +/// 添加buff +/// +type FightAddBuffSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightaddpasskill.go b/modules/battle/fight/skill/afteratk/fightaddpasskill.go new file mode 100644 index 000000000..b1ce37a93 --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightaddpasskill.go @@ -0,0 +1,7 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +type FightAddPasSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightavetreskill.go b/modules/battle/fight/skill/afteratk/fightavetreskill.go new file mode 100644 index 000000000..4d1b7a1b3 --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightavetreskill.go @@ -0,0 +1,7 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +type FightAveTreSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightbuffcdskill.go b/modules/battle/fight/skill/afteratk/fightbuffcdskill.go new file mode 100644 index 000000000..030800be8 --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightbuffcdskill.go @@ -0,0 +1,10 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +/// +/// BUFF回合类操作 +/// +type FightBuffCDSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightdmgskill.go b/modules/battle/fight/skill/afteratk/fightdmgskill.go new file mode 100644 index 000000000..db75b4e7c --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightdmgskill.go @@ -0,0 +1,7 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +type FightDmgSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightdpsbyaddbuffskill.go b/modules/battle/fight/skill/afteratk/fightdpsbyaddbuffskill.go new file mode 100644 index 000000000..17dcbd302 --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightdpsbyaddbuffskill.go @@ -0,0 +1,10 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +/// +/// 添加buff(从之前技能的效果值中取参数) +/// +type FightDpsByAddBuffSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightdrawactvalueskill.go b/modules/battle/fight/skill/afteratk/fightdrawactvalueskill.go new file mode 100644 index 000000000..05274c056 --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightdrawactvalueskill.go @@ -0,0 +1,10 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +/// +/// 吸收目标行动值 +/// +type FightDrawActValueSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightrandbuffskill.go b/modules/battle/fight/skill/afteratk/fightrandbuffskill.go new file mode 100644 index 000000000..0cac80620 --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightrandbuffskill.go @@ -0,0 +1,10 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +/// +/// 随机buff +/// +type FightRandBuffSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightremovedebuffskill.go b/modules/battle/fight/skill/afteratk/fightremovedebuffskill.go new file mode 100644 index 000000000..93449f6a1 --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightremovedebuffskill.go @@ -0,0 +1,7 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +type FightRemoveDebuffSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightrobproskill.go b/modules/battle/fight/skill/afteratk/fightrobproskill.go new file mode 100644 index 000000000..23033936e --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightrobproskill.go @@ -0,0 +1,10 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +/// +/// 抢夺目标属性 +/// +type FightRobProSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightroundskill.go b/modules/battle/fight/skill/afteratk/fightroundskill.go new file mode 100644 index 000000000..eaf0e58b1 --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightroundskill.go @@ -0,0 +1,10 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +/// +/// 立即获得回合 +/// +type FightRoundSkill struct { + skill.FightAfterSkill +} diff --git a/modules/battle/fight/skill/afteratk/fightshiftbuffskill.go b/modules/battle/fight/skill/afteratk/fightshiftbuffskill.go new file mode 100644 index 000000000..caf9e2a8b --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightshiftbuffskill.go @@ -0,0 +1,17 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +/// +/// 转嫁buff +/// +type FightShiftBuffSkill struct { + skill.FightAfterSkill +} + +/// +/// 执行技能逻辑 +/// +func (this *FightShiftBuffSkill) DoLogic() { + +} diff --git a/modules/battle/fight/skill/afteratk/fightskillcdskill.go b/modules/battle/fight/skill/afteratk/fightskillcdskill.go new file mode 100644 index 000000000..c29994d8b --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fightskillcdskill.go @@ -0,0 +1,17 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +/// +/// Skill回合类操作 +/// +type FightSkillCDSkill struct { + skill.FightAfterSkill +} + +/// +/// 执行技能逻辑 +/// +func (this *FightSkillCDSkill) DoLogic() { + +} diff --git a/modules/battle/fight/skill/afteratk/fighttreskill.go b/modules/battle/fight/skill/afteratk/fighttreskill.go new file mode 100644 index 000000000..9b62b663d --- /dev/null +++ b/modules/battle/fight/skill/afteratk/fighttreskill.go @@ -0,0 +1,19 @@ +package afteratk + +import "go_dreamfactory/modules/battle/fight/skill" + +type FightTreSkill struct { + skill.FightlEffectSkill +} + +/// +/// 执行技能逻辑 +/// +func (this *FightTreSkill) DoLogic() { + +} + +func (this *FightTreSkill) Clear() { + this.FightlEffectSkill.Clear() + this.EffectValue = 0 +} diff --git a/modules/battle/fight/skill/fightafterskill.go b/modules/battle/fight/skill/fightafterskill.go index 17194d783..975ab88fb 100644 --- a/modules/battle/fight/skill/fightafterskill.go +++ b/modules/battle/fight/skill/fightafterskill.go @@ -1,10 +1,24 @@ package skill +import "go_dreamfactory/modules/battle/fight/core" + type FightAfterSkill struct { /// /// 技能效果是否生效 /// TakeEffect bool + + /// + /// 子技能效果列表 + /// + ComList []*core.ComEffectSkill +} + +/// +/// 子技能增加战报日志 +/// +func (this *FightAfterSkill) AddLog(pCom *core.ComEffectSkill) { + this.ComList = append(this.ComList, pCom) } /// diff --git a/modules/battle/fight/skill/fightleffectskill.go b/modules/battle/fight/skill/fightleffectskill.go new file mode 100644 index 000000000..80371e173 --- /dev/null +++ b/modules/battle/fight/skill/fightleffectskill.go @@ -0,0 +1,11 @@ +package skill + +type FightlEffectSkill struct { + FightAfterSkill + EffectValue float32 +} + +func (this *FightlEffectSkill) Clear() { + this.FightAfterSkill.Clear() + this.EffectValue = 0 +}