ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_wiz.C
(Generate patch)

Comparing deliantra/server/server/c_wiz.C (file contents):
Revision 1.40 by root, Tue Mar 6 19:02:36 2007 UTC vs.
Revision 1.48 by root, Tue Jun 5 13:05:02 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software; you can redistribute it and/or modify it
9 * it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
10 * the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
11 * (at your option) any later version. 11 * any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful, but
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * GNU General Public License for more details. 16 * for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License along
19 * along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * 21 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <sproto.h> 26#include <sproto.h>
27#include <spells.h> 27#include <spells.h>
423 * we also set up spell_name which is only 423 * we also set up spell_name which is only
424 * the first word. 424 * the first word.
425 */ 425 */
426 426
427 at_spell = archetype::find (cp); 427 at_spell = archetype::find (cp);
428 if (!at_spell || at_spell->clone.type != SPELL) 428 if (!at_spell || at_spell->type != SPELL)
429 at_spell = find_archetype_by_object_name (cp); 429 at_spell = find_archetype_by_object_name (cp);
430 if (!at_spell || at_spell->clone.type != SPELL) 430 if (!at_spell || at_spell->type != SPELL)
431 { 431 {
432 assign (spell_name, cp); 432 assign (spell_name, cp);
433 fsp = strchr (spell_name, ' '); 433 fsp = strchr (spell_name, ' ');
434 if (fsp) 434 if (fsp)
435 { 435 {
436 *fsp = 0; 436 *fsp = 0;
437 fsp++; 437 fsp++;
438 at_spell = archetype::find (spell_name); 438 at_spell = archetype::find (spell_name);
439 439
440 /* Got a spell, update the first string pointer */ 440 /* Got a spell, update the first string pointer */
441 if (at_spell && at_spell->clone.type == SPELL) 441 if (at_spell && at_spell->type == SPELL)
442 bp2 = cp + strlen (spell_name) + 1; 442 bp2 = cp + strlen (spell_name) + 1;
443 else 443 else
444 at_spell = NULL; 444 at_spell = NULL;
445 } 445 }
446 } 446 }
448 /* OK - we didn't find a spell - presume the 'of' 448 /* OK - we didn't find a spell - presume the 'of'
449 * in this case means its an artifact. 449 * in this case means its an artifact.
450 */ 450 */
451 if (!at_spell) 451 if (!at_spell)
452 { 452 {
453 if (find_artifactlist (at->clone.type) == NULL) 453 if (find_artifactlist (at->type) == NULL)
454 new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->clone.type); 454 new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->type);
455 else 455 else
456 { 456 {
457 art = find_artifactlist (at->clone.type)->items; 457 art = find_artifactlist (at->type)->items;
458 458
459 do 459 while (art)
460 { 460 {
461 if (!strcmp (art->item->name, cp)) 461 if (!strcmp (art->item->name, cp))
462 break; 462 break;
463
463 art = art->next; 464 art = art->next;
464 } 465 }
465 while (art != NULL);
466 466
467 if (!art) 467 if (!art)
468 new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->clone.type, cp); 468 new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->type, cp);
469 } 469 }
470 470
471 LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); 471 LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp);
472 } 472 }
473 } /* if cp */ 473 } /* if cp */
474 474
475 if ((at->clone.type == ROD || at->clone.type == WAND || at->clone.type == SCROLL || 475 if ((at->type == ROD || at->type == WAND || at->type == SCROLL ||
476 at->clone.type == HORN || at->clone.type == SPELLBOOK) && !at_spell) 476 at->type == HORN || at->type == SPELLBOOK) && !at_spell)
477 { 477 {
478 new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find spell %s for object that needs it, or it is of wrong type", cp); 478 new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find spell %s for object that needs it, or it is of wrong type", cp);
479 return 1; 479 return 1;
480 } 480 }
481 481
483 * Rather than have two different blocks with a lot of similar code, 483 * Rather than have two different blocks with a lot of similar code,
484 * just create one object, do all the processing, and then determine 484 * just create one object, do all the processing, and then determine
485 * if that one object should be inserted or if we need to make copies. 485 * if that one object should be inserted or if we need to make copies.
486 */ 486 */
487 tmp = arch_to_object (at); 487 tmp = arch_to_object (at);
488
489 if (settings.real_wiz == FALSE)
490 SET_FLAG (tmp, FLAG_WAS_WIZ);
491 488
492 if (set_magic) 489 if (set_magic)
493 set_abs_magic (tmp, magic); 490 set_abs_magic (tmp, magic);
494 491
495 if (art) 492 if (art)
575 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); 572 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2);
576 573
577 bp2 = bp3 + 1; 574 bp2 = bp3 + 1;
578 } 575 }
579 576
580 if (at->clone.nrof) 577 if (at->nrof)
581 { 578 {
582 if (at_spell) 579 if (at_spell)
583 insert_ob_in_ob (arch_to_object (at_spell), tmp); 580 insert_ob_in_ob (arch_to_object (at_spell), tmp);
584 581
585 tmp->x = op->x; 582 tmp->x = op->x;
600 } 597 }
601 else 598 else
602 { 599 {
603 for (i = 0; i < (set_nrof ? nrof : 1); i++) 600 for (i = 0; i < (set_nrof ? nrof : 1); i++)
604 { 601 {
605 archetype *atmp;
606 object *prev = 0, *head = 0; 602 object *prev = 0, *head = 0;
607 603
608 for (atmp = at; atmp; atmp = atmp->more) 604 for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more)
609 { 605 {
610 object *dup = arch_to_object (atmp); 606 object *dup = arch_to_object (atmp);
611 607
612 if (at_spell) 608 if (at_spell)
613 insert_ob_in_ob (arch_to_object (at_spell), dup); 609 insert_ob_in_ob (arch_to_object (at_spell), dup);
620 { 616 {
621 head = dup; 617 head = dup;
622 tmp->copy_to (dup); 618 tmp->copy_to (dup);
623 } 619 }
624 620
625 if (settings.real_wiz == FALSE)
626 SET_FLAG (dup, FLAG_WAS_WIZ);
627
628 dup->x = op->x + dup->arch->clone.x; 621 dup->x = op->x + dup->arch->x;
629 dup->y = op->y + dup->arch->clone.y; 622 dup->y = op->y + dup->arch->y;
630 dup->map = op->map; 623 dup->map = op->map;
631 624
632 if (head != dup) 625 if (head != dup)
633 { 626 {
634 dup->head = head; 627 dup->head = head;
644 int size_x = 0; 637 int size_x = 0;
645 int size_y = 0; 638 int size_y = 0;
646 639
647 while (check) 640 while (check)
648 { 641 {
649 size_x = MAX (size_x, check->arch->clone.x); 642 size_x = MAX (size_x, check->arch->x);
650 size_y = MAX (size_y, check->arch->clone.y); 643 size_y = MAX (size_y, check->arch->y);
651 check = check->more; 644 check = check->more;
652 } 645 }
653 646
654 if (out_of_map (op->map, head->x + size_x, head->y + size_y)) 647 if (out_of_map (op->map, head->x + size_x, head->y + size_y))
655 { 648 {
681 /* Wonder if we really want to push all of these, but since 674 /* Wonder if we really want to push all of these, but since
682 * things like rods have nrof 0, we want to cover those. 675 * things like rods have nrof 0, we want to cover those.
683 */ 676 */
684 dm_stack_push (op->contr, head->count); 677 dm_stack_push (op->contr, head->count);
685 678
686 if (at->clone.randomitems != NULL && !at_spell) 679 if (at->randomitems != NULL && !at_spell)
687 create_treasure (at->clone.randomitems, head, GT_APPLY, op->map->difficulty, 0); 680 create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0);
688 681
689 esrv_send_item (op, head); 682 esrv_send_item (op, head);
690 } 683 }
691 684
692 /* free the one we used to copy */ 685 /* free the one we used to copy */
771 return 1; 764 return 1;
772 } 765 }
773 766
774 if ((arg2 = strchr (arg, ' '))) 767 if ((arg2 = strchr (arg, ' ')))
775 arg2++; 768 arg2++;
776 if (settings.real_wiz == FALSE) 769
777 SET_FLAG (tmp, FLAG_WAS_WIZ); /* To avoid cheating */
778 if (set_variable (tmp, arg) == -1) 770 if (set_variable (tmp, arg) == -1)
779 new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg); 771 new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg);
780 else 772 else
781 {
782 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2); 773 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2);
783 }
784 774
785 return 1; 775 return 1;
786} 776}
787 777
788int 778int
882 } 872 }
883 873
884 pl->ob->stats.exp += i; 874 pl->ob->stats.exp += i;
885 calc_perm_exp (pl->ob); 875 calc_perm_exp (pl->ob);
886 player_lvl_adj (pl->ob, NULL); 876 player_lvl_adj (pl->ob, NULL);
887
888 if (settings.real_wiz == FALSE)
889 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
890 877
891 return 1; 878 return 1;
892 } 879 }
893 880
894 new_draw_info (NDI_UNIQUE, 0, op, "No such player."); 881 new_draw_info (NDI_UNIQUE, 0, op, "No such player.");
970 957
971 for_all_players (pl) 958 for_all_players (pl)
972 { 959 {
973 if (!strcmp (pl->ob->name, thing)) 960 if (!strcmp (pl->ob->name, thing))
974 { 961 {
975 if (settings.real_wiz == FALSE)
976 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
977 if (!strcmp ("str", thing2))
978 pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; 962 if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii;
979 if (!strcmp ("dex", thing2))
980 pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; 963 if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii;
981 if (!strcmp ("con", thing2))
982 pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; 964 if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii;
983 if (!strcmp ("wis", thing2))
984 pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; 965 if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii;
985 if (!strcmp ("cha", thing2))
986 pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii; 966 if (!strcmp ("cha", thing2)) pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii;
987 if (!strcmp ("int", thing2))
988 pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; 967 if (!strcmp ("int", thing2)) pl->ob->stats.Int = iii, pl->orig_stats.Int = iii;
989 if (!strcmp ("pow", thing2))
990 pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; 968 if (!strcmp ("pow", thing2)) pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii;
969
991 sprintf (buf, "%s has been altered.", &pl->ob->name); 970 sprintf (buf, "%s has been altered.", &pl->ob->name);
992 new_draw_info (NDI_UNIQUE, 0, op, buf); 971 new_draw_info (NDI_UNIQUE, 0, op, buf);
993 pl->ob->update_stats (); 972 pl->ob->update_stats ();
994 return 1; 973 return 1;
995 } 974 }
1004{ /* 'nodm' is alias */ 983{ /* 'nodm' is alias */
1005 CLEAR_FLAG (op, FLAG_WIZ); 984 CLEAR_FLAG (op, FLAG_WIZ);
1006 CLEAR_FLAG (op, FLAG_WIZPASS); 985 CLEAR_FLAG (op, FLAG_WIZPASS);
1007 CLEAR_FLAG (op, FLAG_WIZCAST); 986 CLEAR_FLAG (op, FLAG_WIZCAST);
1008 987
1009 if (settings.real_wiz == TRUE)
1010 CLEAR_FLAG (op, FLAG_WAS_WIZ);
1011 if (op->contr->hidden) 988 if (op->contr->hidden)
1012 { 989 {
1013 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); 990 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players");
1014 op->map->players++; 991 op->map->players++;
1015 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); 992 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name);
1077 } 1054 }
1078 1055
1079 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) 1056 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host))
1080 { 1057 {
1081 SET_FLAG (op, FLAG_WIZ); 1058 SET_FLAG (op, FLAG_WIZ);
1082 SET_FLAG (op, FLAG_WAS_WIZ);
1083 SET_FLAG (op, FLAG_WIZPASS); 1059 SET_FLAG (op, FLAG_WIZPASS);
1084 SET_FLAG (op, FLAG_WIZCAST); 1060 SET_FLAG (op, FLAG_WIZCAST);
1061
1085 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); 1062 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!");
1086 /* 1063 /*
1087 * Remove setting flying here - that won't work, because next 1064 * Remove setting flying here - that won't work, because next
1088 * fix_player() is called that will get cleared - proper solution 1065 * fix_player() is called that will get cleared - proper solution
1089 * is probably something like a wiz_force which gives that and any 1066 * is probably something like a wiz_force which gives that and any
1090 * other desired abilities. 1067 * other desired abilities.
1091 */ 1068 */
1092 clear_los (op); 1069 clear_los (op->contr);
1093 op->contr->write_buf[0] = '\0'; 1070 op->contr->write_buf[0] = '\0';
1094 1071
1095 if (!silent) 1072 if (!silent)
1096 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); 1073 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!");
1097 1074
1124command_invisible (object *op, char *params) 1101command_invisible (object *op, char *params)
1125{ 1102{
1126 if (op) 1103 if (op)
1127 { 1104 {
1128 op->invisible += 100; 1105 op->invisible += 100;
1129 update_object (op, UP_OBJ_FACE); 1106 update_object (op, UP_OBJ_CHANGE);
1130 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); 1107 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible.");
1131 } 1108 }
1132 1109
1133 return 0; 1110 return 0;
1134} 1111}
1146 * name than other "spell_xxx" archetypes and would always conflict. 1123 * name than other "spell_xxx" archetypes and would always conflict.
1147 */ 1124 */
1148static object * 1125static object *
1149get_spell_by_name (object *op, const char *spell_name) 1126get_spell_by_name (object *op, const char *spell_name)
1150{ 1127{
1151 archetype *ar; 1128 archetype *at;
1152 archetype *found; 1129 archetype *found;
1153 int conflict_found; 1130 int conflict_found;
1154 size_t spell_name_length; 1131 size_t spell_name_length;
1155 1132
1156 /* First check for full name matches. */ 1133 /* First check for full name matches. */
1157 conflict_found = 0; 1134 conflict_found = 0;
1158 found = NULL; 1135 found = NULL;
1159 for (ar = first_archetype; ar != NULL; ar = ar->next) 1136 for_all_archetypes (at)
1160 { 1137 {
1161 if (ar->clone.type != SPELL) 1138 if (at->type != SPELL)
1162 continue; 1139 continue;
1163 1140
1164 if (strncmp (ar->name, "spelldirect_", 12) == 0) 1141 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1165 continue; 1142 continue;
1166 1143
1167 if (strcmp (ar->clone.name, spell_name) != 0) 1144 if (strcmp (at->object::name, spell_name) != 0)
1168 continue; 1145 continue;
1169 1146
1170 if (found != NULL) 1147 if (found != NULL)
1171 { 1148 {
1172 if (!conflict_found) 1149 if (!conflict_found)
1173 { 1150 {
1174 conflict_found = 1; 1151 conflict_found = 1;
1175 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); 1152 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name);
1176 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->name); 1153 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname);
1177 } 1154 }
1155
1178 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->name); 1156 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname);
1179 continue; 1157 continue;
1180 } 1158 }
1181 1159
1182 found = ar; 1160 found = at;
1183 } 1161 }
1184 1162
1185 /* No match if more more than one archetype matches. */ 1163 /* No match if more more than one archetype matches. */
1186 if (conflict_found) 1164 if (conflict_found)
1187 return NULL; 1165 return NULL;
1192 1170
1193 /* No full match found: now check for partial matches. */ 1171 /* No full match found: now check for partial matches. */
1194 spell_name_length = strlen (spell_name); 1172 spell_name_length = strlen (spell_name);
1195 conflict_found = 0; 1173 conflict_found = 0;
1196 found = NULL; 1174 found = NULL;
1197 for (ar = first_archetype; ar != NULL; ar = ar->next) 1175 for_all_archetypes (at)
1198 { 1176 {
1199 if (ar->clone.type != SPELL) 1177 if (at->type != SPELL)
1200 continue; 1178 continue;
1201 1179
1202 if (strncmp (ar->name, "spelldirect_", 12) == 0) 1180 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1203 continue; 1181 continue;
1204 1182
1205 if (strncmp (ar->clone.name, spell_name, spell_name_length) != 0) 1183 if (strncmp (at->object::name, spell_name, spell_name_length) != 0)
1206 continue; 1184 continue;
1207 1185
1208 if (found != NULL) 1186 if (found != NULL)
1209 { 1187 {
1210 if (!conflict_found) 1188 if (!conflict_found)
1211 { 1189 {
1212 conflict_found = 1; 1190 conflict_found = 1;
1213 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); 1191 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name);
1214 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->clone.name); 1192 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name);
1215 } 1193 }
1216 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->clone.name); 1194 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name);
1217 continue; 1195 continue;
1218 } 1196 }
1219 1197
1220 found = ar; 1198 found = at;
1221 } 1199 }
1222 1200
1223 /* No match if more more than one archetype matches. */ 1201 /* No match if more more than one archetype matches. */
1224 if (conflict_found) 1202 if (conflict_found)
1225 return NULL; 1203 return NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines