#workshop #transpiler #script #dragon #blade #condition #overwatch

dragon_blade

A transpiler from Rust to Overwatch Workshop

3 stable releases

2.1.0 Jul 25, 2023
2.0.0 Jul 24, 2023
1.0.0 Jul 20, 2023

#410 in Programming languages

Download history 2/week @ 2024-02-15 9/week @ 2024-02-22 3/week @ 2024-02-29 1/week @ 2024-03-07 3/week @ 2024-03-14 26/week @ 2024-03-28 25/week @ 2024-04-04

51 downloads per month

MIT/Apache

180KB
3K SLoC

Dragon Blade

This library lets you write code for the Overwatch Workshop in rust.

Example Usage:

use dragon_blade::*;

bind_subroutines! {
    convert_to_healing;
}
bind_player_variables! {
    converted_damage: Number;
}

fn main() {
    let script = Script::new("Heal for damage dealt");
    script.add(Rule {
        name: "Heal for adaptive amoumt",
        event: SubroutineBody(Subroutine::convert_to_healing()),
        conditions: conditions([]),
        actions: || {
            let amount =
                (1.15 - EventPlayer.normalized_health()) * EventPlayer.converted_damage() * 4;
            EventPlayer.heal(Null, amount);
        },
    });
    script.add(Rule {
        name: "heal player when they deal damage",
        event: PlayerDealtDamage(Team::Team1, Everyone),
        conditions: conditions([EventPlayer.is_alive()]),
        actions: || {
            cf_abort_if(Victim.equal(EventPlayer));
            EventPlayer.converted_damage().set(EventDamage);
            Subroutine::convert_to_healing().call();
        },
    });
    let script = script.generate();
    script.write_to_file("script.txt");
    script.copy_to_clipboard();
}

Dependencies

~1–1.5MB
~22K SLoC