mirror of
https://github.com/chev2/RoR2-Mods.git
synced 2025-10-30 08:11:54 +00:00
Artifact of Sequencing v1.0.2
This commit is contained in:
parent
0c2b6e085d
commit
7c5eb929db
3 changed files with 51 additions and 37 deletions
|
|
@ -1,3 +1,7 @@
|
||||||
|
1.0.2 --
|
||||||
|
- Artifact should now apply to all connected players
|
||||||
|
- Fixed a bug where the artifact would still attempt to convert items when the artifact is disabled after a run
|
||||||
|
|
||||||
1.0.1 --
|
1.0.1 --
|
||||||
- Fixed an error in RandomItem() preventing starting items from properly spawning
|
- Fixed an error in RandomItem() preventing starting items from properly spawning
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "ArtifactOfSequencing",
|
"name": "ArtifactOfSequencing",
|
||||||
"version_number": "1.0.1",
|
"version_number": "1.0.2",
|
||||||
"website_url": "https://github.com/chev2/RoR2-Mods",
|
"website_url": "https://github.com/chev2/RoR2-Mods",
|
||||||
"description": "Spawn with a starting item of every tier. Any picked up items will be converted to the starting item of the same tier.",
|
"description": "Spawn with a starting item of every tier. Any picked up items will be converted to the starting item of the same tier.",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"bbepis-BepInExPack-5.4.9",
|
"bbepis-BepInExPack-5.4.9",
|
||||||
"tristanmcpherson-R2API-3.0.25"
|
"tristanmcpherson-R2API-3.0.30"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ using UnityEngine;
|
||||||
namespace Chev
|
namespace Chev
|
||||||
{
|
{
|
||||||
[BepInDependency("com.bepis.r2api")]
|
[BepInDependency("com.bepis.r2api")]
|
||||||
[BepInPlugin("com.Chev.ArtifactOfSequencing", "Artifact of Sequencing", "1.0.1")]
|
[BepInPlugin("com.Chev.ArtifactOfSequencing", "Artifact of Sequencing", "1.0.2")]
|
||||||
[NetworkCompatibility(CompatibilityLevel.EveryoneMustHaveMod, VersionStrictness.EveryoneNeedSameModVersion)]
|
[NetworkCompatibility(CompatibilityLevel.EveryoneMustHaveMod, VersionStrictness.EveryoneNeedSameModVersion)]
|
||||||
[R2APISubmoduleDependency(nameof(ArtifactAPI))]
|
[R2APISubmoduleDependency(nameof(ArtifactAPI))]
|
||||||
public class ArtifactOfSequencingMod : BaseUnityPlugin
|
public class ArtifactOfSequencingMod : BaseUnityPlugin
|
||||||
|
|
@ -56,8 +56,6 @@ namespace Chev
|
||||||
// On run start event
|
// On run start event
|
||||||
// This is when we add our items
|
// This is when we add our items
|
||||||
Run.onRunStartGlobal += AddBeginningItems;
|
Run.onRunStartGlobal += AddBeginningItems;
|
||||||
|
|
||||||
Logger.LogMessage("Loaded mod com.Chev.ArtifactOfSequencing");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -110,33 +108,10 @@ namespace Chev
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddBeginningItems(Run run)
|
/// <summary>
|
||||||
{
|
/// Converts any potential items to their corresponding starter item
|
||||||
// If our artifact is not enabled
|
/// </summary>
|
||||||
if (!RunArtifactManager.instance.IsArtifactEnabled(Artifact.artifactIndex))
|
private void ConvertPotentialItems(Inventory inv, ItemIndex itemIndex, int count)
|
||||||
return;
|
|
||||||
|
|
||||||
CharacterMaster master = PlayerCharacterMasterController.instances[0].master;
|
|
||||||
|
|
||||||
if (master)
|
|
||||||
{
|
|
||||||
// Set starting items
|
|
||||||
CommonItem = RandomItem(ItemTier.Tier1);
|
|
||||||
UncommonItem = RandomItem(ItemTier.Tier2);
|
|
||||||
LegendaryItem = RandomItem(ItemTier.Tier3);
|
|
||||||
BossItem = RandomItem(ItemTier.Boss);
|
|
||||||
LunarItem = RandomItem(ItemTier.Lunar);
|
|
||||||
|
|
||||||
// Give the starting items
|
|
||||||
master.inventory.GiveItem(CommonItem, CommonItemCount.Value);
|
|
||||||
master.inventory.GiveItem(UncommonItem, UncommonItemCount.Value);
|
|
||||||
master.inventory.GiveItem(LegendaryItem, LegendaryItemCount.Value);
|
|
||||||
master.inventory.GiveItem(BossItem, BossItemCount.Value);
|
|
||||||
master.inventory.GiveItem(LunarItem, LunarItemCount.Value);
|
|
||||||
|
|
||||||
// Called every time an item is given
|
|
||||||
// If the item is not a starter item, remove it and give the starter item
|
|
||||||
Inventory.onServerItemGiven += (inv, itemIndex, count) =>
|
|
||||||
{
|
{
|
||||||
ItemDef starterItemToCompare = ItemFromTier(ItemCatalog.GetItemDef(itemIndex).tier);
|
ItemDef starterItemToCompare = ItemFromTier(ItemCatalog.GetItemDef(itemIndex).tier);
|
||||||
|
|
||||||
|
|
@ -148,7 +123,42 @@ namespace Chev
|
||||||
inv.RemoveItem(itemIndex, itemCount);
|
inv.RemoveItem(itemIndex, itemCount);
|
||||||
inv.GiveItem(starterItemToCompare, itemCount);
|
inv.GiveItem(starterItemToCompare, itemCount);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
public void AddBeginningItems(Run run)
|
||||||
|
{
|
||||||
|
// If our artifact is enabled
|
||||||
|
if (RunArtifactManager.instance.IsArtifactEnabled(Artifact.artifactIndex))
|
||||||
|
{
|
||||||
|
// Called every time an item is given
|
||||||
|
// If the item is not a starter item, remove it and give the starter item
|
||||||
|
Inventory.onServerItemGiven += ConvertPotentialItems;
|
||||||
|
}
|
||||||
|
// Else, if our artifact isn't enabled
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Unsubscribe from the event if the artifact is disabled
|
||||||
|
Inventory.onServerItemGiven -= ConvertPotentialItems;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set starting items
|
||||||
|
CommonItem = RandomItem(ItemTier.Tier1);
|
||||||
|
UncommonItem = RandomItem(ItemTier.Tier2);
|
||||||
|
LegendaryItem = RandomItem(ItemTier.Tier3);
|
||||||
|
BossItem = RandomItem(ItemTier.Boss);
|
||||||
|
LunarItem = RandomItem(ItemTier.Lunar);
|
||||||
|
|
||||||
|
// Give the starting items to every palyer
|
||||||
|
for (int i = 0; i < CharacterMaster.readOnlyInstancesList.Count; i++)
|
||||||
|
{
|
||||||
|
CharacterMaster character = CharacterMaster.readOnlyInstancesList[i];
|
||||||
|
|
||||||
|
character.inventory.GiveItem(CommonItem, CommonItemCount.Value);
|
||||||
|
character.inventory.GiveItem(UncommonItem, UncommonItemCount.Value);
|
||||||
|
character.inventory.GiveItem(LegendaryItem, LegendaryItemCount.Value);
|
||||||
|
character.inventory.GiveItem(BossItem, BossItemCount.Value);
|
||||||
|
character.inventory.GiveItem(LunarItem, LunarItemCount.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue