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