MCPcopy Create free account
hub / github.com/diasurgical/devilution / GetStaffPower

Function GetStaffPower

Source/items.cpp:1154–1209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1152}
1153
1154void GetStaffPower(int i, int lvl, int bs, BOOL onlygood)
1155{
1156 int l[256];
1157 char istr[128];
1158 int nl, j, preidx;
1159 BOOL addok;
1160 int tmp;
1161
1162 tmp = random_(15, 10);
1163 preidx = -1;
1164 if (tmp == 0 || onlygood) {
1165 nl = 0;
1166 for (j = 0; PL_Prefix[j].PLPower != -1; j++) {
1167 if (PL_Prefix[j].PLIType & PLT_STAFF && PL_Prefix[j].PLMinLvl <= lvl) {
1168 addok = TRUE;
1169 if (onlygood && !PL_Prefix[j].PLOk)
1170 addok = FALSE;
1171 if (addok) {
1172 l[nl] = j;
1173 nl++;
1174 if (PL_Prefix[j].PLDouble) {
1175 l[nl] = j;
1176 nl++;
1177 }
1178 }
1179 }
1180 }
1181 if (nl != 0) {
1182 preidx = l[random_(16, nl)];
1183 sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
1184 strcpy(item[i]._iIName, istr);
1185 item[i]._iMagical = ITEM_QUALITY_MAGIC;
1186 SaveItemPower(
1187 i,
1188 PL_Prefix[preidx].PLPower,
1189 PL_Prefix[preidx].PLParam1,
1190 PL_Prefix[preidx].PLParam2,
1191 PL_Prefix[preidx].PLMinVal,
1192 PL_Prefix[preidx].PLMaxVal,
1193 PL_Prefix[preidx].PLMultVal);
1194 item[i]._iPrePower = PL_Prefix[preidx].PLPower;
1195 }
1196 }
1197 if (!control_WriteStringToBuffer((BYTE *)item[i]._iIName)) {
1198 strcpy(item[i]._iIName, AllItemsList[item[i].IDidx].iSName);
1199 if (preidx != -1) {
1200 sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
1201 strcpy(item[i]._iIName, istr);
1202 }
1203 sprintf(istr, "%s of %s", item[i]._iIName, spelldata[bs].sNameText);
1204 strcpy(item[i]._iIName, istr);
1205 if (item[i]._iMagical == ITEM_QUALITY_NORMAL)
1206 strcpy(item[i]._iName, item[i]._iIName);
1207 }
1208 CalcItemValue(i);
1209}
1210
1211void GetStaffSpell(int i, int lvl, BOOL onlygood)

Callers 1

GetStaffSpellFunction · 0.85

Calls 4

random_Function · 0.85
SaveItemPowerFunction · 0.85
CalcItemValueFunction · 0.85

Tested by

no test coverage detected