Atrinik Server 2.5
types/rod.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 
00035 void regenerate_rod(object *rod)
00036 {
00037     if (++rod->stats.food > rod->stats.hp / 10 || rod->type == HORN)
00038     {
00039         rod->stats.food = 0;
00040 
00041         if (rod->stats.hp < rod->stats.maxhp)
00042         {
00043             rod->stats.hp += 1 + rod->stats.maxhp / 10;
00044 
00045             if (rod->stats.hp > rod->stats.maxhp)
00046             {
00047                 rod->stats.hp = rod->stats.maxhp;
00048             }
00049 
00050             fix_rod_speed(rod);
00051         }
00052     }
00053 }
00054 
00058 void drain_rod_charge(object *rod)
00059 {
00060     rod->stats.hp -= spells[rod->stats.sp].sp;
00061 
00062     if (QUERY_FLAG(rod, FLAG_ANIMATE))
00063     {
00064         fix_rod_speed(rod);
00065     }
00066 }
00067 
00071 void fix_rod_speed(object *rod)
00072 {
00073     rod->speed = (FABS(rod->arch->clone.speed) * rod->stats.hp) / (float) rod->stats.maxhp;
00074 
00075     if (rod->speed < 0.02f)
00076     {
00077         rod->speed = 0.02f;
00078     }
00079 
00080     update_ob_speed(rod);
00081 }