0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 01:30:44 -05:00

Fix: resolve issue with handing in item to quest that allows multiple types of items to be handed in (e.g. punisher p5 - 2 types of makarov can be handed in) (!63)

Moved some error logging in handoverQuest() to separate functions
Renamed `itemHandoverMode` to `isItemHandoverQuest`

Included some additional pmc responses

Co-authored-by: Dev <dev@noreply.dev.sp-tarkov.com>
Reviewed-on: SPT-AKI/Server#63
This commit is contained in:
chomp 2023-03-13 09:34:04 +00:00
parent 00e367ffa5
commit c81633ac38
2 changed files with 45 additions and 12 deletions

View File

@ -292,6 +292,12 @@
"pmcresponse-victim_negative_33": "You may have got me but I bet you never the thermal i had",
"pmcresponse-victim_negative_34": "I stopped playing live because of the esp and yet here you are",
"pmcresponse-victim_negative_35": "Yeah you killed me but i can bench press more than you",
"pmcresponse-victim_negative_36": "You have the map awareness of Christopher Columbus",
"pmcresponse-victim_negative_37": "I bet you sound like you eat cigarettes",
"pmcresponse-victim_negative_38": "You shoot like an old man. This what you do now you retired?",
"pmcresponse-victim_negative_39": "I bet you look like you were drawn with my left hand",
"pmcresponse-victim_negative_40": "Tell your mom to make your mac n cheese, I'll be home soon",
"pmcresponse-victim_negative_41": "If you were any more inbred you would be a sandwich",
"pmcresponse-victim_plead_1": "I was questing",
"pmcresponse-victim_plead_2": "I just wanted to do a quest, why'd you kill me :(",
"pmcresponse-victim_plead_3": "Hope ur happy i can't even afford a new kit",

View File

@ -1,3 +1,4 @@
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
import { inject, injectable } from "tsyringe";
import { DialogueHelper } from "../helpers/DialogueHelper";
@ -496,7 +497,8 @@ export class QuestController
const quest = this.questHelper.getQuestFromDb(handoverQuestRequest.qid, pmcData);
const handoverQuestTypes = ["HandoverItem", "WeaponAssembly"];
const output = this.eventOutputHolder.getOutput(sessionID);
let itemHandoverMode = true;
let isItemHandoverQuest = true;
let handedInCount = 0;
// Decrement number of items handed in
@ -506,7 +508,7 @@ export class QuestController
if (condition._props.id === handoverQuestRequest.conditionId && handoverQuestTypes.includes(condition._parent))
{
handedInCount = Number.parseInt(<string>condition._props.value);
itemHandoverMode = condition._parent === handoverQuestTypes[0];
isItemHandoverQuest = condition._parent === handoverQuestTypes[0];
handoverRequirements = condition;
const profileCounter = (handoverQuestRequest.conditionId in pmcData.BackendCounters)
@ -525,24 +527,19 @@ export class QuestController
}
}
if (itemHandoverMode && handedInCount === 0)
if (isItemHandoverQuest && handedInCount === 0)
{
const errorMessage = this.localisationService.getText("repeatable-quest_handover_failed_condition_invalid", {questId: handoverQuestRequest.qid, conditionId: handoverQuestRequest.conditionId});
this.logger.error(errorMessage);
return this.httpResponseUtil.appendErrorToOutput(output, errorMessage);
return this.showRepeatableQuestInvalidConditionError(handoverQuestRequest, output);
}
let totalItemCountToRemove = 0;
for (const itemHandover of handoverQuestRequest.items)
{
const handedOverItemProfileDetails = pmcData.Inventory.items.find(x => x._id === itemHandover.id);
if (handedOverItemProfileDetails._tpl !== handoverRequirements._props.target[0])
const matchingItemInProfile = pmcData.Inventory.items.find(x => x._id === itemHandover.id);
if (!handoverRequirements._props.target.includes(matchingItemInProfile._tpl))
{
// Item handed in by player doesnt match what was requested
const errorMessage = this.localisationService.getText("quest-handover_wrong_item", {questId: handoverQuestRequest.qid, handedInTpl: handedOverItemProfileDetails._tpl, requiredTpl: handoverRequirements._props.target[0]});
this.logger.error(errorMessage);
return this.httpResponseUtil.appendErrorToOutput(output, errorMessage);
return this.showQuestItemHandoverMatchError(handoverQuestRequest, matchingItemInProfile, handoverRequirements, output);
}
// Remove the right quantity of given items
@ -582,6 +579,36 @@ export class QuestController
return output;
}
/**
* Show warning to user and write to log that repeatable quest failed a condition check
* @param handoverQuestRequest Quest request
* @param output Response to send to user
* @returns IItemEventRouterResponse
*/
protected showRepeatableQuestInvalidConditionError(handoverQuestRequest: IHandoverQuestRequestData, output: IItemEventRouterResponse): IItemEventRouterResponse
{
const errorMessage = this.localisationService.getText("repeatable-quest_handover_failed_condition_invalid", { questId: handoverQuestRequest.qid, conditionId: handoverQuestRequest.conditionId });
this.logger.error(errorMessage);
return this.httpResponseUtil.appendErrorToOutput(output, errorMessage);
}
/**
* Show warning to user and write to log quest item handed over did not match what is required
* @param handoverQuestRequest Quest request
* @param itemHandedOver Non-matching item found
* @param handoverRequirements Quest handover requirements
* @param output Response to send to user
* @returns IItemEventRouterResponse
*/
protected showQuestItemHandoverMatchError(handoverQuestRequest: IHandoverQuestRequestData, itemHandedOver: Item, handoverRequirements: AvailableForConditions, output: IItemEventRouterResponse): IItemEventRouterResponse
{
const errorMessage = this.localisationService.getText("quest-handover_wrong_item", { questId: handoverQuestRequest.qid, handedInTpl: itemHandedOver._tpl, requiredTpl: handoverRequirements._props.target[0] });
this.logger.error(errorMessage);
return this.httpResponseUtil.appendErrorToOutput(output, errorMessage);
}
/**
* Increment a backend counter stored value by an amount,
* Create counter if it does not exist