Skip to content

Instantly share code, notes, and snippets.

@autodidaddict
Last active February 18, 2019 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save autodidaddict/eb7d6d4cde3a81eef955049cd288b96f to your computer and use it in GitHub Desktop.
Save autodidaddict/eb7d6d4cde3a81eef955049cd288b96f to your computer and use it in GitHub Desktop.
OPA Combat engine - Sample Rules file
package combat
import input.attacker as attacker
import input.defender as defender
import data.armor.mitigation_matrix as mitmat
armor_classes = { k | mitmat[k] }
all_weapon_ids = { w | data.weapons.stats[w] }
weapon_stats = s {
s = data.weapons.stats[attacker.weapon_id]
}
armor_stats = a {
a = data.armor.stats[defender.armor_id]
}
mitigation_factor = mf {
mf = mitmat[armor_stats.armor_class][weapon_stats.damage_class] / 100
}
rawdamage = d {
d = (attacker.dice.d100/100) * weapon_stats.base_damage
}
effectivedamage = d {
d = rawdamage - (rawdamage * mitigation_factor)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment