ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/egoitem.C
Revision: 1.4
Committed: Tue Dec 26 08:54:59 2006 UTC (17 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-2_0
Changes since 1.3: +2 -6 lines
Log Message:
replace update_ob_speed by ->set_speed

File Contents

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