Atrinik Server 2.5
types/marker.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 void move_marker(object *op)
00039 {
00040     object *tmp, *tmp2;
00041 
00042     for (tmp = GET_BOTTOM_MAP_OB(op); tmp != NULL; tmp = tmp->above)
00043     {
00044         /* we've got someone to MARK */
00045         if (tmp->type == PLAYER)
00046         {
00047             /* remove an old force with a slaying field == op->name */
00048             for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below)
00049             {
00050                 if (tmp2->type == FORCE && tmp2->slaying && tmp2->slaying == op->name)
00051                 {
00052                     break;
00053                 }
00054             }
00055 
00056             if (tmp2)
00057             {
00058                 remove_ob(tmp2);
00059             }
00060 
00061             /* cycle through his inventory to look for the MARK we want to place */
00062             for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below)
00063             {
00064                 if (tmp2->type == FORCE && tmp2->slaying && tmp2->slaying == op->slaying)
00065                 {
00066                     break;
00067                 }
00068             }
00069 
00070             /* if we didn't find our own MARK */
00071             if (tmp2 == NULL)
00072             {
00073                 object *force = get_archetype("force");
00074                 force->speed = 0;
00075 
00076                 if (op->stats.food)
00077                 {
00078                     force->speed = 0.01f;
00079                     force->speed_left = (float) -op->stats.food;
00080                 }
00081 
00082                 update_ob_speed(force);
00083                 /* put in the lock code */
00084                 FREE_AND_COPY_HASH(force->slaying, op->slaying);
00085                 insert_ob_in_ob(force, tmp);
00086 
00087                 if (op->msg)
00088                 {
00089                     new_draw_info(0, COLOR_NAVY, tmp, op->msg);
00090                 }
00091 
00092                 if (op->stats.hp > 0)
00093                 {
00094                     op->stats.hp--;
00095 
00096                     if (op->stats.hp == 0)
00097                     {
00098                         /* marker expires -- granted mark number limit */
00099                         destruct_ob(op);
00100                         return;
00101                     }
00102                 }
00103             }
00104         }
00105     }
00106 }