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.94 by root, Tue Nov 10 16:29:20 2009 UTC vs.
Revision 1.101 by root, Fri Mar 26 00:59:20 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)))
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))
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 }
1377 /* No harm setting this for potions/horns */ 1374 /* No harm setting this for potions/horns */
1378 op->other_arch = change->other_arch; 1375 op->other_arch = change->other_arch;
1379 } 1376 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines