mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 02:30:43 -05:00
Fixed Fuel items and Water filters losing FIR status when placed into Generator/Water Collector (!261)
Ignore the other commits, I need to nuke my branch and learn to rebase properly kek Reviewed-on: SPT-AKI/Server#261 Co-authored-by: Arys <arys@noreply.dev.sp-tarkov.com> Co-committed-by: Arys <arys@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
c25be01a15
commit
1dc5db42f3
@ -507,10 +507,12 @@ export class HideoutHelper
|
|||||||
pointsConsumed -= 10;
|
pointsConsumed -= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isFuelItemFoundInRaid = fuelItemInSlot.upd.SpawnedInSession ?? false;
|
||||||
|
|
||||||
if (fuelRemaining > 0)
|
if (fuelRemaining > 0)
|
||||||
{
|
{
|
||||||
// Deducted all used fuel from this container, clean up and exit loop
|
// Deducted all used fuel from this container, clean up and exit loop
|
||||||
fuelItemInSlot.upd = this.getAreaUpdObject(1, fuelRemaining, pointsConsumed);
|
fuelItemInSlot.upd = this.getAreaUpdObject(1, fuelRemaining, pointsConsumed, isFuelItemFoundInRaid);
|
||||||
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Profile: ${pmcData._id} Generator has: ${fuelRemaining} fuel left in slot ${i + 1}`,
|
`Profile: ${pmcData._id} Generator has: ${fuelRemaining} fuel left in slot ${i + 1}`,
|
||||||
@ -521,7 +523,7 @@ export class HideoutHelper
|
|||||||
break; // Break to avoid updating all the fuel tanks
|
break; // Break to avoid updating all the fuel tanks
|
||||||
}
|
}
|
||||||
|
|
||||||
fuelItemInSlot.upd = this.getAreaUpdObject(1, 0, 0);
|
fuelItemInSlot.upd = this.getAreaUpdObject(1, 0, 0, isFuelItemFoundInRaid);
|
||||||
|
|
||||||
// Ran out of fuel items to deduct fuel from
|
// Ran out of fuel items to deduct fuel from
|
||||||
fuelUsedSinceLastTick = Math.abs(fuelRemaining);
|
fuelUsedSinceLastTick = Math.abs(fuelRemaining);
|
||||||
@ -640,9 +642,11 @@ export class HideoutHelper
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const waterFilterItemInSlot = waterFilterArea.slots[i].item[0];
|
||||||
|
|
||||||
// How many units of filter are left
|
// How many units of filter are left
|
||||||
let resourceValue = (waterFilterArea.slots[i].item[0].upd?.Resource)
|
let resourceValue = (waterFilterItemInSlot.upd?.Resource)
|
||||||
? waterFilterArea.slots[i].item[0].upd.Resource.Value
|
? waterFilterItemInSlot.upd.Resource.Value
|
||||||
: null;
|
: null;
|
||||||
if (!resourceValue)
|
if (!resourceValue)
|
||||||
{
|
{
|
||||||
@ -652,7 +656,7 @@ export class HideoutHelper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pointsConsumed = (waterFilterArea.slots[i].item[0].upd.Resource.UnitsConsumed || 0)
|
pointsConsumed = (waterFilterItemInSlot.upd.Resource.UnitsConsumed || 0)
|
||||||
+ filterDrainRate;
|
+ filterDrainRate;
|
||||||
resourceValue -= filterDrainRate;
|
resourceValue -= filterDrainRate;
|
||||||
}
|
}
|
||||||
@ -671,8 +675,10 @@ export class HideoutHelper
|
|||||||
// Filter has some fuel left in it after our adjustment
|
// Filter has some fuel left in it after our adjustment
|
||||||
if (resourceValue > 0)
|
if (resourceValue > 0)
|
||||||
{
|
{
|
||||||
|
const isWaterFilterFoundInRaid = waterFilterItemInSlot.upd.SpawnedInSession ?? false;
|
||||||
|
|
||||||
// Set filters consumed amount
|
// Set filters consumed amount
|
||||||
waterFilterArea.slots[i].item[0].upd = this.getAreaUpdObject(1, resourceValue, pointsConsumed);
|
waterFilterItemInSlot.upd = this.getAreaUpdObject(1, resourceValue, pointsConsumed, isWaterFilterFoundInRaid);
|
||||||
this.logger.debug(`Water filter has: ${resourceValue} units left in slot ${i + 1}`);
|
this.logger.debug(`Water filter has: ${resourceValue} units left in slot ${i + 1}`);
|
||||||
|
|
||||||
break; // Break here to avoid iterating other filters now w're done
|
break; // Break here to avoid iterating other filters now w're done
|
||||||
@ -743,11 +749,12 @@ export class HideoutHelper
|
|||||||
* @param resourceUnitsConsumed
|
* @param resourceUnitsConsumed
|
||||||
* @returns Upd
|
* @returns Upd
|
||||||
*/
|
*/
|
||||||
protected getAreaUpdObject(stackCount: number, resourceValue: number, resourceUnitsConsumed: number): Upd
|
protected getAreaUpdObject(stackCount: number, resourceValue: number, resourceUnitsConsumed: number, isFoundInRaid: boolean): Upd
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
StackObjectsCount: stackCount,
|
StackObjectsCount: stackCount,
|
||||||
Resource: { Value: resourceValue, UnitsConsumed: resourceUnitsConsumed },
|
Resource: { Value: resourceValue, UnitsConsumed: resourceUnitsConsumed },
|
||||||
|
SpawnedInSession: isFoundInRaid,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user