Created
November 30, 2019 08:42
-
-
Save thinkier/584faca70b85e5ecacd514e35b59fac0 to your computer and use it in GitHub Desktop.
Calculate how different armors tank Revenant Horror 4 in Hypixel Skyblock
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
fn main() { | |
let base_hp = 479.; | |
let base_def = 58.; | |
print!("Revenant Armor (50k)"); | |
let mut rev = RevArmor::new(base_hp, base_def, 280. * 3., 5., 5., 0.); | |
tank(&mut rev); | |
print!("Revenant Armor (25k)"); | |
let mut rev = RevArmor::new(base_hp, base_def, 260. * 3., 5., 5., 0.); | |
tank(&mut rev); | |
print!("Revenant Armor (15k)"); | |
let mut rev = RevArmor::new(base_hp, base_def, 240. * 3., 5., 5., 0.); | |
tank(&mut rev); | |
print!("Revenant Armor (10k)"); | |
let mut rev = RevArmor::new(base_hp, base_def, 220. * 3., 5., 5., 0.); | |
tank(&mut rev); | |
print!("Revenant Armor (5k)"); | |
let mut rev = RevArmor::new(base_hp, base_def, 180. * 3., 5., 5., 0.); | |
tank(&mut rev); | |
print!("Revenant Armor (1k)"); | |
let mut rev = RevArmor::new(base_hp, base_def, 90. * 3., 5., 5., 0.); | |
tank(&mut rev); | |
print!("Max HPB G6P6 Superior Dragon Armor"); | |
let mut sup = GenericArmor::new(base_hp + 450. + 90. * 4. + 40. * 4., base_def + 600. + 18. * 4. + 20. * 4.); | |
tank(&mut sup); | |
print!("Protector Dragon Armor"); | |
let mut prot = ProtArmor::new(base_hp, base_def, 5., 5., 0.); | |
tank(&mut prot); | |
} | |
fn tank(armor: &mut dyn Armor) -> usize { | |
let heal = 0.01; // Radiant = 1, Mana = 2, Overflux = 2.5 | |
for count in 0..100000 { | |
if count % 5 == 0 { | |
armor.damage(1500.); // RH4 melee | |
} | |
if armor.health() <= 0. { | |
println!(" tanked {} strikes before dieing", count); | |
return count; | |
} | |
if count % 10 == 0 { // Every second | |
armor.damage(600.); // RH4 Target Ticks (Not melee) | |
armor.heal_pct(heal); // Orb heals | |
armor.heal(25.); // Natural regen | |
} | |
} | |
println!(" survived! Equilibria: {:.0}/{}", armor.health(), armor.max_health()); | |
return 10000; | |
} | |
trait Armor { | |
fn defense(&self) -> f64; | |
fn max_health(&self) -> f64; | |
fn health(&self) -> f64; | |
fn health_mut(&mut self) -> &mut f64; | |
fn damage(&mut self, dmg: f64) -> f64 { | |
let taken = dmg * 100. / (self.defense() + 100.); | |
*self.health_mut() -= taken; | |
taken | |
} | |
fn heal(&mut self, amt: f64); | |
fn heal_pct(&mut self, pct: f64) { | |
self.heal(pct * self.max_health()); | |
} | |
} | |
struct GenericArmor { | |
max_health: f64, | |
health: f64, | |
def: f64 | |
} | |
impl GenericArmor { | |
fn new(total_hp: f64, total_def: f64) -> GenericArmor { | |
GenericArmor { | |
max_health: total_hp, | |
health: total_hp, | |
def: total_def | |
} | |
} | |
} | |
impl Armor for GenericArmor { | |
fn defense(&self) -> f64 { | |
self.def | |
} | |
fn max_health(&self) -> f64 { | |
self.max_health | |
} | |
fn health(&self) -> f64 { | |
self.health | |
} | |
fn health_mut(&mut self) -> &mut f64 { | |
&mut self.health | |
} | |
fn heal(&mut self, amt: f64) { | |
self.health += amt; | |
self.health = self.health.min(self.max_health); | |
} | |
} | |
struct RevArmor { | |
max_health: f64, | |
health: f64, | |
def: f64, | |
} | |
impl RevArmor { | |
fn new(base_hp: f64, base_def: f64, bonus: f64, growth: f64, prot: f64, hpb: f64) -> RevArmor { | |
let health = base_hp + 50. + 400. + growth * 15. * 4. + hpb * 4.; | |
let def = base_def + 220. + prot * 4. + hpb * 2. + 3. * bonus; | |
RevArmor { | |
max_health: health, | |
health, | |
def | |
} | |
} | |
} | |
impl Armor for RevArmor { | |
fn defense(&self) -> f64 { | |
self.def | |
} | |
fn max_health(&self) -> f64 { | |
self.max_health | |
} | |
fn health(&self) -> f64 { | |
self.health | |
} | |
fn health_mut(&mut self) -> &mut f64 { | |
&mut self.health | |
} | |
fn heal(&mut self, amt: f64) { | |
self.health += 2. * amt; | |
self.health = self.health.min(self.max_health); | |
} | |
} | |
struct ProtArmor { | |
max_health: f64, | |
health: f64, | |
base_def: f64, | |
set_def: f64 | |
} | |
impl ProtArmor { | |
fn new(base_hp: f64, base_def: f64, growth: f64, prot: f64, hpb: f64) -> ProtArmor { | |
let hp = base_hp + 350. + growth * 15. * 4. + hpb * 4.; | |
ProtArmor { | |
max_health: hp, | |
health: hp, | |
base_def, | |
set_def: 500. + prot * 4. * 3. + hpb * 2. | |
} | |
} | |
} | |
impl Armor for ProtArmor { | |
fn defense(&self) -> f64 { | |
self.base_def + (1. + ((self.max_health - self.health) / self.max_health)) * self.set_def | |
} | |
fn max_health(&self) -> f64 { | |
self.max_health | |
} | |
fn health(&self) -> f64 { | |
self.health | |
} | |
fn health_mut(&mut self) -> &mut f64 { | |
&mut self.health | |
} | |
fn heal(&mut self, amt: f64) { | |
self.health += amt; | |
self.health = self.health.min(self.max_health); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment