| 1209 | } |
| 1210 | |
| 1211 | void GetStaffSpell(int i, int lvl, BOOL onlygood) |
| 1212 | { |
| 1213 | int l, rv, s, minc, maxc, v, bs; |
| 1214 | char istr[64]; |
| 1215 | |
| 1216 | if (!random_(17, 4)) { |
| 1217 | GetItemPower(i, lvl >> 1, lvl, PLT_STAFF, onlygood); |
| 1218 | } else { |
| 1219 | l = lvl >> 1; |
| 1220 | if (l == 0) |
| 1221 | l = 1; |
| 1222 | rv = random_(18, MAX_SPELLS) + 1; |
| 1223 | #ifdef SPAWN |
| 1224 | if (lvl > 10) |
| 1225 | lvl = 10; |
| 1226 | #endif |
| 1227 | s = 1; |
| 1228 | while (rv > 0) { |
| 1229 | if (spelldata[s].sStaffLvl != -1 && l >= spelldata[s].sStaffLvl) { |
| 1230 | rv--; |
| 1231 | bs = s; |
| 1232 | } |
| 1233 | s++; |
| 1234 | if (gbMaxPlayers == 1 && s == SPL_RESURRECT) |
| 1235 | s = SPL_TELEKINESIS; |
| 1236 | if (gbMaxPlayers == 1 && s == SPL_HEALOTHER) |
| 1237 | s = SPL_FLARE; |
| 1238 | if (s == MAX_SPELLS) |
| 1239 | s = 1; |
| 1240 | } |
| 1241 | sprintf(istr, "%s of %s", item[i]._iName, spelldata[bs].sNameText); |
| 1242 | if (!control_WriteStringToBuffer((BYTE *)istr)) |
| 1243 | sprintf(istr, "Staff of %s", spelldata[bs].sNameText); |
| 1244 | strcpy(item[i]._iName, istr); |
| 1245 | strcpy(item[i]._iIName, istr); |
| 1246 | |
| 1247 | minc = spelldata[bs].sStaffMin; |
| 1248 | maxc = spelldata[bs].sStaffMax - minc + 1; |
| 1249 | item[i]._iSpell = bs; |
| 1250 | item[i]._iCharges = minc + random_(19, maxc); |
| 1251 | item[i]._iMaxCharges = item[i]._iCharges; |
| 1252 | |
| 1253 | item[i]._iMinMag = spelldata[bs].sMinInt; |
| 1254 | v = item[i]._iCharges * spelldata[bs].sStaffCost / 5; |
| 1255 | item[i]._ivalue += v; |
| 1256 | item[i]._iIvalue += v; |
| 1257 | GetStaffPower(i, lvl, bs, onlygood); |
| 1258 | } |
| 1259 | } |
| 1260 | |
| 1261 | void GetItemAttrs(int i, int idata, int lvl) |
| 1262 | { |
no test coverage detected