-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfight.cpp
6449 lines (5562 loc) · 176 KB
/
fight.cpp
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
/**************************************************************************/
// fight.cpp -
/***************************************************************************
* The Dawn of Time v1.69r (c)1997-2004 Michael Garratt *
* >> A number of people have contributed to the Dawn codebase, with the *
* majority of code written by Michael Garratt - www.dawnoftime.org *
* >> To use this source code, you must fully comply with all the licenses *
* in licenses.txt... In particular, you may not remove this copyright *
* notice. *
***************************************************************************
* >> Original Diku Mud copyright (c)1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, & Katja Nyboe. *
* >> Merc Diku Mud improvements copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* >> ROM 2.4 is copyright 1993-1995 Russ Taylor and has been brought to *
* you by the ROM consortium: Russ Taylor([email protected]), *
* Gabrielle Taylor([email protected]) & Brian Moore([email protected]) *
* >> Oblivion 1.2 is copyright 1996 Wes Wagner *
**************************************************************************/
#include "include.h" // dawn standard includes
#include "clan.h"
#include "duel.h"
#include "msp.h"
#define MAX_DAMAGE_MESSAGE 43
/* command procedures needed */
DECLARE_DO_FUN(do_backstab );
DECLARE_DO_FUN(do_pbackstab );
DECLARE_DO_FUN(do_circle );
DECLARE_DO_FUN(do_emote );
DECLARE_DO_FUN(do_berserk );
DECLARE_DO_FUN(do_bash );
DECLARE_DO_FUN(do_trip );
DECLARE_DO_FUN(do_dirt );
DECLARE_DO_FUN(do_flee );
DECLARE_DO_FUN(do_kick );
DECLARE_DO_FUN(do_disarm );
DECLARE_DO_FUN(do_get );
DECLARE_DO_FUN(do_recall );
DECLARE_DO_FUN(do_yell );
DECLARE_DO_FUN(do_gore ); // Kerenos
DECLARE_DO_FUN(do_disarm_trap );
DECLARE_DO_FUN(do_visible );
DECLARE_SPEC_FUN( spec_cast_mage );
DECLARE_SPEC_FUN( spec_cast_cleric );
char *get_weapontype(OBJ_DATA *obj);
void landchar( char_data *ch);
int group_max_level_attacking_victim(char_data *killer, char_data *victim );
void group_bypass_killer_penatly(char_data *killer, char_data *victim, bool death);
void pkill_note_required_message(char_data *ch, char_data *victim, bool bypass_duel_used);
bool can_join_combat( char_data *attacker, char_data *victim);
char * const death_cry_dir_name[]=
{
"the north", "the east", "the south", "the west", "above", "below",
"the northeast", "the southeast", "the southwest", "the northwest"
};
/*
* Local functions.
*/
void pkill_autonote args(( char_data *ch, char_data *victim ));
void check_assist args(( char_data *ch, char_data *victim ));
bool check_dodge args(( char_data *ch, char_data *victim ));
bool check_parry args(( char_data *ch, char_data *victim ));
bool check_shield_block args(( char_data *ch, char_data *victim ));
void dam_message args(( char_data *ch, char_data *victim, int dam,
int dt, bool immune ));
void death_cry args(( char_data *ch, char_data *killer ));
void group_gain args(( char_data *ch, char_data *victim ));
int xp_compute args(( char_data *gch, char_data *victim,
int total_levels));
bool is_safe args(( char_data *ch, char_data *victim ));
void make_corpse args(( char_data *ch, char *killer ));
void one_hit args(( char_data *ch, char_data *victim, int dt, bool second ));
void mob_hit args(( char_data *ch, char_data *victim, int dt ));
void set_fighting args(( char_data *ch, char_data *victim ));
void disarm args(( char_data *ch, char_data *victim ));
void entangle args(( char_data *ch, char_data *victim ));
void mount args(( char_data *, char_data * ));
void dismount args(( char_data * ));
void show_list_to_char args(( OBJ_DATA *list, char_data *ch, char * filter,
bool fShort, bool fShowNothing ));
/**************************************************************************/
// lame way to do this, but it was in the oblivion code and I
// can't be bothered changing it cause the code is only called
// when a pkill happens - it was originally put in update_handler() with
// ran everytime violence_update() was called!!!
void check_death_update(void)
{
char buf[MSL];
char_data *victim;
char_data *next_player;
for ( victim = player_list; victim; victim = next_player )
{
next_player=victim->next_player;
if(victim->pcdata->karns<0)
{
flush_char_outbuffer(victim);
victim->printf(
"You have been pkilled when you had no karns. The system is if you\r\n"
"are pkilled you lose a karn, if you are pkilled when you have no karns\r\n"
"the death is considered permanent.\r\n"
"Please keep in mind that it is bad RP to discuss this unless you think\r\n"
"it was a OOC pkill. If you consider it ooc please note it to admin\r\n"
"we will see what we can do about it.\r\n");
flush_char_outbuffer(victim);
logf( "PERMDEATH: Closing link to %s.", victim->name);
char subject[MIL];
sprintf(subject,"`RPERMDEATH:`W %s!`x", victim->name);
autonote(NOTE_INOTE, "Your friendly neighbourhood pkill system",
subject, "imm", "Subject says it all.", true);
flush_char_outbuffer(victim);
autonote(NOTE_PKNOTE, "Your friendly neighbourhood pkill system",
subject, "imm", "Subject says it all.", true);
char filenamebuf[MIL];
strcpy(filenamebuf, pfilename(victim->name, victim->pcdata->pfiletype));
// disconnect them
extract_char(victim,true);
connection_close(victim->desc);
// move them to the dead directory
sprintf(buf,"mv %s %s &", filenamebuf, DEAD_DIR);
logf("Systeming: '%s'", buf);
system(buf);
}
}
}
/**************************************************************************/
/*
* Control the fights going on.
* Called periodically by update_handler.
*/
void violence_update( void )
{
char_data *ch;
char_data *ch_next;
char_data *victim;
for ( ch = char_list; ch; ch = ch_next )
{
ch_next = ch->next;
if ( ( victim = ch->fighting ) == NULL || ch->in_room == NULL )
continue;
// do a room check
if( ch->in_room!=ch->fighting->in_room){
bug("violence_update(): ch->in_room != ch->fighting->in_room");
stop_fighting(ch,false);
continue;
}
if(ch->bleeding)
{
damage( ch, ch, ch->bleeding, TYPE_UNDEFINED, DAM_NONE,false);
act("$n's deteriorating condition is very apparent.",
ch,NULL,NULL,TO_ROOM);
ch->println("You lose even more blood.");
}
if(ch->is_stunned)
{
ch->is_stunned-=1;
if(ch->is_stunned<=0)
{
ch->position=POS_RESTING;
ch->is_stunned=0;
ch->println("You are no longer stunned.");
}
}
if(ch->will_die)
{
ch->will_die-=20;
if(ch->will_die<=0)
{
ch->will_die=0;
// we know victim exists and is in the same room
kill_char(ch, victim);
continue;
}
}
if ( IS_AWAKE(ch) && ch->in_room == victim->in_room ){
multi_hit( ch, victim, TYPE_UNDEFINED );
}else{
stop_fighting( ch, false ); // Violence_update - not awake/diff room
}
if (( victim = ch->fighting ) == NULL )
continue;
// Fun for the whole family!
check_assist(ch,victim);
if ( IS_NPC( ch ) ) {
if ( HAS_TRIGGER( ch, TRIG_FIGHT ) )
mp_percent_trigger( ch, victim, NULL, NULL, TRIG_FIGHT );
if ( HAS_TRIGGER( ch, TRIG_HPCNT ) )
mp_hprct_trigger( ch, victim );
}
}
return;
}
/**************************************************************************/
int get_sublevels_for_level(int level);
// Called when a player/mob victim is killed:
// - victim position should be POS_DEAD when called
// - handles the loss of karns, and reseting of karn countdowns
// loss of xp when dieing
// - records mobkills, pkills, pkdefeat, pkools
// - does NOT handle pknorecall, pksafe
// - autolooting
// - autonoting pkills
// - mob death trigger
void kill_char(char_data *victim, char_data *ch)
{
if(victim->position != POS_DEAD ){
bug("kill_char(): victim->position != POS_DEAD ");
return;
}
if(!IS_VALID(ch)){
bugf("kill_char(): ch (%d) is not valid!", ch->vnum());
}
ROOM_INDEX_DATA *deathroom;
if(ch->in_room){
deathroom=ch->in_room;
}else if(victim->in_room){
deathroom=victim->in_room;
bug("kill_char(): ch->in_room==NULL, setting it to victim->in_room");
ch->in_room=victim->in_room;
}else{
bugf("kill_char(): Couldn't find DEATHROOM!!!... setting it to limbo.");
deathroom=get_room_index(ROOM_VNUM_LIMBO);
assertp(deathroom);
}
group_gain( ch, victim );
// record mob kill values
if (!IS_NPC(ch) && IS_NPC(victim)){
ch->pcdata->mkills++;
}else if (IS_NPC(ch) && !IS_NPC(victim)){
victim->pcdata->mdefeats++;
}
if ( !IS_NPC(victim) )
{
if (IS_NPC(ch)){ // mob killed player
sprintf( log_buf, "%s mkilled by %s at %d (kill_char())",
victim->name,
ch->short_descr,
deathroom->vnum);
// send the info
info_broadcast(victim, "%s has been toasted by %s.", victim->name, ch->short_descr);
// Log mobkills
{
char mklogbuf[MSL];
sprintf( mklogbuf, "%s mkilled by %s at %d (kill_char())",
victim->name,
ch->short_descr,
deathroom->vnum);
append_datetime_ch_to_file( ch, MKILL_LOGFILE, mklogbuf);
}
}else{ // player killed player
sprintf( log_buf, "%s pkilled by %s at %d (kill_char())",
victim->name,
ch->name,
deathroom->vnum);
// send the info
info_broadcast(victim, "%s has been toasted by %s!", victim->name, ch->name);
}
log_string( log_buf );
if(ch->pkool>0 && victim->level<5){
// ch didn't start the fight so they dont get the pkills on them
// reducing their max karns
ch->pkkills--;
}
if(victim->level<11 && !IS_LETGAINED(victim) && GAMESETTING_LETGAINING_IS_REQUIRED){
if(!GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
ch->pkool+=4000;
}
}
// pk system
if(ch!=victim && !IS_NPC(ch) && !IS_NPC(victim))
{
ch->pkkills+=1;
victim->pkdefeats+=1;
if(!GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
// new pk karn system
if(group_max_level_attacking_victim(ch, victim)<=victim->level+10){
victim->pcdata->karns--;
if(GAMESETTING(GAMESET_NOPERMDEATH) && victim->pcdata->karns<0){
victim->pcdata->karns=0;
}
if(victim->pcdata->karns) // if they actually lost a karn
{
victim->println(
"From within your body you feel a surge of energy,\r\n"
"a ball of light departs from your body and disappears!");
}
}
group_bypass_killer_penatly(ch, victim, true);
if(GAMESETTING3(GAMESET3_KILLER_SYSTEM_ENABLED)
&& !IS_SET(victim->dyn, DYN_STARTED_FIGHT))
{
// mark the attackers as killers if the victim didn't start the fight
char_data *gch;
for ( gch = ch->in_room->people; gch; gch = gch->next_in_room )
{
if ( !IS_NPC(gch) && gch->fighting==victim && is_same_group( gch, ch))
{
if(!IS_KILLER(gch)){
ch->println( "*** You are now tagged as a KILLER!! ***");
}
gch->pcdata->killer_until=current_time+ (60*game_settings->killer_system_tagged_duration);
save_char_obj( gch );
}
}
}
// reduce the victims killer timer
if(IS_KILLER(victim)){
victim->pcdata->killer_until-=
(60*game_settings->killer_system_death_reduction_duration);
if(!IS_KILLER(victim)){
victim->pcdata->killer_until=0;
}
}
// update duels to protect victim
duel_protect_victim(victim);
// karn checking is done at the end of this function
}
if( ch->pknorecall==0){
ch->pknorecall=5;
}
ch->pknoquit=UMAX(ch->pknorecall,ch->pknoquit);
if(GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
ch->pknoquit=UMIN(ch->pknoquit,2);
}
victim->pcdata->next_karn_countdown=
UMIN(victim->pcdata->next_karn_countdown,GET_NEW_KARN_COUNTER(victim));
// autonote the pkill
pkill_autonote(ch, victim);
// deactivate autopkassist
if (IS_SET(victim->dyn,DYN_AUTOPKASSIST))
{
victim->println("`YYour autopkassist setting has been deactivated.`x");
REMOVE_BIT(victim->dyn,DYN_AUTOPKASSIST);
}
// remove thief status on death
if(IS_THIEF(victim)){
victim->println("You are no longer marked as a thief");
victim->pcdata->thief_until=0;
}
}
// Dying penalty: 2/3 way back to previous level for those level 20 or lower
{
if(victim->level<21)
{
if ( victim->exp > exp_per_level(victim,victim->pcdata->points)
* victim->level )
{
gain_exp( victim, (2 * (exp_per_level(victim,victim->pcdata->points)
* victim->level - victim->exp)/3) + 50 );
}
}
else
{
int xp_amount;
if(victim->level>50){
xp_amount=500+(get_sublevels_for_level( victim->level) *150);
}else{
xp_amount=500;
}
if(IS_HERO(victim)){
if(GAMESETTING5(GAMESET5_HEROS_DONT_LOSE_XP_FOR_DYING)){
victim->printlnf("You would have lost %d xp if you weren't a hero.", xp_amount);
}else{
victim->printlnf("You have lost %d xp.", xp_amount);
gain_exp( victim, -xp_amount);
}
}else{
victim->printlnf("You have lost %d xp.", xp_amount);
gain_exp( victim, -xp_amount);
}
if ( IS_HERO( victim )){
do_heroxp( victim, -xp_amount);
}
if(victim->exp<exp_per_level(victim,victim->pcdata->points)* victim->level )
{
drop_level(victim);
check_perm_damage(victim);
}else{
if(number_range(1,get_sublevels_for_level( victim->level+5))<2){
check_perm_damage(victim);
}else{
victim->println("Luckily you have not suffered serious injury.");
}
}
}
}
}
sprintf( log_buf, "%s [lvl %d] got toasted by %s at %s [lvl %d] [room %d] (%s)",
(IS_NPC(victim) ? victim->short_descr : victim->name),
victim->level,
(IS_NPC(ch) ? ch->short_descr : ch->name),
deathroom->name, ch->level, deathroom->vnum,
deathroom->area->name);
if (IS_NPC(victim)){
wiznet(log_buf,NULL,NULL,WIZ_MOBDEATHS,0,0);
}else{
wiznet(log_buf,NULL,NULL,WIZ_DEATHS,0,0);
}
// Death trigger mobprog trigger
if ( IS_NPC( victim ) && HAS_TRIGGER( victim, TRIG_DEATH) )
{
victim->position = POS_STANDING;
mp_percent_trigger( victim, ch, NULL, NULL, TRIG_DEATH );
}
ch->mobmemory = NULL;
victim->mobmemory = NULL;
raw_kill( victim, ch );
// handle players autolooting and autogold mob corpses
if ( !IS_NPC(ch) && IS_NPC(victim) )
{
OBJ_DATA *corpse;
corpse = get_obj_list( ch, "corpse", deathroom->contents );
if(corpse && corpse->contains) // a corpse exists and isnt empty
{
if (IS_SET(ch->act, PLR_AUTOLOOT))
{
do_get( ch, "all corpse" );
}
else
{
if(IS_SET(ch->act,PLR_AUTOGOLD) )
{
OBJ_DATA *coins=get_obj_list(ch,"gcash",corpse->contains);
if (coins)
{
do_get(ch, "all.gcash corpse");
}
}
}
}
if ( corpse
&& HAS_CONFIG(ch, CONFIG_AUTOEXAMINE)
&& !IS_SET( ch->act,PLR_AUTOLOOT ))
{
act( "$p holds:", ch, corpse, NULL, TO_CHAR );
show_list_to_char( corpse->contains, ch, "", true, true );
}
}
if(!IS_NPC(victim)){
check_death_update();
}
}
/**************************************************************************/
// for auto assisting
// victim is being attacked by ch... will rch join in
void check_assist(char_data *ch,char_data *victim)
{
char_data *rch, *rch_next;
for (rch = ch->in_room->people; rch != NULL; rch = rch_next)
{
rch_next = rch->next_in_room;
if (IS_AWAKE(rch) && rch->fighting == NULL)
{
// quick check for ASSIST_PLAYER
if (!IS_NPC(ch) && IS_NPC(rch)
&& IS_SET(rch->off_flags,ASSIST_PLAYERS)
&& rch->level + 6 > victim->level)
{
do_emote(rch,"screams and attacks!");
multi_hit(rch,victim,TYPE_UNDEFINED);
continue;
}
// PCs next
if (!IS_NPC(ch) || IS_AFFECTED(ch,AFF_CHARM))
{
if( !is_same_group(ch,rch)
|| !can_join_combat(rch, victim)
|| is_safe(rch, victim)){
continue;
}
if(IS_NPC(victim)){
if(!IS_AFFECTED(rch,AFF_CHARM)
&& !(!IS_NPC(rch) && IS_SET(rch->act,PLR_AUTOASSIST))){
continue;
}
}else{
if(IS_NPC(rch)){
if(!IS_AFFECTED(rch,AFF_CHARM)){
continue;
}
}else{
if(!IS_SET(rch->dyn,DYN_AUTOPKASSIST)){
rch->println("`YYou dont automatically assist because you dont have autopkassist is off.`x");
continue;
}
}
}
// player attacking another player
if (!IS_NPC(rch) && !IS_NPC(victim))
{
logf( "%s attacking %s at %d (check_assist()(charm) might start pkill)",
rch->name,
victim->name,
rch->in_room->vnum );
}
multi_hit (rch,victim,TYPE_UNDEFINED);
continue;
}
//for horse attacking characters
if (victim->fighting && victim->fighting==rch->mounted_on)
{
// player attacking another player
if (!IS_NPC(rch) && !IS_NPC(victim))
{
logf( "%s attacking %s at %d (check_assist() might start pkill)",
rch->name,
victim->name,
rch->in_room->vnum );
}
multi_hit(rch, victim, TYPE_UNDEFINED);
continue;
}
// now check the NPC cases
if (IS_NPC(ch) && !IS_AFFECTED(ch,AFF_CHARM))
{
if ( (IS_NPC(rch) && IS_SET(rch->off_flags,ASSIST_ALL))
|| (IS_NPC(rch) && rch->helpgroup && rch->helpgroup == ch->group)
|| (IS_NPC(rch) && rch->race == ch->race
&& IS_SET(rch->off_flags,ASSIST_RACE))
|| (IS_NPC(rch) && IS_SET(rch->off_flags,ASSIST_ALIGN)
&& ((IS_GOOD(rch) && IS_GOOD(ch))
|| (IS_EVIL(rch) && IS_EVIL(ch))
|| (IS_NEUTRAL(rch) && IS_NEUTRAL(ch))))
|| (rch->pIndexData == ch->pIndexData
&& IS_SET(rch->off_flags,ASSIST_VNUM)))
{
char_data *vch;
char_data *target;
int number;
if (number_bits(1) == 0)
continue;
target = NULL;
number = 0;
for (vch = ch->in_room->people; vch; vch = vch->next)
{
if (can_see(rch,vch)
&& is_same_group(vch,victim)
&& number_range(0,number) == 0)
{
target = vch;
number++;
}
}
if (target != NULL)
{
do_emote(rch,"screams and attacks!");
multi_hit(rch,target,TYPE_UNDEFINED);
}
}
}
}
}
}
/**************************************************************************/
// Do one group of attacks.
void multi_hit( char_data *ch, char_data *victim, int dt )
{
int chance;
if(IS_MOUNTED(ch))
{
ch->println("Cant do that.");
return;
}
if(!IS_NPC(ch) && !IS_NPC(victim) && ch!=victim)
{
// transfer those to the void that are attacked
// while linkdead and dont have a pkill timer
if ( victim->pknorecall ==0
&& IS_LINKDEAD(victim)
&& victim->was_in_room == NULL
&& victim->in_room != NULL )
{
victim->was_in_room = victim->in_room;
if ( victim->fighting != NULL ){
stop_fighting( victim, true ); // Multi_hit linkdead transfer to void
}
act( "$n disappears into the void.", victim, NULL, NULL, TO_ROOM );
victim->println("You disappear into the void.");
if (victim->level > 1)
save_char_obj( victim);
char_from_room( victim);
char_to_room( victim, get_room_index( ROOM_VNUM_LIMBO ) );
return;
}
ch->pknorecall=15;
victim->pknorecall=15;
if(GAMESETTING5(GAMESET5_DEDICATED_PKILL_STYLE_MUD)){
ch->pknoquit =2;
victim->pknoquit=2;
}else{
ch->pknoquit =20;
victim->pknoquit=20;
}
}
// decrement the wait
if (ch->desc == NULL)
ch->wait = UMAX(0,ch->wait - PULSE_VIOLENCE);
if (ch->desc == NULL)
ch->daze = UMAX(0,ch->daze - PULSE_VIOLENCE);
// no attacks for stunnies -- just a check
if (ch->position < POS_RESTING)
return;
if (IS_NPC(ch))
{
mob_hit(ch,victim,dt);
return;
}
one_hit( ch, victim, dt, false );
if (ch->fighting != victim)
return;
if (IS_AFFECTED(ch,AFF_HASTE))
one_hit(ch,victim,dt,false);
// extra attack if defending your mount
if (victim->fighting==ch->mounted_on)
one_hit(ch,victim,dt,false);
if (get_eq_char (ch, WEAR_SECONDARY))
{
if(GAMESETTING2(GAMESET2_NO_SECOND_SKILL_REQUIRED)){
one_hit( ch, victim, dt, true );
if ( ch->fighting != victim ){
return;
}
}else{
if(number_range(ch->get_skill(gsn_second), 100)>90){
check_improve(ch,gsn_second,true,5);
one_hit( ch, victim, dt, true );
if ( ch->fighting != victim ){
return;
}
}else{
check_improve(ch,gsn_second,false,1);
}
}
}
if ( ch->fighting != victim || dt == gsn_backstab )
return;
chance = get_skill(ch,gsn_second_attack)/2;
if (IS_AFFECTED(ch,AFF_SLOW))
chance /= 2;
if ( number_percent( ) < chance )
{
one_hit( ch, victim, dt, false );
check_improve(ch,gsn_second_attack,true,5);
if ( ch->fighting != victim )
return;
}
chance = get_skill(ch,gsn_third_attack)/3;
if (IS_AFFECTED(ch,AFF_SLOW))
chance = 0;
if ( number_percent( ) < chance )
{
one_hit( ch, victim, dt, false );
check_improve(ch,gsn_third_attack,true,6);
if ( ch->fighting != victim )
return;
}
chance = get_skill(ch,gsn_quad_attack)/2;
if (IS_AFFECTED(ch,AFF_SLOW))
chance = 0;
if ( number_percent( ) < chance )
{
one_hit( ch, victim, dt, false );
check_improve(ch,gsn_quad_attack,true,7);
if ( ch->fighting != victim )
return;
}
return;
}
/**************************************************************************/
// procedure for all mobile attacks
void mob_hit (char_data *ch, char_data *victim, int dt)
{
int chance,number;
char_data *vch, *vch_next;
one_hit(ch,victim,dt,false);
if (ch->fighting != victim)
return;
// Area attack -- BALLS nasty!
// mobs get the extra attack too if defending mount
if (victim->fighting==ch->mounted_on)
one_hit(ch,victim,dt,false);
if (IS_SET(ch->off_flags,OFF_AREA_ATTACK))
{
for (vch = ch->in_room->people; vch != NULL; vch = vch_next)
{
vch_next = vch->next;
if ((vch != victim && vch->fighting == ch))
one_hit(ch,vch,dt,false);
}
}
if (IS_AFFECTED(ch,AFF_HASTE)
|| (IS_SET(ch->off_flags,OFF_FAST) && !IS_AFFECTED(ch,AFF_SLOW)))
one_hit(ch,victim,dt,false);
if (ch->fighting != victim || dt == gsn_backstab)
return;
chance = get_skill(ch,gsn_second_attack)/2;
if (IS_AFFECTED(ch,AFF_SLOW) && !IS_SET(ch->off_flags,OFF_FAST))
chance /= 2;
if (number_percent() < chance)
{
one_hit(ch,victim,dt,false);
if (ch->fighting != victim)
return;
}
chance = get_skill(ch,gsn_third_attack)/4;
if (IS_AFFECTED(ch,AFF_SLOW) && !IS_SET(ch->off_flags,OFF_FAST))
chance = 0;
if (number_percent() < chance)
{
one_hit(ch,victim,dt,false);
if (ch->fighting != victim)
return;
}
// oh boy! Fun stuff!
if (ch->wait > 0)
return;
number = number_range(0,2);
if (number == 1 && IS_SET(ch->act,ACT_MAGE)){
spec_cast_mage(ch);
return;
}
if (number == 2 && IS_SET(ch->act,ACT_CLERIC)){
spec_cast_cleric(ch);
return;
}
// now for the skills
number = number_range(0,9);
switch(number)
{
case (0) :
if (IS_SET(ch->off_flags,OFF_BASH))
do_bash(ch,"");
break;
case (1) :
if (IS_SET(ch->off_flags,OFF_BERSERK) && !IS_AFFECTED(ch,AFF_BERSERK))
do_berserk(ch,"");
break;
case (2) :
if (IS_SET(ch->off_flags,OFF_DISARM)
|| (get_weapon_sn(ch) != gsn_hand_to_hand
&& (IS_SET(ch->act,ACT_WARRIOR)
|| IS_SET(ch->act,ACT_THIEF))))
do_disarm(ch,"");
break;
case (3) :
if (IS_SET(ch->off_flags,OFF_KICK))
do_kick(ch,"");
break;
case (4) :
if (IS_SET(ch->off_flags,OFF_KICK_DIRT))
do_dirt(ch,"");
break;
case (5) :
if (IS_SET(ch->off_flags,OFF_CIRCLE))
{
do_circle(ch,"");
}
break;
case (6) :
if (IS_SET(ch->off_flags,OFF_TRIP))
do_trip(ch,"");
break;
case (7) :
if (IS_SET(ch->off_flags,OFF_CRUSH))
{
/* do_crush(ch,"") */ ;
}
break;
case (8) :
if (IS_SET(ch->off_flags,OFF_BACKSTAB))
{
do_pbackstab(ch,"");
}
case (9) :
if ( IS_SET( ch->off_flags, OFF_GORE ))
do_gore( ch, "" );
break;
}
}
/**************************************************************************/
// Hit one guy once.
void one_hit( char_data *ch, char_data *victim, int dt, bool second )
{
OBJ_DATA *wield;
int victim_ac;
int thac0;
int thac0_00;
int thac0_32;
int dam;
int diceroll;
int sn,skill;
int dam_type;
int result;
int temp_hps;
sn = -1;
// just in case
if (victim == ch
|| ch == NULL || !IS_VALID(ch)
|| victim == NULL || !IS_VALID(victim))
{
return;
}
// Can't beat a dead char! and guard against weird room-leavings.
if ( victim->position == POS_DEAD || ch->in_room != victim->in_room )
return;
OBJ_DATA *primary_weapon= get_eq_char( ch, WEAR_WIELD );
OBJ_DATA *secondary_weapon= get_eq_char( ch, WEAR_SECONDARY);
// Figure out the type of damage message, first find the weapon
wield = second?secondary_weapon:primary_weapon;
if ( dt == TYPE_UNDEFINED )
{
dt = TYPE_HIT;
if ( wield != NULL && wield->item_type == ITEM_WEAPON ){
dt += wield->value[3];
}else{
dt += ch->dam_type;
}
}
if (dt < TYPE_HIT){
if (wield != NULL){
dam_type = attack_table[wield->value[3]].damage;
}else{
dam_type = attack_table[ch->dam_type].damage;
}
}else{
dam_type = attack_table[dt - TYPE_HIT].damage;
}
if (dam_type == -1){
dam_type = DAM_BASH;
}
// get the weapon skill
if(second){ // swap over the secondary and primary to get sn
if(primary_weapon){
primary_weapon->wear_loc = WEAR_SECONDARY;
}
secondary_weapon->wear_loc = WEAR_WIELD;
sn = get_weapon_sn(ch);
if(primary_weapon){
primary_weapon->wear_loc = WEAR_WIELD;
}
secondary_weapon->wear_loc = WEAR_SECONDARY;
}else{
sn = get_weapon_sn(ch);
}
skill = 20 + get_weapon_skill(ch,sn);
if(second){
if(!GAMESETTING2(GAMESET2_NO_SECOND_SKILL_REQUIRED)){
skill*=(ch->get_skill(gsn_second)/100);
}
}
if ( get_eq_char( ch, WEAR_LODGED_ARM )){
skill -= 20;
}
if(HAS_CONFIG(ch,CONFIG_PRACSYS_TESTER)){
skill+=20;
}
/*
* Calculate to-hit-armor-clss-0 versus armor.
*/