1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra 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 | * Deliantra is free software: you can redistribute it and/or modify it under |
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 |
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 |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <sproto.h> |
26 | #include <sproto.h> |
27 | |
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 |
28 | /* peterm: do_power_crystal |
55 | |
29 | |
56 | object *op, object *crystal |
30 | object *op, object *crystal |
57 | |
31 | |
58 | This function handles the application of power crystals. |
32 | This function handles the application of power crystals. |
… | |
… | |
62 | |
36 | |
63 | */ |
37 | */ |
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 | |
|
|
75 | if (available_power >= 0 && power_space > 0) |
45 | if (available_power >= 0 && power_space > 0) |
|
|
46 | { |
76 | power_grab = (int) MIN (power_space, 0.5 * op->stats.sp); |
47 | power_grab = min (power_space, 0.5 * op->stats.sp); |
77 | |
48 | op->statusmsg (format ("The %s takes some of your mana.", query_name (crystal))); |
|
|
49 | } |
78 | if (available_power < 0 && crystal->stats.sp > 0) |
50 | else if (available_power < 0 && crystal->stats.sp > 0) |
|
|
51 | { |
79 | 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 | } |
80 | |
60 | |
81 | op->stats.sp -= power_grab; |
61 | op->stats.sp -= power_grab; |
82 | crystal->stats.sp += power_grab; |
62 | crystal->stats.sp += power_grab; |
83 | crystal->set_speed ((float) crystal->stats.sp / (float) crystal->stats.maxsp); |
63 | crystal->set_speed ((float) crystal->stats.sp / (float) crystal->stats.maxsp); |
84 | |
64 | |