-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBachTuoc.cs
More file actions
624 lines (543 loc) · 9.98 KB
/
BachTuoc.cs
File metadata and controls
624 lines (543 loc) · 9.98 KB
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
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
using System;
public class BachTuoc : Mob, IMapObject
{
public static Image shadowBig = GameCanvas.loadImage("/mainImage/shadowBig.png");
public static EffectData data;
public int xTo;
public int yTo;
public bool haftBody;
public bool change;
private Mob mob1;
public new int xSd;
public new int ySd;
private bool isOutMap;
private int wCount;
public new bool isShadown = true;
private int tick;
private int frame;
public new static Image imgHP = GameCanvas.loadImage("/mainImage/myTexture2dmobHP.png");
private bool wy;
private int wt;
private int fy;
private int ty;
public new int typeSuperEff;
private Char focus;
private bool flyUp;
private bool flyDown;
private int dy;
public bool changePos;
private int tShock;
public new bool isBusyAttackSomeOne = true;
private int tA;
private Char[] charAttack;
private int[] dameHP;
private sbyte type;
public new int[] stand = new int[12]
{
0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1
};
public int[] movee = new int[12]
{
0, 0, 0, 2, 2, 2, 3, 3, 3, 4,
4, 4
};
public new int[] attack1 = new int[12]
{
0, 0, 0, 4, 4, 4, 5, 5, 5, 6,
6, 6
};
public new int[] attack2 = new int[17]
{
0, 0, 0, 7, 7, 7, 8, 8, 8, 9,
9, 9, 10, 10, 10, 11, 11
};
public new int[] hurt = new int[4] { 1, 1, 7, 7 };
private bool shock;
private sbyte[] cou = new sbyte[2] { -1, 1 };
public new Char injureBy;
public new bool injureThenDie;
public new Mob mobToAttack;
public new int forceWait;
public new bool blindEff;
public new bool sleepEff;
public BachTuoc(int id, short px, short py, int templateID, int hp, int maxHp, int s)
{
mobId = id;
xFirst = (x = px + 20);
yFirst = (y = py);
xTo = x;
yTo = y;
base.maxHp = maxHp;
base.hp = hp;
templateId = templateID;
w_hp_bar = 100;
h_hp_bar = 6;
len = w_hp_bar;
updateHp_bar();
getDataB();
status = 2;
}
public void getDataB()
{
data = null;
data = new EffectData();
string patch = "/x" + mGraphics.zoomLevel + "/effectdata/" + 108 + "/data";
try
{
data.readData2(patch);
data.img = GameCanvas.loadImage("/effectdata/" + 108 + "/img.png");
}
catch (Exception)
{
Service.gI().requestModTemplate(templateId);
}
w = data.width;
h = data.height;
}
public override void setBody(short id)
{
changBody = true;
smallBody = id;
}
public override void clearBody()
{
changBody = false;
}
public new static bool isExistNewMob(string id)
{
for (int i = 0; i < Mob.newMob.size(); i++)
{
string text = (string)Mob.newMob.elementAt(i);
if (text.Equals(id))
{
return true;
}
}
return false;
}
public new void checkFrameTick(int[] array)
{
tick++;
if (tick > array.Length - 1)
{
tick = 0;
}
frame = array[tick];
}
private void updateShadown()
{
int num = TileMap.size;
xSd = x;
wCount = 0;
if (ySd <= 0 || TileMap.tileTypeAt(xSd, ySd, 2))
{
return;
}
if (TileMap.tileTypeAt(xSd / num, ySd / num) == 0)
{
isOutMap = true;
}
else if (TileMap.tileTypeAt(xSd / num, ySd / num) != 0 && !TileMap.tileTypeAt(xSd, ySd, 2))
{
xSd = x;
ySd = y;
isOutMap = false;
}
while (isOutMap && wCount < 10)
{
wCount++;
ySd += 24;
if (TileMap.tileTypeAt(xSd, ySd, 2))
{
if (ySd % 24 != 0)
{
ySd -= ySd % 24;
}
break;
}
}
}
private void paintShadow(mGraphics g)
{
int num = TileMap.size;
g.drawImage(shadowBig, xSd, yFirst, 3);
g.setClip(GameScr.cmx, GameScr.cmy - GameCanvas.transY, GameScr.gW, GameScr.gH + 2 * GameCanvas.transY);
}
public new void updateSuperEff()
{
}
public override void update()
{
if (!isUpdate())
{
return;
}
updateShadown();
switch (status)
{
case 2:
updateMobStandWait();
break;
case 3:
updateMobAttack();
break;
case 5:
timeStatus = 0;
updateMobWalk();
break;
case 6:
timeStatus = 0;
p1++;
y += p1;
if (y >= yFirst)
{
y = yFirst;
p1 = 0;
status = 5;
}
break;
case 7:
updateInjure();
break;
case 0:
case 1:
updateDead();
break;
case 4:
break;
}
}
private void updateDead()
{
checkFrameTick(stand);
if (GameCanvas.gameTick % 5 == 0)
{
ServerEffect.addServerEffect(167, Res.random(x - getW() / 2, x + getW() / 2), Res.random(getY() + getH() / 2, getY() + getH()), 1);
}
if (x != xTo || y != yTo)
{
x += (xTo - x) / 4;
y += (yTo - y) / 4;
}
}
public new void setInjure()
{
}
public new void setAttack(Char cFocus)
{
isBusyAttackSomeOne = true;
mobToAttack = null;
base.cFocus = cFocus;
p1 = 0;
p2 = 0;
status = 3;
tick = 0;
dir = ((cFocus.cx > x) ? 1 : (-1));
int cx = cFocus.cx;
int cy = cFocus.cy;
if (Res.abs(cx - x) < w * 2 && Res.abs(cy - y) < h * 2)
{
if (x < cx)
{
x = cx - w;
}
else
{
x = cx + w;
}
p3 = 0;
}
else
{
p3 = 1;
}
}
private bool isSpecial()
{
if ((templateId >= 58 && templateId <= 65) || templateId == 67 || templateId == 68)
{
return true;
}
return false;
}
private void updateInjure()
{
}
private void updateMobStandWait()
{
checkFrameTick(stand);
if (x != xTo || y != yTo)
{
x += (xTo - x) / 4;
y += (yTo - y) / 4;
}
}
public void setFly()
{
status = 4;
flyUp = true;
}
public void setAttack(Char[] cAttack, int[] dame, sbyte type)
{
charAttack = cAttack;
dameHP = dame;
this.type = type;
status = 3;
}
public new void updateMobAttack()
{
if (type == 3)
{
if (tick == attack1.Length - 1)
{
status = 2;
}
dir = ((x < charAttack[0].cx) ? 1 : (-1));
checkFrameTick(attack1);
x += (charAttack[0].cx - x) / 4;
y += (charAttack[0].cy - y) / 4;
xTo = x;
if (tick == 8)
{
for (int i = 0; i < charAttack.Length; i++)
{
charAttack[i].doInjure(dameHP[i], 0, isCrit: false, isMob: false);
ServerEffect.addServerEffect(102, charAttack[i].cx, charAttack[i].cy, 1);
}
}
}
if (type != 4)
{
return;
}
if (tick == attack2.Length - 1)
{
status = 2;
}
dir = ((x < charAttack[0].cx) ? 1 : (-1));
checkFrameTick(attack2);
if (tick == 8)
{
for (int j = 0; j < charAttack.Length; j++)
{
charAttack[j].doInjure(dameHP[j], 0, isCrit: false, isMob: false);
ServerEffect.addServerEffect(102, charAttack[j].cx, charAttack[j].cy, 1);
}
}
}
public new void updateMobWalk()
{
checkFrameTick(movee);
x += ((x >= xTo) ? (-2) : 2);
y = yTo;
dir = ((x < xTo) ? 1 : (-1));
if (Res.abs(x - xTo) <= 1)
{
x = xTo;
status = 2;
}
}
public new bool isPaint()
{
if (x < GameScr.cmx)
{
return false;
}
if (x > GameScr.cmx + GameScr.gW)
{
return false;
}
if (y < GameScr.cmy)
{
return false;
}
if (y > GameScr.cmy + GameScr.gH + 30)
{
return false;
}
if (status == 0)
{
return false;
}
return true;
}
public new bool isUpdate()
{
if (status == 0)
{
return false;
}
return true;
}
public new bool checkIsBoss()
{
if (isBoss || levelBoss > 0)
{
return true;
}
return false;
}
public override void paint(mGraphics g)
{
if (data == null || isHide)
{
return;
}
if (isMafuba)
{
if (!changBody)
{
data.paintFrame(g, frame, xMFB, yMFB, (dir != 1) ? 1 : 0, 2);
}
else
{
SmallImage.drawSmallImage(g, smallBody, xMFB, yMFB, (dir != 1) ? 2 : 0, mGraphics.BOTTOM | mGraphics.HCENTER);
}
return;
}
if (isShadown && status != 0)
{
paintShadow(g);
}
g.translate(0, GameCanvas.transY);
if (!changBody)
{
data.paintFrame(g, frame, x, y + fy, (dir != 1) ? 1 : 0, 2);
}
else
{
SmallImage.drawSmallImage(g, smallBody, x, y + fy - 9, (dir != 1) ? 2 : 0, mGraphics.BOTTOM | mGraphics.HCENTER);
}
g.translate(0, -GameCanvas.transY);
int imageWidth = mGraphics.getImageWidth(imgHPtem);
int imageHeight = mGraphics.getImageHeight(imgHPtem);
int num = imageWidth;
int num2 = imageWidth;
int num3 = x - imageWidth;
int num4 = y - h - 5;
int num5 = imageWidth * 2 * per / 100;
if (num5 > num)
{
num2 = num5 - num;
if (num2 <= 0)
{
num2 = 0;
}
}
else
{
num = num5;
num2 = 0;
}
g.drawImage(GameScr.imgHP_tm_xam, num3, num4, mGraphics.TOP | mGraphics.LEFT);
g.drawImage(GameScr.imgHP_tm_xam, num3 + imageWidth, num4, mGraphics.TOP | mGraphics.LEFT);
g.drawRegion(imgHPtem, 0, 0, num, imageHeight, 0, num3, num4, mGraphics.TOP | mGraphics.LEFT);
g.drawRegion(imgHPtem, 0, 0, num2, imageHeight, 0, num3 + imageWidth, num4, mGraphics.TOP | mGraphics.LEFT);
if (shock)
{
tShock++;
Effect me = new Effect((type != 2) ? 22 : 19, x + tShock * 50, y + 25, 2, 1, -1);
EffecMn.addEff(me);
Effect me2 = new Effect((type != 2) ? 22 : 19, x - tShock * 50, y + 25, 2, 1, -1);
EffecMn.addEff(me2);
if (tShock == 50)
{
tShock = 0;
shock = false;
}
}
}
public new int getHPColor()
{
return 16711680;
}
public new void startDie()
{
hp = 0;
injureThenDie = true;
hp = 0;
status = 1;
p1 = -3;
p2 = -dir;
p3 = 0;
}
public new void attackOtherMob(Mob mobToAttack)
{
this.mobToAttack = mobToAttack;
isBusyAttackSomeOne = true;
cFocus = null;
p1 = 0;
p2 = 0;
status = 3;
tick = 0;
dir = ((mobToAttack.x > x) ? 1 : (-1));
int num = mobToAttack.x;
int num2 = mobToAttack.y;
if (Res.abs(num - x) < w * 2 && Res.abs(num2 - y) < h * 2)
{
if (x < num)
{
x = num - w;
}
else
{
x = num + w;
}
p3 = 0;
}
else
{
p3 = 1;
}
}
public new int getX()
{
return x;
}
public new int getY()
{
return y - 40;
}
public new int getH()
{
return 40;
}
public new int getW()
{
return 40;
}
public new void stopMoving()
{
if (status == 5)
{
status = 2;
p1 = (p2 = (p3 = 0));
forceWait = 50;
}
}
public new bool isInvisible()
{
return status == 0 || status == 1;
}
public new void removeHoldEff()
{
if (holdEffID != 0)
{
holdEffID = 0;
}
}
public new void removeBlindEff()
{
blindEff = false;
}
public new void removeSleepEff()
{
sleepEff = false;
}
public new void move(short xMoveTo)
{
xTo = xMoveTo;
status = 5;
}
}