Skip to content

Commit

Permalink
2.5.8: miners pop an entire rock/node in one whack because completely…
Browse files Browse the repository at this point in the history
… mining the fragments seems impossible
  • Loading branch information
jpw1991 committed Mar 27, 2023
1 parent 8ee5c17 commit da25f5a
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 10 deletions.
Binary file modified ChebsNecromancy/Assets/chebgonaz
Binary file not shown.
7 changes: 4 additions & 3 deletions ChebsNecromancy/Assets/chebgonaz.manifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ManifestFileVersion: 0
CRC: 3722727475
CRC: 3397770505
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: 2d6f3276f148fc3d423326f93344dfa3
Hash: 3468dcdcc05d08b062af4ea18d16b2ce
TypeTreeHash:
serializedVersion: 2
Hash: f217880939f95309b92eb737385684c4
Expand Down Expand Up @@ -283,11 +283,12 @@ Assets:
- Assets/_ChebGonaz/BlackIronArmor/ChebGonaz_HelmetBlackIron.prefab
- Assets/_ChebGonaz/TreasurePylon/ChebGonaz_TreasurePylon.prefab
- Assets/_ChebGonaz/SkeletonMage/ChebGonaz_FireballProjectileGoblin.prefab
- Assets/_ChebGonaz/SkeletonMiner/ChebGonaz_PickaxeProjectile.prefab
- Assets/_ChebGonaz/SkeletonArcher/ChebGonaz_SkeletonArcherFire.prefab
- Assets/_ChebGonaz/Neckro/ChebGonaz_NeckroGathererPylon.mat
- Assets/_ChebGonaz/UndeadWeapons/ChebGonaz_SkeletonMace.prefab
- Assets/_ChebGonaz/UndeadWeapons/ChebGonaz_SkeletonClub.prefab
- Assets/_ChebGonaz/NecromancerCape/ChebGonaz_NecromancerCapeAzathoth.mat
- Assets/_ChebGonaz/Neckro/ChebGonaz_NeckroGathererPylon.mat
- Assets/_ChebGonaz/Draugr/ChebGonaz_DraugrWarriorNeedle.prefab
- Assets/_ChebGonaz/NecromancerCape/ChebGonaz_NecromancerCapeCthulhu.mat
- Assets/_ChebGonaz/LeatherArmors/Lox/ChebGonaz_SkeletonHelmetLeatherPoisonLox.prefab
Expand Down
2 changes: 1 addition & 1 deletion ChebsNecromancy/BasePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal class BasePlugin : BaseUnityPlugin
{
public const string PluginGuid = "com.chebgonaz.ChebsNecromancy";
public const string PluginName = "ChebsNecromancy";
public const string PluginVersion = "2.5.7";
public const string PluginVersion = "2.5.8";
private const string ConfigFileName = PluginGuid + ".cfg";
private static readonly string ConfigFileFullPath = Path.Combine(Paths.ConfigPath, ConfigFileName);

Expand Down
73 changes: 68 additions & 5 deletions ChebsNecromancy/Minions/AI/MinerAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ internal class MinerAI : MonoBehaviour
private string _status;

private bool _inContact;
private float _lerpedValue;
//private float _timeFollowingObject;

private void Awake()
{
Expand All @@ -41,6 +43,7 @@ public void LookForMineableObjects()
if (closest != null)
{
_monsterAI.SetFollowTarget(closest.gameObject);
//_timeFollowingObject = Time.time;
}
}

Expand All @@ -51,14 +54,20 @@ private void Update()
{
if (Vector3.Distance(transform.position, followTarget.transform.position) < 5f)
{
var t = Mathf.PingPong(Time.time, .5f); // This will give you a value between 0 and 1 that oscillates over time.
var lerpedValue = Mathf.Lerp(1f, -1f, t); // This will interpolate between 1 and -1 based on the value of t.

transform.LookAt(followTarget.transform.position + Vector3.down * lerpedValue);
//var t = Mathf.PingPong(Time.time, 2f);
//_lerpedValue = Mathf.Lerp(1f, -1f, t);

transform.LookAt(followTarget.transform.position);// + Vector3.down * _lerpedValue);

}
//followTarget.GetComponent<Destructible>().Damage(new);

TryAttack();
}
// else
// {
// _timeFollowingObject = 0f;
// }
if (Time.time > nextCheck)
{
nextCheck = Time.time + SkeletonMinerMinion.UpdateDelay.Value
Expand All @@ -77,9 +86,63 @@ private void Update()

private void TryAttack()
{
if (_monsterAI.GetFollowTarget() != null && _inContact)
var followTarget = _monsterAI.GetFollowTarget();
if (followTarget != null && _inContact)
//&& (_inContact // in contact with rock (physically touching it)
//|| _timeFollowingObject > 20f // or can't reach it after prolonged period (large rock fragments)
//))
{
_monsterAI.DoAttack(null, false);

var destructible = followTarget.GetComponentInParent<Destructible>();
if (destructible != null)
{
var hitData = new HitData();
hitData.m_damage.m_pickaxe = 500;
destructible.m_nview.InvokeRPC("Damage", hitData);
//destructible.Damage(hitData);
return;
}

var mineRock5 = followTarget.GetComponentInParent<MineRock5>();
if (mineRock5 != null)
{
// destroy all fragments
for (int i = 0; i < mineRock5.m_hitAreas.Count; i++)
{
var hitArea = mineRock5.m_hitAreas[i];
if (hitArea.m_health > 0f)// && !hitArea.m_supported)
{
var hitData = new HitData();
hitData.m_damage.m_damage = hitArea.m_health;
hitData.m_point = hitArea.m_collider.bounds.center;
hitData.m_toolTier = 100;
mineRock5.DamageArea(i, hitData);
}
}
//mineRock5.Damage(hitData);
//mineRock5.m_nview.Destroy();
return;
}

var mineRock = followTarget.GetComponentInParent<MineRock>();
if (mineRock != null)
{
// destroy all fragments
for (int i = 0; i < mineRock.m_hitAreas.Length; i++)
{
var collider = mineRock.m_hitAreas[i];
if (collider.TryGetComponent(out HitArea hitArea) && hitArea.m_health > 0f)
{
var hitData = new HitData();
hitData.m_damage.m_damage = hitArea.m_health;
hitData.m_point = collider.bounds.center;
hitData.m_toolTier = 100;
mineRock5.DamageArea(i, hitData);
}
}
//mineRock.Damage(hitData);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions ChebsNecromancy/Package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ You can find the github [here](https://github.com/jpw1991/chebs-necromancy).

Date | Version | Notes
--- | --- | ---
25/03/2023 | 2.5.8 | miners pop an entire rock/node in one whack because completely mining the fragments seems impossible
25/03/2023 | 2.5.7 | permit multiple miners to whack same rock; overhaul rock whacking logic for lumberjacks and miners; remove collision on draugr heads
23/03/2023 | 2.5.6 | make miners lerp as they mine so that they have increased odds of being able to connect a blow with a stone; fix null object
23/03/2023 | 2.5.5 | pylons suspend their work while players are sleeping
Expand Down
2 changes: 1 addition & 1 deletion ChebsNecromancy/Package/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ChebsNecromancy",
"description": "Cheb's Necromancy adds Necromancy to Valheim via craftable wands and structures. Minions will follow you, guard your base, and perform menial tasks.",
"version_number": "2.5.7",
"version_number": "2.5.8",
"website_url": "https://github.com/jpw1991/chebs-necromancy",
"dependencies": [
"ValheimModding-Jotunn-2.11.0"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ You can find the github [here](https://github.com/jpw1991/chebs-necromancy).

Date | Version | Notes
--- | --- | ---
25/03/2023 | 2.5.8 | miners pop an entire rock/node in one whack because completely mining the fragments seems impossible
25/03/2023 | 2.5.7 | permit multiple miners to whack same rock; overhaul rock whacking logic for lumberjacks and miners; remove collision on draugr heads
23/03/2023 | 2.5.6 | make miners lerp as they mine so that they have increased odds of being able to connect a blow with a stone; fix null object
23/03/2023 | 2.5.5 | pylons suspend their work while players are sleeping
Expand Down

0 comments on commit da25f5a

Please sign in to comment.