HandleDamage(DamageResult : damage_result):void=
if (TargetCharacter := fort_character[DamageResult.Target]):
if (Instigator := DamageResult.Instigator?):
if (InstigatorAgent := Instigator.GetInstigatorAgent[]):
if (InstigatorCharacter := fort_character[InstigatorAgent]):
if (TargetCharacter <> InstigatorCharacter):
if (ScoreTotal := Round[DamageResult.Amount * ScorePerPointOfDamage]):
ScoreManager.SetScoreAward(ScoreTotal)
ScoreManager.Activate(InstigatorAgent)
Is there any way to handle this? It seems like due to the requirement of the Verse to be sure no expression fails I have to do this infinite nesting? Is it possible to make it look more like this (it’s C# code):
private void HandleDamage(DamageResult damageResult)
{
FortCharacter targetCharacter = damageResult.Target;
if (damageResult.Instigator == null)
return;
Agent instigatorAgent = damageResult.Instigator.GetInstigatorAgent();
FortCharacter instigatorCharacter = instigator.GetFortCharacter();
if (targetCharacter == instigatorCharacter)
return;
int scoreTotal = (int) Math.Round(damageResult.Amount * _scorePerPointOfDamage);
_scoreManager.SetScoreAward(scoreTotal);
_scoreManager.Activate(instigatorAgent);
}