Skip to content

Commit

Permalink
Add override to better reflect player's status
Browse files Browse the repository at this point in the history
  • Loading branch information
hel0t committed Jul 3, 2024
1 parent 68b3b6f commit 8f3d68b
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/overrides/controllers/ProfileController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ import { IGetOtherProfileRequest } from "@spt/models/eft/profile/IGetOtherProfil
import { IGetOtherProfileResponse } from "@spt/models/eft/profile/IGetOtherProfileResponse";
import { ISearchFriendRequestData } from "@spt/models/eft/profile/ISearchFriendRequestData";
import { ISearchFriendResponse } from "@spt/models/eft/profile/ISearchFriendResponse";
import { GetProfileStatusResponseData } from "@spt/models/eft/profile/GetProfileStatusResponseData";

import { Override } from "../../di/Override";
import { FikaConfig } from "../../utils/FikaConfig";
import { FikaMatchService } from "../../services/FikaMatchService";
import { FikaGroupService } from "../../services/FikaGroupService";
import { SideType } from "@spt/models/enums/SideType";

@injectable()
export class ProfileControllerOverride extends Override {
constructor(
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
@inject("FikaConfig") protected fikaConfig: FikaConfig,
@inject("FikaMatchService") protected fikaMatchService: FikaMatchService,
@inject("FikaGroupService") protected fikaGroupService: FikaGroupService,
) {
super();
}
Expand Down Expand Up @@ -114,6 +120,49 @@ export class ProfileControllerOverride extends Override {
},
};
};

result.getProfileStatus = (sessionId: string): GetProfileStatusResponseData => {
const account = this.profileHelper.getFullProfile(sessionId).info;
const groupId = this.fikaGroupService.getGroupIdByMember(sessionId);
const matchId = this.fikaMatchService.getMatchIdByProfile(sessionId);
const match = this.fikaMatchService.getMatch(matchId);
const matchPlayer = this.fikaMatchService.getPlayerInMatch(matchId, sessionId);

const profileInfo = {
[matchPlayer.side ?? SideType.PMC]: {
status: match?.ips?.length ? "Busy" : "Free",
location: match?.raidConfig?.location,
raidMode: match?.raidConfig?.raidMode,
mode: groupId ?? undefined,
}
}

const response: GetProfileStatusResponseData = {
maxPveCountExceeded: false,
profiles: [
{
profileid: account.scavId,
profileToken: undefined,
status: "Free", // This will be overwritten
sid: "",
ip: "",
port: 0,
...(profileInfo[SideType.SAVAGE] ?? {})
},
{
profileid: account.id,
profileToken: undefined,
status: "Free", // This will be overwritten
sid: "",
ip: "",
port: 0,
...(profileInfo[SideType.PMC] ?? {})
},
],
};

return response;
}
},
{ frequency: "Always" },
);
Expand Down

0 comments on commit 8f3d68b

Please sign in to comment.