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

Comparing deliantra/server/server/spell_effect.C (file contents):
Revision 1.65 by root, Wed Aug 1 00:26:04 2007 UTC vs.
Revision 1.69 by root, Thu Aug 23 17:17:41 2007 UTC

335 * pl is invisible. 335 * pl is invisible.
336 */ 336 */
337int 337int
338makes_invisible_to (object *pl, object *mon) 338makes_invisible_to (object *pl, object *mon)
339{ 339{
340
341 if (!pl->invisible) 340 if (!pl->invisible)
342 return 0; 341 return 0;
342
343 if (pl->type == PLAYER) 343 if (pl->type == PLAYER)
344 { 344 {
345 /* If race isn't set, then invisible unless it is undead */ 345 /* If race isn't set, then invisible unless it is undead */
346 if (!pl->contr->invis_race) 346 if (!pl->contr->invis_race)
347 { 347 {
348 if (QUERY_FLAG (mon, FLAG_UNDEAD)) 348 if (QUERY_FLAG (mon, FLAG_UNDEAD))
349 return 0; 349 return 0;
350
350 return 1; 351 return 1;
351 } 352 }
353
352 /* invis_race is set if we get here */ 354 /* invis_race is set if we get here */
353 if (!strcmp (pl->contr->invis_race, "undead") && is_true_undead (mon)) 355 if (!strcmp (pl->contr->invis_race, "undead") && is_true_undead (mon))
354 return 1; 356 return 1;
357
355 /* No race, can't be invisible to it */ 358 /* No race, can't be invisible to it */
356 if (!mon->race) 359 if (!mon->race)
357 return 0; 360 return 0;
361
358 if (strstr (mon->race, pl->contr->invis_race)) 362 if (strstr (mon->race, pl->contr->invis_race))
359 return 1; 363 return 1;
364
360 /* Nothing matched above, return 0 */ 365 /* Nothing matched above, return 0 */
361 return 0; 366 return 0;
362 } 367 }
363 else 368 else
364 { 369 {
601 606
602 if (is_dragon_pl (op)) 607 if (is_dragon_pl (op))
603 /* now grab the 'dragon_ability'-force from the player's inventory */ 608 /* now grab the 'dragon_ability'-force from the player's inventory */
604 for (tmp = op->inv; tmp; tmp = tmp->below) 609 for (tmp = op->inv; tmp; tmp = tmp->below)
605 { 610 {
606 if (tmp->type == FORCE && !strcmp (tmp->arch->archname, "dragon_ability_force")) 611 if (tmp->type == FORCE && tmp->arch->archname == shstr_dragon_ability_force)
607 { 612 {
608 if (tmp->stats.exp == 0) 613 if (tmp->stats.exp == 0)
609 buf << "Your metabolism isn't focused on anything.\n"; 614 buf << "Your metabolism isn't focused on anything.\n";
610 else 615 else
611 buf << "Your metabolism is focused on " << change_resist_msg[tmp->stats.exp] << ".\n"; 616 buf << "Your metabolism is focused on " << change_resist_msg[tmp->stats.exp] << ".\n";
1276} 1281}
1277 1282
1278/* Alchemy code by Mark Wedel 1283/* Alchemy code by Mark Wedel
1279 * 1284 *
1280 * This code adds a new spell, called alchemy. Alchemy will turn 1285 * This code adds a new spell, called alchemy. Alchemy will turn
1281 * objects to gold nuggets, the value of the gold nuggets being 1286 * objects to pyrite ("false gold"), henceforth called gold nuggets.
1282 * about 90% of that of the item itself. It uses the value of the
1283 * object before charisma adjustments, because the nuggets themselves
1284 * will be will be adjusted by charisma when sold.
1285 * 1287 *
1286 * Large nuggets are worth 25 gp each (base). You will always get 1288 * The value of the gold nuggets being about 90% of that of the item
1287 * the maximum number of large nuggets you could get. 1289 * itself. It uses the value of the object before charisma adjustments,
1288 * Small nuggets are worth 1 gp each (base). You will get from 0 1290 * because the nuggets themselves will be will be adjusted by charisma
1289 * to the max amount of small nuggets as you could get. 1291 * when sold.
1290 *
1291 * For example, if an item is worth 110 gold, you will get
1292 * 4 large nuggets, and from 0-10 small nuggets.
1293 * 1292 *
1294 * There is also a chance (1:30) that you will get nothing at all 1293 * There is also a chance (1:30) that you will get nothing at all
1295 * for the object. There is also a maximum weight that will be 1294 * for the object. There is also a maximum weight that will be
1296 * alchemised. 1295 * alchemised.
1297 */ 1296 */
1320 total_weight += obj->total_weight (); 1319 total_weight += obj->total_weight ();
1321 1320
1322 obj->destroy (); 1321 obj->destroy ();
1323} 1322}
1324 1323
1325static void
1326update_map (object *op, maptile *m, int small_nuggets, object *small, int large_nuggets, object *large, int x, int y)
1327{
1328 int flag = 0;
1329
1330 /* Put any nuggets below the player, but we can only pass this
1331 * flag if we are on the same space as the player
1332 */
1333 if (x == op->x && y == op->y && op->map == m)
1334 flag = INS_BELOW_ORIGINATOR;
1335
1336 if (small_nuggets)
1337 {
1338 object *tmp = small->clone ();
1339 tmp->nrof = small_nuggets;
1340 m->insert (tmp, x, y, op, flag);
1341 }
1342
1343 if (large_nuggets)
1344 {
1345 object *tmp = large->clone ();
1346 tmp->nrof = large_nuggets;
1347 m->insert (tmp, x, y, op, flag);
1348 }
1349
1350 if (object *pl = m->at (x, y).player ())
1351 if (pl->contr->ns)
1352 pl->contr->ns->look_position = 0;
1353}
1354
1355int 1324int
1356alchemy (object *op, object *caster, object *spell_ob) 1325alchemy (object *op, object *caster, object *spell_ob)
1357{ 1326{
1358 if (op->type != PLAYER) 1327 if (op->type != PLAYER)
1359 return 0; 1328 return 0;
1360 1329
1361 object *large = get_archetype ("largenugget"); 1330 archetype *nugget[3];
1362 object *small = get_archetype ("smallnugget"); 1331
1332 nugget[0] = archetype::find ("pyrite3");
1333 nugget[1] = archetype::find ("pyrite2");
1334 nugget[2] = archetype::find ("pyrite");
1363 1335
1364 /* Put a maximum weight of items that can be alchemised. Limits the power 1336 /* Put a maximum weight of items that can be alchemised. Limits the power
1365 * some, and also prevents people from alchemising every table/chair/clock 1337 * some, and also prevents people from alchemising every table/chair/clock
1366 * in sight 1338 * in sight
1367 */ 1339 */
1419 if (weight > weight_max) 1391 if (weight > weight_max)
1420 break; 1392 break;
1421 } 1393 }
1422 } 1394 }
1423 1395
1396 value -= rndm (value >> 4);
1424 value = min (value, value_max); 1397 value = min (value, value_max);
1425 1398
1426 uint64 count = value / large->value; 1399 for (int i = 0; i < sizeof (nugget) / sizeof (nugget [0]); ++i)
1427 int large_nuggets = count; 1400 if (int nrof = value / nugget [i]->value)
1428 value -= count * large->value;
1429
1430 count = value / small->value;
1431 int small_nuggets = count;
1432
1433 /* Insert all the nuggets at one time. This probably saves time, but
1434 * it also prevents us from alcheming nuggets that were just created
1435 * with this spell.
1436 */ 1401 {
1437 update_map (op, mp, small_nuggets, small, large_nuggets, large, nx, ny); 1402 value -= nrof * nugget[i]->value;
1403
1404 object *tmp = arch_to_object (nugget[i]);
1405 tmp->nrof = nrof;
1406 tmp->flag [FLAG_IDENTIFIED] = true;
1407 op->map->insert (tmp, x, y, op, 0);
1408 }
1438 1409
1439 if (weight > weight_max) 1410 if (weight > weight_max)
1440 goto bailout; 1411 goto bailout;
1441 } 1412 }
1442 } 1413 }
1443 1414
1444bailout: 1415bailout:
1445 large->destroy ();
1446 small->destroy ();
1447 return 1; 1416 return 1;
1448} 1417}
1449 1418
1450 1419
1451/* This function removes the cursed/damned status on equipped 1420/* This function removes the cursed/damned status on equipped

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines