ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/egoitem.C
Revision: 1.5
Committed: Mon Apr 16 06:23:42 2007 UTC (17 years, 1 month ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-2_1
Changes since 1.4: +16 -20 lines
Log Message:
VERY EXPERIMENTAL

- change the way archetypes and treasurelists are being loaded:
  - referring to a nonexisting treasurelist will create an empty one
  - referring to a nonexisting archetype will create an empty one
  - archetypes/treasurelists will overwrite any existing object
    of the same name.

- net effect should be to allow reloading of archetypes and treasurelists
  at runtime at a later stage.

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.5 if (artifactlist *al = find_artifactlist (op->type))
11     for (artifact *art = al->items; art; art = art->next)
12     {
13     char *temptitle = (char *)(malloc (strlen (art->item->name) + 5));
14     strcpy (temptitle, " of ");
15     strcat (temptitle, art->item->name);
16    
17     if (!strcmp (temptitle, artifactname))
18     {
19     free (temptitle);
20     give_artifact_abilities (op, art->item);
21     return 1;
22     }
23    
24     free (temptitle);
25     };
26 root 1.2
27     return 0;
28 elmex 1.1 }
29    
30     /* peterm: do_power_crystal
31    
32     object *op, object *crystal
33    
34     This function handles the application of power crystals.
35     Power crystals, when applied, either suck power from the applier,
36     if he's at full spellpoints, or gives him power, if it's got
37     spellpoins stored.
38    
39     */
40    
41 root 1.2 int
42     apply_power_crystal (object *op, object *crystal)
43     {
44 elmex 1.1 int available_power;
45     int power_space;
46     int power_grab;
47    
48 root 1.2 available_power = op->stats.sp - op->stats.maxsp;
49 elmex 1.1 power_space = crystal->stats.maxsp - crystal->stats.sp;
50     power_grab = 0;
51 root 1.2 if (available_power >= 0 && power_space > 0)
52     power_grab = (int) MIN (power_space, 0.5 * op->stats.sp);
53     if (available_power < 0 && crystal->stats.sp > 0)
54     power_grab = -MIN (-available_power, crystal->stats.sp);
55    
56     op->stats.sp -= power_grab;
57     crystal->stats.sp += power_grab;
58 root 1.4 crystal->set_speed ((float) crystal->stats.sp / (float) crystal->stats.maxsp);
59 elmex 1.1 if (op->type == PLAYER)
60 root 1.2 esrv_update_item (UPD_ANIMSPEED, op, crystal);
61 elmex 1.1
62     return 1;
63     }