ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/egoitem.C
(Generate patch)

Comparing deliantra/server/server/egoitem.C (file contents):
Revision 1.1 by elmex, Sun Aug 13 17:16:04 2006 UTC vs.
Revision 1.2 by root, Sun Sep 10 15:59:57 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines