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

Comparing deliantra/server/common/treasure.C (file contents):
Revision 1.90 by root, Fri Nov 6 13:31:47 2009 UTC vs.
Revision 1.102 by root, Wed Apr 7 19:54:45 2010 UTC

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.
33 33
34//#define TREASURE_VERBOSE 34//#define TREASURE_VERBOSE
35 35
36#include <global.h> 36#include <global.h>
37#include <treasure.h> 37#include <treasure.h>
38#include <loader.h>
39 38
40extern char *spell_mapping[]; 39extern char *spell_mapping[];
41 40
42static treasurelist *first_treasurelist; 41static treasurelist *first_treasurelist;
43 42
310 } 309 }
311 else 310 else
312 { 311 {
313 if (t->item && (t->item->invisible != 0 || !(flag & GT_INVISIBLE))) 312 if (t->item && (t->item->invisible != 0 || !(flag & GT_INVISIBLE)))
314 { 313 {
315 object *tmp = arch_to_object (t->item); 314 object *tmp = t->item->instance ();
316 315
317 if (t->nrof && tmp->nrof <= 1) 316 if (t->nrof && tmp->nrof <= 1)
318 tmp->nrof = rndm (t->nrof) + 1; 317 tmp->nrof = rndm (t->nrof) + 1;
319 318
320 fix_generated_item (tmp, op, difficulty, t->magic, flag); 319 fix_generated_item (tmp, op, difficulty, t->magic, flag);
367 else if (t->nrof) 366 else if (t->nrof)
368 create_one_treasure (tl, op, flag, difficulty, tries); 367 create_one_treasure (tl, op, flag, difficulty, tries);
369 } 368 }
370 else if (t->item && (t->item->invisible != 0 || flag != GT_INVISIBLE)) 369 else if (t->item && (t->item->invisible != 0 || flag != GT_INVISIBLE))
371 { 370 {
372 if (object *tmp = arch_to_object (t->item)) 371 if (object *tmp = t->item->instance ())
373 { 372 {
374 if (t->nrof && tmp->nrof <= 1) 373 if (t->nrof && tmp->nrof <= 1)
375 tmp->nrof = rndm (t->nrof) + 1; 374 tmp->nrof = rndm (t->nrof) + 1;
376 375
377 fix_generated_item (tmp, op, difficulty, t->magic, flag); 376 fix_generated_item (tmp, op, difficulty, t->magic, flag);
834 create_treasure (op->randomitems, op, flags & ~GT_ENVIRONMENT, difficulty, 0); 833 create_treasure (op->randomitems, op, flags & ~GT_ENVIRONMENT, difficulty, 0);
835 /* So the treasure doesn't get created again */ 834 /* So the treasure doesn't get created again */
836 op->randomitems = 0; 835 op->randomitems = 0;
837 } 836 }
838 837
839 if (difficulty < 1) 838 max_it (difficulty, 1);
840 difficulty = 1;
841 839
842 if (INVOKE_OBJECT (ADD_BONUS, op, 840 if (INVOKE_OBJECT (ADD_BONUS, op,
843 ARG_OBJECT (creator != op ? creator : 0), 841 ARG_OBJECT (creator != op ? creator : 0),
844 ARG_INT (difficulty), ARG_INT (max_magic), 842 ARG_INT (difficulty), ARG_INT (max_magic),
845 ARG_INT (flags))) 843 ARG_INT (flags)))
904 * again below */ 902 * again below */
905 } 903 }
906 } 904 }
907 905
908 /* materialtype modifications. Note we allow this on artifacts. */ 906 /* materialtype modifications. Note we allow this on artifacts. */
909 set_materialname (op, difficulty, NULL); 907 select_material (op, difficulty);
910 908
911 if (flags & GT_MINIMAL) 909 if (flags & GT_MINIMAL)
912 { 910 {
913 if (op->type == POTION) 911 if (op->type == POTION)
914 /* Handle healing and magic power potions */ 912 /* Handle healing and magic power potions */
945 int too_many_tries = 0, is_special = 0; 943 int too_many_tries = 0, is_special = 0;
946 944
947 /* Handle healing and magic power potions */ 945 /* Handle healing and magic power potions */
948 if (op->stats.sp && !op->randomitems) 946 if (op->stats.sp && !op->randomitems)
949 { 947 {
950 object *tmp;
951
952 tmp = get_archetype (spell_mapping[op->stats.sp]); 948 object *tmp = get_archetype (spell_mapping[op->stats.sp]);
953 insert_ob_in_ob (tmp, op); 949 insert_ob_in_ob (tmp, op);
954 op->stats.sp = 0; 950 op->stats.sp = 0;
955 } 951 }
956 952
957 while (!(is_special = special_potion (op)) && !op->inv) 953 while (!(is_special = special_potion (op)) && !op->inv)
965 * since the value set on those is already correct. 961 * since the value set on those is already correct.
966 */ 962 */
967 if (op->inv && op->randomitems) 963 if (op->inv && op->randomitems)
968 { 964 {
969 /* value multiplier is same as for scrolls */ 965 /* value multiplier is same as for scrolls */
970 op->value = (op->value * op->inv->value); 966 op->value *= op->inv->value;
971 op->level = op->inv->level / 2 + rndm (difficulty) + rndm (difficulty); 967 op->level = op->inv->level / 2 + rndm (difficulty) + rndm (difficulty);
972 } 968 }
973 else 969 else
974 { 970 {
975 op->name = "potion"; 971 op->name = "potion";
976 op->name_pl = "potions"; 972 op->name_pl = "potions";
977 } 973 }
978 974
979 if (!(flags & GT_ONLY_GOOD) && rndm (2)) 975 if (!(flags & GT_ONLY_GOOD) && rndm (2))
980 SET_FLAG (op, FLAG_CURSED); 976 SET_FLAG (op, FLAG_CURSED);
977
981 break; 978 break;
982 } 979 }
983 980
984 case AMULET: 981 case AMULET:
985 if (IS_ARCH (op->arch, amulet)) 982 if (IS_ARCH (op->arch, amulet))
1097 * 10 time multiplier). This way, the value are a bit more reasonable. 1094 * 10 time multiplier). This way, the value are a bit more reasonable.
1098 */ 1095 */
1099 op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50); 1096 op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50);
1100 /* maxhp is used to denote how many 'charges' the rod holds before */ 1097 /* maxhp is used to denote how many 'charges' the rod holds before */
1101 if (op->stats.maxhp) 1098 if (op->stats.maxhp)
1102 op->stats.maxhp *= MAX (op->inv->stats.sp, op->inv->stats.grace); 1099 op->stats.maxhp *= max (op->inv->stats.sp, op->inv->stats.grace);
1103 else 1100 else
1104 op->stats.maxhp = 2 * MAX (op->inv->stats.sp, op->inv->stats.grace); 1101 op->stats.maxhp = 2 * max (op->inv->stats.sp, op->inv->stats.grace);
1105 1102
1106 op->stats.hp = op->stats.maxhp; 1103 op->stats.hp = op->stats.maxhp;
1107 break; 1104 break;
1108 1105
1109 case SCROLL: 1106 case SCROLL:
1146 1143
1147/* 1144/*
1148 * Allocate and return the pointer to an empty artifactlist structure. 1145 * Allocate and return the pointer to an empty artifactlist structure.
1149 */ 1146 */
1150static artifactlist * 1147static artifactlist *
1151get_empty_artifactlist (void) 1148get_empty_artifactlist ()
1152{ 1149{
1153 return salloc0<artifactlist> (); 1150 return salloc0<artifactlist> ();
1154} 1151}
1155 1152
1156/* 1153/*
1157 * Allocate and return the pointer to an empty artifact structure. 1154 * Allocate and return the pointer to an empty artifact structure.
1158 */ 1155 */
1159static artifact * 1156static artifact *
1160get_empty_artifact (void) 1157get_empty_artifact ()
1161{ 1158{
1162 return salloc0<artifact> (); 1159 return salloc0<artifact> ();
1163} 1160}
1164 1161
1165/* 1162/*
1178 1175
1179/* 1176/*
1180 * Builds up the lists of artifacts from the file in the libdir. 1177 * Builds up the lists of artifacts from the file in the libdir.
1181 */ 1178 */
1182void 1179void
1183init_artifacts (void) 1180init_artifacts ()
1184{ 1181{
1185 static int has_been_inited = 0; 1182 static int has_been_inited = 0;
1186 char filename[MAX_BUF]; 1183 char filename[MAX_BUF];
1187 artifact *art = NULL; 1184 artifact *art = NULL;
1188 artifactlist *al; 1185 artifactlist *al;
1208 1205
1209 { 1206 {
1210 if (!strcmp (f.get_str (), "all")) 1207 if (!strcmp (f.get_str (), "all"))
1211 break; 1208 break;
1212 1209
1213 char *next, *cp = f.get_str (); 1210 const char *cp = f.get_str ();
1214 1211 char *next;
1215 do 1212 do
1216 { 1213 {
1217 if ((next = strchr (cp, ','))) 1214 if ((next = (char *)strchr (cp, ',')))
1218 *next++ = '\0'; 1215 *next++ = '\0';
1219 1216
1220 linked_char *tmp = new linked_char; 1217 linked_char *tmp = new linked_char;
1221 1218
1222 tmp->name = cp; 1219 tmp->name = cp;
1369 if (op->type == HORN || op->type == POTION) 1366 if (op->type == HORN || op->type == POTION)
1370 { 1367 {
1371 /* Remove any spells this object currently has in it */ 1368 /* Remove any spells this object currently has in it */
1372 op->destroy_inv (false); 1369 op->destroy_inv (false);
1373 1370
1374 object *tmp = arch_to_object (change->other_arch); 1371 object *tmp = change->other_arch->instance ();
1375 insert_ob_in_ob (tmp, op); 1372 insert_ob_in_ob (tmp, op);
1376 } 1373 }
1374
1377 /* No harm setting this for potions/horns */ 1375 /* No harm setting this for potions/horns */
1378 op->other_arch = change->other_arch; 1376 op->other_arch = change->other_arch;
1379 } 1377 }
1380 1378
1381 if (change->stats.hp < 0) 1379 if (change->stats.hp < 0)
1465 op->value *= change->value; 1463 op->value *= change->value;
1466 1464
1467 if (change->materials) 1465 if (change->materials)
1468 op->materials = change->materials; 1466 op->materials = change->materials;
1469 1467
1470 if (change->materialname) 1468 if (change->material != MATERIAL_NULL)
1471 op->materialname = change->materialname; 1469 op->material = change->material;
1472 1470
1473 if (change->slaying) 1471 if (change->slaying)
1474 op->slaying = change->slaying; 1472 op->slaying = change->slaying;
1475 1473
1476 if (change->race) 1474 if (change->race)
1688 at->item->destroy (); 1686 at->item->destroy ();
1689 1687
1690 sfree (at); 1688 sfree (at);
1691} 1689}
1692 1690
1693static void
1694free_artifactlist (artifactlist *al)
1695{
1696 artifactlist *nextal;
1697
1698 for (al = first_artifactlist; al; al = nextal)
1699 {
1700 nextal = al->next;
1701
1702 if (al->items)
1703 free_artifact (al->items);
1704
1705 sfree (al);
1706 }
1707}
1708

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines