Skip to content

Commit 1e6093f

Browse files
committed
Merge branch 'dev' of https://github.com/carxt/JohnnyGuitarNVSE into dev
2 parents 73c2473 + 1d22f3b commit 1e6093f

File tree

7 files changed

+220
-4
lines changed

7 files changed

+220
-4
lines changed

.github/workflows/msbuild.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: MSBuild
2+
3+
on:
4+
push:
5+
branches: [ "dev" ]
6+
7+
env:
8+
SOLUTION_FILE_PATH: JG/johnnyguitar.sln
9+
10+
permissions: write-all
11+
12+
jobs:
13+
build:
14+
runs-on: windows-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Add MSBuild to PATH
20+
uses: microsoft/setup-msbuild@v2
21+
22+
- name: Build Release
23+
working-directory: ${{env.GITHUB_WORKSPACE}}
24+
run: msbuild /m /p:Configuration=Release ${{env.SOLUTION_FILE_PATH}} /p:PostBuildEventUseInBuild=false
25+
26+
- name: Build Debug
27+
working-directory: ${{env.GITHUB_WORKSPACE}}
28+
run: msbuild /m /p:Configuration=Debug ${{env.SOLUTION_FILE_PATH}} /p:PostBuildEventUseInBuild=false
29+
30+
- name: Generate Timestamp
31+
run: |
32+
timestamp=$(date +"%Y%m%d%H%M%S")
33+
echo "artifact_timestamp=$timestamp" >> $GITHUB_ENV
34+
shell: bash
35+
36+
- name: Package Artifacts
37+
run: |
38+
mkdir -p artifacts
39+
Compress-Archive -Path JG\Release\johnnyguitar.dll -DestinationPath artifacts\JohnnyGuitarNVSE-Release-${{ env.artifact_timestamp }}.zip
40+
Compress-Archive -Path JG\Debug\johnnyguitar.dll -DestinationPath artifacts\JohnnyGuitarNVSE-Debug-${{ env.artifact_timestamp }}.zip
41+
shell: pwsh
42+
43+
- name: Publish Zipped Artifacts
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: Zipped-Artifacts-${{ env.artifact_timestamp }}
47+
path: artifacts/
48+
49+
- name: Get Release
50+
id: get_release
51+
uses: cardinalby/git-get-release-action@v1
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
with:
55+
tag: 'continuous'
56+
doNotFailIfNotFound: true
57+
- name: Delete old release if exists
58+
if: steps.get_release.outputs.id != ''
59+
uses: dev-drprasad/delete-tag-and-release@v1.0
60+
with:
61+
tag_name: continuous
62+
github_token: ${{ secrets.GITHUB_TOKEN }}
63+
delete_release: true
64+
- name: Create Release
65+
id: create_release
66+
uses: actions/create-release@v1
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
with:
70+
tag_name: continuous
71+
release_name: "Continuous release"
72+
draft: false
73+
prerelease: true
74+
body: |
75+
Continuous release generated from the latest push to development branch.
76+
- name: Upload Artifact (Release)
77+
uses: actions/upload-release-asset@v1
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
with:
81+
upload_url: ${{ steps.create_release.outputs.upload_url }}
82+
asset_path: artifacts/JohnnyGuitarNVSE-Release-${{ env.artifact_timestamp }}.zip
83+
asset_name: JohnnyGuitarNVSE-Release-${{ env.artifact_timestamp }}.zip
84+
asset_content_type: application/zip
85+
- name: Upload Artifact (Debug)
86+
uses: actions/upload-release-asset@v1
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
with:
90+
upload_url: ${{ steps.create_release.outputs.upload_url }}
91+
asset_path: artifacts/JohnnyGuitarNVSE-Debug-${{ env.artifact_timestamp }}.zip
92+
asset_name: JohnnyGuitarNVSE-Debug-${{ env.artifact_timestamp }}.zip
93+
asset_content_type: application/zip

JG/JohnnyGuitarNVSE.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ void MessageHandler(NVSEMessagingInterface::Message* msg) {
7575
hk_BarterHook::barterFilterListRight.clear();
7676
NPCAccuracy::FlushMapRefs();
7777
shakeRequests.clear();
78+
mlcOverridden = false;
79+
mlcOverride = nullptr;
7880
break;
7981
}
8082
case NVSEMessagingInterface::kMessage_PostLoadGame:
@@ -496,8 +498,11 @@ extern "C" {
496498
REG_CMD(RemoveNoteQuest);
497499
REG_CMD(SetHUDShudderPower);
498500
REG_CMD(GetHUDShudderPower);
499-
REG_CMD(SetDialogResponseOverrideValues); // Function is subject to overrides at random and therefore not eligible for documentation. Can be removed at any time, so mod breakage due to using it will not be considered.
500-
501+
REG_CMD(SetDialogResponseOverrideValues); // do not document
502+
REG_CMD(SetMediaLocationControllerOverride); // do not document
503+
REG_CMD(ClearMediaLocationControllerOverride); // do not document
504+
REG_CMD(GetCasinoWinnings);
505+
REG_CMD(SetCasinoWinnings);
501506
g_scriptInterface = (NVSEScriptInterface*)nvse->QueryInterface(kInterface_Script);
502507
g_cmdTableInterface = (NVSECommandTableInterface*)nvse->QueryInterface(kInterface_CommandTable);
503508
s_strArgBuf = (char*)malloc((sizeof(char)) * 1024);

JG/JohnnyGuitarNVSE.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ Setting** g_miscStatData = (Setting**)0x11C6D50;
6969
char g_workingDir[MAX_PATH];
7070
std::unordered_set<DWORD> jg_gameRadioSet;
7171
static float g_viewmodel_near = 0.f;
72-
72+
bool mlcOverridden = false;
73+
MediaLocationController* mlcOverride = nullptr;
7374
extern "C" {
7475
bool __cdecl JGSetViewmodelClipDistance(float value);
7576
float __cdecl JGGetViewmodelClipDistance();
@@ -601,6 +602,7 @@ namespace hk_DialogueTopicResponseManageHook {
601602
}
602603
}
603604
PrintLog("End Dialogue Dump");
605+
return NULL;
604606

605607
}
606608

@@ -1817,6 +1819,17 @@ __declspec (noinline) void HandleDLLInterop() {
18171819
}
18181820
}
18191821

1822+
1823+
MediaLocationController* __fastcall MLCOverrideHook(PlayerCharacter* player)
1824+
{
1825+
if (mlcOverridden)
1826+
{
1827+
return mlcOverride;
1828+
}
1829+
return ThisStdCall<MediaLocationController*>(0x9698A0, player);
1830+
1831+
}
1832+
18201833
float getHUDShakePower() {
18211834
if (shakeRequests.empty()) {
18221835
return 0.0f;
@@ -1885,6 +1898,8 @@ void HandleFunctionPatches() {
18851898

18861899
WriteRelCall(0x8752F2, UInt32(SetViewmodelFrustumHook));
18871900

1901+
WriteRelCall(0x82FC95, (UInt32)MLCOverrideHook);
1902+
18881903
}
18891904
float timer22 = 30.0;
18901905
void HandleGameHooks() {

JG/functions/fn_gameplay.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#pragma once
2+
#include "ParamInfos.h"
23
// Functions affecting gameplay
34
DEFINE_COMMAND_PLUGIN(ToggleLevelUpMenu, , 0, 1, kParams_OneInt);
45
DEFINE_COMMAND_PLUGIN(TogglePipBoy, , 0, 1, kParams_OneOptionalInt);
@@ -58,6 +59,11 @@ DEFINE_COMMAND_PLUGIN(ClearCustomMapMarker, , 0, 0, NULL);
5859
DEFINE_COMMAND_PLUGIN(EjectCasing, , 0, 2, kParams_EjectCasing);
5960
DEFINE_COMMAND_PLUGIN(SetHUDShudderPower, , 0, 1, kParams_OneFloat);
6061
DEFINE_COMMAND_PLUGIN(GetHUDShudderPower, , 0, 0, NULL);
62+
DEFINE_COMMAND_ALT_PLUGIN(SetMediaLocationControllerOverride, SetMLCOverride, , 0, 1, kParams_OneForm);
63+
DEFINE_COMMAND_ALT_PLUGIN(ClearMediaLocationControllerOverride, ClearMLCOverride, , 0, 0, NULL);
64+
DEFINE_COMMAND_ALT_PLUGIN(GetCasinoWinnings, , , 0, 1, kParams_OneCasino);
65+
DEFINE_COMMAND_ALT_PLUGIN(SetCasinoWinnings, , , 0, 2, kParams_OneCasinoOneInt);
66+
6167
void(__cdecl* HandleActorValueChange)(ActorValueOwner* avOwner, int avCode, float oldVal, float newVal, ActorValueOwner* avOwner2) =
6268
(void(__cdecl*)(ActorValueOwner*, int, float, float, ActorValueOwner*))0x66EE50;
6369
bool(*Cmd_HighLightBodyPart)(COMMAND_ARGS) = (bool (*)(COMMAND_ARGS)) 0x5BB570;
@@ -67,6 +73,84 @@ void(__cdecl* HUDMainMenu_UpdateVisibilityState)(signed int) = (void(__cdecl*)(s
6773

6874
std::unordered_map<TESForm*, std::pair<float, float>> tempEffectMap;
6975

76+
bool __cdecl Cmd_SetCasinoWinnings_Execute(COMMAND_ARGS)
77+
{
78+
TESCasino* casino;
79+
SInt32 earnings;
80+
if (ExtractArgs(EXTRACT_ARGS, &casino, &earnings) && casino)
81+
{
82+
83+
auto casinoRefId = casino->refID;
84+
auto iter = PlayerCharacter::GetSingleton()->casinoDataList->Head();
85+
if (iter) {
86+
do
87+
{
88+
if (auto casinoData = iter->data)
89+
{
90+
if (casinoData->casinoRefID == casinoRefId)
91+
{
92+
casinoData->earnings = earnings;
93+
return true;
94+
}
95+
}
96+
} while (iter = iter->next);
97+
}
98+
99+
auto casinoStats = (CasinoStats*)GameHeapAlloc(sizeof(CasinoStats));
100+
casinoStats->earningStage = 0;
101+
casinoStats->earnings = earnings;
102+
casinoStats->casinoRefID = casinoRefId;
103+
PlayerCharacter::GetSingleton()->casinoDataList->Insert(casinoStats);
104+
}
105+
106+
return true;
107+
}
108+
109+
bool __cdecl Cmd_GetCasinoWinnings_Execute(COMMAND_ARGS)
110+
{
111+
*result = 0;
112+
TESCasino* casino = nullptr;
113+
if (ExtractArgs(EXTRACT_ARGS, &casino) && casino)
114+
{
115+
auto casinoRefId = casino->refID;
116+
auto iter = PlayerCharacter::GetSingleton()->casinoDataList->Head();
117+
if (!iter) return true;
118+
do
119+
{
120+
if (auto casinoData = iter->data)
121+
{
122+
if (casinoData->casinoRefID == casinoRefId)
123+
{
124+
*result = casinoData->earnings;
125+
break;
126+
}
127+
}
128+
} while (iter = iter->next);
129+
}
130+
131+
return true;
132+
}
133+
134+
bool Cmd_ClearMediaLocationControllerOverride_Execute(COMMAND_ARGS) {
135+
*result = 0;
136+
mlcOverridden = false;
137+
mlcOverride = nullptr;
138+
*result = 1;
139+
140+
return true;
141+
}
142+
143+
bool Cmd_SetMediaLocationControllerOverride_Execute(COMMAND_ARGS) {
144+
*result = 0;
145+
MediaLocationController* ctrl = NULL;
146+
if (ExtractArgsEx(EXTRACT_ARGS_EX, &ctrl) && IS_TYPE(ctrl, MediaLocationController)) {
147+
mlcOverridden = true;
148+
mlcOverride = ctrl;
149+
*result = 1;
150+
}
151+
return true;
152+
}
153+
70154
bool Cmd_GetHUDShudderPower_Execute(COMMAND_ARGS) {
71155
*result = 0;
72156
UInt8 modId = scriptObj->GetModIndex();

nvse/nvse/GameForms.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5990,3 +5990,11 @@ enum EWhichListForm {
59905990
eWhichListForm_FormList,
59915991
eWhichListForm_Max,
59925992
};
5993+
5994+
struct CasinoStats
5995+
{
5996+
UInt32 casinoRefID;
5997+
SInt32 earnings;
5998+
UInt16 earningStage;
5999+
UInt8 gap0A[2];
6000+
};

nvse/nvse/GameObjects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ class PlayerCharacter : public Character {
811811
TESObjectREFR* lastExteriorDoor; // 604
812812
void* unk608; // 608
813813
void* unk60C; // 60C
814-
void* unk610; // 610
814+
tList<CasinoStats>* casinoDataList; // 610
815815
tList<TESCaravanCard>* caravanCards1; // 614
816816
tList<TESCaravanCard>* caravanCards2; // 618
817817
UInt32 unk61C[7]; // 61C

nvse/nvse/ParamInfos.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,4 +831,15 @@ static ParamInfo kParams_EjectCasing[2] =
831831
{
832832
{ "Target Node", kParamType_String, 1 },
833833
{ "Custom Casing Path", kParamType_String, 1 },
834+
};
835+
836+
static ParamInfo kParams_OneCasino[1] =
837+
{
838+
{ "Casino", kParamType_Casino, 1 },
839+
};
840+
841+
static ParamInfo kParams_OneCasinoOneInt[2] =
842+
{
843+
{ "Casino", kParamType_Casino, 1 },
844+
{ "Earnings", kParamType_Integer, 1 },
834845
};

0 commit comments

Comments
 (0)