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.106 by elmex, Wed Apr 21 09:30:07 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
256 return; 255 return;
257 } 256 }
258 257
259 op->expand_tail (); 258 op->expand_tail ();
260 259
260 if (!creator->is_on_map ()
261 if (!creator->is_on_map () || op->blocked (creator->map, creator->x, creator->y)) 261 || (op->weight && op->blocked (creator->map, creator->x, creator->y)))
262 op->destroy (); 262 op->destroy ();
263 else 263 else
264 { 264 {
265 SET_FLAG (op, FLAG_OBJ_ORIGINAL); 265 op->flag [FLAG_OBJ_ORIGINAL] = true;
266 op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); 266 op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON);
267 } 267 }
268 } 268 }
269 else 269 else
270 { 270 {
271 op = creator->insert (op); 271 op = creator->insert (op);
272 272
273 if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) 273 if ((flags & GT_APPLY) && creator->flag [FLAG_MONSTER])
274 monster_check_apply (creator, op); 274 monster_check_apply (creator, op);
275 } 275 }
276} 276}
277 277
278/* if there are change_xxx commands in the treasure, we include the changes 278/* if there are change_xxx commands in the treasure, we include the changes
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);
510 int olevel = op->inv->level + int (difficulty * (1. - rndm () * rndm () * 2.)); 510 int olevel = op->inv->level + int (difficulty * (1. - rndm () * rndm () * 2.));
511 511
512 if (olevel <= 0) 512 if (olevel <= 0)
513 olevel = rndm (1, op->inv->level); 513 olevel = rndm (1, op->inv->level);
514 514
515 return min (olevel, MAXLEVEL); 515 return min (olevel, MAXLEVEL_TREASURE);
516} 516}
517 517
518/* 518/*
519 * Based upon the specified difficulty and upon the difftomagic_list array, 519 * Based upon the specified difficulty and upon the difftomagic_list array,
520 * a random magical bonus is returned. This is used when determine 520 * a random magical bonus is returned. This is used when determine
612 i = -i; 612 i = -i;
613 if (i > max_magic) 613 if (i > max_magic)
614 i = max_magic; 614 i = max_magic;
615 set_abs_magic (op, i); 615 set_abs_magic (op, i);
616 if (i < 0) 616 if (i < 0)
617 SET_FLAG (op, FLAG_CURSED); 617 op->set_flag (FLAG_CURSED);
618} 618}
619 619
620/* 620/*
621 * Randomly adds one magical ability to the given object. 621 * Randomly adds one magical ability to the given object.
622 * Modified for Partial Resistance in many ways: 622 * Modified for Partial Resistance in many ways:
715 break; 715 break;
716 } 716 }
717 case 20: 717 case 20:
718 if (op->type == AMULET) 718 if (op->type == AMULET)
719 { 719 {
720 SET_FLAG (op, FLAG_REFL_SPELL); 720 op->set_flag (FLAG_REFL_SPELL);
721 op->value *= 11; 721 op->value *= 11;
722 } 722 }
723 else 723 else
724 { 724 {
725 op->stats.hp = 1; /* regenerate hit points */ 725 op->stats.hp = 1; /* regenerate hit points */
728 break; 728 break;
729 729
730 case 21: 730 case 21:
731 if (op->type == AMULET) 731 if (op->type == AMULET)
732 { 732 {
733 SET_FLAG (op, FLAG_REFL_MISSILE); 733 op->set_flag (FLAG_REFL_MISSILE);
734 op->value *= 9; 734 op->value *= 9;
735 } 735 }
736 else 736 else
737 { 737 {
738 op->stats.sp = 1; /* regenerate spell points */ 738 op->stats.sp = 1; /* regenerate spell points */
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 */
925 case WEAPON: 924 case WEAPON:
926 case ARMOUR: 925 case ARMOUR:
927 case SHIELD: 926 case SHIELD:
928 case HELMET: 927 case HELMET:
929 case CLOAK: 928 case CLOAK:
930 if (QUERY_FLAG (op, FLAG_CURSED) && !(rndm (4))) 929 if (op->flag [FLAG_CURSED] && !(rndm (4)))
931 set_ring_bonus (op, -DICE2); 930 set_ring_bonus (op, -DICE2);
932 break; 931 break;
933 932
934 case BRACERS: 933 case BRACERS:
935 if (!rndm (QUERY_FLAG (op, FLAG_CURSED) ? 5 : 20)) 934 if (!rndm (op->flag [FLAG_CURSED] ? 5 : 20))
936 { 935 {
937 set_ring_bonus (op, QUERY_FLAG (op, FLAG_CURSED) ? -DICE2 : DICE2); 936 set_ring_bonus (op, op->flag [FLAG_CURSED] ? -DICE2 : DICE2);
938 if (!QUERY_FLAG (op, FLAG_CURSED)) 937 if (!op->flag [FLAG_CURSED])
939 op->value *= 3; 938 op->value *= 3;
940 } 939 }
941 break; 940 break;
942 941
943 case POTION: 942 case POTION:
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 op->set_flag (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))
988 case RING: 986 case RING:
989 if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */ 987 if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */
990 break; 988 break;
991 989
992 if (!(flags & GT_ONLY_GOOD) && !(rndm (3))) 990 if (!(flags & GT_ONLY_GOOD) && !(rndm (3)))
993 SET_FLAG (op, FLAG_CURSED); 991 op->set_flag (FLAG_CURSED);
994 992
995 set_ring_bonus (op, QUERY_FLAG (op, FLAG_CURSED) ? -DICE2 : DICE2); 993 set_ring_bonus (op, op->flag [FLAG_CURSED] ? -DICE2 : DICE2);
996 994
997 if (op->type != RING) /* Amulets have only one ability */ 995 if (op->type != RING) /* Amulets have only one ability */
998 break; 996 break;
999 997
1000 if (!(rndm (4))) 998 if (!(rndm (4)))
1001 { 999 {
1002 int d = (rndm (2) || QUERY_FLAG (op, FLAG_CURSED)) ? -DICE2 : DICE2; 1000 int d = (rndm (2) || op->flag [FLAG_CURSED]) ? -DICE2 : DICE2;
1003 1001
1004 if (d > 0) 1002 if (d > 0)
1005 op->value *= 3; 1003 op->value *= 3;
1006 1004
1007 set_ring_bonus (op, d); 1005 set_ring_bonus (op, d);
1008 1006
1009 if (!(rndm (4))) 1007 if (!(rndm (4)))
1010 { 1008 {
1011 int d = (rndm (3) || QUERY_FLAG (op, FLAG_CURSED)) ? -DICE2 : DICE2; 1009 int d = (rndm (3) || op->flag [FLAG_CURSED]) ? -DICE2 : DICE2;
1012 1010
1013 if (d > 0) 1011 if (d > 0)
1014 op->value *= 5; 1012 op->value *= 5;
1015 set_ring_bonus (op, d); 1013 set_ring_bonus (op, d);
1016 } 1014 }
1027 * creator and/or map level we found it on. 1025 * creator and/or map level we found it on.
1028 */ 1026 */
1029 if (!op->msg && rndm (10)) 1027 if (!op->msg && rndm (10))
1030 { 1028 {
1031 /* set the book level properly */ 1029 /* set the book level properly */
1032 if (creator->level == 0 || QUERY_FLAG (creator, FLAG_ALIVE)) 1030 if (creator->level == 0 || creator->flag [FLAG_ALIVE])
1033 { 1031 {
1034 if (op->map && op->map->difficulty) 1032 if (op->map && op->map->difficulty)
1035 op->level = rndm (op->map->difficulty) + rndm (10) + 1; 1033 op->level = rndm (op->map->difficulty) + rndm (10) + 1;
1036 else 1034 else
1037 op->level = rndm (20) + 1; 1035 op->level = rndm (20) + 1;
1050 /* creator related stuff */ 1048 /* creator related stuff */
1051 1049
1052 /* for library, chained books. Note that some monsters have no_pick 1050 /* for library, chained books. Note that some monsters have no_pick
1053 * set - we don't want to set no pick in that case. 1051 * set - we don't want to set no pick in that case.
1054 */ 1052 */
1055 if (QUERY_FLAG (creator, FLAG_NO_PICK) && !QUERY_FLAG (creator, FLAG_MONSTER)) 1053 if (creator->flag [FLAG_NO_PICK] && !creator->flag [FLAG_MONSTER])
1056 SET_FLAG (op, FLAG_NO_PICK); 1054 op->set_flag (FLAG_NO_PICK);
1057 if (creator->slaying && !op->slaying) /* for check_inv floors */ 1055 if (creator->slaying && !op->slaying) /* for check_inv floors */
1058 op->slaying = creator->slaying; 1056 op->slaying = creator->slaying;
1059 break; 1057 break;
1060 1058
1061 case SPELLBOOK: 1059 case SPELLBOOK:
1062 op->value = op->value * op->inv->value; 1060 op->value *=
1061 pow ((op->inv->value > 0 ? op->inv->value : 1)
1062 * op->inv->level,
1063 1.5);
1063 /* add exp so learning gives xp */ 1064 /* add exp so learning gives xp */
1064 op->level = op->inv->level; 1065 op->level = op->inv->level;
1065 op->stats.exp = op->value; 1066 op->stats.exp = op->value;
1066 break; 1067 break;
1067 1068
1097 * 10 time multiplier). This way, the value are a bit more reasonable. 1098 * 10 time multiplier). This way, the value are a bit more reasonable.
1098 */ 1099 */
1099 op->value = op->value * op->inv->value * (op->level + 50) / (op->inv->level + 50); 1100 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 */ 1101 /* maxhp is used to denote how many 'charges' the rod holds before */
1101 if (op->stats.maxhp) 1102 if (op->stats.maxhp)
1102 op->stats.maxhp *= MAX (op->inv->stats.sp, op->inv->stats.grace); 1103 op->stats.maxhp *= max (op->inv->stats.sp, op->inv->stats.grace);
1103 else 1104 else
1104 op->stats.maxhp = 2 * MAX (op->inv->stats.sp, op->inv->stats.grace); 1105 op->stats.maxhp = 2 * max (op->inv->stats.sp, op->inv->stats.grace);
1105 1106
1106 op->stats.hp = op->stats.maxhp; 1107 op->stats.hp = op->stats.maxhp;
1107 break; 1108 break;
1108 1109
1109 case SCROLL: 1110 case SCROLL:
1124 break; 1125 break;
1125 } /* switch type */ 1126 } /* switch type */
1126 1127
1127 if (flags & GT_STARTEQUIP) 1128 if (flags & GT_STARTEQUIP)
1128 { 1129 {
1129 if (op->nrof < 2 && op->type != CONTAINER && op->type != MONEY && !QUERY_FLAG (op, FLAG_IS_THROWN)) 1130 if (op->nrof < 2 && op->type != CONTAINER && op->type != MONEY && !op->flag [FLAG_IS_THROWN])
1130 SET_FLAG (op, FLAG_STARTEQUIP); 1131 op->set_flag (FLAG_STARTEQUIP);
1131 else if (op->type != MONEY) 1132 else if (op->type != MONEY)
1132 op->value = 0; 1133 op->value = 0;
1133 } 1134 }
1134 1135
1135 if (!(flags & GT_ENVIRONMENT)) 1136 if (!(flags & GT_ENVIRONMENT))
1146 1147
1147/* 1148/*
1148 * Allocate and return the pointer to an empty artifactlist structure. 1149 * Allocate and return the pointer to an empty artifactlist structure.
1149 */ 1150 */
1150static artifactlist * 1151static artifactlist *
1151get_empty_artifactlist (void) 1152get_empty_artifactlist ()
1152{ 1153{
1153 return salloc0<artifactlist> (); 1154 return salloc0<artifactlist> ();
1154} 1155}
1155 1156
1156/* 1157/*
1157 * Allocate and return the pointer to an empty artifact structure. 1158 * Allocate and return the pointer to an empty artifact structure.
1158 */ 1159 */
1159static artifact * 1160static artifact *
1160get_empty_artifact (void) 1161get_empty_artifact ()
1161{ 1162{
1162 return salloc0<artifact> (); 1163 return salloc0<artifact> ();
1163} 1164}
1164 1165
1165/* 1166/*
1178 1179
1179/* 1180/*
1180 * Builds up the lists of artifacts from the file in the libdir. 1181 * Builds up the lists of artifacts from the file in the libdir.
1181 */ 1182 */
1182void 1183void
1183init_artifacts (void) 1184init_artifacts ()
1184{ 1185{
1185 static int has_been_inited = 0; 1186 static int has_been_inited = 0;
1186 char filename[MAX_BUF]; 1187 char filename[MAX_BUF];
1187 artifact *art = NULL; 1188 artifact *art = NULL;
1188 artifactlist *al; 1189 artifactlist *al;
1208 1209
1209 { 1210 {
1210 if (!strcmp (f.get_str (), "all")) 1211 if (!strcmp (f.get_str (), "all"))
1211 break; 1212 break;
1212 1213
1213 char *next, *cp = f.get_str (); 1214 const char *cp = f.get_str ();
1214 1215 char *next;
1215 do 1216 do
1216 { 1217 {
1217 if ((next = strchr (cp, ','))) 1218 if ((next = (char *)strchr (cp, ',')))
1218 *next++ = '\0'; 1219 *next++ = '\0';
1219 1220
1220 linked_char *tmp = new linked_char; 1221 linked_char *tmp = new linked_char;
1221 1222
1222 tmp->name = cp; 1223 tmp->name = cp;
1317 op->path_repelled |= change->path_repelled; 1318 op->path_repelled |= change->path_repelled;
1318 op->path_denied |= change->path_denied; 1319 op->path_denied |= change->path_denied;
1319 op->move_type |= change->move_type; 1320 op->move_type |= change->move_type;
1320 op->stats.luck += change->stats.luck; 1321 op->stats.luck += change->stats.luck;
1321 1322
1322 if (QUERY_FLAG (change, FLAG_CURSED)) 1323 if (change->flag [FLAG_CURSED])
1323 SET_FLAG (op, FLAG_CURSED); 1324 op->set_flag (FLAG_CURSED);
1324 if (QUERY_FLAG (change, FLAG_DAMNED)) 1325 if (change->flag [FLAG_DAMNED])
1325 SET_FLAG (op, FLAG_DAMNED); 1326 op->set_flag (FLAG_DAMNED);
1326 if ((QUERY_FLAG (change, FLAG_CURSED) || QUERY_FLAG (change, FLAG_DAMNED)) && op->magic > 0) 1327 if ((change->flag [FLAG_CURSED] || change->flag [FLAG_DAMNED]) && op->magic > 0)
1327 set_abs_magic (op, -op->magic); 1328 set_abs_magic (op, -op->magic);
1328 1329
1329 if (QUERY_FLAG (change, FLAG_LIFESAVE)) 1330 if (change->flag [FLAG_LIFESAVE])
1330 SET_FLAG (op, FLAG_LIFESAVE); 1331 op->set_flag (FLAG_LIFESAVE);
1331 if (QUERY_FLAG (change, FLAG_REFL_SPELL)) 1332 if (change->flag [FLAG_REFL_SPELL])
1332 SET_FLAG (op, FLAG_REFL_SPELL); 1333 op->set_flag (FLAG_REFL_SPELL);
1333 if (QUERY_FLAG (change, FLAG_STEALTH)) 1334 if (change->flag [FLAG_STEALTH])
1334 SET_FLAG (op, FLAG_STEALTH); 1335 op->set_flag (FLAG_STEALTH);
1335 if (QUERY_FLAG (change, FLAG_XRAYS)) 1336 if (change->flag [FLAG_XRAYS])
1336 SET_FLAG (op, FLAG_XRAYS); 1337 op->set_flag (FLAG_XRAYS);
1337 if (QUERY_FLAG (change, FLAG_BLIND)) 1338 if (change->flag [FLAG_BLIND])
1338 SET_FLAG (op, FLAG_BLIND); 1339 op->set_flag (FLAG_BLIND);
1339 if (QUERY_FLAG (change, FLAG_SEE_IN_DARK)) 1340 if (change->flag [FLAG_SEE_IN_DARK])
1340 SET_FLAG (op, FLAG_SEE_IN_DARK); 1341 op->set_flag (FLAG_SEE_IN_DARK);
1341 if (QUERY_FLAG (change, FLAG_REFL_MISSILE)) 1342 if (change->flag [FLAG_REFL_MISSILE])
1342 SET_FLAG (op, FLAG_REFL_MISSILE); 1343 op->set_flag (FLAG_REFL_MISSILE);
1343 if (QUERY_FLAG (change, FLAG_MAKE_INVIS)) 1344 if (change->flag [FLAG_MAKE_INVIS])
1344 SET_FLAG (op, FLAG_MAKE_INVIS); 1345 op->set_flag (FLAG_MAKE_INVIS);
1345 1346
1346 if (QUERY_FLAG (change, FLAG_STAND_STILL)) 1347 if (change->flag [FLAG_STAND_STILL])
1347 { 1348 {
1348 CLEAR_FLAG (op, FLAG_ANIMATE); 1349 op->clr_flag (FLAG_ANIMATE);
1349 /* so artifacts will join */ 1350 /* so artifacts will join */
1350 if (!QUERY_FLAG (op, FLAG_ALIVE)) 1351 if (!op->flag [FLAG_ALIVE])
1351 op->speed = 0.0; 1352 op->speed = 0.0;
1352 1353
1353 op->set_speed (op->speed); 1354 op->set_speed (op->speed);
1354 } 1355 }
1355 1356
1369 if (op->type == HORN || op->type == POTION) 1370 if (op->type == HORN || op->type == POTION)
1370 { 1371 {
1371 /* Remove any spells this object currently has in it */ 1372 /* Remove any spells this object currently has in it */
1372 op->destroy_inv (false); 1373 op->destroy_inv (false);
1373 1374
1374 object *tmp = arch_to_object (change->other_arch); 1375 object *tmp = change->other_arch->instance ();
1375 insert_ob_in_ob (tmp, op); 1376 insert_ob_in_ob (tmp, op);
1376 } 1377 }
1378
1377 /* No harm setting this for potions/horns */ 1379 /* No harm setting this for potions/horns */
1378 op->other_arch = change->other_arch; 1380 op->other_arch = change->other_arch;
1379 } 1381 }
1380 1382
1381 if (change->stats.hp < 0) 1383 if (change->stats.hp < 0)
1465 op->value *= change->value; 1467 op->value *= change->value;
1466 1468
1467 if (change->materials) 1469 if (change->materials)
1468 op->materials = change->materials; 1470 op->materials = change->materials;
1469 1471
1470 if (change->materialname) 1472 if (change->material != MATERIAL_NULL)
1471 op->materialname = change->materialname; 1473 op->material = change->material;
1472 1474
1473 if (change->slaying) 1475 if (change->slaying)
1474 op->slaying = change->slaying; 1476 op->slaying = change->slaying;
1475 1477
1476 if (change->race) 1478 if (change->race)
1528 op->title = new_name; 1530 op->title = new_name;
1529 add_abilities (op, artifct); /* Give out the bonuses */ 1531 add_abilities (op, artifct); /* Give out the bonuses */
1530 1532
1531#if 0 /* Bit verbose, but keep it here until next time I need it... */ 1533#if 0 /* Bit verbose, but keep it here until next time I need it... */
1532 { 1534 {
1533 char identified = QUERY_FLAG (op, FLAG_IDENTIFIED); 1535 char identified = op->flag [FLAG_IDENTIFIED];
1534 1536
1535 SET_FLAG (op, FLAG_IDENTIFIED); 1537 op->set_flag (FLAG_IDENTIFIED);
1536 LOG (llevDebug, "Generated artifact %s %s [%s]\n", op->name, op->title, describe_item (op, NULL)); 1538 LOG (llevDebug, "Generated artifact %s %s [%s]\n", op->name, op->title, describe_item (op, NULL));
1537 if (!identified) 1539 if (!identified)
1538 CLEAR_FLAG (op, FLAG_IDENTIFIED); 1540 op->clr_flag (FLAG_IDENTIFIED);
1539 } 1541 }
1540#endif 1542#endif
1541 return; 1543 return;
1542} 1544}
1543 1545
1654 item->type = POISON; 1656 item->type = POISON;
1655 1657
1656 if (donor->attacktype & AT_ACID) 1658 if (donor->attacktype & AT_ACID)
1657 item->stats.hp = -1 * item->stats.food; 1659 item->stats.hp = -1 * item->stats.food;
1658 1660
1659 SET_FLAG (item, FLAG_NO_STEAL); 1661 item->set_flag (FLAG_NO_STEAL);
1660 } 1662 }
1661} 1663}
1662 1664
1663static void 1665static void
1664free_treasurestruct (treasure *t) 1666free_treasurestruct (treasure *t)
1688 at->item->destroy (); 1690 at->item->destroy ();
1689 1691
1690 sfree (at); 1692 sfree (at);
1691} 1693}
1692 1694
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