Skip to content

Commit

Permalink
4.4.0: add Aegis
Browse files Browse the repository at this point in the history
  • Loading branch information
jpw1991 committed Jan 23, 2024
1 parent 7fa37ae commit 75f03c8
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 12 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@ name: Publish package
on:
release:
types: [published] # run when a new release is published
tags:
- 'v*' # Trigger only if the tag matches eg. v1.0.0

env:
name: ChebsMythicalWeapons
jsonf: manifest.json
dlpath: https://github.com/jpw1991/chebs-mythical-weapons/releases/download
dependencies: "ValheimModding-Jotunn@2.11.2" # dependencies separated by spaces
dependencies: "ValheimModding-Jotunn@2.16.2" # dependencies separated by spaces
categories: "Mods" # categories separated by spaces
namespace: ChebGonaz

jobs:
verify:
verify_manifest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check that version matches
run: |
if [[ "$(jq -r '.version_number' $(find ./${{env.name}}/Package -name ${{env.jsonf}}))" != "${{github.event.release.tag_name}}" ]]; then
echo "::debug::${{github.event.release.tag_name}}"
echo "::debug::$(cat $(find ./ -name ${{env.jsonf}}))"
echo "::error::Version in ${{env.jsonf}} does not match tag version"
version=$(grep -Po "AssemblyVersion\(\"\K([0-9]+\.[0-9]+\.[0-9]+)" ${{env.name}}/Properties/AssemblyInfo.cs)
versionfrommanifest="$(jq -r '.version_number' $(find ./${{env.name}}/Package -name ${{env.jsonf}}))"
[ -z "$version" ] && echo "::error::version is empty!" && exit 1
[ -z "$versionfrommanifest" ] && echo "::error::versionfrommanifest is empty!" && exit 1
if [[ $versionfrommanifest != $version ]]; then
echo "::error::Version in ${{env.jsonf}} does not match assembly version"
exit 1
fi
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Get Description
id: get_description
run: |
Expand All @@ -42,9 +47,9 @@ jobs:
community: valheim
namespace: ${{env.namespace}}
name: ${{env.name}}
version: ${{github.event.release.tag_name}}
version: ${{env.VERSION}}
description: ${{env.DESCRIPTION}}
token: ${{secrets.TS_KEY}}
deps: ${{env.dependencies}}
categories: ${{env.categories}}
file: ${{env.name}}.${{github.event.release.tag_name}}.zip
file: ${{env.name}}.${{env.VERSION}}.zip
13 changes: 12 additions & 1 deletion ChebsMythicalWeapons/ChebsMythicalWeapons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class ChebsMythicalWeapons : BaseUnityPlugin
{
public const string PluginGuid = "com.chebgonaz.chebsmythicalweapons";
public const string PluginName = "ChebsMythicalWeapons";
public const string PluginVersion = "4.3.4";
public const string PluginVersion = "4.4.0";

private const string ConfigFileName = PluginGuid + ".cfg";
private static readonly string ConfigFileFullPath = Path.Combine(Paths.ConfigPath, ConfigFileName);
Expand All @@ -48,6 +48,7 @@ internal class ChebsMythicalWeapons : BaseUnityPlugin
public static BladeOfOlympusItem BladeOfOlympus = new();
public static GreatswordOfOlympusItem GreatswordOfOlympus = new();
public static JoyceItem Joyce = new();
public static AegisItem Aegis = new();

private void Awake()
{
Expand Down Expand Up @@ -147,6 +148,10 @@ private void CreateConfigValues()
MinotaurCreature.CreateConfigs(this);

#endregion

#region Aegis
Aegis.CreateConfigs(this);
#endregion
}

private void LoadAssetBundle()
Expand Down Expand Up @@ -263,6 +268,12 @@ private void LoadAssetBundle()

CreatureManager.Instance.AddCreature(customCreature);
}
{
// Aegis
var prefab = Base.LoadPrefabFromBundle(Aegis.PrefabName, chebgonazAssetBundle,
RadeonFriendly.Value);
ItemManager.Instance.AddItem(Aegis.GetCustomItemFromPrefab(prefab));
}
}
catch (Exception ex)
{
Expand Down
1 change: 1 addition & 0 deletions ChebsMythicalWeapons/ChebsMythicalWeapons.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Creatures\MinotaurCreature.cs" />
<Compile Include="Items\AegisItem.cs" />
<Compile Include="Items\ApolloBowItem.cs" />
<Compile Include="Items\BladeOfOlympusItem.cs" />
<Compile Include="Items\ExcaliburItem.cs" />
Expand Down
84 changes: 84 additions & 0 deletions ChebsMythicalWeapons/Items/AegisItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using BepInEx;
using BepInEx.Configuration;
using ChebsValheimLibrary.Common;
using ChebsValheimLibrary.Items;
using Jotunn.Configs;
using Jotunn.Entities;
using UnityEngine;
using Logger = Jotunn.Logger;

namespace ChebsMythicalWeapons.Items
{
public class AegisItem : Item
{
public override string ItemName => "ChebGonaz_Aegis";
public override string PrefabName => "ChebGonaz_Aegis.prefab";
public override string NameLocalization => "$chebgonaz_aegis";
public override string DescriptionLocalization => "$chebgonaz_aegis_desc";

public static ConfigEntry<float> BlockPower,
BlockPowerPerLevel,
DeflectionForce,
DeflectionForcePerLevel;

public override void CreateConfigs(BaseUnityPlugin plugin)
{
BlockPower = plugin.Config.Bind($"{GetType().Name} (Server Synced)", "BlockPower",
70f, new ConfigDescription(
"Aegis's base blocking power.", null,
new ConfigurationManagerAttributes { IsAdminOnly = true }));
BlockPowerPerLevel = plugin.Config.Bind($"{GetType().Name} (Server Synced)", "BlockPowerPerLevel",
0f, new ConfigDescription(
"Aegis's blocking power increase per level.", null,
new ConfigurationManagerAttributes { IsAdminOnly = true }));
DeflectionForce = plugin.Config.Bind($"{GetType().Name} (Server Synced)", "DeflectionForce",
50f, new ConfigDescription(
"Aegis's base deflection force.", null,
new ConfigurationManagerAttributes { IsAdminOnly = true }));
DeflectionForcePerLevel = plugin.Config.Bind($"{GetType().Name} (Server Synced)", "DeflectionForcePerLevel",
0f, new ConfigDescription(
"Aegis's deflection force increase per level.", null,
new ConfigurationManagerAttributes { IsAdminOnly = true }));
}

public override CustomItem GetCustomItemFromPrefab(GameObject prefab)
{
var config = new ItemConfig
{
Name = NameLocalization,
Description = DescriptionLocalization,
CraftingStation = InternalName.GetName(CraftingTable.Forge),
Requirements = new[]
{
// add an upgrade amount of 20 silver per level of Aegis
new RequirementConfig()
{
Amount = 20,
AmountPerLevel = 20,
Item = "Silver",
}
},
};

var customItem = new CustomItem(prefab, false, config);
if (customItem.ItemPrefab == null)
{
Logger.LogError($"GetCustomItemFromPrefab: {PrefabName}'s ItemPrefab is null!");
return null;
}

var itemDataShared = customItem.ItemDrop.m_itemData.m_shared;

#region ShieldSettings

itemDataShared.m_blockPower = BlockPower.Value; // block force
itemDataShared.m_blockPowerPerLevel = BlockPowerPerLevel.Value;
itemDataShared.m_deflectionForce = DeflectionForce.Value;
itemDataShared.m_deflectionForcePerLevel = DeflectionForcePerLevel.Value;

#endregion

return customItem;
}
}
}
1 change: 1 addition & 0 deletions ChebsMythicalWeapons/Package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ You can find the github [here](https://github.com/jpw1991/chebs-mythical-weapons

Date | Version | Notes
--- | --- | ---
23/01/2023 | 4.4.0 | Add Aegis for evaluation
15/01/2023 | 4.3.4 | Update CVL and Jotunn
30/11/2023 | 4.3.3 | Fix issue of configs not syncing reliably
12/11/2023 | 4.3.1 | Fix crash when blocking with Apollo bow
Expand Down
2 changes: 1 addition & 1 deletion ChebsMythicalWeapons/Package/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ChebsMythicalWeapons",
"description": "Adds mythical weapons to Valheim. The weapons are found in special locations; eg. Excalibur must be found somewhere in the world and only someone with 100 sword skill can remove it from the stone and use it.",
"version_number": "4.3.4",
"version_number": "4.4.0",
"website_url": "https://github.com/jpw1991/chebs-mythical-weapons",
"dependencies": [
"ValheimModding-Jotunn-2.16.1"
Expand Down
1 change: 1 addition & 0 deletions ChebsMythicalWeapons/Patches/InventoryGuiPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static void UpdateRecipeList(InventoryGui __instance, ref List<Recipe> recipes)
return recipeAsStr.Contains(ChebsMythicalWeapons.Excalibur.ItemName)
|| recipeAsStr.Contains(ChebsMythicalWeapons.ApolloBow.ItemName)
|| recipeAsStr.Contains(ChebsMythicalWeapons.Joyce.ItemName)
|| recipeAsStr.Contains(ChebsMythicalWeapons.Aegis.ItemName)
|| (!thunderstormActive &&
(recipeAsStr.Contains(ChebsMythicalWeapons.BladeOfOlympus.ItemName)
|| recipeAsStr.Contains(ChebsMythicalWeapons.GreatswordOfOlympus.ItemName)));
Expand Down
4 changes: 2 additions & 2 deletions ChebsMythicalWeapons/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.3.4.0")]
[assembly: AssemblyFileVersion("4.3.4.0")]
[assembly: AssemblyVersion("4.4.0.0")]
[assembly: AssemblyFileVersion("4.4.0.0")]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ You can find the github [here](https://github.com/jpw1991/chebs-mythical-weapons

Date | Version | Notes
--- | --- | ---
23/01/2023 | 4.4.0 | Add Aegis for evaluation
15/01/2023 | 4.3.4 | Update CVL and Jotunn
30/11/2023 | 4.3.3 | Fix issue of configs not syncing reliably
12/11/2023 | 4.3.1 | Fix crash when blocking with Apollo bow
Expand Down

0 comments on commit 75f03c8

Please sign in to comment.