Move ammo stack size calcualtion into its own function
This commit is contained in:
parent
98b592f0c2
commit
cc2e820290
@ -1020,19 +1020,12 @@ export class RepeatableQuestGenerator
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The budget for this ammo stack
|
|
||||||
const stackRoubleBudget = roublesBudget / rewardNumItems;
|
|
||||||
|
|
||||||
const singleCartridgePrice = this.handbookHelper.getTemplatePrice(itemSelected._id);
|
|
||||||
|
|
||||||
// Get a stack size of ammo that fits rouble budget
|
|
||||||
const stackSizeThatFitsBudget = Math.round(stackRoubleBudget / singleCartridgePrice);
|
|
||||||
|
|
||||||
// Get itemDbs max stack size for ammo - don't go above 100 (some mods mess around with stack sizes)
|
|
||||||
const stackMaxCount = Math.min(itemSelected._props.StackMaxSize, 100);
|
|
||||||
|
|
||||||
// Choose smallest value between budget fitting size and stack max
|
// Choose smallest value between budget fitting size and stack max
|
||||||
rewardItemStackCount = Math.min(stackSizeThatFitsBudget, stackMaxCount);
|
rewardItemStackCount = this.calculateAmmoStackSizeThatFitsBudget(
|
||||||
|
itemSelected,
|
||||||
|
roublesBudget,
|
||||||
|
rewardNumItems,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 25% chance to double, triple quadruple reward stack (Only occurs when item is stackable and not weapon or ammo)
|
// 25% chance to double, triple quadruple reward stack (Only occurs when item is stackable and not weapon or ammo)
|
||||||
@ -1094,6 +1087,26 @@ export class RepeatableQuestGenerator
|
|||||||
return rewards;
|
return rewards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected calculateAmmoStackSizeThatFitsBudget(
|
||||||
|
itemSelected: ITemplateItem,
|
||||||
|
roublesBudget: number,
|
||||||
|
rewardNumItems: number,
|
||||||
|
): number
|
||||||
|
{
|
||||||
|
// The budget for this ammo stack
|
||||||
|
const stackRoubleBudget = roublesBudget / rewardNumItems;
|
||||||
|
|
||||||
|
const singleCartridgePrice = this.handbookHelper.getTemplatePrice(itemSelected._id);
|
||||||
|
|
||||||
|
// Get a stack size of ammo that fits rouble budget
|
||||||
|
const stackSizeThatFitsBudget = Math.round(stackRoubleBudget / singleCartridgePrice);
|
||||||
|
|
||||||
|
// Get itemDbs max stack size for ammo - don't go above 100 (some mods mess around with stack sizes)
|
||||||
|
const stackMaxCount = Math.min(itemSelected._props.StackMaxSize, 100);
|
||||||
|
|
||||||
|
return Math.min(stackSizeThatFitsBudget, stackMaxCount);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should reward item have stack size increased (25% chance)
|
* Should reward item have stack size increased (25% chance)
|
||||||
* @param item Item to possibly increase stack size of
|
* @param item Item to possibly increase stack size of
|
||||||
|
Loading…
Reference in New Issue
Block a user