ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/egoitem.C
Revision: 1.6
Committed: Mon May 28 21:28:36 2007 UTC (17 years ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.5: +24 -0 lines
Log Message:
update copyrights in server/*.C

File Contents

# Content
1 /*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 *
8 * Crossfire TRT is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */
24
25 #include <global.h>
26 #include <sproto.h>
27
28 /* GROS: I put this here, because no other file seemed quite good. Returns 1 if
29 * the artifact could be created.
30 */
31 int
32 create_artifact (object *op, const char *artifactname)
33 {
34 if (artifactlist *al = find_artifactlist (op->type))
35 for (artifact *art = al->items; art; art = art->next)
36 {
37 char *temptitle = (char *)(malloc (strlen (art->item->name) + 5));
38 strcpy (temptitle, " of ");
39 strcat (temptitle, art->item->name);
40
41 if (!strcmp (temptitle, artifactname))
42 {
43 free (temptitle);
44 give_artifact_abilities (op, art->item);
45 return 1;
46 }
47
48 free (temptitle);
49 };
50
51 return 0;
52 }
53
54 /* peterm: do_power_crystal
55
56 object *op, object *crystal
57
58 This function handles the application of power crystals.
59 Power crystals, when applied, either suck power from the applier,
60 if he's at full spellpoints, or gives him power, if it's got
61 spellpoins stored.
62
63 */
64
65 int
66 apply_power_crystal (object *op, object *crystal)
67 {
68 int available_power;
69 int power_space;
70 int power_grab;
71
72 available_power = op->stats.sp - op->stats.maxsp;
73 power_space = crystal->stats.maxsp - crystal->stats.sp;
74 power_grab = 0;
75 if (available_power >= 0 && power_space > 0)
76 power_grab = (int) MIN (power_space, 0.5 * op->stats.sp);
77 if (available_power < 0 && crystal->stats.sp > 0)
78 power_grab = -MIN (-available_power, crystal->stats.sp);
79
80 op->stats.sp -= power_grab;
81 crystal->stats.sp += power_grab;
82 crystal->set_speed ((float) crystal->stats.sp / (float) crystal->stats.maxsp);
83 if (op->type == PLAYER)
84 esrv_update_item (UPD_ANIMSPEED, op, crystal);
85
86 return 1;
87 }