1 |
root |
1.6 |
/* |
2 |
root |
1.8 |
* This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 |
root |
1.6 |
* |
4 |
root |
1.10 |
* Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 |
root |
1.6 |
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 |
|
|
* Copyright (©) 1992,2007 Frank Tore Johansen |
7 |
|
|
* |
8 |
root |
1.8 |
* Deliantra is free software: you can redistribute it and/or modify |
9 |
root |
1.7 |
* it under the terms of the GNU General Public License as published by |
10 |
|
|
* the Free Software Foundation, either version 3 of the License, or |
11 |
|
|
* (at your option) any later version. |
12 |
root |
1.6 |
* |
13 |
root |
1.7 |
* 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 |
root |
1.6 |
* |
18 |
root |
1.7 |
* You should have received a copy of the GNU General Public License |
19 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 |
root |
1.6 |
* |
21 |
root |
1.8 |
* The authors can be reached via e-mail to <support@deliantra.net> |
22 |
root |
1.6 |
*/ |
23 |
|
|
|
24 |
elmex |
1.1 |
#include <global.h> |
25 |
root |
1.4 |
#include <sproto.h> |
26 |
elmex |
1.1 |
|
27 |
|
|
/* GROS: I put this here, because no other file seemed quite good. Returns 1 if |
28 |
|
|
* the artifact could be created. |
29 |
|
|
*/ |
30 |
root |
1.2 |
int |
31 |
|
|
create_artifact (object *op, const char *artifactname) |
32 |
elmex |
1.1 |
{ |
33 |
root |
1.5 |
if (artifactlist *al = find_artifactlist (op->type)) |
34 |
|
|
for (artifact *art = al->items; art; art = art->next) |
35 |
|
|
{ |
36 |
|
|
char *temptitle = (char *)(malloc (strlen (art->item->name) + 5)); |
37 |
|
|
strcpy (temptitle, " of "); |
38 |
|
|
strcat (temptitle, art->item->name); |
39 |
|
|
|
40 |
|
|
if (!strcmp (temptitle, artifactname)) |
41 |
|
|
{ |
42 |
|
|
free (temptitle); |
43 |
|
|
give_artifact_abilities (op, art->item); |
44 |
|
|
return 1; |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
free (temptitle); |
48 |
|
|
}; |
49 |
root |
1.2 |
|
50 |
|
|
return 0; |
51 |
elmex |
1.1 |
} |
52 |
|
|
|
53 |
|
|
/* peterm: do_power_crystal |
54 |
|
|
|
55 |
|
|
object *op, object *crystal |
56 |
|
|
|
57 |
|
|
This function handles the application of power crystals. |
58 |
|
|
Power crystals, when applied, either suck power from the applier, |
59 |
|
|
if he's at full spellpoints, or gives him power, if it's got |
60 |
|
|
spellpoins stored. |
61 |
|
|
|
62 |
|
|
*/ |
63 |
root |
1.2 |
int |
64 |
|
|
apply_power_crystal (object *op, object *crystal) |
65 |
|
|
{ |
66 |
elmex |
1.1 |
int available_power; |
67 |
|
|
int power_space; |
68 |
|
|
int power_grab; |
69 |
|
|
|
70 |
root |
1.2 |
available_power = op->stats.sp - op->stats.maxsp; |
71 |
elmex |
1.1 |
power_space = crystal->stats.maxsp - crystal->stats.sp; |
72 |
|
|
power_grab = 0; |
73 |
root |
1.9 |
|
74 |
root |
1.2 |
if (available_power >= 0 && power_space > 0) |
75 |
|
|
power_grab = (int) MIN (power_space, 0.5 * op->stats.sp); |
76 |
root |
1.9 |
|
77 |
root |
1.2 |
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 |
root |
1.4 |
crystal->set_speed ((float) crystal->stats.sp / (float) crystal->stats.maxsp); |
83 |
root |
1.9 |
|
84 |
|
|
if (object *pl = op->visible_to ()) |
85 |
|
|
esrv_update_item (UPD_ANIMSPEED, pl, crystal); |
86 |
elmex |
1.1 |
|
87 |
|
|
return 1; |
88 |
|
|
} |