-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskills.cpp
executable file
·5716 lines (4999 loc) · 144 KB
/
skills.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
/****************************************************************************
* [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame | \\._.// *
* -----------------------------------------------------------| (0...0) *
* SMAUG 1.0 (C) 1994, 1995, 1996 by Derek Snider | ).:.( *
* -----------------------------------------------------------| {o o} *
* SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus, | / ' ' \ *
* Scryn, Rennard, Swordbearer, Gorog, Grishnakh and Tricops |~'~.VxvxV.~'~*
* ------------------------------------------------------------------------ *
* Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* ------------------------------------------------------------------------ *
* Player skills module *
****************************************************************************/
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mud.h"
#include "commands.h"
//#include "connection.h"
SkillType::SkillType()
{
spell_fun = NULL;
skill_fun = NULL;
target = minimum_position = slot = min_mana = beats = 0;
min_level = type = 0;
flags = 0;
hit_char = hit_vict = hit_room = miss_char = miss_vict
= miss_room = die_char = die_vict = die_room
= imm_char = imm_vict = imm_room = dice = NULL;
value = 0;
saves = difficulty = 0;
affects = NULL;
components = teachers = NULL;
participants = 0;
userec.num_uses = 0;
struct timeval empty;
empty.tv_sec = 0;
empty.tv_usec = 0;
userec.total_time = userec.min_time = userec.max_time = empty;
Prerequisites = NULL;
for ( int x = 0; x < MAX_CLASS; x++ )
{
skill_level[x] = LEVEL_IMMORTAL;
skill_adept[x] = 95;
}
guild = -1;
}
const char * const spell_flag[] =
{ "water", "earth", "air", "astral", "area", "distant", "reverse",
"save_half_dam", "save_negates", "accumulative", "recastable", "noscribe",
"nobrew", "group", "object", "character", "secretskill", "persistant",
"stoponfail", "specialtrainers"};
const char * const spell_saves[] =
{ "none", "poison_death", "wands", "para_petri", "breath", "spell_staff" };
const char * const spell_damage[] =
{ "none", "fire", "cold", "electricity", "energy", "acid", "poison", "drain" };
const char * const spell_action[] =
{ "none", "create", "destroy", "resist", "suscept", "divinate", "obscure",
"change" };
const char * const spell_power[] =
{ "none", "minor", "greater", "major" };
const char * const spell_class[] =
{ "none", "lunar", "solar", "travel", "summon", "life", "death", "illusion" };
const char * const target_type[] =
{ "ignore", "offensive", "defensive", "self", "objinv" };
void show_char_to_char( CHAR_DATA *List, CHAR_DATA *ch );
void show_list_to_char( OBJ_DATA *List, CHAR_DATA *ch, bool fShort,
bool fShowN );
int ris_save( CHAR_DATA *ch, int chance, int ris );
/* from magic.c */
void failed_casting( SkillType *skill, CHAR_DATA *ch,
CHAR_DATA *victim, OBJ_DATA *obj );
/*
* Dummy function ** DUMMY
*/
void skill_notfound( CHAR_DATA *ch, const char *argument )
{
send_to_char( "But you don't know this skill.\n\r", ch );
return;
}
int get_ssave( const char *name )
{
unsigned int x;
for ( x = 0; x < sizeof(spell_saves) / sizeof(spell_saves[0]); x++ )
if ( !str_cmp( name, spell_saves[x] ) )
return x;
return -1;
}
int get_starget( const char *name )
{
unsigned int x;
for ( x = 0; x < sizeof(target_type) / sizeof(target_type[0]); x++ )
if ( !str_cmp( name, target_type[x] ) )
return x;
return -1;
}
int get_sflag( const char *name )
{
unsigned int x;
for ( x = 0; x < sizeof(spell_flag) / sizeof(spell_flag[0]); x++ )
if ( !str_cmp( name, spell_flag[x] ) )
return x;
return -1;
}
int get_sdamage( const char *name )
{
unsigned int x;
for ( x = 0; x < sizeof(spell_damage) / sizeof(spell_damage[0]); x++ )
if ( !str_cmp( name, spell_damage[x] ) )
return x;
return -1;
}
int get_saction( const char *name )
{
unsigned int x;
for ( x = 0; x < sizeof(spell_action) / sizeof(spell_action[0]); x++ )
if ( !str_cmp( name, spell_action[x] ) )
return x;
return -1;
}
int get_spower( const char *name )
{
unsigned int x;
for ( x = 0; x < sizeof(spell_power) / sizeof(spell_power[0]); x++ )
if ( !str_cmp( name, spell_power[x] ) )
return x;
return -1;
}
int get_sclass( const char *name )
{
unsigned int x;
for ( x = 0; x < sizeof(spell_class) / sizeof(spell_class[0]); x++ )
if ( !str_cmp( name, spell_class[x] ) )
return x;
return -1;
}
extern const char *target_name; /* from magic.c */
/*
* Perform a binary search on a section of the skill table
* Each different section of the skill table is sorted alphabetically
* Only match skills player knows -Thoric
*/
bool check_skill( CHAR_DATA *ch, const char *command, const char *argument )
{
int sn;
int first = gsn_first_skill;
int top = gsn_first_weapon-1;
int mana, blood;
struct timeval time_used;
/* bsearch for the skill */
for (;;)
{
sn = (first + top) >> 1;
if ( LOWER(command[0]) == LOWER(skill_table[sn]->name_.c_str()[0])
&& !str_prefix(command, skill_table[sn]->name_.c_str())
&& (skill_table[sn]->skill_fun || skill_table[sn]->spell_fun != spell_null)
&& (IS_NPC(ch)
|| (ch->pcdata->learned[sn] > 0
#if 0 /* Testaur - do allow forbidden skills/spells so long as they are learned */
&& ch->level >= skill_table[sn]->skill_level[ch->class]
#endif
)) )
break;
if (first >= top)
return FALSE;
if (strcmp( command, skill_table[sn]->name_.c_str()) < 1)
top = sn - 1;
else
first = sn + 1;
}
if ( !check_pos( ch, skill_table[sn]->minimum_position ) )
return TRUE;
if ( IS_NPC(ch)
&& (IS_AFFECTED( ch, AFF_CHARM ) || IS_AFFECTED( ch, AFF_POSSESS )) )
{
send_to_char( "For some reason, you seem unable to perform that...\n\r", ch );
act( AT_GREY,"$n wanders around aimlessly.", ch, NULL, NULL, TO_ROOM );
return TRUE;
}
/* check if mana is required */
if ( skill_table[sn]->min_mana )
{
mana = IS_NPC(ch) ? 0 : UMAX(skill_table[sn]->min_mana,
100 / ( 2 + ch->level - skill_table[sn]->skill_level[ch->Class] ) );
blood = UMAX(1, (mana+4) / 8); /* NPCs don't have PCDatas. -- Altrag */
if ( IS_VAMPIRE(ch) )
{
if (ch->pcdata->condition[COND_BLOODTHIRST] < blood)
{
send_to_char( "You don't have enough blood power.\n\r", ch );
return TRUE;
}
}
else
if ( !IS_NPC(ch) && ch->mana < mana )
{
send_to_char( "You don't have enough mana.\n\r", ch );
return TRUE;
}
}
else
{
mana = 0;
blood = 0;
}
/*
* Is this a real do-fun, or a really a spell?
*/
if ( !skill_table[sn]->skill_fun )
{
ch_ret retcode = rNONE;
void *vo = NULL;
CHAR_DATA *victim = NULL;
OBJ_DATA *obj = NULL;
target_name = "";
switch ( skill_table[sn]->target )
{
default:
bug( "Check_skill: bad target for sn %d.", sn );
send_to_char( "Something went wrong...\n\r", ch );
return TRUE;
case TAR_IGNORE:
vo = NULL;
if ( argument[0] == '\0' )
{
if ( (victim=ch->GetVictim()) != NULL )
target_name = victim->getName().c_str();
}
else
target_name = (char *) argument;
break;
case TAR_CHAR_OFFENSIVE:
if ( argument[0] == '\0'
&& (victim=ch->GetVictim()) == NULL )
{
ch_printf( ch, "%s who?\n\r", capitalize( skill_table[sn]->name_.c_str() ) );
return TRUE;
}
else
if ( argument[0] != '\0'
&& (victim=get_char_room(ch, (char *) argument)) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return TRUE;
}
if ( is_safe( ch, victim ) )
return TRUE;
vo = (void *) victim;
break;
case TAR_CHAR_DEFENSIVE:
if ( argument[0] != '\0'
&& (victim=get_char_room(ch, (char *) argument)) == NULL )
{
send_to_char( "They aren't here.\n\r", ch );
return TRUE;
}
if ( !victim )
victim = ch;
vo = (void *) victim;
break;
case TAR_CHAR_SELF:
vo = (void *) ch;
break;
case TAR_OBJ_INV:
if ( (obj=get_obj_carry(ch, (char *) argument)) == NULL )
{
send_to_char( "You can't find that.\n\r", ch );
return TRUE;
}
vo = (void *) obj;
break;
}
/* waitstate */
ch->AddWait( skill_table[sn]->beats );
/* check for failure */
if ( (number_percent( ) + skill_table[sn]->difficulty * 5)
> (IS_NPC(ch) ? 75 : ch->pcdata->learned[sn]) )
{
failed_casting( skill_table[sn], ch, (CHAR_DATA *) vo, obj );
learn_from_failure( ch, sn );
if ( mana )
{
if ( IS_VAMPIRE(ch) )
gain_condition( ch, COND_BLOODTHIRST, - blood/2 );
else
ch->mana -= mana/2;
}
return TRUE;
}
if ( mana )
{
if ( IS_VAMPIRE(ch) )
gain_condition( ch, COND_BLOODTHIRST, - blood );
else
ch->mana -= mana;
}
start_timer(&time_used);
retcode = (*skill_table[sn]->spell_fun) ( sn, ch->level, ch, vo );
end_timer(&time_used);
update_userec(&time_used, &skill_table[sn]->userec);
if ( retcode == rCHAR_DIED || retcode == rERROR )
return TRUE;
if ( char_died(ch) )
return TRUE;
if ( retcode == rSPELL_FAILED )
{
learn_from_failure( ch, sn );
retcode = rNONE;
}
else
learn_from_success( ch, sn );
if ( skill_table[sn]->target == TAR_CHAR_OFFENSIVE
&& victim != ch
&& !char_died(victim) )
{
CHAR_DATA *vch;
CHAR_DATA *vch_next;
for ( vch = ch->GetInRoom()->first_person; vch; vch = vch_next )
{
vch_next = vch->next_in_room;
if ( victim == vch && !victim->IsAttacking() && victim->GetMaster() != ch )
{
retcode = multi_hit( victim, ch, TYPE_UNDEFINED );
break;
}
}
}
return TRUE;
}
if ( mana )
{
if ( IS_VAMPIRE(ch) )
gain_condition( ch, COND_BLOODTHIRST, - blood );
else
ch->mana -= mana;
}
ch->prev_cmd = ch->last_cmd; /* haus, for automapping */
ch->last_cmd = skill_table[sn]->skill_fun;
start_timer(&time_used);
(*skill_table[sn]->skill_fun) ( ch, (char *) argument );
end_timer(&time_used);
update_userec(&time_used, &skill_table[sn]->userec);
tail_chain( );
return TRUE;
}
/*
* Lookup a skills information
* High god command
*/
void do_slookup(CHAR_DATA *ch, const char* argument)
{
char buf[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
int sn;
int iClass;
SkillType *skill = NULL;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Slookup what?\n\r", ch );
return;
}
if ( !str_cmp( arg, "all" ) )
{
for ( sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name_.length() > 0; sn++ )
pager_printf( ch, "Sn: %4d Slot: %4d Skill/spell: '%-20s' Damtype: %s\n\r",
sn, skill_table[sn]->slot, skill_table[sn]->name_.c_str(),
spell_damage[SPELL_DAMAGE( skill_table[sn] )] );
}
else
if ( !str_cmp( arg, "herbs" ) )
{
for ( sn = 0; sn < top_herb && herb_table[sn] && herb_table[sn]->name_.c_str(); sn++ )
pager_printf( ch, "%d) %s\n\r", sn, herb_table[sn]->name_.c_str() );
}
else
{
SMAUG_AFF *aff;
int cnt = 0;
if ( arg[0] == 'h' && is_number(arg+1) )
{
sn = atoi(arg+1);
if ( !IS_VALID_HERB(sn) )
{
send_to_char( "Invalid herb.\n\r", ch );
return;
}
skill = herb_table[sn];
}
else
if ( is_number(arg) )
{
sn = atoi(arg);
if ( (skill=get_skilltype(sn)) == NULL )
{
send_to_char( "Invalid sn.\n\r", ch );
return;
}
sn %= 1000;
}
else
if ( ( sn = skill_lookup( arg ) ) >= 0 )
skill = skill_table[sn];
else
if ( ( sn = herb_lookup( arg ) ) >= 0 )
skill = herb_table[sn];
else
{
send_to_char( "No such skill, spell, proficiency or tongue.\n\r", ch );
return;
}
if ( !skill )
{
send_to_char( "Not created yet.\n\r", ch );
return;
}
ch_printf( ch, "Sn: %4d Slot: %4d %s: '%-20s'\n\r",
sn, skill->slot, skill_tname[skill->type], skill->name_.c_str() );
if ( skill->flags )
{
int x;
ch_printf( ch, "Damtype: %s Acttype: %s Classtype: %s Powertype: %s\n\r",
spell_damage[SPELL_DAMAGE( skill )],
spell_action[SPELL_ACTION( skill )],
spell_class[SPELL_CLASS( skill )],
spell_power[SPELL_POWER( skill )] );
strcpy( buf, "Flags:" );
for ( x = 11; x < 32; x++ )
if ( SPELL_FLAG( skill, 1 << x ) )
{
strcat( buf, " " );
strcat( buf, spell_flag[x-11] );
}
strcat( buf, "\n\r" );
send_to_char( buf, ch );
}
ch_printf( ch, "Saves: %s\n\r", spell_saves[(int) skill->saves] );
if ( skill->difficulty != '\0' )
ch_printf( ch, "Difficulty: %d\n\r", (int) skill->difficulty );
ch_printf( ch, "Type: %s Target: %s Minpos: %d Mana: %d Beats: %d\n\r",
skill_tname[skill->type],
target_type[URANGE(TAR_IGNORE, skill->target, TAR_OBJ_INV)],
skill->minimum_position,
skill->min_mana,
skill->beats );
ch_printf( ch, "Value: %d Guild: %d Code: %s\n\r",
skill->value,
skill->guild,
skill->skill_fun ? skill_name(skill->skill_fun)
: spell_name(skill->spell_fun));
if ( skill->Prerequisites && skill->Prerequisites[0] != '\0')
ch_printf( ch, "Prereqs: %s\n\r", skill->Prerequisites);
ch_printf( ch, "Dammsg: %s\n\rWearoff: %s\n",
skill->nounDamage_.c_str(),
skill->msgOff_.length() > 0 ? skill->msgOff_.c_str() : "(none set)" );
if ( skill->dice && skill->dice[0] != '\0' )
ch_printf( ch, "Dice: %s\n\r", skill->dice );
if ( skill->teachers && skill->teachers[0] != '\0' )
ch_printf( ch, "Teachers: %s\n\r", skill->teachers );
if ( skill->components && skill->components[0] != '\0' )
ch_printf( ch, "Components: %s\n\r", skill->components );
if ( skill->participants )
ch_printf( ch, "Participants: %d\n\r", (int) skill->participants );
if ( skill->userec.num_uses )
send_timer(&skill->userec, ch);
for ( aff = skill->affects; aff; aff = aff->next )
{
if ( aff == skill->affects )
send_to_char( "\n\r", ch );
sprintf( buf, "Affect %d", ++cnt );
if ( aff->location )
{
strcat( buf, " modifies " );
strcat( buf, a_types[aff->location % REVERSE_APPLY] );
strcat( buf, " by '" );
strcat( buf, aff->modifier );
if ( aff->bitvector )
strcat( buf, "' and" );
else
strcat( buf, "'" );
}
if ( aff->bitvector )
{
int x;
strcat( buf, " applies" );
for ( x = 0; x < 32; x++ )
if ( IS_SET(aff->bitvector, 1 << x) )
{
strcat( buf, " " );
strcat( buf, a_flags[x] );
}
}
if ( aff->duration[0] != '\0' && aff->duration[0] != '0' )
{
strcat( buf, " for '" );
strcat( buf, aff->duration );
strcat( buf, "' rounds" );
}
if ( aff->location >= REVERSE_APPLY )
strcat( buf, " (affects caster only)" );
strcat( buf, "\n\r" );
send_to_char( buf, ch );
if ( !aff->next )
send_to_char( "\n\r", ch );
}
if ( skill->hit_char && skill->hit_char[0] != '\0' )
ch_printf( ch, "Hitchar : %s\n\r", skill->hit_char );
if ( skill->hit_vict && skill->hit_vict[0] != '\0' )
ch_printf( ch, "Hitvict : %s\n\r", skill->hit_vict );
if ( skill->hit_room && skill->hit_room[0] != '\0' )
ch_printf( ch, "Hitroom : %s\n\r", skill->hit_room );
if ( skill->miss_char && skill->miss_char[0] != '\0' )
ch_printf( ch, "Misschar : %s\n\r", skill->miss_char );
if ( skill->miss_vict && skill->miss_vict[0] != '\0' )
ch_printf( ch, "Missvict : %s\n\r", skill->miss_vict );
if ( skill->miss_room && skill->miss_room[0] != '\0' )
ch_printf( ch, "Missroom : %s\n\r", skill->miss_room );
if ( skill->die_char && skill->die_char[0] != '\0' )
ch_printf( ch, "Diechar : %s\n\r", skill->die_char );
if ( skill->die_vict && skill->die_vict[0] != '\0' )
ch_printf( ch, "Dievict : %s\n\r", skill->die_vict );
if ( skill->die_room && skill->die_room[0] != '\0' )
ch_printf( ch, "Dieroom : %s\n\r", skill->die_room );
if ( skill->imm_char && skill->imm_char[0] != '\0' )
ch_printf( ch, "Immchar : %s\n\r", skill->imm_char );
if ( skill->imm_vict && skill->imm_vict[0] != '\0' )
ch_printf( ch, "Immvict : %s\n\r", skill->imm_vict );
if ( skill->imm_room && skill->imm_room[0] != '\0' )
ch_printf( ch, "Immroom : %s\n\r", skill->imm_room );
if ( skill->type != SKILL_HERB )
{
for ( iClass = 0; iClass < MAX_CLASS; iClass++ )
{
strcpy( buf, class_table[iClass]->whoName_.c_str() );
sprintf(buf+3, ") lvl: %3d max: %2d%%",
skill->skill_level[iClass],
skill->skill_adept[iClass] );
if ( iClass % 3 == 2 )
strcat(buf, "\n\r" );
else
strcat(buf, " " );
send_to_char( buf, ch );
}
}
send_to_char( "\n\r", ch );
}
return;
}
/*
* Set a skill's attributes or what skills a player has.
* High god command, with support for creating skills/spells/herbs/etc
*/
void do_sset(CHAR_DATA *ch, const char* argument)
{
char arg1 [MAX_INPUT_LENGTH];
char arg2 [MAX_INPUT_LENGTH];
CHAR_DATA *victim;
int value;
int sn;
bool fAll;
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if ( arg1[0] == '\0' || arg2[0] == '\0' || argument[0] == '\0' )
{
send_to_char( "Syntax: sset <victim> <skill> <value>\n\r", ch );
send_to_char( "or: sset <victim> all <value>\n\r", ch );
send_to_char( "or: sset save skill table\n\r", ch );
send_to_char( "or: sset save herb table\n\r", ch );
send_to_char( "or: sset create skill 'new skill'\n\r", ch );
send_to_char( "or: sset create herb 'new herb'\n\r", ch );
send_to_char( "or: sset <sn> <field> <value>\n\r", ch );
send_to_char( "\n\rField being one of:\n\r", ch );
send_to_char( " name code target minpos slot mana beats dammsg wearoff guild minlevel\n\r", ch );
send_to_char( " type damtype acttype classtype powertype flag dice value difficulty affect\n\r", ch );
send_to_char( " rmaffect level adept hit miss die imm (char/vict/room)\n\r", ch );
send_to_char( " components teachers\n\r", ch );
send_to_char( "Affect having the fields: <location> <modfifier> [duration] [bitvector]\n\r", ch );
send_to_char( "(See AFFECTTYPES for location, and AFFECTED_BY for bitvector)\n\r", ch );
send_to_char( "Skill being any skill or spell.\n\r", ch );
return;
}
if (
!str_cmp( arg1, "save" )
&& !str_cmp( argument, "table" ) )
{
if ( !str_cmp( arg2, "skill" ) )
{
send_to_char( "Saving skill table...\n\r", ch );
save_skill_table();
save_classes();
return;
}
if ( !str_cmp( arg2, "herb" ) )
{
send_to_char( "Saving herb table...\n\r", ch );
save_herb_table();
return;
}
}
if (
!str_cmp( arg1, "create" )
&& (!str_cmp( arg2, "skill" ) || !str_cmp( arg2, "herb" )) )
{
SkillType * skill;
sh_int type = SKILL_UNKNOWN;
if ( !str_cmp( arg2, "herb" ) )
{
type = SKILL_HERB;
if ( top_herb >= MAX_HERB )
{
ch_printf( ch, "The current top herb is %d, which is the maximum. "
"To add more herbs,\n\rMAX_HERB will have to be "
"raised in mud.h, and the mud recompiled.\n\r",
top_sn );
return;
}
}
else
if ( top_sn >= MAX_SKILL )
{
ch_printf( ch, "The current top sn is %d, which is the maximum. "
"To add more skills,\n\rMAX_SKILL will have to be "
"raised in mud.h, and the mud recompiled.\n\r",
top_sn );
return;
}
skill = new SkillType;
if ( type == SKILL_HERB )
{
int max, x;
herb_table[top_herb++] = skill;
for ( max = x = 0; x < top_herb-1; x++ )
if ( herb_table[x] && herb_table[x]->slot > max )
max = herb_table[x]->slot;
skill->slot = max+1;
}
else
skill_table[top_sn++] = skill;
skill->name_ = argument;
skill->nounDamage_ = "";
skill->msgOff_ = "";
skill->spell_fun = spell_smaug;
skill->type = type;
send_to_char( "Done.\n\r", ch );
return;
}
if ( arg1[0] == 'h' )
sn = atoi( arg1+1 );
else
sn = atoi( arg1 );
if (
((arg1[0] == 'h' && is_number(arg1+1) && (sn=atoi(arg1+1))>=0)
|| (is_number(arg1) && (sn=atoi(arg1)) >= 0)) )
{
SkillType *skill;
if ( arg1[0] == 'h' )
{
if ( sn >= top_herb )
{
send_to_char( "Herb number out of range.\n\r", ch );
return;
}
skill = herb_table[sn];
}
else
{
if ( (skill=get_skilltype(sn)) == NULL )
{
send_to_char( "Skill number out of range.\n\r", ch );
return;
}
sn %= 1000;
}
if ( !str_cmp( arg2, "difficulty" ) )
{
skill->difficulty = atoi( argument );
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "participants" ) )
{
skill->participants = atoi( argument );
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "prereqs" ) || !str_cmp( arg2, "prerequisites" ) )
{
if ( skill->Prerequisites )
DISPOSE(skill->Prerequisites);
if ( !str_cmp( argument, "clear" ) )
skill->Prerequisites = str_dup( "" );
else
skill->Prerequisites = str_dup( argument );
ch_printf(ch, "Prequisites set to %s.\n\r", argument);
return;
}
if ( !str_cmp( arg2, "damtype" ) )
{
int x = get_sdamage( argument );
if ( x == -1 )
send_to_char( "Not a spell damage type.\n\r", ch );
else
{
SET_SDAM( skill, x );
send_to_char( "Ok.\n\r", ch );
}
return;
}
if ( !str_cmp( arg2, "acttype" ) )
{
int x = get_saction( argument );
if ( x == -1 )
send_to_char( "Not a spell action type.\n\r", ch );
else
{
SET_SACT( skill, x );
send_to_char( "Ok.\n\r", ch );
}
return;
}
if ( !str_cmp( arg2, "classtype" ) )
{
int x = get_sclass( argument );
if ( x == -1 )
send_to_char( "Not a spell class type.\n\r", ch );
else
{
SET_SCLA( skill, x );
send_to_char( "Ok.\n\r", ch );
}
return;
}
if ( !str_cmp( arg2, "powertype" ) )
{
int x = get_spower( argument );
if ( x == -1 )
send_to_char( "Not a spell power type.\n\r", ch );
else
{
SET_SPOW( skill, x );
send_to_char( "Ok.\n\r", ch );
}
return;
}
if ( !str_cmp( arg2, "flag" ) )
{
int x = get_sflag( argument );
if ( x == -1 )
send_to_char( "Not a spell flag.\n\r", ch );
else
{
TOGGLE_BIT( skill->flags, 1 << (x+11) );
send_to_char( "Ok.\n\r", ch );
}
return;
}
if ( !str_cmp( arg2, "saves" ) )
{
int x = get_ssave( argument );
if ( x == -1 )
send_to_char( "Not a saving type.\n\r", ch );
else
{
skill->saves = x;
send_to_char( "Ok.\n\r", ch );
}
return;
}
if ( !str_cmp( arg2, "code" ) )
{
SPELL_FUN *spellfun;
DO_FUN *dofun;
if ( (spellfun=spell_function(argument)) != spell_notfound )
{
skill->spell_fun = spellfun;
skill->skill_fun = NULL;
}
else
if ( (dofun=skill_function(argument)) != skill_notfound )
{
skill->skill_fun = dofun;
skill->spell_fun = NULL;
}
else
{
send_to_char( "Not a spell or skill.\n\r", ch );
return;
}
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "target" ) )
{
int x = get_starget( argument );
if ( x == -1 )
send_to_char( "Not a valid target type.\n\r", ch );
else
{
skill->target = x;
send_to_char( "Ok.\n\r", ch );
}
return;
}
if ( !str_cmp( arg2, "minpos" ) )
{
skill->minimum_position = URANGE( POS_DEAD, atoi( argument ), POS_DRAG );
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "minlevel" ) )
{
skill->min_level = URANGE( 1, atoi( argument ), MAX_LEVEL );
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "slot" ) )
{
skill->slot = URANGE( 0, atoi( argument ), 30000 );
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "mana" ) )
{
skill->min_mana = URANGE( 0, atoi( argument ), 2000 );
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "beats" ) )
{
skill->beats = URANGE( 0, atoi( argument ), 120 );
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "guild" ) )
{
skill->guild = atoi( argument );
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "value" ) )
{
skill->value = atoi( argument );
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "type" ) )
{
skill->type = get_skill( argument );
send_to_char( "Ok.\n\r", ch );
return;
}
if ( !str_cmp( arg2, "rmaffect" ) )
{
SMAUG_AFF *aff = skill->affects;
SMAUG_AFF *aff_next;
int num = atoi( argument );
int cnt = 1;
if ( !aff )
{
send_to_char( "This spell has no special affects to remove.\n\r", ch );
return;
}
if ( num == 1 )
{
skill->affects = aff->next;
DISPOSE( aff->duration );
DISPOSE( aff->modifier );
DISPOSE( aff );
send_to_char( "Removed.\n\r", ch );
return;
}
for ( ; aff; aff = aff->next )
{
if ( ++cnt == num && (aff_next=aff->next) != NULL )
{
aff->next = aff_next->next;
DISPOSE( aff_next->duration );
DISPOSE( aff_next->modifier );
DISPOSE( aff_next );
send_to_char( "Removed.\n\r", ch );
return;
}
}
send_to_char( "Not found.\n\r", ch );
return;
}
/*
* affect <location> <modifier> <duration> <bitvector>
*/
if ( !str_cmp( arg2, "affect" ) )
{
char location[MAX_INPUT_LENGTH];
char modifier[MAX_INPUT_LENGTH];
char duration[MAX_INPUT_LENGTH];
char bitvector[MAX_INPUT_LENGTH];
int loc, bit, tmpbit;
SMAUG_AFF *aff;