Skip to content

Instantly share code, notes, and snippets.

@billw2012
billw2012 / script.ps1
Last active March 4, 2023 18:26
Powershell script that generates a mod to scale X4 module build time
$diff = New-Object System.Xml.XmlDocument
$diff.AppendChild($diff.CreateXmlDeclaration("1.0", "UTF-8", $null))
$diffRoot = $diff.CreateElement("diff")
$diff.AppendChild($diffRoot)
$inputFiles = Get-ChildItem -Path "C:\Temp\X4" -Filter "wares.xml" -Recurse
foreach ($file in $inputFiles) {
[xml]$xml = Get-Content $file.FullName
@billw2012
billw2012 / AffiliateSpoofingHttpCallHandler.cs
Last active May 5, 2021 14:22
Allows spoofing of affiliate status when using TwitchLib, for testing channel point rewards
// Usage:
// var affiliateSpoofing = new Dummy.AffiliateSpoofingHttpCallHandler();
// api = new TwitchAPI(http: affiliateSpoofing);
// affiliateSpoofing.OnRewardRedeemed += OnRewardRedeemed;
//
// Then add/remove rewards via the normal API.
// Test redemption like:
// affiliateSpoofing.FakeRedeem("My Reward Title", "fake_user_name", "text");
using System;
@billw2012
billw2012 / PBR_ZeroAttenuation.hlsl
Last active September 29, 2022 22:52
Remove point light attenuation in URP
// Drop this into a custom Shader Graph node, then output it to Unlit master Color and Alpha.
// If you want the point light to also behave as a directional light then instead of passing
// the Vertex world position pass the last column of the model Transformation matrix (Transformation node)
// instead.
// NOTE: this function removes GI feature entirely, as it wasn't necessary for my purpose.
void PBR_ZeroAttenuation_half(half3 Albedo,
half Metallic,
half3 Specular,
half Smoothness,
half3 Emission,
@billw2012
billw2012 / .cs
Created July 4, 2020 16:38
Troop cost/wage inflation
public static class Util
{
struct PriceInflation
{
public int UpdatedDay;
public bool NeedsUpdate => (int)Campaign.Current.CampaignStartTime.ElapsedDaysUntilNow > UpdatedDay;
public float Inflation;
};
@billw2012
billw2012 / VerticalScrollViewerStyle.xaml
Last active May 10, 2019 10:26
ScrollViewer with top and bottom shadows to indicate out of view content (requires a MultiValueConverter to compare values).
<Style x:Key="VerticalScrollViewer" TargetType="{x:Type ScrollViewer}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <chrono>
#include <cstdlib>
#include <algorithm>
#define USE_STD_STR
@billw2012
billw2012 / reveal-caves.lua
Created August 27, 2018 17:24
Reveal all undiscovered caves after embark.
-- Reveal all cave sites after embark
-- by billw
--[====[
reveal-caves
=========
Reveal all undiscovered cave sites.
]====]
@billw2012
billw2012 / mw_update.bat
Created July 17, 2018 19:47
Merge Masterwork and Mephs latest tileset.
@echo off
echo Usage: unzip Masterwork zip to Masterwork folder, and Meph tileset zip to Meph Tileset folder, put this script next to them and run it!
pause
cd /D "%~dp0"
if NOT exist Masterwork (
echo "Masterwork" directory not found!
goto fail_exit
)
if NOT exist "Meph Tileset" (