Atrinik Server 2.5
types/identify_altar.c
Go to the documentation of this file.
00001 /************************************************************************
00002 *            Atrinik, a Multiplayer Online Role Playing Game            *
00003 *                                                                       *
00004 *    Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team    *
00005 *                                                                       *
00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game)     *
00007 * and Crossfire (Multiplayer game for X-windows).                       *
00008 *                                                                       *
00009 * This program is free software; you can redistribute it and/or modify  *
00010 * it under the terms of the GNU General Public License as published by  *
00011 * the Free Software Foundation; either version 2 of the License, or     *
00012 * (at your option) any later version.                                   *
00013 *                                                                       *
00014 * This program is distributed in the hope that it will be useful,       *
00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00017 * GNU General Public License for more details.                          *
00018 *                                                                       *
00019 * You should have received a copy of the GNU General Public License     *
00020 * along with this program; if not, write to the Free Software           *
00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             *
00022 *                                                                       *
00023 * The author can be reached at admin@atrinik.org                        *
00024 ************************************************************************/
00025 
00030 #include <global.h>
00031 
00038 int apply_identify_altar(object *money, object *altar, object *pl)
00039 {
00040     object *id, *marked;
00041     int success = 0;
00042 
00043     if (pl == NULL || pl->type != PLAYER)
00044     {
00045         return 0;
00046     }
00047 
00048     /* Check for MONEY type is a special hack - it prevents 'nothing needs
00049      * identifying' from being printed out more than it needs to be. */
00050     if (!check_altar_sacrifice(altar, money) || money->type != MONEY)
00051     {
00052         return 0;
00053     }
00054 
00055     marked = find_marked_object(pl);
00056 
00057     /* if the player has a marked item, identify that if it needs to be
00058      * identified.  IF it doesn't, then go through the player inventory. */
00059     if (marked && !QUERY_FLAG(marked, FLAG_IDENTIFIED) && need_identify(marked))
00060     {
00061         if (operate_altar(altar, &money))
00062         {
00063             identify(marked);
00064             new_draw_info_format(0, COLOR_WHITE, pl, "You have %s.", long_desc(marked, pl));
00065 
00066             if (marked->msg)
00067             {
00068                 new_draw_info(0, COLOR_WHITE, pl, "The item has a story:");
00069                 new_draw_info(0, COLOR_WHITE, pl, marked->msg);
00070             }
00071 
00072             return money == NULL;
00073         }
00074     }
00075 
00076     for (id = pl->inv; id; id = id->below)
00077     {
00078         if (!QUERY_FLAG(id, FLAG_IDENTIFIED) && !IS_INVISIBLE(id, pl) && need_identify(id))
00079         {
00080             if (operate_altar(altar, &money))
00081             {
00082                 identify(id);
00083                 new_draw_info_format(0, COLOR_WHITE, pl, "You have %s.", long_desc(id, pl));
00084 
00085                 if (id->msg)
00086                 {
00087                     new_draw_info(0, COLOR_WHITE, pl, "The item has a story:");
00088                     new_draw_info(0, COLOR_WHITE, pl, id->msg);
00089                 }
00090 
00091                 success = 1;
00092 
00093                 /* If no more money, might as well quit now */
00094                 if (money == NULL || !check_altar_sacrifice(altar, money))
00095                 {
00096                     break;
00097                 }
00098             }
00099             else
00100             {
00101                 LOG(llevBug, "apply_identify_altar(): Couldn't do sacrifice when we should have been able to.\n");
00102                 break;
00103             }
00104         }
00105     }
00106 
00107     if (!success)
00108     {
00109         new_draw_info(0, COLOR_WHITE, pl, "You have nothing that needs identifying.");
00110     }
00111 
00112     return money == NULL;
00113 }