void handle_waterwheel_crystal_destroyed(CHAR_DATA & ch, OBJ_DATA & obj) { // Look for the effect AFFECT_DATA * paf(get_obj_affect(&obj, gsn_constructwaterwheel)); if (paf == NULL) return; // Echoes act("As you destroy $p, a surge of energy rushes from it and into you!", &ch, &obj, NULL, TO_CHAR); act("As $n destroys $p, a flash of blue light shines out from it, focused on $m!", &ch, &obj, NULL, TO_ROOM); // Strip the effect from the char if present for (AFFECT_DATA * waf(get_affect(&ch, gsn_constructwaterwheel)); waf != NULL; waf = get_affect(&ch, gsn_constructwaterwheel, waf)) { if (waf->location == APPLY_MANA) { affect_remove(&ch, waf); break; } } // Determine modifier int modifier(paf->duration); if (number_percent() <= get_skill(&ch, gsn_stonecraft)) check_improve(&ch, NULL, gsn_stonecraft, true, 4); else { check_improve(&ch, NULL, gsn_stonecraft, false, 4); modifier /= 2; } // Grant the new effect AFFECT_DATA af = {0}; af.where = TO_AFFECTS; af.type = gsn_constructwaterwheel; af.level = paf->level; af.modifier = UMAX(1, modifier); af.duration = af.modifier; af.location = APPLY_MANA; affect_to_char(&ch, &af); }
float nwaf_dist(int len, float *list1, float *list2){ return(1 - waf(len,list1,list2)); }