choose a note not used by any trap on current level, ignoring ttmp; if all are in use, pick a random one */
| 3080 | /* choose a note not used by any trap on current level, |
| 3081 | ignoring ttmp; if all are in use, pick a random one */ |
| 3082 | staticfn int |
| 3083 | choose_trapnote(struct trap *ttmp) |
| 3084 | { |
| 3085 | int tavail[12], tpick[12], tcnt = 0, k; |
| 3086 | struct trap *t; |
| 3087 | |
| 3088 | for (k = 0; k < 12; ++k) |
| 3089 | tavail[k] = tpick[k] = 0; |
| 3090 | for (t = gf.ftrap; t; t = t->ntrap) |
| 3091 | if (t->ttyp == SQKY_BOARD && t != ttmp) |
| 3092 | tavail[t->tnote] = 1; |
| 3093 | /* now populate tpick[] with the available indices */ |
| 3094 | for (k = 0; k < 12; ++k) |
| 3095 | if (tavail[k] == 0) |
| 3096 | tpick[tcnt++] = k; |
| 3097 | /* choose an unused note; if all are in use, pick a random one */ |
| 3098 | return ((tcnt > 0) ? tpick[rn2(tcnt)] : rn2(12)); |
| 3099 | } |
| 3100 | |
| 3101 | staticfn int |
| 3102 | steedintrap(struct trap *trap, struct obj *otmp) |