Skip to content

Commit

Permalink
Merge pull request #62 from carxt/c6/515
Browse files Browse the repository at this point in the history
add casino functions, MLC override functions, GHA
  • Loading branch information
c6-dev authored Jan 15, 2025
2 parents 7281f44 + 0697c8e commit 1d22f3b
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 5 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: MSBuild

on:
push:
branches: [ "dev" ]

env:
SOLUTION_FILE_PATH: JG/johnnyguitar.sln

permissions: write-all

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2

- name: Build Release
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /m /p:Configuration=Release ${{env.SOLUTION_FILE_PATH}} /p:PostBuildEventUseInBuild=false

- name: Build Debug
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /m /p:Configuration=Debug ${{env.SOLUTION_FILE_PATH}} /p:PostBuildEventUseInBuild=false

- name: Generate Timestamp
run: |
timestamp=$(date +"%Y%m%d%H%M%S")
echo "artifact_timestamp=$timestamp" >> $GITHUB_ENV
shell: bash

- name: Package Artifacts
run: |
mkdir -p artifacts
Compress-Archive -Path JG\Release\johnnyguitar.dll -DestinationPath artifacts\JohnnyGuitarNVSE-Release-${{ env.artifact_timestamp }}.zip
Compress-Archive -Path JG\Debug\johnnyguitar.dll -DestinationPath artifacts\JohnnyGuitarNVSE-Debug-${{ env.artifact_timestamp }}.zip
shell: pwsh

- name: Publish Zipped Artifacts
uses: actions/upload-artifact@v4
with:
name: Zipped-Artifacts-${{ env.artifact_timestamp }}
path: artifacts/

- name: Get Release
id: get_release
uses: cardinalby/git-get-release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: 'continuous'
doNotFailIfNotFound: true
- name: Delete old release if exists
if: steps.get_release.outputs.id != ''
uses: dev-drprasad/[email protected]
with:
tag_name: continuous
github_token: ${{ secrets.GITHUB_TOKEN }}
delete_release: true
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: continuous
release_name: "Continuous release"
draft: false
prerelease: true
body: |
Continuous release generated from the latest push to development branch.
- name: Upload Artifact (Release)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/JohnnyGuitarNVSE-Release-${{ env.artifact_timestamp }}.zip
asset_name: JohnnyGuitarNVSE-Release-${{ env.artifact_timestamp }}.zip
asset_content_type: application/zip
- name: Upload Artifact (Debug)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/JohnnyGuitarNVSE-Debug-${{ env.artifact_timestamp }}.zip
asset_name: JohnnyGuitarNVSE-Debug-${{ env.artifact_timestamp }}.zip
asset_content_type: application/zip
11 changes: 8 additions & 3 deletions JG/JohnnyGuitarNVSE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ HMODULE JohnnyHandle;
_CaptureLambdaVars CaptureLambdaVars;
_UncaptureLambdaVars UncaptureLambdaVars;
NiTMap<const char*, TESForm*>** g_gameFormEditorIDsMap = reinterpret_cast<NiTMap<const char*, TESForm*>**>(0x11C54C8);
#define JG_VERSION 514
#define JG_VERSION 515
void MessageHandler(NVSEMessagingInterface::Message* msg) {
switch (msg->type) {
case NVSEMessagingInterface::kMessage_NewGame:
Expand All @@ -75,6 +75,8 @@ void MessageHandler(NVSEMessagingInterface::Message* msg) {
hk_BarterHook::barterFilterListRight.clear();
NPCAccuracy::FlushMapRefs();
shakeRequests.clear();
mlcOverridden = false;
mlcOverride = nullptr;
break;
}
case NVSEMessagingInterface::kMessage_PostLoadGame:
Expand Down Expand Up @@ -496,8 +498,11 @@ extern "C" {
REG_CMD(RemoveNoteQuest);
REG_CMD(SetHUDShudderPower);
REG_CMD(GetHUDShudderPower);
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.

REG_CMD(SetDialogResponseOverrideValues); // do not document
REG_CMD(SetMediaLocationControllerOverride); // do not document
REG_CMD(ClearMediaLocationControllerOverride); // do not document
REG_CMD(GetCasinoWinnings);
REG_CMD(SetCasinoWinnings);
g_scriptInterface = (NVSEScriptInterface*)nvse->QueryInterface(kInterface_Script);
g_cmdTableInterface = (NVSECommandTableInterface*)nvse->QueryInterface(kInterface_CommandTable);
s_strArgBuf = (char*)malloc((sizeof(char)) * 1024);
Expand Down
17 changes: 16 additions & 1 deletion JG/JohnnyGuitarNVSE.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Setting** g_miscStatData = (Setting**)0x11C6D50;
char g_workingDir[MAX_PATH];
std::unordered_set<DWORD> jg_gameRadioSet;
static float g_viewmodel_near = 0.f;

bool mlcOverridden = false;
MediaLocationController* mlcOverride = nullptr;
extern "C" {
bool __cdecl JGSetViewmodelClipDistance(float value);
float __cdecl JGGetViewmodelClipDistance();
Expand Down Expand Up @@ -585,6 +586,7 @@ namespace hk_DialogueTopicResponseManageHook {
}
}
PrintLog("End Dialogue Dump");
return NULL;

}

Expand Down Expand Up @@ -1795,6 +1797,17 @@ __declspec (noinline) void HandleDLLInterop() {
}
}


MediaLocationController* __fastcall MLCOverrideHook(PlayerCharacter* player)
{
if (mlcOverridden)
{
return mlcOverride;
}
return ThisStdCall<MediaLocationController*>(0x9698A0, player);

}

float getHUDShakePower() {
if (shakeRequests.empty()) {
return 0.0f;
Expand Down Expand Up @@ -1863,6 +1876,8 @@ void HandleFunctionPatches() {

WriteRelCall(0x8752F2, UInt32(SetViewmodelFrustumHook));

WriteRelCall(0x82FC95, (UInt32)MLCOverrideHook);

}
float timer22 = 30.0;
void HandleGameHooks() {
Expand Down
84 changes: 84 additions & 0 deletions JG/functions/fn_gameplay.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "ParamInfos.h"
// Functions affecting gameplay
DEFINE_COMMAND_PLUGIN(ToggleLevelUpMenu, , 0, 1, kParams_OneInt);
DEFINE_COMMAND_PLUGIN(TogglePipBoy, , 0, 1, kParams_OneOptionalInt);
Expand Down Expand Up @@ -58,6 +59,11 @@ DEFINE_COMMAND_PLUGIN(ClearCustomMapMarker, , 0, 0, NULL);
DEFINE_COMMAND_PLUGIN(EjectCasing, , 0, 2, kParams_EjectCasing);
DEFINE_COMMAND_PLUGIN(SetHUDShudderPower, , 0, 1, kParams_OneFloat);
DEFINE_COMMAND_PLUGIN(GetHUDShudderPower, , 0, 0, NULL);
DEFINE_COMMAND_ALT_PLUGIN(SetMediaLocationControllerOverride, SetMLCOverride, , 0, 1, kParams_OneForm);
DEFINE_COMMAND_ALT_PLUGIN(ClearMediaLocationControllerOverride, ClearMLCOverride, , 0, 0, NULL);
DEFINE_COMMAND_ALT_PLUGIN(GetCasinoWinnings, , , 0, 1, kParams_OneCasino);
DEFINE_COMMAND_ALT_PLUGIN(SetCasinoWinnings, , , 0, 2, kParams_OneCasinoOneInt);

void(__cdecl* HandleActorValueChange)(ActorValueOwner* avOwner, int avCode, float oldVal, float newVal, ActorValueOwner* avOwner2) =
(void(__cdecl*)(ActorValueOwner*, int, float, float, ActorValueOwner*))0x66EE50;
bool(*Cmd_HighLightBodyPart)(COMMAND_ARGS) = (bool (*)(COMMAND_ARGS)) 0x5BB570;
Expand All @@ -67,6 +73,84 @@ void(__cdecl* HUDMainMenu_UpdateVisibilityState)(signed int) = (void(__cdecl*)(s

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

bool __cdecl Cmd_SetCasinoWinnings_Execute(COMMAND_ARGS)
{
TESCasino* casino;
SInt32 earnings;
if (ExtractArgs(EXTRACT_ARGS, &casino, &earnings) && casino)
{

auto casinoRefId = casino->refID;
auto iter = PlayerCharacter::GetSingleton()->casinoDataList->Head();
if (iter) {
do
{
if (auto casinoData = iter->data)
{
if (casinoData->casinoRefID == casinoRefId)
{
casinoData->earnings = earnings;
return true;
}
}
} while (iter = iter->next);
}

auto casinoStats = (CasinoStats*)GameHeapAlloc(sizeof(CasinoStats));
casinoStats->earningStage = 0;
casinoStats->earnings = earnings;
casinoStats->casinoRefID = casinoRefId;
PlayerCharacter::GetSingleton()->casinoDataList->Insert(casinoStats);
}

return true;
}

bool __cdecl Cmd_GetCasinoWinnings_Execute(COMMAND_ARGS)
{
*result = 0;
TESCasino* casino = nullptr;
if (ExtractArgs(EXTRACT_ARGS, &casino) && casino)
{
auto casinoRefId = casino->refID;
auto iter = PlayerCharacter::GetSingleton()->casinoDataList->Head();
if (!iter) return true;
do
{
if (auto casinoData = iter->data)
{
if (casinoData->casinoRefID == casinoRefId)
{
*result = casinoData->earnings;
break;
}
}
} while (iter = iter->next);
}

return true;
}

bool Cmd_ClearMediaLocationControllerOverride_Execute(COMMAND_ARGS) {
*result = 0;
mlcOverridden = false;
mlcOverride = nullptr;
*result = 1;

return true;
}

bool Cmd_SetMediaLocationControllerOverride_Execute(COMMAND_ARGS) {
*result = 0;
MediaLocationController* ctrl = NULL;
if (ExtractArgsEx(EXTRACT_ARGS_EX, &ctrl) && IS_TYPE(ctrl, MediaLocationController)) {
mlcOverridden = true;
mlcOverride = ctrl;
*result = 1;
}
return true;
}

bool Cmd_GetHUDShudderPower_Execute(COMMAND_ARGS) {
*result = 0;
UInt8 modId = scriptObj->GetModIndex();
Expand Down
8 changes: 8 additions & 0 deletions nvse/nvse/GameForms.h
Original file line number Diff line number Diff line change
Expand Up @@ -5990,3 +5990,11 @@ enum EWhichListForm {
eWhichListForm_FormList,
eWhichListForm_Max,
};

struct CasinoStats
{
UInt32 casinoRefID;
SInt32 earnings;
UInt16 earningStage;
UInt8 gap0A[2];
};
2 changes: 1 addition & 1 deletion nvse/nvse/GameObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ class PlayerCharacter : public Character {
TESObjectREFR* lastExteriorDoor; // 604
void* unk608; // 608
void* unk60C; // 60C
void* unk610; // 610
tList<CasinoStats>* casinoDataList; // 610
tList<TESCaravanCard>* caravanCards1; // 614
tList<TESCaravanCard>* caravanCards2; // 618
UInt32 unk61C[7]; // 61C
Expand Down
11 changes: 11 additions & 0 deletions nvse/nvse/ParamInfos.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,4 +831,15 @@ static ParamInfo kParams_EjectCasing[2] =
{
{ "Target Node", kParamType_String, 1 },
{ "Custom Casing Path", kParamType_String, 1 },
};

static ParamInfo kParams_OneCasino[1] =
{
{ "Casino", kParamType_Casino, 1 },
};

static ParamInfo kParams_OneCasinoOneInt[2] =
{
{ "Casino", kParamType_Casino, 1 },
{ "Earnings", kParamType_Integer, 1 },
};

0 comments on commit 1d22f3b

Please sign in to comment.