00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #if defined(macintosh)
00013 #include <types.h>
00014 #else
00015 #include <sys/types.h>
00016 #include <sys/time.h>
00017 #endif
00018 #include <ctype.h>
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #include <string.h>
00022 #include <time.h>
00023
00024 #include "merc.h"
00025 #include "tables.h"
00026 #include "olc.h"
00027 #include "lookup.h"
00028 #include "recycle.h"
00029 extern OCLASS_DATA *class_last;
00030 #define CEDIT( fun ) bool fun(CHAR_DATA *ch, char*argument)
00031
00032 const struct olc_cmd_type cedit_table[] = {
00033 {"show", cedit_show},
00034 {"name", cedit_name},
00035 {"wname", cedit_wname},
00036 {"thac0", cedit_thac_0},
00037 {"thac32", cedit_thac_32},
00038 {"primary", cedit_primary},
00039
00040
00041
00042 {"skill", cedit_skill},
00043 {"minhp", cedit_min_hp},
00044 {"maxhp", cedit_max_hp},
00045 {"base" , cedit_base},
00046 {"default", cedit_default},
00047 {"commands", show_commands},
00048 {"csave", cedit_save},
00049 {"?", show_help},
00050 {NULL,0}
00051 };
00052
00053 void do_cedit(CHAR_DATA *ch, char *argument)
00054 {
00055 char arg[MAX_STRING_LENGTH];
00056 OCLASS_DATA *pClass;
00057 OCLASS_DATA *cClass;
00058 pClass = cClass;
00059
00060
00061 if (IS_NPC(ch))
00062 return;
00063 argument = one_argument(argument, arg);
00064 if (is_number(arg))
00065 {
00066 send_to_char("Syntax - cedit [create] class\n\r",ch);
00067 return;
00068 }
00069 else if (!str_cmp(arg, "create"))
00070 {
00071 if (ch->pcdata->security < 5)
00072 {
00073 send_to_char("CEdit: Not enough security.\n\r",ch);
00074 return;
00075 }
00076
00077 cedit_create (ch, "");
00078 ch->desc->editor = ED_CLASS;
00079 return;
00080 }
00081 else
00082 {
00083 send_to_char("no.\n\r",ch);
00084 return;
00085 }
00086 ch->desc->pEdit=(void *) pClass;
00087 ch->desc->editor = ED_CLASS;
00088 return;
00089 }
00090
00091
00092
00093 CEDIT (cedit_create)
00094 {
00095 OCLASS_DATA *pClass;
00096 extern OCLASS_DATA *class_first;
00097 pClass = new_class();
00098 pClass->name = str_dup("New Class");
00099 pClass->who_name = str_dup("NWC");
00100 pClass->thac_0 = 0;
00101 pClass->thac_32 = 0;
00102 pClass->primary = 0;
00103 pClass->weapon = 0;
00104 pClass->guild1 = 0;
00105 pClass->guild2 = 0;
00106 pClass->skill = 0;
00107 pClass->minhp = 0;
00108 pClass->maxhp = 0;
00109 pClass->base = str_dup("New Class Basics");
00110 pClass->c_default = str_dup("New Class Default");
00111
00112
00113 if (class_first)
00114 class_first = pClass;
00115 class_last= pClass;
00116 pClass->next = NULL;
00117 ch->desc->pEdit = (OCLASS_DATA*) pClass;
00118 ch->desc->editor = ED_CLASS;
00119 send_to_char("Class created\n\r",ch);
00120 send_to_char("Warning. This will not save when you do done. And you cannot do asave changed.\n\r You must type 'csave' to save it for review.\n\r",ch);
00121 return FALSE;
00122
00123
00124
00125 }
00126 CEDIT (cedit_wname)
00127 {
00128 OCLASS_DATA *pClass;
00129 EDIT_CLASS(ch, pClass);
00130
00131 if (is_number(argument))
00132 {
00133 send_to_char("Value cannot be a number.\n\r",ch);
00134 return TRUE;
00135 }
00136 if (argument[0] == '\0')
00137 {
00138 send_to_char("wname <name> (Three leters)",ch);
00139 return TRUE;
00140 }
00141 if (strlen(argument) > 3)
00142 {
00143 send_to_char("Only THREE characters\n\r",ch);
00144 return TRUE;
00145 }
00146
00147 pClass->who_name = str_dup(argument);
00148 free_string(argument);
00149
00150
00151
00152 return TRUE;
00153 }
00154 CEDIT (cedit_thac_0)
00155 {
00156 OCLASS_DATA *pClass;
00157 EDIT_CLASS(ch,pClass);
00158
00159 if (argument[0] == '\0')
00160 {
00161 send_to_char("thac_0 <number>",ch);
00162 return TRUE;
00163 }
00164 if (!is_number(argument))
00165 {
00166 send_to_char("Value must be numberic\n\r",ch);
00167 return TRUE;
00168 }
00169 if (atoi (argument) > 50 || atoi (argument) < 5)
00170 {
00171 send_to_char("Be real...\n\r",ch);
00172 return TRUE;
00173 }
00174 pClass->thac_0 =atoi (argument);
00175 free_string(argument);
00176
00177
00178 return TRUE;
00179 }
00180 CEDIT (cedit_thac_32)
00181 {
00182 OCLASS_DATA *pClass;
00183 EDIT_CLASS(ch,pClass);
00184 if (argument[0] == '\0')
00185 {
00186 send_to_char("thac_32 <number>",ch);
00187 return TRUE;
00188 }
00189 if (!is_number(argument))
00190 {
00191 send_to_char("Value must be numberic\n\r",ch);
00192 return TRUE;
00193 }
00194 if (atoi (argument) > 0 || atoi (argument) < -50)
00195 {
00196 send_to_char("Be real...\n\r",ch);
00197 return TRUE;
00198 }
00199 pClass->thac_32 =atoi (argument);
00200 free_string(argument);
00201
00202
00203
00204
00205 return TRUE;
00206 }
00207 CEDIT (cedit_primary)
00208 {
00209 OCLASS_DATA *pClass;
00210 EDIT_CLASS (ch, pClass);
00211 if (argument[0] == '\0')
00212 {
00213 send_to_char("primary <number> (0 through 4)",ch);
00214 return TRUE;
00215 }
00216 if (!str_cmp(argument, "?"))
00217 {
00218 send_to_char("\n\r0 = strength\n\r1 = intelligence\n\r2 = Wisdom\n\r3 = Dexterity\n\r4 = Con\n\r",ch);
00219 return TRUE;
00220 }
00221
00222 if (!is_number(argument))
00223 {
00224 send_to_char("Value must be numeric.\n\r",ch);
00225 return TRUE;
00226 }
00227 if (atoi (argument) < 0 || atoi (argument) > 4)
00228 {
00229 send_to_char("Only 0 - 4\n\r",ch);
00230 return TRUE;
00231 }
00232 pClass->primary = atoi (argument);
00233 free_string(argument);
00234
00235 return TRUE;
00236 }
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287 CEDIT (cedit_skill)
00288 {
00289 OCLASS_DATA *pClass;
00290 EDIT_CLASS(ch, pClass);
00291 if (argument[0] == '\0')
00292 {
00293 send_to_char("skill <number>\n\r",ch);
00294 return TRUE;
00295 }
00296 if (!is_number(argument))
00297 {
00298 send_to_char("Value must be numeric\n\r",ch);
00299 return TRUE;
00300 }
00301 if (atoi (argument) < 10 || atoi (argument) > 80)
00302 {
00303 send_to_char("Must be between 10 and 80\n\r",ch);
00304 return TRUE;
00305 }
00306 pClass->skill = atoi (argument);
00307 free_string(argument);
00308
00309 return TRUE;
00310 }
00311 CEDIT (cedit_min_hp)
00312 {
00313 OCLASS_DATA *pClass;
00314 EDIT_CLASS(ch, pClass);
00315 if (argument[0] == '\0')
00316 {
00317 send_to_char("minhp <number>\n\r",ch);
00318 return TRUE;
00319 }
00320 if (!is_number(argument))
00321 {
00322 send_to_char("Value must be numeric\n\r",ch);
00323 return TRUE;
00324 }
00325 if (atoi (argument) < 5 || atoi (argument) > 15)
00326 {
00327 send_to_char("Between 5 and 15 only!\n\r",ch);
00328 return TRUE;
00329 }
00330 pClass->minhp = atoi (argument);
00331 free_string(argument);
00332
00333 return TRUE;
00334 }
00335 CEDIT (cedit_max_hp)
00336 {
00337 OCLASS_DATA *pClass;
00338 EDIT_CLASS(ch,pClass);
00339 if (argument[0] == '\0')
00340 {
00341 send_to_char("maxhp <number>\n\r",ch);
00342 return TRUE;
00343 }
00344 if (!is_number(argument))
00345 {
00346 send_to_char("Value must be numeric\n\r",ch);
00347 return TRUE;
00348 }
00349 if (atoi (argument) < 16 || atoi (argument) > 40)
00350 {
00351 send_to_char("Between 16 and 40 only!\n\r",ch);
00352 return TRUE;
00353 }
00354 pClass->maxhp = atoi (argument);
00355 free_string(argument);
00356
00357 return TRUE;
00358 }
00359 CEDIT (cedit_base)
00360 {
00361 OCLASS_DATA *pClass;
00362 EDIT_CLASS(ch, pClass);
00363 if (argument[0] == '\0')
00364 {
00365 send_to_char("base <base skill>\n\r",ch);
00366 return TRUE;
00367 }
00368 if (is_number(argument))
00369 {
00370 send_to_char("Non-numeric value, please.\n\r",ch);
00371 return TRUE;
00372 }
00373 pClass->base = str_dup(argument);
00374 free_string(argument);
00375
00376 return TRUE;
00377 }
00378 CEDIT (cedit_default)
00379 {
00380 OCLASS_DATA *pClass;
00381 EDIT_CLASS(ch,pClass);
00382 if (argument[0] == '\0')
00383 {
00384 send_to_char("default <default group>\n\r",ch);
00385 return TRUE;
00386 }
00387 if (is_number(argument))
00388 {
00389 send_to_char("Non-numeric value, please.\n\r",ch);
00390 return TRUE;
00391 }
00392 pClass->c_default = str_dup(argument);
00393 free_string(argument);
00394
00395 return TRUE;
00396 }
00397
00398 CEDIT (cedit_name)
00399 {
00400 OCLASS_DATA *pClass;
00401 EDIT_CLASS(ch, pClass);
00402 if (argument[0] == '\0')
00403 {
00404 send_to_char("name <name>\n\r",ch);
00405 return TRUE;
00406 }
00407 pClass->name = str_dup(argument);
00408
00409 return TRUE;
00410 }
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435 CEDIT (cedit_show)
00436 {
00437 OCLASS_DATA *pClass;
00438 EDIT_CLASS(ch, pClass);
00439 char buf[MAX_STRING_LENGTH];
00440
00441 sprintf(buf, "Name - [%s]\n\r", str_dup(pClass->name));
00442 send_to_char(buf,ch);
00443 sprintf(buf, "Wname - [%s]\n\r", str_dup(pClass->who_name));
00444 send_to_char(buf,ch);
00445 sprintf(buf, "Thac0 - [%d]\n\r", pClass->thac_0);
00446 send_to_char(buf,ch);
00447 sprintf(buf, "Thac32 - [%d]\n\r",pClass->thac_32);
00448 send_to_char(buf,ch);
00449 sprintf(buf, "Primary - [%d]\n\r",pClass->primary);
00450 send_to_char(buf,ch);
00451 sprintf(buf, "Weapon - [%d]\n\r",pClass->weapon);
00452 send_to_char(buf,ch);
00453 sprintf(buf, "Guild1 - [%d]\n\r", pClass->guild1);
00454 send_to_char(buf,ch);
00455 sprintf(buf, "Guild2 - [%d]\n\r", pClass->guild2);
00456 send_to_char(buf,ch);
00457 sprintf(buf, "Skill - [%d]\n\r", pClass->skill);
00458 send_to_char(buf,ch);
00459 sprintf(buf, "Maxhp - [%d]\n\r", pClass->maxhp);
00460 send_to_char(buf,ch);
00461 sprintf(buf, "Minhp - [%d]\n\r",pClass->minhp);
00462 send_to_char(buf,ch);
00463 sprintf(buf, "Base skills - [%s]\n\r", pClass->base);
00464 send_to_char(buf,ch);
00465 sprintf(buf, "Default skills - [%s]\n\r", pClass->c_default);
00466 send_to_char(buf,ch);
00467 return TRUE;
00468 }
00469 CEDIT (cedit_save)
00470 {
00471 OCLASS_DATA *pClass;
00472 EDIT_CLASS(ch,pClass);
00473 char buf[MAX_STRING_LENGTH];
00474 FILE *fp;
00475 if (pClass->name[0] == '\0' || pClass->name == NULL || !str_cmp(pClass->name, "New Class"))
00476 {
00477 send_to_char("Please supply a name.\n\r",ch);
00478 return TRUE;
00479 }
00480 if (pClass->who_name[0] == '\0' || pClass->who_name == NULL || !str_cmp(pClass->who_name, "NWC"))
00481 {
00482 send_to_char("Please supply a who name (wname)\n\r",ch);
00483 return TRUE;
00484 }
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501 if (pClass->maxhp == 0)
00502 {
00503 send_to_char("Maxhp needs to be set.\n\r",ch);
00504 return TRUE;
00505 }
00506 if (pClass->minhp == 0)
00507 {
00508 send_to_char("Minhp needs to be set.\n\r",ch);
00509 return TRUE;
00510 }
00511 if (pClass->base[0] == '\0' || pClass->base == NULL || !str_cmp(pClass->base, "New Class Basics"))
00512 {
00513 send_to_char("Base needs to be set.\n\r",ch);
00514 return TRUE;
00515 }
00516 if (pClass->c_default[0] == '\0' || pClass->c_default == NULL || !str_cmp(pClass->c_default, "New Class Default"))
00517 {
00518 send_to_char("Default needs to be set.\n\r",ch);
00519 return TRUE;
00520 }
00521 if (pClass->skill == 0)
00522 {
00523 send_to_char("Skill level needs to be set. (This is how far they can practice a skill to.)\n\r",ch);
00524 return TRUE;
00525 }
00526 send_to_char("Saving ... ",ch);
00527 sprintf(buf, "class/%s.class", pClass->name);
00528 fp = fopen (buf, "w");
00529 if (!fp)
00530 {
00531 send_to_char("Failed! -- Contact the head coder for details.\n\r",ch);
00532 return FALSE;
00533 }
00534 fprintf(fp, "#CLASS\n");
00535 fprintf(fp, "Name %s~\n", pClass->name);
00536 fprintf(fp, "WhoN %s~\n", pClass->who_name);
00537 fprintf(fp, "Prime %d\n", pClass->primary);
00538 fprintf(fp, "Weapon %d\n", pClass->weapon);
00539 fprintf(fp, "Guild1 %d\n",pClass->guild1);
00540 fprintf(fp, "Guild2 %d\n", pClass->guild2);
00541 fprintf(fp, "Skill %d\n", pClass->skill);
00542 fprintf(fp, "Thac00 %d\n", pClass->thac_0);
00543 fprintf(fp, "Thac32 %d\n", pClass->thac_32);
00544 fprintf(fp, "HPMIN %d\n", pClass->minhp);
00545 fprintf(fp, "HPMAX %d\n", pClass->maxhp);
00546 fprintf(fp, "FMana 0\n");
00547 fprintf(fp, "Pick 0\n");
00548 fprintf(fp, "Base %s~\n", pClass->base);
00549 fprintf(fp, "Default %s~\n", pClass->c_default);
00550 fprintf(fp, "End\n");
00551 send_to_char(" Done!\n\r",ch);
00552 send_to_char("This does not mean it will be loaded now. Submit note to Tribul, and tell him the name of the class.\n\r",ch);
00553 send_to_char("He will review it, and see if it is worthy, or not.\n\r",ch);
00554 send_to_char("Type done, and you may be on your way.\n\r",ch);
00555 fclose(fp);
00556 return TRUE;
00557
00558 }
00559
00560
00561 void cedit (CHAR_DATA *ch, char *argument)
00562 {
00563 char arg[MAX_INPUT_LENGTH];
00564 char command[MAX_INPUT_LENGTH];
00565 smash_tilde (argument);
00566 strcpy(arg, argument);
00567 argument = one_argument(argument, command);
00568 if (ch->level < 55)
00569 {
00570 send_to_char ("CEdit: You're not high enough level to do this.\n\r",ch);
00571 edit_done(ch);
00572 return;
00573 }
00574 if (!str_cmp(command, "done"))
00575 {
00576 edit_done (ch);
00577 return;
00578 }
00579
00580
00581 if (command[0] == '\0')
00582 {
00583 return;
00584 }
00585 int cmd;
00586 for (cmd = 0; cedit_table[cmd].name != NULL; cmd++)
00587 {
00588 if (!str_prefix(command, cedit_table[cmd].name))
00589 {
00590 if ((*cedit_table[cmd].olc_fun) (ch, argument))
00591 {
00592 return;
00593 }
00594 else
00595 return;
00596 }
00597 }
00598 interpret (ch, arg);
00599 return;
00600 }
00601