1 |
elmex |
1.1 |
/* |
2 |
|
|
* static char *rcsid_egoitem_c = |
3 |
|
|
* "$Id$"; |
4 |
|
|
*/ |
5 |
|
|
|
6 |
|
|
|
7 |
|
|
#include <global.h> |
8 |
|
|
#ifndef __CEXTRACT__ |
9 |
|
|
#include <sproto.h> |
10 |
|
|
#endif |
11 |
|
|
|
12 |
|
|
/* GROS: I put this here, because no other file seemed quite good. Returns 1 if |
13 |
|
|
* the artifact could be created. |
14 |
|
|
*/ |
15 |
|
|
int create_artifact(object *op, const char *artifactname) |
16 |
|
|
{ |
17 |
|
|
artifactlist *al; |
18 |
|
|
artifact *art; |
19 |
|
|
char *temptitle; |
20 |
|
|
al = find_artifactlist(op->type); |
21 |
|
|
if (al==NULL) |
22 |
|
|
return 0; |
23 |
|
|
for (art=al->items; art!=NULL; art=art->next) |
24 |
|
|
{ |
25 |
|
|
temptitle = (char *)(malloc(strlen(art->item->name) + 5)); |
26 |
|
|
strcpy(temptitle, " of "); |
27 |
|
|
strcat(temptitle, art->item->name); |
28 |
|
|
if (!strcmp (temptitle, artifactname)) |
29 |
|
|
{ |
30 |
|
|
give_artifact_abilities(op, art->item); |
31 |
|
|
free(temptitle); |
32 |
|
|
return 1; |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
free(temptitle); |
36 |
|
|
}; |
37 |
|
|
return 0; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
|
41 |
|
|
/* peterm: do_power_crystal |
42 |
|
|
|
43 |
|
|
object *op, object *crystal |
44 |
|
|
|
45 |
|
|
This function handles the application of power crystals. |
46 |
|
|
Power crystals, when applied, either suck power from the applier, |
47 |
|
|
if he's at full spellpoints, or gives him power, if it's got |
48 |
|
|
spellpoins stored. |
49 |
|
|
|
50 |
|
|
*/ |
51 |
|
|
|
52 |
|
|
int apply_power_crystal(object *op, object *crystal) { |
53 |
|
|
int available_power; |
54 |
|
|
int power_space; |
55 |
|
|
int power_grab; |
56 |
|
|
|
57 |
|
|
available_power = op->stats.sp - op->stats.maxsp; |
58 |
|
|
power_space = crystal->stats.maxsp - crystal->stats.sp; |
59 |
|
|
power_grab = 0; |
60 |
|
|
if(available_power>=0 && power_space> 0 ) |
61 |
|
|
power_grab = (int) MIN ( power_space, 0.5 * op->stats.sp ); |
62 |
|
|
if(available_power < 0 && crystal->stats.sp >0 ) |
63 |
|
|
power_grab = - MIN( -available_power, crystal->stats.sp); |
64 |
|
|
|
65 |
|
|
op->stats.sp-=power_grab; |
66 |
|
|
crystal->stats.sp +=power_grab; |
67 |
|
|
crystal->speed = (float)crystal->stats.sp/(float)crystal->stats.maxsp; |
68 |
|
|
update_ob_speed(crystal); |
69 |
|
|
if (op->type == PLAYER) |
70 |
|
|
esrv_update_item(UPD_ANIMSPEED, op, crystal); |
71 |
|
|
|
72 |
|
|
return 1; |
73 |
|
|
} |
74 |
|
|
|