forked from LuminariMUD/Luminari-Source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathact.offensive.c
executable file
·9035 lines (7650 loc) · 251 KB
/
act.offensive.c
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
/**************************************************************************
* File: act.offensive.c Part of LuminariMUD *
* Usage: Player-level commands of an offensive nature. *
* *
* All rights reserved. See license for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/
#include <zconf.h>
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "spells.h"
#include "act.h"
#include "fight.h"
#include "mud_event.h"
#include "constants.h"
#include "spec_procs.h"
#include "class.h"
#include "mudlim.h"
#include "actions.h"
#include "actionqueues.h"
#include "assign_wpn_armor.h"
#include "feats.h"
#include "missions.h"
#include "domains_schools.h"
#include "encounters.h"
#include "constants.h"
#include "spec_procs.h" /* for is_wearing() */
/* externs */
extern char cast_arg2[MAX_INPUT_LENGTH];
/* defines */
#define RAGE_AFFECTS 7
#define SACRED_FLAMES_AFFECTS 1
#define INNER_FIRE_AFFECTS 6
#define D_STANCE_AFFECTS 4
/**** Utility functions *******/
// Centralize the rage bonus calculation logic.
int get_rage_bonus(struct char_data *ch)
{
int bonus;
if (!ch)
return 0;
if (IS_NPC(ch) || IS_MORPHED(ch))
{
bonus = (GET_LEVEL(ch) / 3) + 3;
}
else
{
bonus = 4;
if (!IS_NPC(ch) && HAS_FEAT(ch, FEAT_GREATER_RAGE))
bonus += 2;
if (!IS_NPC(ch) && HAS_FEAT(ch, FEAT_MIGHTY_RAGE))
bonus += 3;
if (!IS_NPC(ch) && HAS_FEAT(ch, FEAT_INDOMITABLE_RAGE))
bonus += 3;
}
return bonus;
}
/* simple function to check whether ch has a piercing weapon, has 3 modes:
wield == 1 -- primary one hand weapon
wield == 2 -- off hand weapon
wield == 3 -- two hand weapon
*/
/* NOTE - this is probably deprecated by the IS_PIERCE() macro */
bool has_piercing_weapon(struct char_data *ch, int wield)
{
if (!ch)
return FALSE;
if (wield < 1 || wield > 3)
return FALSE;
if (wield == 1 && GET_EQ(ch, WEAR_WIELD_1) &&
IS_PIERCE(GET_EQ(ch, WEAR_WIELD_1)))
{
return TRUE;
}
if (wield == 2 && GET_EQ(ch, WEAR_WIELD_OFFHAND) &&
GET_OBJ_VAL(GET_EQ(ch, WEAR_WIELD_OFFHAND), 3) == TYPE_PIERCE - TYPE_HIT)
{
return TRUE;
}
if (wield == 3 && GET_EQ(ch, WEAR_WIELD_2H) &&
GET_OBJ_VAL(GET_EQ(ch, WEAR_WIELD_2H), 3) == TYPE_PIERCE - TYPE_HIT)
{
return TRUE;
}
return FALSE;
}
/* End utility */
/* death arrow engine: The death arrow is reliant on a successful RANGED attack */
void perform_deatharrow(struct char_data *ch)
{
if (!IS_NPC(ch))
start_daily_use_cooldown(ch, FEAT_ARROW_OF_DEATH);
send_to_char(ch, "Your body glows with a \tDblack aura\tn as the power of \tDdeath\tn enters your ammo pouch!\r\n");
act("$n's body begins to glow with a \tDblack aura\tn!", FALSE, ch, 0, 0, TO_ROOM);
/* glowing with powahhh */
struct affected_type af;
new_affect(&af);
af.spell = SKILL_DEATH_ARROW;
af.duration = 24;
affect_to_char(ch, &af);
}
/* quivering palm engine: The quivering palm is reliant on a successful UNARMED
* attack (or an attack with a KI_STRIKE weapon) */
void perform_quiveringpalm(struct char_data *ch)
{
struct affected_type af;
new_affect(&af);
af.spell = SKILL_QUIVERING_PALM;
af.duration = 24;
affect_to_char(ch, &af);
if (!IS_NPC(ch))
start_daily_use_cooldown(ch, FEAT_QUIVERING_PALM);
send_to_char(ch, "You beging to meditate and focus all your ki energy towards your palms... \tBYour body begins to vibrate with massive amounts of \tYenergy\tB.\tn");
act("$n's body begins to \tBvibrate\tn with massive amounts of \tYenergy\tn!", FALSE, ch, 0, 0, TO_ROOM);
}
/* stunningfist engine */
/* The stunning fist is reliant on a successful UNARMED attack (or an attack with a KI_STRIKE weapon) */
void perform_stunningfist(struct char_data *ch)
{
struct affected_type af;
new_affect(&af);
af.spell = SKILL_STUNNING_FIST;
af.duration = 24;
affect_to_char(ch, &af);
if (!IS_NPC(ch))
start_daily_use_cooldown(ch, FEAT_STUNNING_FIST);
send_to_char(ch, "You focus your Ki energies and prepare a disabling unarmed attack.\r\n");
act("$n's focuses $s Ki, preparing a disabling unarmed attack!", FALSE, ch, 0, 0, TO_ROOM);
}
/* rp_surprise_accuracy engine */
/* The surprise-accuracy is reliant on rage */
void perform_surpriseaccuracy(struct char_data *ch)
{
struct affected_type af;
new_affect(&af);
af.spell = SKILL_SURPRISE_ACCURACY;
af.duration = 24;
affect_to_char(ch, &af);
attach_mud_event(new_mud_event(eSURPRISE_ACCURACY, ch, NULL), SECS_PER_MUD_DAY * 1);
send_to_char(ch, "You focus your rage and prepare a surprise accurate attack.\r\n");
act("$n's focuses $s rage, preparing a surprise accuracy attack!", FALSE, ch, 0, 0, TO_ROOM);
}
/* rp_come_and_get_me engine */
/* The come and get me is reliant on rage */
void perform_comeandgetme(struct char_data *ch)
{
struct affected_type af;
new_affect(&af);
af.spell = SKILL_COME_AND_GET_ME;
af.duration = 2;
affect_to_char(ch, &af);
attach_mud_event(new_mud_event(eCOME_AND_GET_ME, ch, NULL), SECS_PER_MUD_DAY * 1);
send_to_char(ch, "You focus your rage and prepare to SMASH.\r\n");
act("$n's focuses $s rage, preparing to SMASH!", FALSE, ch, 0, 0, TO_ROOM);
}
/* rp_powerful_blow engine */
/* The powerful blow is reliant on rage */
void perform_powerfulblow(struct char_data *ch)
{
struct affected_type af;
new_affect(&af);
af.spell = SKILL_POWERFUL_BLOW;
af.duration = 24;
affect_to_char(ch, &af);
attach_mud_event(new_mud_event(ePOWERFUL_BLOW, ch, NULL), SECS_PER_MUD_DAY * 1);
send_to_char(ch, "You focus your rage and prepare a powerful blow.\r\n");
act("$n's focuses $s rage, preparing a powerful blow!", FALSE, ch, 0, 0, TO_ROOM);
}
/* inner fire engine */
void perform_inner_fire(struct char_data *ch)
{
struct affected_type af[INNER_FIRE_AFFECTS];
int bonus = 0, duration = 0, i = 0;
/* bonus of 4 */
bonus = 4;
/* a little bit over a minute */
duration = GET_WIS_BONUS(ch) + CLASS_LEVEL(ch, CLASS_SACRED_FIST);
send_to_char(ch, "You activate \tWinner \tRfire\tn!\r\n");
act("$n activates \tWinner \tRfire\tn!", FALSE, ch, 0, 0, TO_ROOM);
/* init affect array */
for (i = 0; i < INNER_FIRE_AFFECTS; i++)
{
new_affect(&(af[i]));
af[i].spell = SKILL_INNER_FIRE;
af[i].duration = duration;
af[i].modifier = bonus;
af[i].bonus_type = BONUS_TYPE_SACRED;
}
af[0].location = APPLY_AC_NEW;
af[1].location = APPLY_SAVING_FORT;
af[2].location = APPLY_SAVING_WILL;
af[3].location = APPLY_SAVING_REFL;
af[4].location = APPLY_SAVING_POISON;
af[5].location = APPLY_SAVING_DEATH;
for (i = 0; i < INNER_FIRE_AFFECTS; i++)
affect_join(ch, af + i, FALSE, FALSE, FALSE, FALSE);
}
/* sacred flames engine */
void perform_sacred_flames(struct char_data *ch)
{
struct affected_type af;
int bonus = 0, duration = 0;
/* The additional damage is equal to the sacred fist's class levels plus his wisdom modifier */
bonus = GET_WIS_BONUS(ch) + CLASS_LEVEL(ch, CLASS_SACRED_FIST);
/* a little bit over a minute */
duration = 12;
send_to_char(ch, "You activate \tWsacred \tRflames\tn!\r\n");
act("$n activates \tWsacred \tRflames\tn!", FALSE, ch, 0, 0, TO_ROOM);
new_affect(&af);
af.spell = SKILL_SACRED_FLAMES;
af.duration = duration;
af.location = APPLY_DAMROLL;
af.modifier = bonus;
af.bonus_type = BONUS_TYPE_SACRED;
affect_join(ch, &af, FALSE, FALSE, FALSE, FALSE);
}
/* rage (berserk) engine */
void perform_rage(struct char_data *ch)
{
struct affected_type af[RAGE_AFFECTS];
int bonus = 0, duration = 0, i = 0;
if (char_has_mud_event(ch, eRAGE))
{
send_to_char(ch, "You must wait longer before you can use this ability "
"again.\r\n");
return;
}
if (AFF_FLAGGED(ch, AFF_FATIGUED))
{
send_to_char(ch, "You are are too fatigued to rage!\r\n");
return;
}
if (affected_by_spell(ch, SKILL_RAGE))
{
send_to_char(ch, "You are already raging!\r\n");
return;
}
bonus = get_rage_bonus(ch);
duration = 6 + GET_CON_BONUS(ch) * 2;
send_to_char(ch, "You go into a \tRR\trA\tRG\trE\tn!.\r\n");
act("$n goes into a \tRR\trA\tRG\trE\tn!", FALSE, ch, 0, 0, TO_ROOM);
/* init affect array */
for (i = 0; i < RAGE_AFFECTS; i++)
{
new_affect(&(af[i]));
af[i].spell = SKILL_RAGE;
af[i].duration = duration;
}
af[0].location = APPLY_STR;
af[0].modifier = bonus;
af[0].bonus_type = BONUS_TYPE_MORALE;
af[1].location = APPLY_CON;
af[1].modifier = bonus;
af[1].bonus_type = BONUS_TYPE_MORALE;
af[2].location = APPLY_SAVING_WILL;
af[2].modifier = bonus;
af[2].bonus_type = BONUS_TYPE_MORALE;
// this is a penalty
af[3].location = APPLY_AC_NEW;
af[3].modifier = -2;
af[4].location = APPLY_HIT;
af[4].modifier = bonus * 2;
af[4].bonus_type = BONUS_TYPE_MORALE;
for (i = 0; i < RAGE_AFFECTS; i++)
affect_join(ch, af + i, FALSE, FALSE, FALSE, FALSE);
GET_HIT(ch) += bonus * 2;
if (GET_HIT(ch) > GET_MAX_HIT(ch))
GET_HIT(ch)
--;
/* Add another affect for heavy shrug. */
// if (HAS_FEAT(ch, FEAT_RP_HEAVY_SHRUG)) {
// struct affected_type heavy_shrug_af;
// struct damage_reduction_type *new_dr;
//
// new_affect(&heavy_shrug_af);
// heavy_shrug_af.spell = SKILL_RAGE;
// heavy_shrug_af.duration = duration;
// heavy_shrug_af.location = APPLY_DR;
// heavy_shrug_af.modifier = 0;
//
// CREATE(new_dr, struct damage_reduction_type, 1);
//
// new_dr->bypass_cat[0] = DR_BYPASS_CAT_NONE;
// new_dr->bypass_val[0] = 0;
//
// new_dr->bypass_cat[1] = DR_BYPASS_CAT_UNUSED;
// new_dr->bypass_val[1] = 0; /* Unused. */
//
// new_dr->bypass_cat[2] = DR_BYPASS_CAT_UNUSED;
// new_dr->bypass_val[2] = 0; /* Unused. */
//
// new_dr->amount = 3;
// new_dr->max_damage = -1;
// new_dr->spell = SKILL_RAGE;
// new_dr->feat = FEAT_RP_HEAVY_SHRUG;
// new_dr->next = GET_DR(ch);
// GET_DR(ch) = new_dr;
//
// affect_join(ch, &heavy_shrug_af, FALSE, FALSE, FALSE, FALSE);
//
// }
attach_mud_event(new_mud_event(eRAGE, ch, NULL), (180 * PASSES_PER_SEC));
USE_STANDARD_ACTION(ch);
}
/* rescue skill mechanic */
void perform_rescue(struct char_data *ch, struct char_data *vict)
{
struct char_data *tmp_ch;
if (vict == ch)
{
send_to_char(ch, "What about fleeing instead?\r\n");
return;
}
if (FIGHTING(ch) == vict)
{
send_to_char(ch, "How can you rescue someone you are trying to kill?\r\n");
return;
}
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_SINGLEFILE) &&
ch->next_in_room != vict && vict->next_in_room != ch)
{
send_to_char(ch, "You simply can't reach that far.\r\n");
return;
}
for (tmp_ch = world[IN_ROOM(ch)].people; tmp_ch &&
(FIGHTING(tmp_ch) != vict);
tmp_ch = tmp_ch->next_in_room)
;
if ((FIGHTING(vict) != NULL) && (FIGHTING(ch) == FIGHTING(vict)) && (tmp_ch == NULL))
{
tmp_ch = FIGHTING(vict);
if (FIGHTING(tmp_ch) == ch)
{
send_to_char(ch, "You have already rescued %s from %s.\r\n", GET_NAME(vict), GET_NAME(FIGHTING(ch)));
return;
}
}
if (!tmp_ch)
{
act("But nobody is fighting $M!", FALSE, ch, 0, vict, TO_CHAR);
return;
}
if (attack_roll(ch, vict, ATTACK_TYPE_PRIMARY, FALSE, 1) <= 0)
{
send_to_char(ch, "You fail the rescue!\r\n");
return;
}
act("You place yourself between $N and $S opponent, rescuing $M!", FALSE, ch, 0, vict, TO_CHAR);
act("You are rescued by $N, you are confused!", FALSE, vict, 0, ch, TO_CHAR);
act("$n heroically rescues $N!", FALSE, ch, 0, vict, TO_NOTVICT);
if (FIGHTING(vict) == tmp_ch)
{
/* don't forget to remove the fight event! */
if (char_has_mud_event(vict, eCOMBAT_ROUND))
{
event_cancel_specific(vict, eCOMBAT_ROUND);
}
stop_fighting(vict);
}
if (FIGHTING(tmp_ch))
{
/* don't forget to remove the fight event! */
if (char_has_mud_event(tmp_ch, eCOMBAT_ROUND))
{
event_cancel_specific(tmp_ch, eCOMBAT_ROUND);
}
stop_fighting(tmp_ch);
}
if (FIGHTING(ch))
{
/* don't forget to remove the fight event! */
if (char_has_mud_event(ch, eCOMBAT_ROUND))
{
event_cancel_specific(ch, eCOMBAT_ROUND);
}
stop_fighting(ch);
}
set_fighting(ch, tmp_ch);
set_fighting(tmp_ch, ch);
USE_FULL_ROUND_ACTION(ch);
}
/* charge mechanic */
#define CHARGE_AFFECTS 3
void perform_charge(struct char_data *ch, struct char_data *vict)
{
struct affected_type af[CHARGE_AFFECTS];
extern struct index_data *mob_index;
int (*name)(struct char_data * ch, void *me, int cmd, const char *argument);
int i = 0;
if (AFF_FLAGGED(ch, AFF_CHARGING))
{
send_to_char(ch, "You are already charging!\r\n");
return;
}
/* init affect array */
for (i = 0; i < CHARGE_AFFECTS; i++)
{
new_affect(&(af[i]));
af[i].spell = SKILL_CHARGE;
af[i].duration = 1;
}
SET_BIT_AR(af[0].bitvector, AFF_CHARGING);
af[1].location = APPLY_HITROLL; /* bonus */
af[1].modifier = 2;
af[2].location = APPLY_AC_NEW; /* penalty */
af[2].modifier = -2;
for (i = 0; i < CHARGE_AFFECTS; i++)
affect_join(ch, af + i, FALSE, FALSE, FALSE, FALSE);
if (RIDING(ch))
{
act("You urge $N forward for a \tYcharge\tn!", FALSE, ch, NULL, RIDING(ch), TO_CHAR);
act("$n urges you forward for a \tYcharge\tn!", FALSE, ch, NULL, RIDING(ch), TO_VICT);
act("$n urges $N forward for a \tYcharge\tn!", FALSE, ch, NULL, RIDING(ch), TO_NOTVICT);
name = mob_index[GET_MOB_RNUM(RIDING(ch))].func;
if (name)
(name)(ch, RIDING(ch), 0, "charge");
}
else
{
act("You run forward for a \tYcharge\tn!", FALSE, ch, NULL, NULL, TO_CHAR);
act("$n runs forward for a \tYcharge\tn!", FALSE, ch, NULL, NULL, TO_NOTVICT);
}
if (!IS_NPC(ch) && HAS_FEAT(ch, FEAT_RIDE_BY_ATTACK))
{
USE_MOVE_ACTION(ch);
}
else
{
USE_FULL_ROUND_ACTION(ch);
}
if (!FIGHTING(ch) && vict && vict != ch)
hit(ch, vict, TYPE_UNDEFINED, DAM_RESERVED_DBC, 0, FALSE);
if (vict && vict != ch)
{
if (GET_POS(ch) > POS_STUNNED && (FIGHTING(ch) == NULL))
set_fighting(ch, vict);
if (GET_POS(vict) > POS_STUNNED && (FIGHTING(vict) == NULL))
{
set_fighting(vict, ch);
}
}
}
#undef CHARGE_AFFECTS
/* engine for knockdown, used in bash/trip/etc */
bool perform_knockdown(struct char_data *ch, struct char_data *vict, int skill)
{
int penalty = 0, attack_check = 0, defense_check = 0;
bool success = FALSE, counter_success = FALSE, skilled_monk = FALSE;
if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_SINGLEFILE) &&
ch->next_in_room != vict && vict->next_in_room != ch)
{
send_to_char(ch, "You simply can't reach that far.\r\n");
return FALSE;
}
if (MOB_FLAGGED(vict, MOB_NOKILL))
{
send_to_char(ch, "This mob is protected.\r\n");
return FALSE;
}
if (!is_mission_mob(ch, vict))
{
send_to_char(ch, "This mob cannot be attacked by you.\r\n");
return FALSE;
}
if ((GET_SIZE(ch) - GET_SIZE(vict)) >= 2)
{
send_to_char(ch, "Your knockdown attempt is unsuccessful due to the target being too small!\r\n");
return FALSE;
}
if ((GET_SIZE(vict) - GET_SIZE(ch)) >= 2)
{
send_to_char(ch, "Your knockdown attempt is unsuccessful due to the target being too big!\r\n");
return FALSE;
}
if (GET_POS(vict) == POS_SITTING)
{
send_to_char(ch, "You can't knock down something that is already down!\r\n");
return FALSE;
}
if (IS_INCORPOREAL(vict) && !is_using_ghost_touch_weapon(ch))
{
act("$n sprawls completely through $N as $e tries to attack $M, slamming into the ground!",
FALSE, ch, NULL, vict, TO_NOTVICT);
act("You sprawl completely through $N as you try to attack $M, slamming into the ground!",
FALSE, ch, NULL, vict, TO_CHAR);
act("$n sprawls completely through you as $e tries to attack you, slamming into the ground!",
FALSE, ch, NULL, vict, TO_VICT);
change_position(ch, POS_SITTING);
return FALSE;
}
if (MOB_FLAGGED(vict, MOB_NOBASH))
{
send_to_char(ch, "You realize you will probably not succeed: ");
penalty = -100;
}
if (is_wearing(vict, 132133))
{
send_to_char(ch, "You failed to knock over %s due to stability boots! Incoming counter attack!!! ...\r\n", GET_NAME(vict));
send_to_char(vict, "You stand your ground against %s, and with a snarl attempt a counterattack!\r\n",
GET_NAME(ch));
act("$N via stability boots a knockdown attack from $n is resisted... $N follows up with a counterattack!", FALSE, ch, 0, vict,
TO_NOTVICT);
perform_knockdown(vict, ch, SKILL_BASH);
return FALSE;
}
switch (skill)
{
case SKILL_SHIELD_CHARGE:
case SKILL_BASH:
attack_check = GET_STR_BONUS(ch);
if (is_flying(vict))
{
send_to_char(ch, "Impossible, your target is flying!\r\n");
return FALSE;
}
if (!HAS_FEAT(ch, FEAT_IMPROVED_TRIP))
attack_of_opportunity(vict, ch, 0);
break;
case SKILL_BODYSLAM:
attack_check = GET_WIS_BONUS(ch);
if (is_flying(vict))
{
send_to_char(ch, "Impossible, your target is flying!\r\n");
return FALSE;
}
if (!HAS_FEAT(ch, FEAT_IMPROVED_TRIP))
attack_of_opportunity(vict, ch, 0);
break;
case SKILL_TRIP:
attack_check = GET_DEX_BONUS(ch);
// whips give a +5 bonus to the check
if ((GET_EQ(ch, WEAR_WIELD_1) && GET_WEAPON_TYPE(GET_EQ(ch, WEAR_WIELD_1)) == WEAPON_TYPE_WHIP) ||
(GET_EQ(ch, WEAR_WIELD_2H) && GET_WEAPON_TYPE(GET_EQ(ch, WEAR_WIELD_2H)) == WEAPON_TYPE_WHIP) ||
(GET_EQ(ch, WEAR_WIELD_OFFHAND) && GET_WEAPON_TYPE(GET_EQ(ch, WEAR_WIELD_OFFHAND)) == WEAPON_TYPE_WHIP))
{
attack_check += 5;
}
if (is_flying(vict))
{
send_to_char(ch, "Impossible, your target is flying!\r\n");
return FALSE;
}
if (!HAS_FEAT(ch, FEAT_IMPROVED_TRIP))
attack_of_opportunity(vict, ch, 0);
break;
default:
log("Invalid skill sent to perform knockdown!\r\n");
return FALSE;
}
/* Perform the unarmed touch attack */
if ((attack_roll(ch, vict, ATTACK_TYPE_UNARMED, TRUE, 1) + penalty) > 0)
{
/* Successful unarmed touch attacks. */
/* Perform strength check. */
// if the teamwork feat tandem trip is in effect, we'll take the highest of two d20 rolls.
// Otherwise, just one d20.
attack_check += MAX(d20(ch), has_teamwork_feat(ch, FEAT_TANDEM_TRIP) ? d20(ch) : 0);
attack_check += d20(ch) + size_modifiers[GET_SIZE(ch)]; /* we added stat bonus above */
defense_check = d20(vict) + MAX(GET_STR_BONUS(vict), GET_DEX_BONUS(vict)) + size_modifiers[GET_SIZE(vict)];
if (!IS_NPC(ch) && HAS_FEAT(ch, FEAT_IMPROVED_TRIP))
{
/* You do not provoke an attack of opportunity when you attempt to trip an opponent while you are unarmed.
* You also gain a +4 bonus on your Strength check to trip your opponent.
*
* If you trip an opponent in melee combat, you immediately get a melee attack against that opponent as if
* you hadn't used your attack for the trip attempt.
*
* Normal:
* Without this feat, you provoke an attack of opportunity when you attempt to trip an opponent while you
* are unarmed. */
attack_check += 4;
}
if (MONK_TYPE(ch) >= 10)
{
attack_check += 8;
skilled_monk = TRUE;
}
if (GET_RACE(vict) == RACE_DWARF ||
GET_RACE(vict) == RACE_CRYSTAL_DWARF ||
GET_RACE(vict) == RACE_DUERGAR) /* dwarven stability */
defense_check += 4;
/*DEBUG*/ /*send_to_char(ch, "attack check: %d, defense_check: %d\r\n", attack_check, defense_check);*/
if (attack_check >= defense_check)
{
if (attack_check == defense_check)
{
/* Check the bonuses. */
if ((GET_STR_BONUS(ch) + (GET_SIZE(ch) - GET_SIZE(vict)) * 4) >= (MAX(GET_STR_BONUS(vict), GET_DEX_BONUS(vict))))
success = TRUE;
else
success = FALSE;
}
else
{
success = TRUE;
}
}
if (success == TRUE)
{
switch (skill)
{
case SKILL_SHIELD_CHARGE:
/* Messages for shield charge */
act("\tyYou knock $N to the ground!\tn", FALSE, ch, NULL, vict, TO_CHAR);
act("\ty$n knocks you to the ground!\tn", FALSE, ch, NULL, vict, TO_VICT);
act("\ty$n knocks $N to the ground!\tn", FALSE, ch, NULL, vict, TO_NOTVICT);
break;
case SKILL_BODYSLAM:
/* Messages for body slam */
act("\tyYou grab and SLAM $N, throwing $M to the ground!\tn", FALSE, ch, NULL, vict, TO_CHAR);
act("\ty$n grabs and SLAMS you, throwing you to the ground!\tn", FALSE, ch, NULL, vict, TO_VICT);
act("\ty$n grabs and SLAMS $N, throwing $M to the ground!\tn", FALSE, ch, NULL, vict, TO_NOTVICT);
break;
default:
/* (Default) Messages for successful trip */
act("\tyYou grab and overpower $N, throwing $M to the ground!\tn", FALSE, ch, NULL, vict, TO_CHAR);
act("\ty$n grabs and overpowers you, throwing you to the ground!\tn", FALSE, ch, NULL, vict, TO_VICT);
act("\ty$n grabs and overpowers $N, throwing $M to the ground!\tn", FALSE, ch, NULL, vict, TO_NOTVICT);
break;
}
}
else
{ /* failed!! */
/* Messages for shield charge */
if (skill == SKILL_SHIELD_CHARGE)
{
/* just moved this to damage-messages */
}
else
{
/* Messages for failed trip */
if (GET_STR_BONUS(vict) >= GET_DEX_BONUS(vict))
{
act("\tyYou grab $N but $E tears out of your grasp!\tn", FALSE, ch, NULL, vict, TO_CHAR);
act("\ty$n grabs you but you tear yourself from $s grasp!\tn", FALSE, ch, NULL, vict, TO_VICT);
act("\ty$n grabs $N but $E tears out of $s grasp!\tn", FALSE, ch, NULL, vict, TO_NOTVICT);
}
else
{
act("\tyYou grab $N but $E deftly turns away from your attack!\tn", FALSE, ch, NULL, vict, TO_CHAR);
act("\ty$n grabs you and you deftly turn away from $s attack!\tn", FALSE, ch, NULL, vict, TO_VICT);
act("\ty$n grabs $N but $E deftly turns away from $s attack!\tn", FALSE, ch, NULL, vict, TO_NOTVICT);
}
}
/* Victim gets a chance to countertrip */
if (skill != SKILL_SHIELD_CHARGE && GET_POS(vict) > POS_SITTING)
{
attack_check = (d20(vict) + GET_STR_BONUS(vict) + (GET_SIZE(vict) - GET_SIZE(ch)) * 4);
defense_check = (d20(ch) + MAX(GET_STR_BONUS(ch), GET_DEX_BONUS(ch)));
if (GET_RACE(ch) == RACE_DWARF ||
GET_RACE(ch) == RACE_DUERGAR ||
GET_RACE(ch) == RACE_CRYSTAL_DWARF) /* Dwarves get a stability bonus. */
defense_check += 4;
/*DEBUG*/ /*send_to_char(ch, "counterattack check: %d, defense_check: %d\r\n", attack_check, defense_check);*/
if (attack_check >= defense_check)
{
if (attack_check == defense_check)
{
/* Check the bonuses. */
if ((GET_STR_BONUS(vict) + (GET_SIZE(vict) - GET_SIZE(ch)) * 4) >= (MAX(GET_STR_BONUS(ch), GET_DEX_BONUS(ch))))
counter_success = TRUE;
else
counter_success = FALSE;
}
else
{
counter_success = TRUE;
}
}
/* No tripping someone already on the ground. */
if (GET_POS(ch) == POS_SITTING)
{
act("\tyYou can't counter-trip someone who is already down!\tn", FALSE, ch, NULL, vict, TO_VICT);
}
else if (counter_success == TRUE)
{
/* Messages for successful counter-trip */
act("\tyTaking advantage of your failed attack, $N throws you to the ground!\tn", FALSE, ch, NULL, vict, TO_CHAR);
act("\tyTaking advantage of $n's failed attack, you throw $m to the ground!\tn", FALSE, ch, NULL, vict, TO_VICT);
act("\tyTaking advantage of $n's failed attack, $N throws $m to the ground!\tn", FALSE, ch, NULL, vict, TO_NOTVICT);
}
else
{
/* Messages for failed counter-trip */
if (GET_STR_BONUS(ch) >= GET_DEX_BONUS(ch))
{
act("\tyYou resist $N's attempt to take advantage of your failed attack.\tn", FALSE, ch, NULL, vict, TO_CHAR);
act("\ty$n resists your attempt to take advantage of $s failed attack.\tn", FALSE, ch, NULL, vict, TO_VICT);
act("\ty$n resists $N's attempt to take advantage of $s failed attack.\tn", FALSE, ch, NULL, vict, TO_NOTVICT);
}
else
{
act("\tyYou twist away from $N's attempt to take advantage of your failed attack.\tn", FALSE, ch, NULL, vict, TO_CHAR);
act("\ty$n twists away from your attempt to take advantage of $s failed attack.\tn", FALSE, ch, NULL, vict, TO_VICT);
act("\ty$n twists away from $N's attempt to take advantage of $s failed attack.\t\n", FALSE, ch, NULL, vict, TO_NOTVICT);
}
}
}
}
/* FAILED attack roll */
}
else
{
/* Messages for a missed unarmed touch attack. */
if (skill == SKILL_SHIELD_CHARGE)
{
/* just moved this to damage-messages */
}
else
{
act("\tyYou are unable to grab $N!\tn", FALSE, ch, NULL, vict, TO_CHAR);
act("\ty$n tries to grab you, but you dodge easily away!\tn", FALSE, ch, NULL, vict, TO_VICT);
act("\ty$n tries to grab $N, but $N dodges easily away!\tn", FALSE, ch, NULL, vict, TO_NOTVICT);
}
}
/* further processing: set position, special feats, etc */
if (!success)
{
if (counter_success)
{
change_position(ch, POS_SITTING);
}
}
else
{ /* success! */
change_position(vict, POS_SITTING);
if ((skill == SKILL_TRIP) ||
(skill == SKILL_BASH) ||
(skill == SKILL_BODYSLAM) ||
(skill == SKILL_SHIELD_CHARGE))
{
/* bodyslam with a skilled monk */
if (skill == SKILL_BODYSLAM && skilled_monk)
{
damage(ch, vict, dice(MONK_TYPE(ch), 8) + GET_WIS_BONUS(ch), SKILL_BODYSLAM, DAM_FORCE, FALSE);
}
/* Successful trip, cheat for feats */
if (!IS_NPC(ch) && HAS_FEAT(ch, FEAT_IMPROVED_TRIP))
{
/* You get a free swing on the tripped opponent. */
hit(ch, vict, TYPE_UNDEFINED, DAM_RESERVED_DBC, 0, FALSE);
}
}
}
/* fire-shield, etc check */
if (success)
damage_shield_check(ch, vict, ATTACK_TYPE_UNARMED, TRUE);
/* make sure combat starts */
if (vict != ch)
{
if (GET_POS(ch) > POS_STUNNED && (FIGHTING(ch) == NULL))
set_fighting(ch, vict);
if (GET_POS(vict) > POS_STUNNED && (FIGHTING(vict) == NULL))
{
set_fighting(vict, ch);
}
}
return TRUE;
}
/* shieldpunch engine :
* Perform the shield punch, check for proficiency and the required
* equipment, also check for any enhancing feats. */
bool perform_shieldpunch(struct char_data *ch, struct char_data *vict)
{
extern struct index_data *obj_index;
int (*name)(struct char_data * ch, void *me, int cmd, const char *argument);
struct obj_data *shield = GET_EQ(ch, WEAR_SHIELD);
if (!shield)
{
send_to_char(ch, "You need a shield to do that.\r\n");
return FALSE;
}
if (!vict)
{
send_to_char(ch, "Shieldpunch who?\r\n");
return FALSE;
}
if (vict == ch)
{
send_to_char(ch, "Aren't we funny today...\r\n");
return FALSE;
}
if (!CAN_SEE(ch, vict))
{
send_to_char(ch, "You don't see well enough to attempt that.\r\n");
return FALSE;
}
if (ROOM_FLAGGED(ch->in_room, ROOM_SINGLEFILE))
{
if (ch->next_in_room != vict && vict->next_in_room != ch)
{
send_to_char(ch, "You simply can't reach that far.\r\n");
return FALSE;
}
}
if (!HAS_FEAT(ch, FEAT_IMPROVED_SHIELD_PUNCH))
{
/* Remove shield bonus from ac. */
attach_mud_event(new_mud_event(eSHIELD_RECOVERY, ch, NULL), PULSE_VIOLENCE);
}
/* Use an attack mechanic to determine success. */
if (attack_roll(ch, vict, ATTACK_TYPE_OFFHAND, FALSE, 1) <= 0)
{
damage(ch, vict, 0, SKILL_SHIELD_PUNCH, DAM_FORCE, FALSE);
}
else
{
damage(ch, vict, dice(1, 6) + (GET_STR_BONUS(ch) / 2), SKILL_SHIELD_PUNCH, DAM_FORCE, FALSE);
name = obj_index[GET_OBJ_RNUM(shield)].func;
if (name)
(name)(ch, shield, 0, "shieldpunch");
/* fire-shield, etc check */
damage_shield_check(ch, vict, ATTACK_TYPE_UNARMED, TRUE);
}
return TRUE;
}
/* shieldcharge engine :
* Perform the shieldcharge, check for proficiency and the required
* equipment, also check for any enhancing feats. Perform a trip attack
* on success
*
* Note - Charging gives +2 to your attack
*/
bool perform_shieldcharge(struct char_data *ch, struct char_data *vict)
{
extern struct index_data *obj_index;
int (*name)(struct char_data * ch, void *me, int cmd, const char *argument);
struct obj_data *shield = GET_EQ(ch, WEAR_SHIELD);
if (!shield)
{
send_to_char(ch, "You need a shield to do that.\r\n");
return FALSE;
}
if (!vict)
{
send_to_char(ch, "Shieldcharge who?\r\n");
return FALSE;
}
if (vict == ch)
{
send_to_char(ch, "Aren't we funny today...\r\n");
return FALSE;