/
ability.py
3722 lines (3471 loc) · 136 KB
/
ability.py
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
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
import sys
from dice import *
import listener
from combat import *
import trap
import location
ROOT_FOLDER = "./res/images/icons/skills/"
FIGHTER_SKILLS = ROOT_FOLDER + "fighter_skills/"
THIEF_SKILLS = ROOT_FOLDER + "thief_skills/"
RANGER_SKILLS = ROOT_FOLDER + "ranger_skills/"
WIZARD_SKILLS = ROOT_FOLDER + "wizard_skills/"
ANARCHIST_SKILLS = ROOT_FOLDER + "anarchist_skills/"
ARCANE_ARCHER_SKILLS = ROOT_FOLDER + "arcane_archer_skills/"
ASSASSIN_SKILLS = ROOT_FOLDER + "assassin_skills/"
BATTLEMAGE_SKILLS = ROOT_FOLDER + "battlemage_skills/"
BARBARIAN_SKILLS = ROOT_FOLDER + "barbarian_skills/"
DRAGOON_SKILLS = ROOT_FOLDER + "dragoon_skills/"
DRUID_SKILLS = ROOT_FOLDER + "druid_skills/"
MARKSMAN_SKILLS = ROOT_FOLDER + "marksman_skills/"
NIGHTBLADE_SKILLS = ROOT_FOLDER + "nightblade_skills/"
NINJA_SKILLS = ROOT_FOLDER + "ninja_skills/"
SHADOW_SKILLS = ROOT_FOLDER + "shadow_skills/"
SORCERER_SKILLS = ROOT_FOLDER + "sorcerer_skills/"
SPELLSWORD_SKILLS = ROOT_FOLDER + "spellsword_skills/"
TACTICIAN_SKILLS = ROOT_FOLDER + "tactician_skills/"
TRICKSTER_SKILLS = ROOT_FOLDER + "trickster_skills/"
WEAPONMASTER_SKILLS = ROOT_FOLDER + "weaponmaster_skills/"
# ability.py
# Author: Devin Ekins -- G. Cube
#
# This module contains all Abilities used by players and monsters.
# Individual methods are not typically commented as they represent
# the functionality of individual abilities -- those abilities already have
# documentation on their functionality as detailed in the description
# on both the wiki and the dictionary containing the parameters of these
# functions.
class AbilityStub(object):
def __init__(self, name):
self.name = name
info = Ability.allAbilities[name]
self.text = 'TODO'
self.image = './res/images/icons/cubeforce.png'
rangeText = str(info['range'])
if info['range'] == -1:
rangeText = "Weapon Range"
cooldownText = "0"
if info['cooldown']:
cooldownText = `info['cooldown']`
if 'text' in info:
self.text = 'AP: ' + `info['APCost']` + ' Cooldown: ' + cooldownText + ' Range: ' + rangeText + \
"\n" + info['text']
if 'image' in info:
self.image = info['image']
class Ability(object):
def __init__(self, name, owner):
self.owner = owner
self.name = name
info = Ability.allAbilities[name]
self.level = info['level']
self.HPCost = info['HPCost']
self.APCost = info['APCost']
self.range = info['range']
rangeText = str(self.range)
if self.range == -1:
rangeText = "Weapon Range"
self.targetType = info['target']
self.action = info['action']
self.cooldown = info['cooldown']
cooldownText = "0"
if self.cooldown:
cooldownText = `self.cooldown`
self.checkFunction = info['checkFunction']
self.breakStealth = info['breakStealth']
if 'text' in info:
self.text = 'AP: ' + `self.APCost` + ' Cooldown: ' + cooldownText + ' Range: ' + rangeText + \
"\n" + info['text']
else:
self.text = 'No description yet.'
if 'image' in info:
self.image = info['image']
else:
self.image = './res/images/icons/cubeforce.png'
if name == "Melee Attack":
if owner.totalMeleeAttackAPCost <= 0:
self.APCost = 99
else:
self.APCost = owner.totalMeleeAttackAPCost
self.text = 'AP: ' + `self.APCost` + "\n" + "Basic Melee Attack"
elif name == "Ranged Attack":
if owner.totalRangedAttackAPCost <= 0:
self.APCost = 99
else:
self.APCost = owner.totalRangedAttackAPCost
self.text = 'AP: ' + `self.APCost` + "\n" + "Basic Ranged Attack"
if 'specialTargeting' in info:
self.specialTargeting = info['specialTargeting']
else:
self.specialTargeting = "DEFAULT"
if 'radius' in info:
self.radius = info['radius']
else:
self.radius = 0
if 'placesField' in info:
self.placesField = info['placesField']
else:
self.placesField = False
@staticmethod
def convertAbilityName(aName):
firstChar = aName[0].lower()
aName = "_" + firstChar + aName[1:]
aName = aName.replace(" ", "")
return aName
def canUse(self, target):
'''
target: Person (later, Location?)
'''
mod = 0 # dummy code
source = self.owner
if source.team == "Players" and not source.equippedItems.equippedWeapon:
return (False, "You cannot use any abilities without a weapon!!")
if source.AP < self.APCost - mod:
return (False, "Insufficient AP")
if self.targetType == "self" and self.owner is not target:
target = self.owner
messageCode = (True, "")
if self.checkFunction:
messageCode = self.checkFunction(self, target)
if not messageCode[0]:
return messageCode
if self.targetType == "self" and self.owner is not target:
return (False, "Ability is self-only, and the given target is not the user.")
if self.targetType == "hostile" and source.team == target.team:
return (False, "Cannot target own team with hostile ability.")
if self.targetType == "friendly" and source.team != target.team:
return (False, "Cannot target hostile with beneficial ability.")
# TODO: Modify inRange to accept a location object as well.
if not self.targetType == 'location' and not self.targetType == 'trap' and not source.inRange(target, self.range):
return (False, "Target is out of range.")
if source.onCooldown(self.name):
return (False, self.name + " is on Cooldown " + source.getCooldownTurns(self.name) +
" turns left.")
return (True, "")
def use(self, target):
''' Uses the given ability on or around the given target Person (Location?)
Performs a check if this is possible, but this is not where the canUse
check should be made. If caught here, it will raise an exception!'''
if self.canUse(target)[0]:
hpLoss = self.HPCost
if "Percent" in str(self.HPCost):
hpLoss = round(int(self.HPCost.split(" ")[0]) / 100.0 * self.owner.totalHP)
Combat.modifyResource(self.owner, "HP", -hpLoss)
Combat.modifyResource(self.owner, "AP", -self.APCost)
if self.cooldown:
Combat.applyCooldown(self.owner, self.name, self.cooldown)
self.action(self, target)
if self.owner.inStealth():
if Dice.rollBeneath(self.breakStealth):
Combat.removeStealth(self.owner)
if self.breakStealth < 100:
Combat.sendCombatMessage(self.owner.name + " broke stealth early!", self.owner, color='white')
else:
Combat.sendCombatMessage(self.owner.name + " exited stealth.", self.owner, color='white')
else:
print "WARNING: Ability failed late!"
def _basicAttack(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical")
Combat.basicAttack(source, target, hit)
def _basicMeleeAttackCheck(self, target):
source = self.owner
if source.usingWeapon("Melee"):
return (True, "")
return (False, "Must be using a melee weapon to perform: " + self.name)
def _basicRangedAttackCheck(self, target):
source = self.owner
if source.usingWeapon("Ranged"):
return (True, "")
return (False, "Must be using a ranged weapon to perform: " + self.name)
def _mightyBlow(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", modifier=-5)
Combat.basicAttack(source, target, hit, forceMod=1.5)
def _mightyBlowCheck(self, target):
if self.owner.usingWeapon("Melee"):
return (True, "")
return (False, self.name + " requires a Melee weapon.")
def _brace(self, target):
source = self.owner
duration = 1
Combat.addStatus(source, self.name, duration)
Combat.endTurn(source)
def _dash(self, target):
source = self.owner
Combat.resetMovementTiles(source, freeMove=True)
def _quickStrike(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", modifier=-12)
Combat.basicAttack(source, target, hit, forceMod=0.5)
def _quickStrikeCheck(self, target):
if self.owner.usingWeapon("Melee"):
return (True, "")
return (False, self.name + " requires a Melee weapon.")
def _preciseBlow(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", modifier=5, critMod=3)
Combat.basicAttack(source, target, hit)
def _preciseBlowCheck(self, target):
if self.owner.usingWeapon("Melee"):
return (True, "")
return (False, self.name + " requires a Melee weapon.")
def _thrust(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", modifier=1)
Combat.basicAttack(source, target, hit, elementOverride="Piercing")
def _thrustCheck(self, target):
if self.owner.usingWeapon("Sword"):
return (True, "")
return (False, "Must be using a sword to use " + self.name + ".")
def _clobber(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", modifier=-3)
Combat.basicAttack(source, target, hit, armorPenetrationMod=10, overallDamageMod=1.1)
if hit != "Miss" and target.size != "Huge" and target.size != "Large":
if Dice.rollBeneath(25):
duration = 1
Combat.addStatus(target, "Stun", duration)
def _clobberCheck(self, target):
if self.owner.usingWeapon("Club"):
return (True, "")
return (False, "Must be using a club to use " + self.name + ".")
def _backstab(self, target):
source = self.owner
critChance = 0
critMag = 0
accuracy = 0
if source.usingWeapon("Sword"):
critChance = 33
critMag = 1.65
if source.usingWeaponStyle("Single"):
accuracy = 9
elif source.usingWeapon("Knife"):
critChance = 50
critMag = 2
if source.usingWeaponStyle("Single"):
accuracy = 5
hit = Combat.calcHit(source, target, "Physical", modifier=accuracy, critMod=critChance)
if hit != "Critical Hit":
if source.usingWeaponStyle("Single"):
Combat.basicAttack(source, target, hit, overallDamageMod=1.5)
else:
Combat.basicAttack(source, target, hit, overallDamageMod=1.25)
else:
Combat.basicAttack(source, target, hit, criticalDamageMod=critMag)
def _backstabCheck(self, target):
source = self.owner
if not source.inStealth():
return (False, "Must be in stealth to perform " + self.name + " .")
if not Combat.inBackstabPosition(source, target):
return (False, "Must be in backstab position to perform " + self.name + " .")
if not source.usingWeapon("Sword") and not source.usingWeapon("Knife"):
return (False, "Must be using either swords or knives to preform " + self.name + " .")
return (True, "")
def _chainGrasp(self, target):
source = self.owner
chance = min(90, (source.totalCunning - target.totalCunning) * 9)
success = Dice.rollBeneath(chance)
if success:
Combat.sendCombatMessage("Success! (" + str(chance) + ")", source, color="darkorange", toAll=False)
duration = 3
Combat.addStatus(target, "Chain Grasp", duration)
else:
Combat.sendCombatMessage("Failed. (" + str(chance) + ")", source, color="darkorange", toAll=False)
def _chainGraspCheck(self, target):
if target.size == "Huge":
return (False, self.name + " cannot be used on Huge targets.")
return (True, "")
def _disarmTraps(self, target):
source = self.owner
Combat.disarmTraps(source)
def _agilePosition(self, target):
source = self.owner
duration = 1
Combat.addStatus(source, "Agile Position", duration)
Combat.endTurn(source)
def _agilePositionCheck(self, target):
return (True, "")
def _hitAndRun(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical")
Combat.basicAttack(source, target, hit, noCounter=True)
direction = target.cLocation.direction_to(source.cLocation)
choiceBase = source.cLocation
choiceA = choiceBase.move(direction, 2)
choiceB = choiceBase.move(direction, 1)
if Combat.gameServer.tile_is_open(choiceA, cPane=target.cPane):
Combat.instantMove(source, choiceA)
elif Combat.gameServer.tile_is_open(choiceB, cPane=target.cPane):
Combat.instantMove(source, choiceB)
def _feint(self, target):
source = self.owner
chance = min(80, (source.totalCunning - target.totalCunning) * 8)
success = Dice.rollBeneath(chance)
if success:
duration = 2
Combat.addStatus(target, "Feint", duration)
Combat.sendCombatMessage("Success! (" + str(chance) + ")", source, color="darkorange", toAll=False)
else:
Combat.sendCombatMessage("Failed. (" + str(chance) + ")", source, color="darkorange", toAll=False)
def _farSightedFocus(self, target):
source = self.owner
duration = 3
Combat.addStatus(source, "Far-Sighted Focus", duration)
def _farSightedFocusCheck(self, target):
return (True, "")
def _expertNotch(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", modifier=6)
Combat.basicAttack(source, target, hit)
def _expertNotchCheck(self, target):
source = self.owner
if not source.usingWeapon("Bow"):
return (False, "Must be using a bow to use " + self.name)
return (True, "")
def _tunnelVision(self, target):
source = self.owner
duration = 4
Combat.addStatus(source, "Tunnel Vision", duration)
def _tunnelVisionCheck(self, target):
return (True, "")
def _balm(self, target):
source = self.owner
healPercent = 18 + source.totalCunning / 10
Combat.healTarget(source, source, round(source.totalHP * healPercent * 0.01))
def _rapidReload(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", modifier=-8)
Combat.basicAttack(source, target, hit)
def _rapidReloadCheck(self, target):
source = self.owner
if source.usingWeapon("Crossbow"):
return (True, "")
return (False, "Must be using a Crossbow to use " + self.name + ".")
def _rangersAim(self, target):
source = self.owner
duration = 1
Combat.addStatus(source, "Ranger's Aim", duration)
def _shrapnelTrap(self, targetLocation):
source = self.owner
Combat.gameServer.pane[source.cPane].addTrap(targetLocation, trap.Trap("Shrapnel Trap", player=source, location=targetLocation))
source.record.recordTrapPlacement()
def _shrapnelTrapCheck(self, targetLocation):
source = self.owner
contentString = Combat.gameServer.pane[source.cPane].getTileContents(targetLocation)
if contentString == "Nothing" or contentString == "Trap-Friendly":
return (True, "")
if contentString == "Trap-Hostile":
return (False, "Something prevents you from placing your trap...")
if contentString == "Obstacle":
return (False, "Cannot place a trap on an obstacle.")
return (False, "TODO: Failed to catch a case...")
#if contentString == "Monster":
#return (False, "Cannot place a trap on a monster.")
# Handled in game.py
def _trapChaosCheck(self, target):
source = self.owner
if isinstance(target, location.Location):
contentString = Combat.gameServer.pane[source.cPane].getTileContents(target)
if contentString == "Nothing" or contentString == "Trap-Friendly":
return (True, "")
if contentString == "Trap-Hostile":
return (False, "Something prevents you from placing your trap...")
if contentString == "Obstacle":
return (False, "Cannot place a trap on an obstacle.")
return (False, "TODO: Failed to catch a case...")
else:
return (True, "")
def _shrapnelTrapAnarchist(self, target):
source = self.owner
source.record.recordTrapPlacement()
if isinstance(target, location.Location):
Combat.gameServer.pane[source.cPane].addTrap(target, trap.Trap("Shrapnel Trap", player=source, location=target))
else:
source.record.recordTrapChaos()
trapChaosBonusRating = 5 + source.totalCunning / 10
trapRating = int(16 * (1 + 0.015 * source.totalCunning) + source.bonusTrapRating + trapChaosBonusRating)
didHit = Dice.rollTrapHit(trapRating, target, True)
if didHit:
minDamage = int(5 * (1 + source.totalCunning * 0.017) * (1 + source.bonusTrapDamage * 0.01))
maxDamage = int(14 * (1 + source.totalCunning * 0.017) * (1 + source.bonusTrapDamage * 0.01))
element = "Piercing"
damage = Combat.calcDamage(source, target, minDamage, maxDamage, element, "Normal Hit")
Combat.lowerHP(target, damage)
source.record.recordTrapSuccess()
else:
source.record.recordTrapFailure()
Combat.sendCombatMessage(target.name + " evaded. (" +
`trapRating` + " vs. " + `target.totalTrapEvade` + ")",
source, color='orange')
source.record.recordTrapRemoval()
def _stickyTrap(self, targetLocation):
source = self.owner
Combat.gameServer.pane[source.cPane].addTrap(targetLocation, trap.Trap("Sticky Trap", player=source, location=targetLocation))
source.record.recordTrapPlacement()
def _stickyTrapAnarchist(self, target):
source = self.owner
source.record.recordTrapPlacement()
if isinstance(target, location.Location):
Combat.gameServer.pane[source.cPane].addTrap(target, trap.Trap("Sticky Trap", player=source, location=target))
else:
source.record.recordTrapChaos()
trapChaosBonusRating = 5 + source.totalCunning / 10
trapRating = int(24 * (1 + 0.007 * source.totalCunning) + source.bonusTrapRating + trapChaosBonusRating)
didHit = Dice.rollTrapHit(trapRating, target, True)
if didHit:
duration = 6
Combat.addStatus(target, "Sticky Trap", duration)
Combat.sendCombatMessage("Lowered monster movement speed.", self.owner, color="orange")
source.record.recordTrapSuccess()
else:
source.record.recordTrapFailure()
Combat.sendCombatMessage(target.name + " evaded. (" +
`trapRating` + " vs. " + `target.totalTrapEvade` + ")",
source, color='orange')
source.record.recordTrapRemoval()
def _boulderPitTrap(self, targetLocation):
source = self.owner
Combat.gameServer.pane[source.cPane].addTrap(targetLocation, trap.Trap("Boulder Pit Trap", player=source, location=targetLocation))
source.record.recordTrapPlacement()
def _boulderPitTrapAnarchist(self, target):
source = self.owner
source.record.recordTrapPlacement()
if isinstance(target, location.Location):
Combat.gameServer.pane[source.cPane].addTrap(target, trap.Trap("Boulder Pit Trap", player=source, location=target))
else:
source.record.recordTrapChaos()
trapChaosBonusRating = 5 + source.totalCunning / 10
trapRating = int(30 * (1 + 0.007 * source.totalCunning) + source.bonusTrapRating + trapChaosBonusRating)
didHit = Dice.rollTrapHit(trapRating, target, True)
if didHit:
minDamage = int(4 * (1 + source.totalCunning * 0.02) * (1 + source.bonusTrapDamage * 0.01))
maxDamage = int(11 * (1 + source.totalCunning * 0.02) * (1 + source.bonusTrapDamage * 0.01))
element = "Bludgeoning"
damage = Combat.calcDamage(source, target, minDamage, maxDamage, element, "Normal Hit")
Combat.lowerHP(target, damage)
if (target.size == "Small" or target.size == "Medium") and Dice.rollBeneath(30):
Combat.addStatus(target, "Stun", duration=2)
Combat.sendCombatMessage("Stunned " + target.name, source, color="orange")
source.record.recordTrapSuccess()
else:
source.record.recordTrapFailure()
Combat.sendCombatMessage(target.name + " evaded. (" +
`trapRating` + " vs. " + `target.totalTrapEvade` + ")",
source, color='orange')
source.record.recordTrapRemoval()
def _magicGuard(self, target):
source = self.owner
duration = 1
Combat.addStatus(source, self.name, duration)
Combat.endTurn(source)
def _gather(self, target):
source = self.owner
duration = 1
Combat.addStatus(source, self.name, duration)
def _reverseHex(self, target):
Combat.removeStatusOfType(target, "Debuff")
def _spellSight(self, target):
source = self.owner
duration = -1
Combat.addStatus(source, "Spell Sight", duration)
newListener = listener.Listener(self, self.owner, [], Ability._spellSightDisable, ['Outgoing Spell Cast Complete', 'Outgoing Ranged Attack Complete'])
source.listeners.append(newListener)
@staticmethod
def _spellSightDisable(cls, target, **kwargs):
Combat.removeStatus(target, "Spell Sight")
toRemove = None
for x in target.listeners:
if x.action == Ability._spellSightDisable:
toRemove = x
if toRemove:
target.listeners.remove(toRemove)
def _berserkerRage(self, target):
duration = 6
Combat.addStatus(self.owner, self.name, duration)
def _berserkerRageCheck(self, target):
source = self.owner
if source.HP <= source.totalHP * 0.75:
return (True, "")
return (False, "Too much HP to use " + self.name)
def _sacrificialStrike(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", critMod=2)
Combat.basicAttack(source, target, hit, forceMod=1.40)
def _sacrificialStrikeCheck(self, target):
source = self.owner
if source.HP < source.totalHP * 0.05 + 1:
return (False, "Insufficient HP to use " + self.name)
if source.usingWeapon("Melee"):
return (True, "")
else:
return (False, self.name + " requires a melee weapon.")
def _desperateStrike(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", modifier=10, critMod=20)
Combat.basicAttack(source, target, hit, forceMod=2.5, armorPenetrationMod=10)
doStun = Dice.rollPresetChance(source, target, "Occasional")
Combat.addStatus(target, "Stun", duration=1, hitValue=hit, chance=doStun)
def _desperateStrikeCheck(self, target):
source = self.owner
if source.HP > source.totalHP * 0.25:
return (False, "Excess HP; cannot use " + self.name)
if source.usingWeapon("Melee"):
return (True, "")
else:
return (False, self.name + " requires a melee weapon.")
def _bloodOfTheAncients(self, target):
source = self.owner
Combat.healTarget(source, source, round(source.totalHP * 0.15))
duration = 1
Combat.addStatus(source, "Blood of the Ancients", duration)
def _bloodOfTheAncientsCheck(self, target):
source = self.owner
if source.HP < source.totalHP:
return (True, "")
return (False, "HP already at maximum; cannot use: " + self.name + " .")
def _crushArmor(self, target):
source = self.owner
damageBonusPercent = 0
if (source.usingWeaponStyle("Two-Handed") or source.usingWeaponStyle("Dual Same Type")) and \
source.usingWeapon("Club"):
damageBonusPercent = 0.25
attackBonus = 0
if source.HP > source.totalHP * 0.75:
attackBonus = 5
hit = Combat.calcHit(source, target, "Physical", modifier=attackBonus)
Combat.basicAttack(source, target, hit, overallDamageMod=(0.75 + damageBonusPercent))
if hit != "Miss":
duration = 3
Combat.addStatus(target, "Crush Armor", duration)
def _crushArmorCheck(self, target):
source = self.owner
if source.usingWeapon("Melee"):
return (True, "")
return (False, "Must be using a melee weapon to use " + self.name)
# Dragoon
def _jumpAttack(self, target):
source = self.owner
landingZone = Combat.getRandomAdjacentLocation(target.cPane, target.cLocation)
Combat.instantMove(source, landingZone)
hit = Combat.calcHit(source, target, "Physical")
Combat.basicAttack(source, target, hit, overallDamageMod=1.75, noCounter=True)
if hit:
for t in Combat.getAOETargets(source.cPane, source.cLocation, radius=1, selectMonsters=True):
Combat.basicAttack(source, t, "Normal Hit", overallDamageMod=0.25, ignoreOnHitEffects=True,
elementOverride="Bludgeoning", noCounter=True)
def _jumpAttackCheck(self, target):
source = self.owner
if not source.usingWeapon("Polearm"):
return (False, "Must have a polearm equipped to use: " + self.name)
if Combat.getRandomAdjacentLocation(target.cPane, target.cLocation):
return (True, "")
return (False, "No valid landing zones exist near target; cannot use " + self.name)
def _diagonalThrusts(self, target):
source = self.owner
targetList = Combat.getDiagonalTargets(source.cPane, source.cLocation)
for t in targetList:
hit = Combat.calcHit(source, t, "Physical")
Combat.basicAttack(source, t, hitType=hit, forceMod=1.20, criticalDamageMod=1.05)
def _diagonalThrustsCheck(self, target):
source = self.owner
if source.usingWeapon("Polearm"):
return (True, "")
return (False, "Must be using a polearm to use: " + self.name)
def _longReach(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical")
Combat.basicAttack(source, target, hit, noCounter=True)
def _longReachCheck(self, target):
source = self.owner
if source.usingWeapon("Polearm"):
return (True, "")
return (False, "Must be using a polearm to use: " + self.name)
def _crushingJumpAttack(self, target):
source = self.owner
landingZone = Combat.getRandomAdjacentLocation(target.cPane, target.cLocation)
Combat.instantMove(source, landingZone)
hit = Combat.calcHit(source, target, "Physical")
Combat.basicAttack(source, target, hit, overallDamageMod=2.0, noCounter=True)
if hit:
for t in Combat.getAOETargets(source.cPane, source.cLocation, radius=1, selectMonsters=True):
Combat.basicAttack(source, t, "Normal Hit", overallDamageMod=0.30, ignoreOnHitEffects=True,
elementOverride="Bludgeoning", noCounter=True)
if target.size != "Huge" and Dice.rollPresetChance(source, target, "Rare"):
Combat.addStatus(target, "Stun", 1)
def _spearPierce(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", modifier=-2)
Combat.basicAttack(source, target, hit)
if hit != "Miss" and Dice.rollPresetChance(source, target, "Reliable"):
duration = 3
magnitude = 10
Combat.addStatus(target, "Bleeding", duration, magnitude)
def _spearPierceCheck(self, target):
if self.owner.usingWeapon("Polearm"):
return (True, "")
return (False, "Must be using a polearm to use: " + self.name)
#Weapon Master
def _shieldDeflection(self, target):
source = self.owner
duration = 2
Combat.addStatus(target, "Shield Deflection", duration)
def _shieldDeflectionCheck(self, target):
source = self.owner
if source.usingShield("Heavy"):
return (True, "")
return (False, "Must be using a Heavy Shield to use: " + self.name)
def _shieldBash(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical")
Combat.basicAttack(source, target, hit, elementOverride="Bludgeoning", overallDamageMod=0.30)
if hit != "Miss":
chance = 80
if target.size == "Large":
chance = 30
elif target.size == "Huge":
chance = 0
if target.totalDR >= 20:
chance = 0
if Dice.rollSuccess(chance) == "Normal Hit":
duration = 1
Combat.addStatus(target, "Stun", duration)
Combat.sendCombatMessage("Stun Success! (" + str(chance) + ")", source, color="darkorange", toAll=False)
elif chance !=0:
Combat.sendCombatMessage("Failed to Stun! (" + str(chance) + ")", source, color="darkorange", toAll=False)
else:
Combat.sendCombatMessage("Target Immune to Shield Bash stun.", source, color="darkorange", toAll=False)
def _shieldBashCheck(self, target):
source = self.owner
if source.usingShield():
return (True, "")
return (False, "Must be using a Shield to use: " + self.name)
def _trueFriend(self, target):
source = self.owner
bonusDodge = False
if source.usingShield():
selfMagnitude = 35
friendMagnitude = 30
else:
selfMagnitude = 30
friendMagnitude = 25
bonusDodge = True
duration = 1
Combat.addStatus(source, "True Friend", duration, selfMagnitude)
for ally in Combat.getAOETargets(source.cPane, source.cLocation, radius=1, selectMonsters=False):
if ally != source:
Combat.addStatus(ally, "True Friend", duration, friendMagnitude)
if bonusDodge:
Combat.addStatus(ally, "True Friend Parry", duration)
Combat.endTurn(source)
# Spellsword
def _martialMode(self, target):
source = self.owner
duration = -1
Combat.addStatus(target, "Martial Mode", duration)
newListener = listener.Listener(self, self.owner, [], Ability._martialModeDisable, ['Player MP level changed'])
source.listeners.append(newListener)
def _martialModeCheck(self, target):
source = self.owner
if source.MP > source.totalMP * 0.15:
return (False, "Too much MP remaining to use " + self.name)
else:
return (True, "")
@staticmethod
def _martialModeDisable(cls, target, reverse=False, percent=None):
if percent > 0.15:
Combat.removeStatus(target, "Martial Mode")
toRemove = None
for x in target.listeners:
if x.action == Ability._martialModeDisable:
toRemove = x
if toRemove:
target.listeners.remove(toRemove)
def _splashMagic(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical")
Combat.basicAttack(source, target, hit)
if hit != "Miss":
stat = None
for status in source.statusList:
if status.categoryList and "Weapon Enchantment" in status.categoryList:
stat = status
break
element = stat.element
if not element or element == "None":
element = "Arcane"
allTargets = Combat.getAOETargets(source.cPane, target.cLocation, radius=1)
damage = 3 + source.totalSpellpower / 3
for tar in allTargets:
tarDamage = Combat.calcDamage(source, tar, damage, damage, element, "Normal Hit")
Combat.lowerHP(tar, tarDamage)
def _splashMagicCheck(self, target):
source = self.owner
if source.hasWeaponEnchant():
return (True, "")
return (False, "Must have a Spellsword enchantment active to use " + self.name)
def _rebound(self, target):
source = self.owner
duration = 3
Combat.addStatus(source, "Rebound", 3) # For display only.
newListener = listener.Listener(self, self.owner, ['Outgoing Spell Resisted'], Ability._reboundEffect, [])
source.listeners.append(newListener)
@staticmethod
def _reboundEffect(cls, target, reverse=False, spell=None):
if target.hasStatus("Rebound"):
if spell.MPCost >= 5:
Combat.modifyResource(target, "MP", 5)
else:
toRemove = None
for x in target.listeners:
if x.action == Ability._reboundEffect:
toRemove = x
if toRemove:
target.listeners.remove(toRemove)
# Anarchist
def _followUp(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical")
Combat.basicAttack(source, target, hit, armorPenetrationMod=20)
def _followUpCheck(self, target):
source = self.owner
if not source.usingWeapon("Melee"):
return (False, "Must be using a melee weapon to use " + self.name)
if source.record._currentTurnTrapChaos > 0:
return (True, "")
return (False, "Must use trap chaos before using " + self.name)
def _faceShot(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", ignoreMeleeBowPenalty=True, critMod=5)
Combat.basicAttack(source, target, hit, criticalDamageMod=1.15, armorPenetrationMod=5)
def _faceShotCheck(self, target):
source = self.owner
if not source.usingWeapon("Ranged"):
return (False, "Must be using a ranged weapon in melee range to use " + self.name)
if source.record._currentTurnTrapChaos > 0:
return (True, "")
return (False, "Must use trap chaos before using " + self.name)
def _trapWorry(self, target):
source = self.owner
successChance = min(80, 20 + (10 * (source.totalCunning - target.totalCunning)))
if Dice.rollBeneath(successChance):
duration = 3
Combat.addStatus(target, "Trap Worry", duration)
Combat.sendCombatMessage("Success! (" + `successChance` + ")", source, color="darkorange", toAll=False)
else:
Combat.sendCombatMessage("Failed. (" + `successChance` + ")", source, color="darkorange", toAll=False)
def _harmlessGrin(self, target):
source = self.owner
successChance = min(80, 10 + (10 * (source.totalCunning - target.totalCunning)))
if Dice.rollBeneath(successChance):
duration = 3
Combat.addStatus(target, "Harmless Grin", duration)
Combat.sendCombatMessage("Success! (" + `successChance` + ")", source, color="darkorange", toAll=False)
else:
Combat.sendCombatMessage("Failed. (" + `successChance` + ")", source, color="darkorange", toAll=False)
def _explosiveTrap(self, target):
source = self.owner
source.record.recordTrapPlacement()
if isinstance(target, location.Location):
Combat.gameServer.pane[source.cPane].addTrap(target, trap.Trap("Explosive Trap", player=source, location=target))
else:
source.record.recordTrapChaos()
trapChaosBonusRating = 5 + source.totalCunning / 10
trapRating = int(25 * (1 + 0.01 * source.totalCunning) + source.bonusTrapRating + trapChaosBonusRating)
didHit = Dice.rollTrapHit(trapRating, target, True)
if didHit:
minDamage = int(9 * (1 + source.totalCunning * 0.01) * (1 + source.bonusTrapDamage * 0.01))
maxDamage = int(18 * (1 + source.totalCunning * 0.01) * (1 + source.bonusTrapDamage * 0.01))
element = "Fire"
damage = Combat.calcDamage(source, target, minDamage, maxDamage, element, "Normal Hit")
Combat.lowerHP(target, damage)
source.record.recordTrapSuccess()
splashMin = int(minDamage * 0.75)
splashMax = int(maxDamage * 0.75)
targetGroup = Combat.getAOETargets(target.cPane, target.cLocation, radius=1)
for tar in targetGroup:
dam = Combat.calcDamage(source, tar, splashMin, splashMax, element, "Normal Hit")
Combat.lowerHP(tar, dam)
else:
source.record.recordTrapFailure()
Combat.sendCombatMessage(target.name + " evaded. (" +
`trapRating` + " vs. " + `target.totalTrapEvade` + ")",
source, color='orange')
source.record.recordTrapRemoval()
def _grabBag(self, target):
source = self.owner
allTargets = Combat.getAOETargets(source.cPane, source.cLocation, radius=1)
for tar in allTargets:
sizeFactor = 0
if tar.size == "Large":
sizeFactor = 0.25
if tar.size == "Huge":
sizeFactor = 0.50
minDam = int(2 * (1 + sizeFactor))
maxDam = int(17 * (1 + sizeFactor))
dam = Combat.calcDamage(source, tar, minDam, maxDam, "Piercing", "Normal Hit", scalesWith="Cunning", scaleFactor=0.01)
Combat.lowerHP(tar, dam)
# Marksman
def _cuspOfEscape(self, target):
source = self.owner
hitType = Combat.calcHit(source, target, "Physical", modifier=12, critMod=12)
Combat.basicAttack(source, target, hitType, criticalDamageMod=1.12)
def _cuspOfEscapeCheck(self, target):
source = self.owner
if source.usingWeapon("Melee"):
return (False, "Must be using a ranged weapon for: " + self.name)
if source.cLocation.distance(target.cLocation) != source.attackRange:
return (False, "Target must be exactly " + `source.attackRange` + " tiles away.")
return (True, "")
def _huntersShot(self, target):
source = self.owner
hitType = Combat.calcHit(source, target, "Physical", modifier=-5, critMod=5)
sizeMod = 1.0
if target.size == "Huge" or target.size == "Large":
sizeMod = 1.05
Combat.basicAttack(source, target, hitType, criticalDamageMod=1.2, mightMod=6, overallDamageMod=sizeMod)
def _huntersShotCheck(self, target):
source = self.owner
if source.usingWeapon("Melee"):
return (False, "Must be using a ranged weapon for: " + self.name)
return (True, "")
def _hotArrow(self, target):
source = self.owner
hitType = Combat.calcHit(source, target, "Physical", modifier=-1)
Combat.basicAttack(source, target, hitType)
fireBase = 3 + source.totalCunning / 8
fireDamage = Combat.calcDamage(source, target, fireBase, fireBase, "Fire", hitType)
Combat.lowerHP(target, fireDamage)
def _hotArrowCheck(self, target):
source = self.owner
if not source.usingWeapon("Bow") and not source.usingWeapon("Crossbow"):
return (False, "Must be using a bow or crossbow to use " + self.name)
return (True, "")
def _hotBullet(self, target):
source = self.owner
hitType = Combat.calcHit(source, target, "Physical")
Combat.basicAttack(source, target, hitType, criticalDamageMod=1.1)
fireBase = 8 + source.totalCunning / 6
fireDamage = Combat.calcDamage(source, target, fireBase, fireBase, "Fire", hitType)
Combat.lowerHP(target, fireDamage)
def _hotBulletCheck(self, target):
source = self.owner
if source.usingWeapon("Sling"):
return (True, "")
return (False, "Must be using a sling to use " + self.name)
def _suppressingFire(self, target):
source = self.owner
duration = 4
Combat.addStatus(source, "Suppressing Fire", duration)
def _smokingProjectile(self, target):
source = self.owner
hit = Combat.calcHit(source, target, "Physical", modifier=5)
Combat.basicAttack(source, target, hit, overallDamageMod=0.0)
fireDam = Combat.calcDamage(source, target, 2, 10, "Fire", hit, scalesWith="Cunning", scaleFactor=0.03)
duration = 4
if hit != "Miss":
Combat.addStatus(target, "Smoking Projectile", duration=4, magnitude=fireDam)
def _smokingProjectileCheck(self, target):
source = self.owner
if source.usingWeapon("Ranged"):
return (True, "")
return (False, "Must be using a ranged weapon to use " + self.name)
# Thief
def _stealth(self, target):
source = self.owner
newAPCost = 6
if source.characterClass == "Assassin":
newAPCost = 8