ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/egoitem.C
Revision: 1.24
Committed: Sat Nov 17 23:40:03 2018 UTC (5 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.23: +1 -0 lines
Log Message:
copyright update 2018

File Contents

# Content
1 /*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 *
4 * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
7 * Copyright (©) 1992 Frank Tore Johansen
8 *
9 * Deliantra is free software: you can redistribute it and/or modify it under
10 * the terms of the Affero GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the Affero GNU General Public License
20 * and the GNU General Public License along with this program. If not, see
21 * <http://www.gnu.org/licenses/>.
22 *
23 * The authors can be reached via e-mail to <support@deliantra.net>
24 */
25
26 #include <global.h>
27 #include <sproto.h>
28
29 /* peterm: do_power_crystal
30
31 object *op, object *crystal
32
33 This function handles the application of power crystals.
34 Power crystals, when applied, either suck power from the applier,
35 if he's at full spellpoints, or gives him power, if it's got
36 spellpoins stored.
37
38 */
39 int
40 apply_power_crystal (object *op, object *crystal)
41 {
42 int available_power = op->stats.sp - op->stats.maxsp;
43 int power_space = crystal->stats.maxsp - crystal->stats.sp;
44 int power_grab;
45
46 if (available_power >= 0 && power_space > 0)
47 {
48 power_grab = min (power_space, op->stats.sp / 2);
49 op->statusmsg (format ("The %s takes some of your mana.", query_name (crystal)));
50 }
51 else if (available_power < 0 && crystal->stats.sp > 0)
52 {
53 power_grab = -min (-available_power, crystal->stats.sp);
54 op->statusmsg (format ("Mana from the %s is entering your body.", query_name (crystal)));
55 }
56 else
57 {
58 power_grab = 0;
59 op->statusmsg (format ("You touch the %s, but nothing happens.", query_name (crystal)));
60 }
61
62 op->stats.sp -= power_grab;
63 crystal->stats.sp += power_grab;
64 crystal->set_speed ((float) crystal->stats.sp / (float) crystal->stats.maxsp);
65
66 if (object *pl = op->visible_to ())
67 esrv_update_item (UPD_ANIMSPEED, pl, crystal);
68
69 return 1;
70 }