Announcement

Collapse
No announcement yet.

Do you use Excel character sheets? I have a VBA function you might like.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Do you use Excel character sheets? I have a VBA function you might like.

    Hey all,

    I was doing a little work on a refreshed character sheet in Excel. In prior editions, I had a fairly good system for tracking damage, though it never did handle overflow.

    I managed to come up with this, and thought I'd share!



    Function DamageTrack(Health As Integer, AggravatedDamage As Integer, LethalDamage As Integer, BashingDamage As Integer)

    ' Recursively exchange and consume damage types up to a limit of Health dots
    ' VBA doesn't natively handle unicode. I might try a wrapper function sometime later.


    If AggravatedDamage >= Health Then
    'We are full of aggravated damage and there's nothing else to think about
    DamageTrack = String(Health, "A")

    ElseIf (AggravatedDamage + LethalDamage + BashingDamage) > Health Then
    ' We are out of health track and need to promote a damage
    ' We always have to convert two of something to one higher up

    If LethalDamage > 1 And (LethalDamage + AggravatedDamage) > Health Then
    ' convert two overflowing lethal to one aggravated
    DamageTrack = DamageTrack(Health, AggravatedDamage + 1, LethalDamage - 2, BashingDamage)

    ElseIf LethalDamage = 1 And BashingDamage > 0 And (LethalDamage + AggravatedDamage) > Health Then
    ' convert one overflowing lethal and one overflowing bashing to one aggravated
    DamageTrack = DamageTrack(Health, AggravatedDamage + 1, LethalDamage - 1, BashingDamage - 1)

    ElseIf BashingDamage > 0 And (LethalDamage + AggravatedDamage) >= Health Then
    ' convert two over-overflowing bashing to one aggravated
    DamageTrack = DamageTrack(Health, AggravatedDamage + 1, LethalDamage, BashingDamage - 2)

    Else
    ' convert two overflowing bashing to one lethal
    DamageTrack = DamageTrack(Health, AggravatedDamage, LethalDamage + 1, BashingDamage - 2)

    End If


    ElseIf AggravatedDamage > 0 And Health > 0 Then
    ' Consume 1 Aggravated Damage and one Health
    ' These should all finish and consume before exchanging and consuming Lethals
    DamageTrack = "A" + DamageTrack(Health - 1, AggravatedDamage - 1, LethalDamage, BashingDamage)

    ElseIf LethalDamage > 0 And Health > 0 Then
    ' Consume 1 bashing damage and one Health
    DamageTrack = "L" + DamageTrack(Health - 1, AggravatedDamage, LethalDamage - 1, BashingDamage)

    ElseIf BashingDamage > 0 And Health > 0 Then
    ' Consume 1 bashing damage and one Health
    DamageTrack = "B" + DamageTrack(Health - 1, AggravatedDamage, LethalDamage, BashingDamage - 1)

    ElseIf Health >= 1 Then
    ' fill out the rest of the track
    DamageTrack = String(Health, "O")

    Else
    'Done with the string
    DamageTrack = ""


    End If

    ' Future Features
    ' error checking (negatives, text inputs?) or do we care?


    End Function

    I've got some additional stuff going on in my cells, replacing the ASCII with unicode for appropriate boxes to display.


    Check out Momentum Exalted!

  • #2
    looks very impressive


    Malfeas F'Tagn - go check out my epic MLP/Exalted crossover "The Scroll of Exalted ponies" @ Fimfiction

    Comment

    Working...
    X