/* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * * Deliantra is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * The authors can be reached via e-mail to */ #include #include /* GROS: I put this here, because no other file seemed quite good. Returns 1 if * the artifact could be created. */ int create_artifact (object *op, const char *artifactname) { if (artifactlist *al = find_artifactlist (op->type)) for (artifact *art = al->items; art; art = art->next) { char *temptitle = (char *)(malloc (strlen (art->item->name) + 5)); strcpy (temptitle, " of "); strcat (temptitle, art->item->name); if (!strcmp (temptitle, artifactname)) { free (temptitle); give_artifact_abilities (op, art->item); return 1; } free (temptitle); }; return 0; } /* peterm: do_power_crystal object *op, object *crystal This function handles the application of power crystals. Power crystals, when applied, either suck power from the applier, if he's at full spellpoints, or gives him power, if it's got spellpoins stored. */ int apply_power_crystal (object *op, object *crystal) { int available_power; int power_space; int power_grab; available_power = op->stats.sp - op->stats.maxsp; power_space = crystal->stats.maxsp - crystal->stats.sp; power_grab = 0; if (available_power >= 0 && power_space > 0) power_grab = (int) MIN (power_space, 0.5 * op->stats.sp); if (available_power < 0 && crystal->stats.sp > 0) power_grab = -MIN (-available_power, crystal->stats.sp); op->stats.sp -= power_grab; crystal->stats.sp += power_grab; crystal->set_speed ((float) crystal->stats.sp / (float) crystal->stats.maxsp); if (object *pl = op->visible_to ()) esrv_update_item (UPD_ANIMSPEED, pl, crystal); return 1; }