commit cdf05260aa4a50aea2226c777729331e6f8ad7c2 Author: Jack O'Sullivan Date: Sun Sep 15 18:49:00 2024 +0100 Initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e759b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,330 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ diff --git a/AntiYoink/AntiYoink.cs b/AntiYoink/AntiYoink.cs new file mode 100644 index 0000000..1c41f2c --- /dev/null +++ b/AntiYoink/AntiYoink.cs @@ -0,0 +1,140 @@ +using BepInEx; +using R2API; +using RoR2; +using UnityEngine; +using UnityEngine.AddressableAssets; + +namespace AntiYoink +{ + // This is an example plugin that can be put in + // BepInEx/plugins/ExamplePlugin/ExamplePlugin.dll to test out. + // It's a small plugin that adds a relatively simple item to the game, + // and gives you that item whenever you press F2. + + // This attribute specifies that we have a dependency on a given BepInEx Plugin, + // We need the R2API ItemAPI dependency because we are using for adding our item to the game. + // You don't need this if you're not using R2API in your plugin, + // it's just to tell BepInEx to initialize R2API before this plugin so it's safe to use R2API. + [BepInDependency(ItemAPI.PluginGUID)] + + // This one is because we use a .language file for language tokens + // More info in https://risk-of-thunder.github.io/R2Wiki/Mod-Creation/Assets/Localization/ + [BepInDependency(LanguageAPI.PluginGUID)] + + // This attribute is required, and lists metadata for your plugin. + [BepInPlugin(PluginGUID, PluginName, PluginVersion)] + + // This is the main declaration of our plugin class. + // BepInEx searches for all classes inheriting from BaseUnityPlugin to initialize on startup. + // BaseUnityPlugin itself inherits from MonoBehaviour, + // so you can use this as a reference for what you can declare and use in your plugin class + // More information in the Unity Docs: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html + public class ExamplePlugin : BaseUnityPlugin + { + // The Plugin GUID should be a unique ID for this plugin, + // which is human readable (as it is used in places like the config). + public const string PluginGUID = PluginAuthor + "." + PluginName; + public const string PluginAuthor = "devplayer0"; + public const string PluginName = "AntiYoink"; + public const string PluginVersion = "0.1.0"; + + // We need our item definition to persist through our functions, and therefore make it a class field. + private static ItemDef myItemDef; + + // The Awake() method is run at the very start when the game is initialized. + public void Awake() + { + // Init our logging class so that we can properly log for debugging + Log.Init(Logger); + + // First let's define our item + myItemDef = ScriptableObject.CreateInstance(); + + // Language Tokens, explained there https://risk-of-thunder.github.io/R2Wiki/Mod-Creation/Assets/Localization/ + myItemDef.name = "EXAMPLE_CLOAKONKILL_NAME"; + myItemDef.nameToken = "EXAMPLE_CLOAKONKILL_NAME"; + myItemDef.pickupToken = "EXAMPLE_CLOAKONKILL_PICKUP"; + myItemDef.descriptionToken = "EXAMPLE_CLOAKONKILL_DESC"; + myItemDef.loreToken = "EXAMPLE_CLOAKONKILL_LORE"; + + // The tier determines what rarity the item is: + // Tier1=white, Tier2=green, Tier3=red, Lunar=Lunar, Boss=yellow, + // and finally NoTier is generally used for helper items, like the tonic affliction +#pragma warning disable Publicizer001 // Accessing a member that was not originally public. Here we ignore this warning because with how this example is setup we are forced to do this + myItemDef._itemTierDef = Addressables.LoadAssetAsync("RoR2/Base/Common/Tier2Def.asset").WaitForCompletion(); +#pragma warning restore Publicizer001 + // Instead of loading the itemtierdef directly, you can also do this like below as a workaround + // myItemDef.deprecatedTier = ItemTier.Tier2; + + // You can create your own icons and prefabs through assetbundles, but to keep this boilerplate brief, we'll be using question marks. + myItemDef.pickupIconSprite = Addressables.LoadAssetAsync("RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion(); + myItemDef.pickupModelPrefab = Addressables.LoadAssetAsync("RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion(); + + // Can remove determines + // if a shrine of order, + // or a printer can take this item, + // generally true, except for NoTier items. + myItemDef.canRemove = true; + + // Hidden means that there will be no pickup notification, + // and it won't appear in the inventory at the top of the screen. + // This is useful for certain noTier helper items, such as the DrizzlePlayerHelper. + myItemDef.hidden = false; + + // You can add your own display rules here, + // where the first argument passed are the default display rules: + // the ones used when no specific display rules for a character are found. + // For this example, we are omitting them, + // as they are quite a pain to set up without tools like https://thunderstore.io/package/KingEnderBrine/ItemDisplayPlacementHelper/ + var displayRules = new ItemDisplayRuleDict(null); + + // Then finally add it to R2API + ItemAPI.Add(new CustomItem(myItemDef, displayRules)); + + // But now we have defined an item, but it doesn't do anything yet. So we'll need to define that ourselves. + GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal; + } + + private void GlobalEventManager_onCharacterDeathGlobal(DamageReport report) + { + // If a character was killed by the world, we shouldn't do anything. + if (!report.attacker || !report.attackerBody) + { + return; + } + + var attackerCharacterBody = report.attackerBody; + + // We need an inventory to do check for our item + if (attackerCharacterBody.inventory) + { + // Store the amount of our item we have + var garbCount = attackerCharacterBody.inventory.GetItemCount(myItemDef.itemIndex); + if (garbCount > 0 && + // Roll for our 50% chance. + Util.CheckRoll(50, attackerCharacterBody.master)) + { + // Since we passed all checks, we now give our attacker the cloaked buff. + // Note how we are scaling the buff duration depending on the number of the custom item in our inventory. + attackerCharacterBody.AddTimedBuff(RoR2Content.Buffs.Cloak, 3 + garbCount); + } + } + } + + // The Update() method is run on every frame of the game. + private void Update() + { + // This if statement checks if the player has currently pressed F2. + if (Input.GetKeyDown(KeyCode.F2)) + { + // Get the player body to use a position: + var transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform; + + // And then drop our defined item in front of the player. + + Log.Info($"Player pressed F2. Spawning our custom item at coordinates {transform.position}"); + PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(myItemDef.itemIndex), transform.position, transform.forward * 20f); + } + } + } +} diff --git a/AntiYoink/AntiYoink.csproj b/AntiYoink/AntiYoink.csproj new file mode 100644 index 0000000..a212e6f --- /dev/null +++ b/AntiYoink/AntiYoink.csproj @@ -0,0 +1,25 @@ + + + + netstandard2.1 + preview + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + \ No newline at end of file diff --git a/AntiYoink/Log.cs b/AntiYoink/Log.cs new file mode 100644 index 0000000..573fed0 --- /dev/null +++ b/AntiYoink/Log.cs @@ -0,0 +1,21 @@ +using BepInEx.Logging; + +namespace AntiYoink +{ + internal static class Log + { + private static ManualLogSource _logSource; + + internal static void Init(ManualLogSource logSource) + { + _logSource = logSource; + } + + internal static void Debug(object data) => _logSource.LogDebug(data); + internal static void Error(object data) => _logSource.LogError(data); + internal static void Fatal(object data) => _logSource.LogFatal(data); + internal static void Info(object data) => _logSource.LogInfo(data); + internal static void Message(object data) => _logSource.LogMessage(data); + internal static void Warning(object data) => _logSource.LogWarning(data); + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..a33cbdb --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# AntiYoink + +Anti-yoinking mod. diff --git a/RoR2Mods.sln b/RoR2Mods.sln new file mode 100644 index 0000000..b75b3f3 --- /dev/null +++ b/RoR2Mods.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33530.505 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AntiYoink", "AntiYoink\AntiYoink.csproj", "{2F8A40CC-6D15-486D-B689-0A7A472DB89E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2F8A40CC-6D15-486D-B689-0A7A472DB89E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F8A40CC-6D15-486D-B689-0A7A472DB89E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F8A40CC-6D15-486D-B689-0A7A472DB89E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F8A40CC-6D15-486D-B689-0A7A472DB89E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {25394121-1456-4FD9-A853-060A4DBBB74C} + EndGlobalSection +EndGlobal diff --git a/Thunderstore/CHANGELOG.md b/Thunderstore/CHANGELOG.md new file mode 100644 index 0000000..bcf08a5 --- /dev/null +++ b/Thunderstore/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.1.0 + +- First release diff --git a/Thunderstore/README.md b/Thunderstore/README.md new file mode 100644 index 0000000..a33cbdb --- /dev/null +++ b/Thunderstore/README.md @@ -0,0 +1,3 @@ +# AntiYoink + +Anti-yoinking mod. diff --git a/Thunderstore/icon.png b/Thunderstore/icon.png new file mode 100644 index 0000000..5232170 Binary files /dev/null and b/Thunderstore/icon.png differ diff --git a/Thunderstore/manifest.json b/Thunderstore/manifest.json new file mode 100644 index 0000000..ddad353 --- /dev/null +++ b/Thunderstore/manifest.json @@ -0,0 +1,12 @@ +{ + "name": "AntiYoink", + "version_number": "0.1.0", + "website_url": "https://git.nul.ie/dev/RoR2-AntiYoink", + "description": "Prevent yoinking.", + "dependencies": [ + "bbepis-BepInExPack-5.4.2117", + "RiskofThunder-HookGenPatcher-1.2.4", + "RiskofThunder-R2API_Items-1.0.4", + "RiskofThunder-R2API_Language-1.0.1" + ] +} diff --git a/Thunderstore/plugins/AntiYoink/AntiYoink.language b/Thunderstore/plugins/AntiYoink/AntiYoink.language new file mode 100644 index 0000000..e1f16c2 --- /dev/null +++ b/Thunderstore/plugins/AntiYoink/AntiYoink.language @@ -0,0 +1,20 @@ +{ + "strings": { + "EXAMPLE_CLOAKONKILL_NAME": "FALLBACK DEFAULT LANGUAGE Cuthroat's Garb", + "EXAMPLE_CLOAKONKILL_PICKUP": "FALLBACK DEFAULT LANGUAGE Chance to cloak on kill", + "EXAMPLE_CLOAKONKILL_DESC": "FALLBACK DEFAULT LANGUAGE Whenever you kill an enemy, you have a 50% chance to cloak for 4s (+1s per stack).", + "EXAMPLE_CLOAKONKILL_LORE": "FALLBACK DEFAULT LANGUAGE Those who visit in the night are either praying for a favour, or preying on a neighbour." + }, + "FR": { + "EXAMPLE_CLOAKONKILL_NAME": "FRENCH Cuthroat's Garb", + "EXAMPLE_CLOAKONKILL_PICKUP": "FRENCH Chance to cloak on kill", + "EXAMPLE_CLOAKONKILL_DESC": "FRENCH Whenever you kill an enemy, you have a 50% chance to cloak for 4s (+1s per stack).", + "EXAMPLE_CLOAKONKILL_LORE": "FRENCH Those who visit in the night are either praying for a favour, or preying on a neighbour." + }, + "en": { + "EXAMPLE_CLOAKONKILL_NAME": "ENGLISH Cuthroat's Garb", + "EXAMPLE_CLOAKONKILL_PICKUP": "ENGLISH Chance to cloak on kill", + "EXAMPLE_CLOAKONKILL_DESC": "ENGLISH Whenever you kill an enemy, you have a 50% chance to cloak for 4s (+1s per stack).", + "EXAMPLE_CLOAKONKILL_LORE": "ENGLISH Those who visit in the night are either praying for a favour, or preying on a neighbour." + } +} \ No newline at end of file diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..429ce75 --- /dev/null +++ b/nuget.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file