Last active
February 18, 2019 14:47
-
-
Save autodidaddict/eb7d6d4cde3a81eef955049cd288b96f to your computer and use it in GitHub Desktop.
OPA Combat engine - Sample Rules file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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