Help with Combat system + widgets

Twine Version: 2.3.14
Story Format: SugarCube 2.34.1

Please keep in mind that I am very noob, in both twine and D&D stuff. I only doing this for fun, please have patience with me. Also: english is not my native language, forgive me for any mistake.

Relevant info:

Player dexterity: $Dex
Player strength: $Str
Dagger damage: $Ddmg

Enemy Armor: $Earmor
Enemy Defense: $Edef
Enemy Health: $Ehealth

(These are not the real variables names that I am using, its just for easier understanding, because I am Brazilian and my variables are in Portuguese haha)

The process for the combat:

Step 1. Do a ability check: 3d6 + ability

In this case, a dex check: <<set $DexCheck to random (1, 6) + random (1, 6) + random (1, 6) + $Dex>>

Step 2. Do a check for Attacking: Dex Check + strength

In this case: <<set $Atq to $DexCheck + $Str>>

Step 3. If the atq is greater then the enemy defense, the attack succeeded. If not, the attack missed.

In this case: <<If $Atq is gte $Edef>>Success!<>You missed<>

Step 4. Then, calculate the (dagger) damage minus the enemy Armor value:

In this case: <<set $Ddmg to random (1, 6) + 1 + $Str - $Earmor>>

Step 5. Subtract the result in the enemy health

In this case: <<set $Ehealth to -= $Ddmg>>

Step 6. That’s it. Putting everything together:

<<set $DexCheck to random (1, 6) + random (1, 6) + random (1, 6) + $Dex>><<set $Atq to $DexCheck + $Str>>

<<If $Atq is gte $Edef>>

<<set $Ddmg to random (1, 6) + 1 + $Str - $Earmor>><<set $Ehealth to -= $Ddmg>>

Success!

You caused: $Ddmg damage
Enemy health: <<print $Ehealth>>

<>

You missed.<>

This is the simplest combat system I managed to do, with my very limited abilities. I am kinda using (or trying to use) the Dragon Age system, more or less.

My question is: is there a more practical/better way to apply this whole system? Is it possible to transform these in widgets so I dont need to write the whole thing everytime?

Do you have any combat tips for me?

Also, totally unrelated but can someone for the love of god teach me a SIMPLE way to display text when you hover over a phrase? I wanted to use this for showing words/phrases translation like this:

“Ar lath ma, vhenan.” (Elven language)

Then when you hover over it, it shows: “Translation: I love you, my heart”

For the hover translation, put this in a passage called StoryInit


<<widget "translate">>
<span style="text-decoration:underline; text-decoration-style: dotted;" @title="$args[1]">$args[0]</span>
<</widget>>

Then in any passage use this widget whenever you need a translation (replacing the text as necessary)

<<translate "original text" "hover text">>

1 Like

THANK YOU SO MUCH! this is exactly what I need!