stone-to-flesh spell hits and maybe transforms or animates obj */
| 1990 | |
| 1991 | /* stone-to-flesh spell hits and maybe transforms or animates obj */ |
| 1992 | staticfn int |
| 1993 | stone_to_flesh_obj(struct obj *obj) /* nonnull */ |
| 1994 | { |
| 1995 | struct permonst *ptr; |
| 1996 | struct monst *mon, *shkp; |
| 1997 | struct obj *item; |
| 1998 | coordxy oox, ooy; |
| 1999 | boolean smell = FALSE, golem_xform = FALSE; |
| 2000 | int res = 1; /* affected object by default */ |
| 2001 | |
| 2002 | if (objects[obj->otyp].oc_material != MINERAL |
| 2003 | && objects[obj->otyp].oc_material != GEMSTONE) |
| 2004 | return 0; |
| 2005 | /* Heart of Ahriman usually resists; ordinary items rarely do */ |
| 2006 | if (obj_resists(obj, 2, 98)) |
| 2007 | return 0; |
| 2008 | |
| 2009 | (void) get_obj_location(obj, &oox, &ooy, 0); |
| 2010 | /* add more if stone objects are added... */ |
| 2011 | switch (objects[obj->otyp].oc_class) { |
| 2012 | case ROCK_CLASS: /* boulders and statues */ |
| 2013 | case TOOL_CLASS: /* figurines */ |
| 2014 | if (obj->otyp == BOULDER) { |
| 2015 | obj = poly_obj(obj, ENORMOUS_MEATBALL); |
| 2016 | smell = TRUE; |
| 2017 | } else if (obj->otyp == STATUE || obj->otyp == FIGURINE) { |
| 2018 | ptr = &mons[obj->corpsenm]; |
| 2019 | if (is_golem(ptr)) { |
| 2020 | golem_xform = (ptr != &mons[PM_FLESH_GOLEM]); |
| 2021 | } else if (vegetarian(ptr)) { |
| 2022 | /* Don't animate monsters that aren't flesh */ |
| 2023 | obj = poly_obj(obj, MEATBALL); |
| 2024 | smell = TRUE; |
| 2025 | break; |
| 2026 | } |
| 2027 | if (obj->otyp == STATUE) { |
| 2028 | /* animate_statue() forces all golems to become flesh golems */ |
| 2029 | mon = animate_statue(obj, oox, ooy, ANIMATE_SPELL, (int *) 0); |
| 2030 | } else { /* (obj->otyp == FIGURINE) */ |
| 2031 | if (golem_xform) |
| 2032 | ptr = &mons[PM_FLESH_GOLEM]; |
| 2033 | mon = makemon(ptr, oox, ooy, NO_MINVENT|MM_NOMSG); |
| 2034 | if (mon) { |
| 2035 | if (costly_spot(oox, ooy) |
| 2036 | && (carried(obj) ? obj->unpaid : !obj->no_charge)) { |
| 2037 | shkp = shop_keeper(*in_rooms(oox, ooy, SHOPBASE)); |
| 2038 | stolen_value(obj, oox, ooy, |
| 2039 | (shkp && shkp->mpeaceful), FALSE); |
| 2040 | } |
| 2041 | if (obj->timed) |
| 2042 | obj_stop_timers(obj); |
| 2043 | if (carried(obj)) |
| 2044 | useup(obj); |
| 2045 | else |
| 2046 | delobj(obj); |
| 2047 | if (cansee(mon->mx, mon->my)) |
| 2048 | pline_The("figurine %sanimates!", |
| 2049 | golem_xform ? "turns to flesh and " : ""); |
no test coverage detected