-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathImpact.go
577 lines (542 loc) · 17.3 KB
/
Impact.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
package GameFight
import (
"errors"
)
type Impact struct {
LogicFuncArray [EmImpactLogicCount]func()
impactID int //ID
pHolder *FightObject //拥有者
pCaster *FightObject //施放者
skillID int //技能ID
startTime int //开始时间
life int //开始周期
logicTime int //开始作用时间
term int //开始间隔
conAttTimes int //连击次数
}
func (impact Impact) GetImpactRow() (TableRowImpact, error) {
id := impact.GetImpactID()
if impact, ok := G_Impact[id]; ok {
return impact, nil
} else {
return TableRowImpact{}, errors.New("config err")
}
}
func (impact Impact) GetImpactID() int {
return impact.impactID
}
func (impact Impact) GetHolder() *FightObject {
return impact.pHolder
}
func (impact Impact) GetCaster() *FightObject {
return impact.pCaster
}
func (impact Impact) IsValid() bool {
if impact.impactID > 0 {
return true
}
return false
}
func (impact *Impact) Init(nImpactID, conAttTimes, nRound, nSkillID int, pCaster, pHolder *FightObject) bool {
impact.impactID = nImpactID
impact.pHolder = pHolder
impact.pCaster = pCaster
impact.skillID = nSkillID
impact.startTime = nRound
impact.life = nRound
impact.logicTime = nRound
impact.conAttTimes = 0
impact.term = 1
pRow, err := impact.GetImpactRow()
if err != nil {
return false
}
switch pRow.LogicID {
case EmImpactLogic0, EmImpactLogic1, EmImpactLogic6:
if conAttTimes > 0 {
impact.conAttTimes = conAttTimes
}
break
case EmImpactLogic2,EmImpactLogic3:
//2=物理持续攻击
//逻辑参数3:持续时间,单位回合(10)
//逻辑参数4:生效间隔,单位回合(2)
impact.life += pRow.Param[2] - pRow.Param[3]
impact.term = pRow.Param[3]
break
case EmImpactLogic4,EmImpactLogic5:
//逻辑参数3:持续时间,单位回合(10)
impact.life += pRow.Param[2] - 1
break
default:
break
}
impact.LogicFuncArray[0] = impact.ImpactLogic0
impact.LogicFuncArray[1] = impact.ImpactLogic1
impact.LogicFuncArray[2] = impact.ImpactLogic2
impact.LogicFuncArray[3] = impact.ImpactLogic3
impact.LogicFuncArray[4] = impact.ImpactLogic4
impact.LogicFuncArray[5] = impact.ImpactLogic5
impact.LogicFuncArray[6] = impact.ImpactLogic6
return true
}
//0=单次物理攻击;
//逻辑参数1:从英雄物理攻击中取得的倍率(例:150)
//逻辑参数2:额外增加的物理伤害(例:50)
//如英雄物理攻击为100,则最终的技能物理攻击=英雄物理攻击(100)*逻辑参数1(150/100)+逻辑参数2(50)
func (impact Impact) ImpactLogic0() {
var (
pImpactInfo *ImpactInfo
pAttackInfo *AttackInfo
pSkillAttack *SkillAttack
pFightCell *FightCell
index int
pRow TableRowImpact
nPhysicAttack int
nAttack int
nDefend int
nDecay int
nDamage int
fConAttHurt int
)
index = InvalidId
pAttackInfo = impact.pCaster.GetAttackInfo()
if pAttackInfo != nil && pAttackInfo.IsValid() {
pSkillAttack = pAttackInfo.GetSkillAttack(impact.skillID)
if pSkillAttack != nil {
pImpactInfo = pSkillAttack.GetImpactInfo(impact.impactID)
if pImpactInfo != nil {
index = pImpactInfo.GetTargetIndex(impact.pHolder.GetGuid())
}
}
}
pFightCell = impact.pHolder.GetFightCell()
nPhysicAttack = impact.pCaster.GetPhysicAttack()
pRow, err := impact.GetImpactRow()
if err != nil {
panic(err)
}
nAttack = int(nPhysicAttack*pRow.Param[0]/100 + pRow.Param[1])
if pFightCell.GetFightType() == EmTypeFightStair && impact.pCaster.IsAttacker() {
nAttack += nAttack * pFightCell.GetPlusAtt() / 100
}
nDefend = impact.pHolder.GetPhysicDefend()
nDecay = impact.pHolder.GetPhysicHurtDecay()
//本次物理攻击伤害=(自身当前经过连击计算后的物理攻击-目标物理防御)*(1-目标物理伤害减免/100)
nDamage = CalcDamage(nAttack, nDefend, nDecay)
nDamage = ChkMin(nDamage, 0)
impact.pHolder.SetHP(impact.pHolder.GetHP() - nDamage)
if pImpactInfo != nil && index >= 0 {
pImpactInfo.Hurts[index][0] = nDamage
}
//连击
fConAttHurt = impact.pCaster.GetConAttHurt() / 100
for i := 1; i < impact.conAttTimes; i++ {
nAttack = int(nAttack * fConAttHurt)
nDamage = CalcDamage(nAttack, nDefend, nDecay)
nDamage = ChkMin(nDamage, 0)
impact.pHolder.SetHP(impact.pHolder.GetHP() - nDamage)
if pImpactInfo != nil && index >= 0 {
pImpactInfo.Hurts[index][i] = nDamage
}
}
}
func (impact Impact) ImpactLogic1() {
var (
pImpactInfo *ImpactInfo
pAttackInfo *AttackInfo
pSkillAttack *SkillAttack
pFightCell *FightCell
index int
pRow TableRowImpact
nPhysicAttack int
nAttack int
nDefend int
nDecay int
nDamage int
fConAttHurt int
)
index = InvalidId
pAttackInfo = impact.pCaster.GetAttackInfo()
if pAttackInfo != nil && pAttackInfo.IsValid() {
pSkillAttack = pAttackInfo.GetSkillAttack(impact.skillID)
if pSkillAttack != nil {
pImpactInfo = pSkillAttack.GetImpactInfo(impact.impactID)
if pImpactInfo != nil {
index = pImpactInfo.GetTargetIndex(impact.pHolder.GetGuid())
}
}
}
pFightCell = impact.pHolder.GetFightCell()
nPhysicAttack = impact.pCaster.GetPhysicAttack()
pRow, err := impact.GetImpactRow()
if err != nil {
panic(err)
}
nAttack = int(nPhysicAttack*pRow.Param[0]/100 + pRow.Param[1])
if pFightCell.GetFightType() == EmTypeFightStair && impact.pCaster.IsAttacker() {
nAttack += int(nAttack * pFightCell.GetPlusAtt() / 100)
}
nDefend = impact.pHolder.GetMagicDefend()
nDecay = impact.pHolder.GetMagicHurtDecay()
nDamage = CalcDamage(nAttack, nDefend, nDecay)
nDamage = ChkMin(nDamage, 0)
//本次魔法攻击伤害=(自身当前经过连击计算后的魔法攻击-目标魔法防御)*(1-目标魔法伤害减免/100)
impact.pHolder.SetHP(impact.pHolder.GetHP() - nDamage)
if pImpactInfo != nil && index >= 0 {
pImpactInfo.Hurts[index][0] = nDamage
}
//连击
fConAttHurt = impact.pCaster.GetConAttHurt() / 100
for i := 1; i < impact.conAttTimes; i++ {
nAttack = int(nAttack * fConAttHurt)
nDamage = CalcDamage(nAttack, nDefend, nDecay)
nDamage = ChkMin(nDamage, 0)
impact.pHolder.SetHP(impact.pHolder.GetHP() - nDamage)
if pImpactInfo != nil && index >= 0 {
pImpactInfo.Hurts[index][i] = nDamage
}
}
}
//2=物理持续攻击
//逻辑参数1:从英雄物理攻击中取得的倍率(例:150)
//逻辑参数2:额外增加的物理伤害(例:50)
//逻辑参数3:持续时间,单位回合(10)
//逻辑参数4:生效间隔,单位回合(2)
//此效果的最终效果为:每2回合对目标造成一次物理伤害,持续10回合(生效5次),每次造成的物理攻击具体数值=英雄物理攻击(100)*逻辑参数1(150/100)+逻辑参数2(50)
func (impact Impact) ImpactLogic2() {
var (
pImpactInfo *ImpactInfo
pAttackInfo *AttackInfo
pSkillAttack *SkillAttack
pFightCell *FightCell
index int
nPhysicAttack int
nAttack int
nDefend int
nDecay int
nDamage int
pRoundInfo *FightRoundInfo
pFObjectInfo *FObjectInfo
)
index = InvalidId
pAttackInfo = impact.pCaster.GetAttackInfo()
if pAttackInfo != nil && pAttackInfo.IsValid() {
pSkillAttack = pAttackInfo.GetSkillAttack(impact.skillID)
if pSkillAttack != nil {
pImpactInfo = pSkillAttack.GetImpactInfo(impact.impactID)
if pImpactInfo != nil {
index = pImpactInfo.GetTargetIndex(impact.pHolder.GetGuid())
}
}
}
pFightCell = impact.pHolder.GetFightCell()
if impact.logicTime <= impact.life {
nPhysicAttack = impact.pCaster.GetPhysicAttack()
pRow, err := impact.GetImpactRow()
if err != nil {
panic(err)
}
nAttack = int(nPhysicAttack*pRow.Param[0]/100 + pRow.Param[1])
if pFightCell.GetFightType() == EmTypeFightStair && impact.pCaster.IsAttacker() {
nAttack += nAttack * pFightCell.GetPlusAtt() / 100
}
nDefend = impact.pHolder.GetPhysicDefend()
nDecay = impact.pHolder.GetPhysicHurtDecay()
//本次物理攻击伤害=(自身当前经过连击计算后的物理攻击-目标物理防御)*(1-目标物理伤害减免/100)
nDamage = CalcDamage(nAttack, nDefend, nDecay)
nDamage = ChkMin(nDamage, 0)
impact.pHolder.SetHP(impact.pHolder.GetHP() - nDamage)
if impact.startTime == impact.logicTime {
if pImpactInfo != nil && index >= 0 {
pImpactInfo.Hurts[index][0] = nDamage
}
} else if impact.startTime < impact.logicTime {
pRoundInfo = pFightCell.GetRoundInfo()
pFObjectInfo = pRoundInfo.GetFObjectInfoByGuid(impact.pHolder.GetGuid())
if pFObjectInfo != nil {
for i := 0; i < pFObjectInfo.ImpactCount; i++ {
if pFObjectInfo.ImpactList[i] == impact.impactID {
pFObjectInfo.ImpactHurt[i] = nDamage
break
}
}
}
}
}
impact.logicTime += impact.term
}
//3=持续魔法攻击
//逻辑参数1:从英雄物理攻击(因为英雄默认没有魔法攻击)中取得的倍率(例:150)
//逻辑参数2:额外增加的魔法伤害(例:50)
//逻辑参数3:持续时间,单位回合(10)
//逻辑参数4:生效间隔,单位回合(2)
//此效果的最终效果为:每2回合对目标造成一次魔法伤害,持续10回合(生效5次),每次造成的魔法攻击具体数值=英雄物理攻击(100)*逻辑参数1(150/100)+逻辑参数2(50)
func (impact *Impact) ImpactLogic3() {
var (
pImpactInfo *ImpactInfo
pAttackInfo *AttackInfo
pSkillAttack *SkillAttack
pFightCell *FightCell
index int
nPhysicAttack int
nAttack int
nDefend int
nDecay int
nDamage int
pRoundInfo *FightRoundInfo
pFObjectInfo *FObjectInfo
)
index = InvalidId
pAttackInfo = impact.pCaster.GetAttackInfo()
if pAttackInfo != nil && pAttackInfo.IsValid() {
pSkillAttack = pAttackInfo.GetSkillAttack(impact.skillID)
if pSkillAttack != nil {
pImpactInfo = pSkillAttack.GetImpactInfo(impact.impactID)
if pImpactInfo != nil {
index = pImpactInfo.GetTargetIndex(impact.pHolder.GetGuid())
}
}
}
pFightCell = impact.pHolder.GetFightCell()
if impact.logicTime <= impact.life {
nPhysicAttack = impact.pCaster.GetPhysicAttack()
pRow, err := impact.GetImpactRow()
if err != nil {
panic(err)
}
nAttack = int(nPhysicAttack*pRow.Param[0]/100 + pRow.Param[1])
if pFightCell.GetFightType() == EmTypeFightStair && impact.pCaster.IsAttacker() {
nAttack += nAttack * pFightCell.GetPlusAtt() / 100
}
nDefend = impact.pHolder.GetMagicDefend()
nDecay = impact.pHolder.GetMagicHurtDecay()
//本次物理攻击伤害=(自身当前经过连击计算后的物理攻击-目标物理防御)*(1-目标物理伤害减免/100)
nDamage = CalcDamage(nAttack, nDefend, nDecay)
nDamage = ChkMin(nDamage, 0)
impact.pHolder.SetHP(impact.pHolder.GetHP() - nDamage)
}
if impact.startTime == impact.logicTime {
if pImpactInfo != nil && index >= 0 {
pImpactInfo.Hurts[index][0] = nDamage
}
} else if impact.startTime < impact.logicTime {
pRoundInfo = pFightCell.GetRoundInfo()
pFObjectInfo = pRoundInfo.GetFObjectInfoByGuid(impact.pHolder.GetGuid())
if pFObjectInfo != nil {
for i := 0; i < pFObjectInfo.ImpactCount; i++ {
if pFObjectInfo.ImpactList[i] == impact.impactID {
pFObjectInfo.ImpactHurt[i] = nDamage
break
}
}
}
}
impact.logicTime += impact.term
}
func (impact *Impact) ImpactLogic4() {
var (
pImpactInfo *ImpactInfo
pAttackInfo *AttackInfo
pSkillAttack *SkillAttack
pFightCell *FightCell
index int
pRoundInfo *FightRoundInfo
pFObjectInfo *FObjectInfo
)
index = InvalidId
pAttackInfo = impact.pCaster.GetAttackInfo()
if pAttackInfo != nil && pAttackInfo.IsValid() {
pSkillAttack = pAttackInfo.GetSkillAttack(impact.skillID)
if pSkillAttack != nil {
pImpactInfo = pSkillAttack.GetImpactInfo(impact.impactID)
if pImpactInfo != nil {
index = pImpactInfo.GetTargetIndex(impact.pHolder.GetGuid())
}
}
}
if impact.logicTime <= impact.life {
pRow, err := impact.GetImpactRow()
if err != nil {
panic(err)
}
impact.pHolder.ChangeEffect(EmAttribute(pRow.Param[0]), pRow.Param[1], false)
if impact.startTime == impact.logicTime {
if pImpactInfo != nil && index >= 0 {
if EmAttribute(pRow.Param[0]) == EmAttributeHp {
impact.pHolder.SetHP(impact.pHolder.GetHP())
pImpactInfo.Hurts[index][0] = pRow.Param[1] * -1
}
if EmAttribute(pRow.Param[0]) == EmAttributeMp {
pImpactInfo.Mp[index] = pRow.Param[1] * -1
}
}
} else if impact.startTime == impact.logicTime {
pFightCell = impact.pHolder.GetFightCell()
pRoundInfo = pFightCell.GetRoundInfo()
pFObjectInfo = pRoundInfo.GetFObjectInfoByGuid(impact.pHolder.GetGuid())
if pFObjectInfo != nil {
for i := 0; i < pFObjectInfo.ImpactCount; i++ {
if pFObjectInfo.ImpactList[i] == impact.impactID {
if EmAttribute(pRow.Param[0]) == EmAttributeHp {
pFObjectInfo.ImpactHurt[i] = pRow.Param[1] * -1
}
if EmAttribute(pRow.Param[0]) == EmAttributeMp {
pFObjectInfo.ImpactMP[i] = pRow.Param[1] * -1
}
break
}
}
}
}
}
impact.logicTime += 1
}
//5=debuff削弱类
//逻辑参数1:改变的英雄属性id,读取AttributeData.tab表。
//逻辑参数2:改变的具体数值
//逻辑参数3:持续时间,单位回合(10)
//最终可实现的效果如敌人攻击减少X点持续10回合。
func (impact *Impact) ImpactLogic5() {
var (
pImpactInfo *ImpactInfo
pAttackInfo *AttackInfo
pSkillAttack *SkillAttack
pFightCell *FightCell
index int
pRoundInfo *FightRoundInfo
pFObjectInfo *FObjectInfo
)
index = InvalidId
pAttackInfo = impact.pCaster.GetAttackInfo()
if pAttackInfo != nil && pAttackInfo.IsValid() {
pSkillAttack = pAttackInfo.GetSkillAttack(impact.skillID)
if pSkillAttack != nil {
pImpactInfo = pSkillAttack.GetImpactInfo(impact.impactID)
if pImpactInfo != nil {
index = pImpactInfo.GetTargetIndex(impact.pHolder.GetGuid())
}
}
}
if impact.logicTime <= impact.life {
pRow, err := impact.GetImpactRow()
if err != nil {
panic(err)
}
impact.pHolder.ChangeEffect(EmAttribute(pRow.Param[0]), pRow.Param[1]*(-1), false)
if impact.startTime == impact.logicTime {
if pImpactInfo != nil && index >= 0 {
if EmAttribute(pRow.Param[0]) == EmAttributeHp {
impact.pHolder.SetHP(impact.pHolder.GetHP())
pImpactInfo.Hurts[index][0] = pRow.Param[1]
}
if EmAttribute(pRow.Param[0]) == EmAttributeMp {
pImpactInfo.Mp[index] = pRow.Param[1]
}
}
} else if impact.startTime == impact.logicTime {
pFightCell = impact.pHolder.GetFightCell()
pRoundInfo = pFightCell.GetRoundInfo()
pFObjectInfo = pRoundInfo.GetFObjectInfoByGuid(impact.pHolder.GetGuid())
if pFObjectInfo != nil {
for i := 0; i < pFObjectInfo.ImpactCount; i++ {
if pFObjectInfo.ImpactList[i] == impact.impactID {
if EmAttribute(pRow.Param[0]) == EmAttributeHp {
pFObjectInfo.ImpactHurt[i] = pRow.Param[1]
}
if EmAttribute(pRow.Param[0]) == EmAttributeMp {
pFObjectInfo.ImpactMP[i] = pRow.Param[1]
}
break
}
}
}
}
}
impact.logicTime += 1
}
func (impact Impact) ImpactLogic6() {
var (
pImpactInfo *ImpactInfo
pAttackInfo *AttackInfo
pSkillAttack *SkillAttack
nMagicAttack int
nAttack int
nDefend int
nDecay int
nDamage int
fConAttHurt int
pFightCell *FightCell
index int
)
index = InvalidId
pAttackInfo = impact.pCaster.GetAttackInfo()
if pAttackInfo != nil && pAttackInfo.IsValid() {
pSkillAttack = pAttackInfo.GetSkillAttack(impact.skillID)
if pSkillAttack != nil {
pImpactInfo = pSkillAttack.GetImpactInfo(impact.impactID)
if pImpactInfo != nil {
index = pImpactInfo.GetTargetIndex(impact.pHolder.GetGuid())
}
}
}
pFightCell = impact.pHolder.GetFightCell()
nMagicAttack = impact.pCaster.GetMagicAttack()
pRow, err := impact.GetImpactRow()
if err != nil {
panic(err)
}
nAttack = int(nMagicAttack*pRow.Param[0]/100 + pRow.Param[1])
if pFightCell.GetFightType() == EmTypeFightStair && impact.pCaster.IsAttacker() {
nAttack += int(nAttack * pFightCell.GetPlusAtt() / 100)
}
nDefend = impact.pHolder.GetMagicDefend()
nDecay = impact.pHolder.GetMagicHurtDecay()
nDamage = CalcDamage(nAttack, nDefend, nDecay)
nDamage = ChkMin(nDamage, 0)
//本次魔法攻击伤害=(自身当前经过连击计算后的魔法攻击-目标魔法防御)*(1-目标魔法伤害减免/100)
impact.pHolder.SetHP(impact.pHolder.GetHP() - nDamage)
if pImpactInfo != nil && index >= 0 {
pImpactInfo.Hurts[index][0] = nDamage
}
//连击
fConAttHurt = impact.pCaster.GetConAttHurt() / 100
for i := 1; i < impact.conAttTimes; i++ {
nAttack = int(nAttack * fConAttHurt)
nDamage = CalcDamage(nAttack, nDefend, nDecay)
nDamage = ChkMin(nDamage, 0)
impact.pHolder.SetHP(impact.pHolder.GetHP() - nDamage)
if pImpactInfo != nil && index >= 0 {
pImpactInfo.Hurts[index][i] = nDamage
}
}
}
func (impact *Impact) CleanUp() {
impact.impactID = InvalidId
impact.pHolder = nil
impact.pCaster = nil
impact.startTime = 0
impact.life = 0
impact.term = 0
impact.logicTime = 0
impact.conAttTimes = 0
}
func (impact *Impact) HeartBeat(uTime int) bool {
if !impact.IsValid() {
return false
}
if uTime == impact.logicTime {
pRow, err := impact.GetImpactRow()
if err != nil {
panic(err)
}
if pRow.LogicID >= 0 && pRow.LogicID < EmImpactLogicCount {
logicFunc := impact.LogicFuncArray[pRow.LogicID]
logicFunc()
}
}
if uTime >= impact.life {
impact.CleanUp()
}
return true
}