1 | /* |
1 | /* |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) 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, |
… | |
… | |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License 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 |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * |
20 | * |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | #include <global.h> |
24 | #include <global.h> |
25 | #include <sproto.h> |
25 | #include <sproto.h> |
26 | #include <spells.h> |
26 | #include <spells.h> |
… | |
… | |
178 | command_kick (object *op, char *params) |
178 | command_kick (object *op, char *params) |
179 | { |
179 | { |
180 | for_all_players (pl) |
180 | for_all_players (pl) |
181 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
181 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
182 | { |
182 | { |
183 | object *op = pl->ob; |
183 | object *plop = pl->ob; |
184 | |
184 | |
185 | if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) |
185 | if (!QUERY_FLAG (plop, FLAG_REMOVED) && !QUERY_FLAG (plop, FLAG_FREED)) |
186 | { |
186 | { |
187 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &op->name); |
187 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &plop->name); |
188 | strcpy (op->contr->killer, "kicked"); |
188 | plop->contr->killer = op; |
189 | } |
189 | } |
190 | |
190 | |
191 | pl->ns->destroy (); |
191 | pl->ns->destroy (); |
192 | } |
192 | } |
193 | |
193 | |
… | |
… | |
279 | /* we have nowhere to send the prisoner.... */ |
279 | /* we have nowhere to send the prisoner.... */ |
280 | new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); |
280 | new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); |
281 | return 0; |
281 | return 0; |
282 | } |
282 | } |
283 | |
283 | |
284 | pl->ob->enter_exit (dummy); |
284 | pl->ob->player_goto (dummy->slaying, dummy->stats.hp, dummy->stats.sp);//TODO |
285 | dummy->destroy (); |
285 | dummy->destroy (); |
|
|
286 | |
286 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); |
287 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); |
287 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
288 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
288 | LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); |
289 | LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); |
289 | return 1; |
290 | return 1; |
290 | } |
291 | } |
… | |
… | |
314 | { |
315 | { |
315 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
316 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
316 | return 1; |
317 | return 1; |
317 | } |
318 | } |
318 | |
319 | |
319 | dummy = object::create (); |
320 | pl->ob->player_goto (op->map->path, op->x + freearr_x[i], op->y + freearr_y[i]); |
320 | EXIT_PATH (dummy) = op->map->path; |
|
|
321 | EXIT_X (dummy) = op->x + freearr_x[i]; |
|
|
322 | EXIT_Y (dummy) = op->y + freearr_y[i]; |
|
|
323 | pl->ob->enter_exit (dummy); |
|
|
324 | dummy->destroy (); |
|
|
325 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
321 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
326 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
322 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
327 | |
323 | |
328 | return 1; |
324 | return 1; |
329 | } |
325 | } |
… | |
… | |
455 | { |
451 | { |
456 | art = find_artifactlist (at->type)->items; |
452 | art = find_artifactlist (at->type)->items; |
457 | |
453 | |
458 | while (art) |
454 | while (art) |
459 | { |
455 | { |
460 | if (!strcmp (art->item->name, cp)) |
456 | if (!strcmp (&art->item->name, cp)) |
461 | break; |
457 | break; |
462 | |
458 | |
463 | art = art->next; |
459 | art = art->next; |
464 | } |
460 | } |
465 | |
461 | |
… | |
… | |
574 | } |
570 | } |
575 | |
571 | |
576 | if (at->nrof) |
572 | if (at->nrof) |
577 | { |
573 | { |
578 | if (at_spell) |
574 | if (at_spell) |
579 | insert_ob_in_ob (arch_to_object (at_spell), tmp); |
575 | tmp->insert (arch_to_object (at_spell)); |
580 | |
576 | |
581 | tmp->x = op->x; |
577 | tmp->x = op->x; |
582 | tmp->y = op->y; |
578 | tmp->y = op->y; |
|
|
579 | tmp->map = op->map; |
583 | |
580 | |
584 | if (set_nrof) |
581 | if (set_nrof) |
585 | tmp->nrof = nrof; |
582 | tmp->nrof = nrof; |
586 | |
583 | |
587 | tmp->map = op->map; |
584 | op->insert (tmp); |
588 | |
|
|
589 | tmp = insert_ob_in_ob (tmp, op); |
|
|
590 | esrv_send_item (op, tmp); |
|
|
591 | |
585 | |
592 | /* Let's put this created item on stack so dm can access it easily. */ |
586 | /* Let's put this created item on stack so dm can access it easily. */ |
593 | dm_stack_push (op->contr, tmp->count); |
587 | dm_stack_push (op->contr, tmp->count); |
594 | |
588 | |
595 | return 1; |
589 | return 1; |
… | |
… | |
673 | /* Wonder if we really want to push all of these, but since |
667 | /* Wonder if we really want to push all of these, but since |
674 | * things like rods have nrof 0, we want to cover those. |
668 | * things like rods have nrof 0, we want to cover those. |
675 | */ |
669 | */ |
676 | dm_stack_push (op->contr, head->count); |
670 | dm_stack_push (op->contr, head->count); |
677 | |
671 | |
678 | if (at->randomitems != NULL && !at_spell) |
672 | if (at->randomitems && !at_spell) |
679 | create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0); |
673 | create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0); |
680 | |
|
|
681 | esrv_send_item (op, head); |
|
|
682 | } |
674 | } |
683 | |
675 | |
684 | /* free the one we used to copy */ |
676 | /* free the one we used to copy */ |
685 | tmp->destroy (); |
677 | tmp->destroy (); |
686 | } |
678 | } |
… | |
… | |
693 | */ |
685 | */ |
694 | |
686 | |
695 | int |
687 | int |
696 | command_inventory (object *op, char *params) |
688 | command_inventory (object *op, char *params) |
697 | { |
689 | { |
|
|
690 | int i; |
698 | object *tmp; |
691 | object *tmp; |
699 | int i; |
|
|
700 | |
692 | |
701 | if (!params) |
693 | if (!params || !sscanf (params, "%d", &i) || !(tmp = find_object (i))) |
702 | { |
694 | { |
703 | inventory (op, NULL); |
695 | op->contr->failmsg ("Inventory of what object (nr)?"); |
704 | return 0; |
696 | return 1; |
705 | } |
|
|
706 | |
|
|
707 | if (!sscanf (params, "%d", &i) || (tmp = find_object (i)) == NULL) |
|
|
708 | { |
697 | } |
709 | new_draw_info (NDI_UNIQUE, 0, op, "Inventory of what object (nr)?"); |
|
|
710 | return 1; |
|
|
711 | } |
|
|
712 | |
698 | |
713 | inventory (op, tmp); |
699 | op->contr->infobox (MSG_CHANNEL ("examine"), tmp->query_inventory (op)); |
|
|
700 | |
714 | return 1; |
701 | return 1; |
715 | } |
702 | } |
716 | |
703 | |
717 | /* just show player's their skills for now. Dm's can |
704 | /* just show player's their skills for now. Dm's can |
718 | * already see skills w/ inventory command - b.t. |
705 | * already see skills w/ inventory command - b.t. |
… | |
… | |
902 | new_draw_info (NDI_UNIQUE, 0, op, "Who?"); |
889 | new_draw_info (NDI_UNIQUE, 0, op, "Who?"); |
903 | return 1; |
890 | return 1; |
904 | } |
891 | } |
905 | |
892 | |
906 | for_all_players (pl) |
893 | for_all_players (pl) |
907 | if (!strcmp (pl->ob->name, thing)) |
894 | if (!strcmp (&pl->ob->name, thing)) |
908 | { |
895 | { |
909 | sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); |
896 | sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); |
910 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
897 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
911 | sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); |
898 | sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); |
912 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
899 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
… | |
… | |
955 | return 1; |
942 | return 1; |
956 | } |
943 | } |
957 | |
944 | |
958 | for_all_players (pl) |
945 | for_all_players (pl) |
959 | { |
946 | { |
960 | if (!strcmp (pl->ob->name, thing)) |
947 | if (!strcmp (&pl->ob->name, thing)) |
961 | { |
948 | { |
962 | if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; |
949 | if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; |
963 | if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; |
950 | if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; |
964 | if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; |
951 | if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; |
965 | if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; |
952 | if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; |
… | |
… | |
982 | command_nowiz (object *op, char *params) |
969 | command_nowiz (object *op, char *params) |
983 | { /* 'nodm' is alias */ |
970 | { /* 'nodm' is alias */ |
984 | CLEAR_FLAG (op, FLAG_WIZ); |
971 | CLEAR_FLAG (op, FLAG_WIZ); |
985 | CLEAR_FLAG (op, FLAG_WIZPASS); |
972 | CLEAR_FLAG (op, FLAG_WIZPASS); |
986 | CLEAR_FLAG (op, FLAG_WIZCAST); |
973 | CLEAR_FLAG (op, FLAG_WIZCAST); |
|
|
974 | CLEAR_FLAG (op, FLAG_WIZLOOK); |
|
|
975 | op->contr->do_los = 1; |
987 | |
976 | |
988 | if (op->contr->hidden) |
977 | if (op->contr->hidden) |
989 | { |
978 | { |
990 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
979 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); |
991 | op->map->players++; |
980 | op->map->players++; |
… | |
… | |
993 | op->contr->hidden = 0; |
982 | op->contr->hidden = 0; |
994 | op->invisible = 1; |
983 | op->invisible = 1; |
995 | } |
984 | } |
996 | else |
985 | else |
997 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); |
986 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); |
|
|
987 | |
998 | return 1; |
988 | return 1; |
999 | } |
989 | } |
1000 | |
990 | |
1001 | /** |
991 | /** |
1002 | * object *op is trying to become dm. |
992 | * object *op is trying to become dm. |
… | |
… | |
1056 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1046 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1057 | { |
1047 | { |
1058 | SET_FLAG (op, FLAG_WIZ); |
1048 | SET_FLAG (op, FLAG_WIZ); |
1059 | SET_FLAG (op, FLAG_WIZPASS); |
1049 | SET_FLAG (op, FLAG_WIZPASS); |
1060 | SET_FLAG (op, FLAG_WIZCAST); |
1050 | SET_FLAG (op, FLAG_WIZCAST); |
|
|
1051 | SET_FLAG (op, FLAG_WIZLOOK); |
|
|
1052 | op->contr->do_los = 1; |
1061 | |
1053 | |
1062 | new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); |
1054 | new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); |
1063 | /* |
|
|
1064 | * Remove setting flying here - that won't work, because next |
|
|
1065 | * fix_player() is called that will get cleared - proper solution |
|
|
1066 | * is probably something like a wiz_force which gives that and any |
|
|
1067 | * other desired abilities. |
|
|
1068 | */ |
|
|
1069 | clear_los (op->contr); |
|
|
1070 | op->contr->write_buf[0] = '\0'; |
1055 | op->contr->write_buf[0] = '\0'; |
1071 | |
1056 | |
1072 | if (!silent) |
1057 | if (!silent) |
1073 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
1058 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
1074 | |
1059 | |
… | |
… | |
1114 | * Returns spell object (from archetypes) by name. |
1099 | * Returns spell object (from archetypes) by name. |
1115 | * Returns NULL if 0 or more than one spell matches. |
1100 | * Returns NULL if 0 or more than one spell matches. |
1116 | * Used for wizard's learn spell/prayer. |
1101 | * Used for wizard's learn spell/prayer. |
1117 | * |
1102 | * |
1118 | * op is the player issuing the command. |
1103 | * op is the player issuing the command. |
1119 | * |
|
|
1120 | * Ignores archetypes "spelldirect_xxx" since these archetypes are not used |
|
|
1121 | * anymore (but may still be present in some player's inventories and thus |
|
|
1122 | * cannot be removed). We have to ignore them here since they have the same |
|
|
1123 | * name than other "spell_xxx" archetypes and would always conflict. |
|
|
1124 | */ |
1104 | */ |
1125 | static object * |
1105 | static object * |
1126 | get_spell_by_name (object *op, const char *spell_name) |
1106 | get_spell_by_name (object *op, shstr_cmp spell_name) |
1127 | { |
1107 | { |
1128 | archetype *at; |
1108 | archetype *at; |
1129 | archetype *found; |
1109 | archetype *found; |
1130 | int conflict_found; |
1110 | int conflict_found; |
1131 | size_t spell_name_length; |
1111 | size_t spell_name_length; |
… | |
… | |
1136 | for_all_archetypes (at) |
1116 | for_all_archetypes (at) |
1137 | { |
1117 | { |
1138 | if (at->type != SPELL) |
1118 | if (at->type != SPELL) |
1139 | continue; |
1119 | continue; |
1140 | |
1120 | |
1141 | if (strncmp (at->archname, "spelldirect_", 12) == 0) |
1121 | if (at->object::name != spell_name) |
1142 | continue; |
1122 | continue; |
1143 | |
1123 | |
1144 | if (strcmp (at->object::name, spell_name) != 0) |
|
|
1145 | continue; |
|
|
1146 | |
|
|
1147 | if (found != NULL) |
1124 | if (found) |
1148 | { |
1125 | { |
1149 | if (!conflict_found) |
1126 | if (!conflict_found) |
1150 | { |
1127 | { |
1151 | conflict_found = 1; |
1128 | conflict_found = 1; |
1152 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); |
1129 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", &spell_name); |
1153 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); |
1130 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); |
1154 | } |
1131 | } |
1155 | |
1132 | |
1156 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); |
1133 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); |
1157 | continue; |
1134 | continue; |
… | |
… | |
1186 | if (found != NULL) |
1163 | if (found != NULL) |
1187 | { |
1164 | { |
1188 | if (!conflict_found) |
1165 | if (!conflict_found) |
1189 | { |
1166 | { |
1190 | conflict_found = 1; |
1167 | conflict_found = 1; |
1191 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); |
1168 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", &spell_name); |
1192 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name); |
1169 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name); |
1193 | } |
1170 | } |
1194 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name); |
1171 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name); |
1195 | continue; |
1172 | continue; |
1196 | } |
1173 | } |
… | |
… | |
1205 | /* Return if exactly one archetype matches. */ |
1182 | /* Return if exactly one archetype matches. */ |
1206 | if (found != NULL) |
1183 | if (found != NULL) |
1207 | return arch_to_object (found); |
1184 | return arch_to_object (found); |
1208 | |
1185 | |
1209 | /* No spell found: just print an error message. */ |
1186 | /* No spell found: just print an error message. */ |
1210 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spell %s does not exist.", spell_name); |
1187 | new_draw_info_format (NDI_UNIQUE, 0, op, "The spell %s does not exist.", &spell_name); |
1211 | return NULL; |
1188 | return NULL; |
1212 | } |
1189 | } |
1213 | |
1190 | |
1214 | static int |
1191 | static int |
1215 | command_learn_spell_or_prayer (object *op, char *params, int special_prayer) |
1192 | command_learn_spell_or_prayer (object *op, char *params, int special_prayer) |
… | |
… | |
1598 | return 0; |
1575 | return 0; |
1599 | } |
1576 | } |
1600 | |
1577 | |
1601 | if (!QUERY_FLAG (right, FLAG_REMOVED)) |
1578 | if (!QUERY_FLAG (right, FLAG_REMOVED)) |
1602 | right->remove (); |
1579 | right->remove (); |
|
|
1580 | |
1603 | inserted = insert_ob_in_ob (right, left); |
1581 | insert_ob_in_ob (right, left); |
1604 | if (left->type == PLAYER) |
|
|
1605 | if (inserted == right) |
|
|
1606 | esrv_send_item (left, right); |
|
|
1607 | else |
|
|
1608 | esrv_update_item (UPD_WEIGHT | UPD_NAME | UPD_NROF, left, inserted); |
|
|
1609 | |
1582 | |
1610 | new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left)); |
1583 | new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left)); |
1611 | |
1584 | |
1612 | return 0; |
1585 | return 0; |
1613 | |
1586 | |