ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/egoitem.C
Revision: 1.11
Committed: Mon Oct 12 14:00:59 2009 UTC (14 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-2_82, rel-2_81
Changes since 1.10: +7 -6 lines
Log Message:
clarify license

File Contents

# Content
1 /*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
21 *
22 * The authors can be reached via e-mail to <support@deliantra.net>
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 int
65 apply_power_crystal (object *op, object *crystal)
66 {
67 int available_power;
68 int power_space;
69 int power_grab;
70
71 available_power = op->stats.sp - op->stats.maxsp;
72 power_space = crystal->stats.maxsp - crystal->stats.sp;
73 power_grab = 0;
74
75 if (available_power >= 0 && power_space > 0)
76 power_grab = (int) MIN (power_space, 0.5 * op->stats.sp);
77
78 if (available_power < 0 && crystal->stats.sp > 0)
79 power_grab = -MIN (-available_power, crystal->stats.sp);
80
81 op->stats.sp -= power_grab;
82 crystal->stats.sp += power_grab;
83 crystal->set_speed ((float) crystal->stats.sp / (float) crystal->stats.maxsp);
84
85 if (object *pl = op->visible_to ())
86 esrv_update_item (UPD_ANIMSPEED, pl, crystal);
87
88 return 1;
89 }