Skip to content

Commit 1d22f3b

Browse files
authored
Merge pull request #62 from carxt/c6/515
add casino functions, MLC override functions, GHA
2 parents 7281f44 + 0697c8e commit 1d22f3b

File tree

7 files changed

+221
-5
lines changed

7 files changed

+221
-5
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: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ HMODULE JohnnyHandle;
4949
_CaptureLambdaVars CaptureLambdaVars;
5050
_UncaptureLambdaVars UncaptureLambdaVars;
5151
NiTMap<const char*, TESForm*>** g_gameFormEditorIDsMap = reinterpret_cast<NiTMap<const char*, TESForm*>**>(0x11C54C8);
52-
#define JG_VERSION 514
52+
#define JG_VERSION 515
5353
void MessageHandler(NVSEMessagingInterface::Message* msg) {
5454
switch (msg->type) {
5555
case NVSEMessagingInterface::kMessage_NewGame:
@@ -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
@@ -68,7 +68,8 @@ Setting** g_miscStatData = (Setting**)0x11C6D50;
6868
char g_workingDir[MAX_PATH];
6969
std::unordered_set<DWORD> jg_gameRadioSet;
7070
static float g_viewmodel_near = 0.f;
71-
71+
bool mlcOverridden = false;
72+
MediaLocationController* mlcOverride = nullptr;
7273
extern "C" {
7374
bool __cdecl JGSetViewmodelClipDistance(float value);
7475
float __cdecl JGGetViewmodelClipDistance();
@@ -585,6 +586,7 @@ namespace hk_DialogueTopicResponseManageHook {
585586
}
586587
}
587588
PrintLog("End Dialogue Dump");
589+
return NULL;
588590

589591
}
590592

@@ -1795,6 +1797,17 @@ __declspec (noinline) void HandleDLLInterop() {
17951797
}
17961798
}
17971799

1800+
1801+
MediaLocationController* __fastcall MLCOverrideHook(PlayerCharacter* player)
1802+
{
1803+
if (mlcOverridden)
1804+
{
1805+
return mlcOverride;
1806+
}
1807+
return ThisStdCall<MediaLocationController*>(0x9698A0, player);
1808+
1809+
}
1810+
17981811
float getHUDShakePower() {
17991812
if (shakeRequests.empty()) {
18001813
return 0.0f;
@@ -1863,6 +1876,8 @@ void HandleFunctionPatches() {
18631876

18641877
WriteRelCall(0x8752F2, UInt32(SetViewmodelFrustumHook));
18651878

1879+
WriteRelCall(0x82FC95, (UInt32)MLCOverrideHook);
1880+
18661881
}
18671882
float timer22 = 30.0;
18681883
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)