Skip to content

Commit

Permalink
Fixes to CombatSystem in udon. How long has this been broken?
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanLaser committed May 4, 2021
1 parent b2e057e commit 8dbd4da
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions CyanEmu/Scripts/VRCSDK2/CyanEmuCombatSystemHelper.cs
Expand Up @@ -83,16 +83,16 @@ public static IVRC_Destructible CombatGetDestructible(VRCPlayerApi player)

public static void CombatSetCurrentHitpoints(VRCPlayerApi player, float health)
{
bool less = health < instance.currentHealth_;
instance.currentHealth_ = health;
if (less)
float delta = health - instance.currentHealth_;
if (delta <= 0)
{
instance.ApplyDamage(0);
instance.ApplyDamage(-delta);
}
else
{
instance.ApplyHealing(0);
instance.ApplyHealing(delta);
}
instance.currentHealth_ = health;
}

private void Awake()
Expand Down Expand Up @@ -151,7 +151,14 @@ private void ApplyVisualDamage()
{
if (visualDamage_ != null)
{
visualDamage_.SetDamagePercent(1 - (currentHealth_ / maxPlayerHealth_));
try
{
visualDamage_.SetDamagePercent(1 - (currentHealth_ / maxPlayerHealth_));
}
catch (Exception e)
{
this.LogWarning("Error applying damage: "+ e);
}
}
}

Expand Down

0 comments on commit 8dbd4da

Please sign in to comment.