Skip to content

Commit

Permalink
fix decoy ermsharks eating ermfish from your hands
Browse files Browse the repository at this point in the history
move kill squad spawn point a tiny bit forward if raycast blocked
  • Loading branch information
Govorunb committed May 11, 2024
1 parent 9332db9 commit e4cb0e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
17 changes: 13 additions & 4 deletions SCHIZO/Creatures/Ermshark/Ermshark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@ private void Mitosis(Vector3 position, GameObject hurtEffect)
const float splitScaleModifier = 0.69f;
if (!_ermsharkPrefab)
{
LOGGER.LogError($"No prefab for mitosis, committing Minecraft");
LOGGER.LogWarning("No prefab for mitosis, committing Minecraft");
mitosisRemaining = 0;
SOS();
return;
}

liveMixin.ResetHealth();
transform.position = position + Random.insideUnitSphere * 0.5f;
transform.GetChild(0).localScale *= splitScaleModifier;
Transform model = transform.GetChild(0);
model.localScale *= splitScaleModifier;
// if the shark gets small enough, carrying other fish looks weird (bc they're bigger than it)
if (model.localScale.x < 0.3f) DisableCarry(gameObject);

mitosisRemaining--;
SpawnDecoy(position);
Expand All @@ -93,7 +96,13 @@ private void SpawnDecoy(Vector3 position)

ermshark.mitosisRemaining = mitosisRemaining;

CarryCreature carry = decoy.GetComponent<CarryCreature>();
if (carry) carry.enabled = false;
DisableCarry(decoy);
}

private static void DisableCarry(GameObject shark)
{
// forgor there are actually two of them on the shark
foreach (CarryCreature carry in shark.GetComponents<CarryCreature>())
Destroy(carry);
}
}
4 changes: 3 additions & 1 deletion SCHIZO/Creatures/Ermshark/ErmsharkAttack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public override void OnTouch(Collider collider)
if (player)
{
GameObject heldObject = Inventory.main.GetHeldObject();
if (heldObject && canBeFed && player.CanBeAttacked() && TryEat(heldObject, true))
if (heldObject && canBeFed && player.CanBeAttacked()
&& !heldObject.GetComponent<Carryable>() // otherwise decoy ermsharks eat ermfish from your hands
&& TryEat(heldObject, true))
{
if (this.GetBiteSound()) Utils.PlayEnvSound(this.GetBiteSound(), mouth.transform.position);
gameObject.SendMessage("OnMeleeAttack", heldObject, SendMessageOptions.DontRequireReceiver);
Expand Down
5 changes: 2 additions & 3 deletions SCHIZO/Events/ErmfishDefenseForce/ErmfishDefenseForce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using RuntimeDebugDraw;
using Unity.Collections;
using UnityEngine;
using UWE;
Expand Down Expand Up @@ -184,8 +183,8 @@ private IEnumerator SpawnDefenderGroup(Defender defender)
.OrderBy(hit => hit.point.DistanceSqrXZ(player.transform.position))
.FirstOrDefault();
if (blockingHit.point != default)
spawnPos = blockingHit.point;
spawnPos = blockingHit.point + blockingHit.normal * 0.1f;

GameObject instance = GameObject.Instantiate(prefab);
instance.transform.position = spawnPos;
if (debugSpawns)
Expand Down

0 comments on commit e4cb0e1

Please sign in to comment.