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

Comparing deliantra/server/common/utils.C (file contents):
Revision 1.60 by root, Sun Jul 1 05:00:18 2007 UTC vs.
Revision 1.61 by root, Tue Jul 10 05:51:37 2007 UTC

258void 258void
259set_materialname (object *op, int difficulty, materialtype_t *nmt) 259set_materialname (object *op, int difficulty, materialtype_t *nmt)
260{ 260{
261 materialtype_t *mt, *lmt; 261 materialtype_t *mt, *lmt;
262 262
263#ifdef NEW_MATERIAL_CODE
264 int j;
265#endif
266
267 if (op->materialname != NULL) 263 if (op->materialname != NULL)
268 return; 264 return;
269 265
270
271
272 if (nmt == NULL) 266 if (nmt == NULL)
273 { 267 {
274 lmt = NULL; 268 lmt = NULL;
275#ifndef NEW_MATERIAL_CODE 269
276 for (mt = materialt; mt && mt->next; mt = mt->next) 270 for (mt = materialt; mt && mt->next; mt = mt->next)
277 { 271 if (op->materials & mt->material && rndm (1, 100) <= mt->chance &&
278 if (op->materials & mt->material) 272 difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0))
279 { 273 {
280 lmt = mt; 274 lmt = mt;
275 if (!(op->is_weapon () || op->is_armor ()))
281 break; 276 break;
282 } 277 }
283 }
284
285#else
286 for (mt = materialt; mt && mt->next; mt = mt->next)
287 {
288 if (op->materials & mt->material && rndm (1, 100) <= mt->chance &&
289 difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0))
290 {
291 lmt = mt;
292 if (!(op->is_weapon () || op->is_armor ()))
293 break;
294 }
295 }
296#endif
297 } 278 }
298 else 279 else
299 {
300 lmt = nmt; 280 lmt = nmt;
301 }
302 281
303 if (lmt != NULL) 282 if (lmt != NULL)
304 { 283 {
305#ifndef NEW_MATERIAL_CODE
306 op->materialname = lmt->name;
307 return;
308#else
309
310 if (op->stats.dam && op->is_weapon ()) 284 if (op->stats.dam && op->is_weapon ())
311 { 285 {
312 op->stats.dam += lmt->damage; 286 op->stats.dam += lmt->damage;
313 if (op->stats.dam < 1) 287 if (op->stats.dam < 1)
314 op->stats.dam = 1; 288 op->stats.dam = 1;
320 op->stats.wc += lmt->wc; 294 op->stats.wc += lmt->wc;
321 if (op->is_armor ()) 295 if (op->is_armor ())
322 { 296 {
323 if (op->stats.ac) 297 if (op->stats.ac)
324 op->stats.ac += lmt->ac; 298 op->stats.ac += lmt->ac;
299
325 for (j = 0; j < NROFATTACKS; j++) 300 for (int j = 0; j < NROFATTACKS; j++)
326 if (op->resist[j] != 0) 301 if (op->resist[j] != 0)
327 { 302 {
328 op->resist[j] += lmt->mod[j]; 303 op->resist[j] += lmt->mod[j];
329 if (op->resist[j] > 100) 304 if (op->resist[j] > 100)
330 op->resist[j] = 100; 305 op->resist[j] = 100;
331 if (op->resist[j] < -100) 306 if (op->resist[j] < -100)
332 op->resist[j] = -100; 307 op->resist[j] = -100;
333 } 308 }
334 } 309 }
310
335 op->materialname = lmt->name; 311 op->materialname = lmt->name;
336 /* dont make it unstackable if it doesn't need to be */ 312 /* dont make it unstackable if it doesn't need to be */
337 if (op->is_weapon () || op->is_armor ()) 313 if (op->is_weapon () || op->is_armor ())
338 { 314 {
339 op->weight = (op->weight * lmt->weight) / 100; 315 op->weight = (op->weight * lmt->weight) / 100;
340 op->value = (op->value * lmt->value) / 100; 316 op->value = (op->value * lmt->value) / 100;
341 } 317 }
342#endif
343 } 318 }
344} 319}
345 320
346/* 321/*
347 * Strip out the media tags from a String. 322 * Strip out the media tags from a String.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines