Skip to content

Commit

Permalink
reset fumo poke dmg after a while
Browse files Browse the repository at this point in the history
  • Loading branch information
Govorunb committed Dec 16, 2023
1 parent 6e6a4d5 commit c9389aa
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
31 changes: 29 additions & 2 deletions SCHIZO/Items/FumoItem/EvilFumoItemTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ partial class EvilFumoItemTool
public Knife stolenKnife;
private static float _knifeScale = 0.9f;

private static float _dmgResetTime = 60f;
private float _timeUntilDamageReset;
private float _currentDamage;

private void Start()
{
_currentDamage = damageOnPoke;
}
protected override void ApplyAltEffect(bool active)
{
if (active)
{
float dmg = damageOnPoke;
float dmg = _currentDamage;
if (stealKnife && TryFindKnife(out Knife knife)
&& Inventory.main.InternalDropItem(knife.pickupable))
{
Expand All @@ -21,7 +29,7 @@ protected override void ApplyAltEffect(bool active)
dmg *= 4;
}
usingPlayer.liveMixin.TakeDamage(dmg);
damageOnPoke *= 1.25f; // negative reward function
_currentDamage *= 1.25f; // negative reward function
}
else
{
Expand Down Expand Up @@ -55,6 +63,25 @@ private void YoinkKnife()
stolenKnife.transform.SetParent(knifeSocket.Exists() ?? transform, true);
stolenKnife.transform.localScale *= _knifeScale;
}
protected override void FixedUpdate()
{
base.FixedUpdate();
UpdateDamageReset();
}

private void UpdateDamageReset()
{
if (_currentDamage == damageOnPoke) return;

if (isAltEffectActive)
_timeUntilDamageReset = _dmgResetTime;
else
{
_timeUntilDamageReset -= Time.fixedDeltaTime;
if (_timeUntilDamageReset < 0)
_currentDamage = damageOnPoke;
}
}

protected override void Update()
{
Expand Down
30 changes: 17 additions & 13 deletions SCHIZO/Items/FumoItem/FumoItemTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,28 @@ partial class FumoItemTool
base.Awake();
}

public void FixedUpdate()
protected virtual void FixedUpdate()
{
if (!usingPlayer) return;
UpdateAltEffect();
}

if (_altEffectOnHug)
{
if (_isHugging)
{
_hugTime += Time.fixedDeltaTime;
if (_hugTime > altEffectMinHugTime) SetAltEffect(true);
}
else
{
_hugTime = 0;
}
}
private void UpdateAltEffect()
{
_altEffectTimeRemaining -= Time.fixedDeltaTime;
if (_altEffectTimeRemaining < 0f) SetAltEffect(false);

if (!_altEffectOnHug) return;

if (_isHugging)
{
_hugTime += Time.fixedDeltaTime;
if (_hugTime > altEffectMinHugTime && !isAltEffectActive) SetAltEffect(true);
}
else
{
_hugTime = 0;
}
}

protected virtual void Update()
Expand Down

0 comments on commit c9389aa

Please sign in to comment.