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.89 by root, Fri Nov 6 13:03:34 2009 UTC vs.
Revision 1.98 by root, Sun Nov 29 17:41:07 2009 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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 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
310 } 310 }
311 else 311 else
312 { 312 {
313 if (t->item && (t->item->invisible != 0 || !(flag & GT_INVISIBLE))) 313 if (t->item && (t->item->invisible != 0 || !(flag & GT_INVISIBLE)))
314 { 314 {
315 object *tmp = arch_to_object (t->item); 315 object *tmp = t->item->instance ();
316 316
317 if (t->nrof && tmp->nrof <= 1) 317 if (t->nrof && tmp->nrof <= 1)
318 tmp->nrof = rndm (t->nrof) + 1; 318 tmp->nrof = rndm (t->nrof) + 1;
319 319
320 fix_generated_item (tmp, op, difficulty, t->magic, flag); 320 fix_generated_item (tmp, op, difficulty, t->magic, flag);
367 else if (t->nrof) 367 else if (t->nrof)
368 create_one_treasure (tl, op, flag, difficulty, tries); 368 create_one_treasure (tl, op, flag, difficulty, tries);
369 } 369 }
370 else if (t->item && (t->item->invisible != 0 || flag != GT_INVISIBLE)) 370 else if (t->item && (t->item->invisible != 0 || flag != GT_INVISIBLE))
371 { 371 {
372 if (object *tmp = arch_to_object (t->item)) 372 if (object *tmp = t->item->instance ())
373 { 373 {
374 if (t->nrof && tmp->nrof <= 1) 374 if (t->nrof && tmp->nrof <= 1)
375 tmp->nrof = rndm (t->nrof) + 1; 375 tmp->nrof = rndm (t->nrof) + 1;
376 376
377 fix_generated_item (tmp, op, difficulty, t->magic, flag); 377 fix_generated_item (tmp, op, difficulty, t->magic, flag);
834 create_treasure (op->randomitems, op, flags & ~GT_ENVIRONMENT, difficulty, 0); 834 create_treasure (op->randomitems, op, flags & ~GT_ENVIRONMENT, difficulty, 0);
835 /* So the treasure doesn't get created again */ 835 /* So the treasure doesn't get created again */
836 op->randomitems = 0; 836 op->randomitems = 0;
837 } 837 }
838 838
839 if (difficulty < 1) 839 max_it (difficulty, 1);
840 difficulty = 1;
841 840
842 if (INVOKE_OBJECT (ADD_BONUS, op, 841 if (INVOKE_OBJECT (ADD_BONUS, op,
843 ARG_OBJECT (creator != op ? creator : 0), 842 ARG_OBJECT (creator != op ? creator : 0),
844 ARG_INT (difficulty), ARG_INT (max_magic), 843 ARG_INT (difficulty), ARG_INT (max_magic),
845 ARG_INT (flags))) 844 ARG_INT (flags)))
904 * again below */ 903 * again below */
905 } 904 }
906 } 905 }
907 906
908 /* materialtype modifications. Note we allow this on artifacts. */ 907 /* materialtype modifications. Note we allow this on artifacts. */
909 set_materialname (op, difficulty, NULL); 908 select_material (op, difficulty);
910 909
911 if (flags & GT_MINIMAL) 910 if (flags & GT_MINIMAL)
912 { 911 {
913 if (op->type == POTION) 912 if (op->type == POTION)
914 /* Handle healing and magic power potions */ 913 /* Handle healing and magic power potions */
945 int too_many_tries = 0, is_special = 0; 944 int too_many_tries = 0, is_special = 0;
946 945
947 /* Handle healing and magic power potions */ 946 /* Handle healing and magic power potions */
948 if (op->stats.sp && !op->randomitems) 947 if (op->stats.sp && !op->randomitems)
949 { 948 {
950 object *tmp;
951
952 tmp = get_archetype (spell_mapping[op->stats.sp]); 949 object *tmp = get_archetype (spell_mapping[op->stats.sp]);
953 insert_ob_in_ob (tmp, op); 950 insert_ob_in_ob (tmp, op);
954 op->stats.sp = 0; 951 op->stats.sp = 0;
955 } 952 }
956 953
957 while (!(is_special = special_potion (op)) && !op->inv) 954 while (!(is_special = special_potion (op)) && !op->inv)
965 * since the value set on those is already correct. 962 * since the value set on those is already correct.
966 */ 963 */
967 if (op->inv && op->randomitems) 964 if (op->inv && op->randomitems)
968 { 965 {
969 /* value multiplier is same as for scrolls */ 966 /* value multiplier is same as for scrolls */
970 op->value = (op->value * op->inv->value); 967 op->value *= op->inv->value;
971 op->level = op->inv->level / 2 + rndm (difficulty) + rndm (difficulty); 968 op->level = op->inv->level / 2 + rndm (difficulty) + rndm (difficulty);
972 } 969 }
973 else 970 else
974 { 971 {
975 op->name = "potion"; 972 op->name = "potion";
976 op->name_pl = "potions"; 973 op->name_pl = "potions";
977 } 974 }
978 975
979 if (!(flags & GT_ONLY_GOOD) && rndm (2)) 976 if (!(flags & GT_ONLY_GOOD) && rndm (2))
980 SET_FLAG (op, FLAG_CURSED); 977 SET_FLAG (op, FLAG_CURSED);
978
981 break; 979 break;
982 } 980 }
983 981
984 case AMULET: 982 case AMULET:
985 if (IS_ARCH (op->arch, amulet)) 983 if (IS_ARCH (op->arch, amulet))
1097 * 10 time multiplier). This way, the value are a bit more reasonable. 1095 * 10 time multiplier). This way, the value are a bit more reasonable.
1098 */ 1096 */
1099 op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50); 1097 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 */ 1098 /* maxhp is used to denote how many 'charges' the rod holds before */
1101 if (op->stats.maxhp) 1099 if (op->stats.maxhp)
1102 op->stats.maxhp *= MAX (op->inv->stats.sp, op->inv->stats.grace); 1100 op->stats.maxhp *= max (op->inv->stats.sp, op->inv->stats.grace);
1103 else 1101 else
1104 op->stats.maxhp = 2 * MAX (op->inv->stats.sp, op->inv->stats.grace); 1102 op->stats.maxhp = 2 * max (op->inv->stats.sp, op->inv->stats.grace);
1105 1103
1106 op->stats.hp = op->stats.maxhp; 1104 op->stats.hp = op->stats.maxhp;
1107 break; 1105 break;
1108 1106
1109 case SCROLL: 1107 case SCROLL:
1146 1144
1147/* 1145/*
1148 * Allocate and return the pointer to an empty artifactlist structure. 1146 * Allocate and return the pointer to an empty artifactlist structure.
1149 */ 1147 */
1150static artifactlist * 1148static artifactlist *
1151get_empty_artifactlist (void) 1149get_empty_artifactlist ()
1152{ 1150{
1153 return salloc0<artifactlist> (); 1151 return salloc0<artifactlist> ();
1154} 1152}
1155 1153
1156/* 1154/*
1157 * Allocate and return the pointer to an empty artifact structure. 1155 * Allocate and return the pointer to an empty artifact structure.
1158 */ 1156 */
1159static artifact * 1157static artifact *
1160get_empty_artifact (void) 1158get_empty_artifact ()
1161{ 1159{
1162 return salloc0<artifact> (); 1160 return salloc0<artifact> ();
1163} 1161}
1164 1162
1165/* 1163/*
1178 1176
1179/* 1177/*
1180 * Builds up the lists of artifacts from the file in the libdir. 1178 * Builds up the lists of artifacts from the file in the libdir.
1181 */ 1179 */
1182void 1180void
1183init_artifacts (void) 1181init_artifacts ()
1184{ 1182{
1185 static int has_been_inited = 0; 1183 static int has_been_inited = 0;
1186 char filename[MAX_BUF]; 1184 char filename[MAX_BUF];
1187 artifact *art = NULL; 1185 artifact *art = NULL;
1188 artifactlist *al; 1186 artifactlist *al;
1208 1206
1209 { 1207 {
1210 if (!strcmp (f.get_str (), "all")) 1208 if (!strcmp (f.get_str (), "all"))
1211 break; 1209 break;
1212 1210
1213 char *next, *cp = f.get_str (); 1211 const char *cp = f.get_str ();
1214 1212 char *next;
1215 do 1213 do
1216 { 1214 {
1217 if ((next = strchr (cp, ','))) 1215 if ((next = strchr (cp, ',')))
1218 *next++ = '\0'; 1216 *next++ = '\0';
1219 1217
1369 if (op->type == HORN || op->type == POTION) 1367 if (op->type == HORN || op->type == POTION)
1370 { 1368 {
1371 /* Remove any spells this object currently has in it */ 1369 /* Remove any spells this object currently has in it */
1372 op->destroy_inv (false); 1370 op->destroy_inv (false);
1373 1371
1374 object *tmp = arch_to_object (change->other_arch); 1372 object *tmp = change->other_arch->instance ();
1375 insert_ob_in_ob (tmp, op); 1373 insert_ob_in_ob (tmp, op);
1376 } 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 }
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
1709static void
1710free_all_treasures (void)
1711{
1712 treasurelist *tl, *next;
1713
1714 for (tl = first_treasurelist; tl; tl = next)
1715 {
1716 clear (tl);
1717
1718 next = tl->next;
1719 delete tl;
1720 }
1721
1722 free_artifactlist (first_artifactlist);
1723}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines