Set malign to have the proper effect on player alignment if monster is * killed. Negative numbers mean it's bad to kill this monster; positive * numbers mean it's good. Since there are more hostile monsters than * peaceful monsters, the penalty for killing a peaceful monster should be * greater than the bonus for killing a hostile monster to maintain balance. * Rules: * it's bad to kill
| 2318 | * it's never bad to kill a hostile monster, although it may not be good. |
| 2319 | */ |
| 2320 | void |
| 2321 | set_malign(struct monst *mtmp) |
| 2322 | { |
| 2323 | schar mal = mtmp->data->maligntyp; |
| 2324 | boolean coaligned; |
| 2325 | |
| 2326 | if (mtmp->ispriest || mtmp->isminion) { |
| 2327 | /* some monsters have individual alignments; check them */ |
| 2328 | if (mtmp->ispriest && EPRI(mtmp)) |
| 2329 | mal = EPRI(mtmp)->shralign; |
| 2330 | else if (mtmp->isminion && EMIN(mtmp)) |
| 2331 | mal = EMIN(mtmp)->min_align; |
| 2332 | /* unless alignment is none, set mal to -5,0,5 */ |
| 2333 | /* (see align.h for valid aligntyp values) */ |
| 2334 | if (mal != A_NONE) |
| 2335 | mal *= 5; |
| 2336 | } |
| 2337 | |
| 2338 | coaligned = (sgn(mal) == sgn(u.ualign.type)); |
| 2339 | if (mtmp->data->msound == MS_LEADER) { |
| 2340 | mtmp->malign = -20; |
| 2341 | } else if (mal == A_NONE) { |
| 2342 | if (mtmp->mpeaceful) |
| 2343 | mtmp->malign = 0; |
| 2344 | else |
| 2345 | mtmp->malign = 20; /* really hostile */ |
| 2346 | } else if (always_peaceful(mtmp->data)) { |
| 2347 | int absmal = abs(mal); |
| 2348 | if (mtmp->mpeaceful) |
| 2349 | mtmp->malign = -3 * max(5, absmal); |
| 2350 | else |
| 2351 | mtmp->malign = 3 * max(5, absmal); /* renegade */ |
| 2352 | } else if (always_hostile(mtmp->data)) { |
| 2353 | int absmal = abs(mal); |
| 2354 | if (coaligned) |
| 2355 | mtmp->malign = 0; |
| 2356 | else |
| 2357 | mtmp->malign = max(5, absmal); |
| 2358 | } else if (coaligned) { |
| 2359 | int absmal = abs(mal); |
| 2360 | if (mtmp->mpeaceful) |
| 2361 | mtmp->malign = -3 * max(3, absmal); |
| 2362 | else /* renegade */ |
| 2363 | mtmp->malign = max(3, absmal); |
| 2364 | } else /* not coaligned and therefore hostile */ |
| 2365 | mtmp->malign = abs(mal); |
| 2366 | } |
| 2367 | |
| 2368 | /* allocate a new mcorpsenm field for a monster; only need mextra itself */ |
| 2369 | void |
no test coverage detected