diff --git a/rogueviz/ru/classes.cpp b/rogueviz/ru/classes.cpp index 382d2a66..973b9c1e 100644 --- a/rogueviz/ru/classes.cpp +++ b/rogueviz/ru/classes.cpp @@ -378,8 +378,10 @@ using boxfun = hr::function; struct effect { power *p; - int attack_facing; - int attack_when; + int facing; + int when; + int length; + hr::function cf; boxfun f; }; diff --git a/rogueviz/ru/man.cpp b/rogueviz/ru/man.cpp index 51a72d83..c143c3f8 100644 --- a/rogueviz/ru/man.cpp +++ b/rogueviz/ru/man.cpp @@ -185,9 +185,15 @@ void man::launch_attack(power *p, int fac, boxfun f) { effects.emplace_back(); auto& e = effects.back(); e.p = p; - e.attack_facing = fac; - e.attack_when = gframeid; + e.facing = fac; + e.when = gframeid; e.f = f; + e.length = 50; + e.cf = [&] (color_t col, int t) { + auto& alpha = part(col, 0); + alpha = max (0, alpha - 5 * t); + }; + auto pb = f(0); auto bb = pixel_to_block(pb); for(auto& e: current_room->entities) diff --git a/rogueviz/ru/powers.cpp b/rogueviz/ru/powers.cpp index cc83507e..3c6b6fd5 100644 --- a/rogueviz/ru/powers.cpp +++ b/rogueviz/ru/powers.cpp @@ -115,8 +115,8 @@ power& power::be_armor(const vector>& v) { m.effects.emplace_back(); auto& e = m.effects.back(); e.p = this; - e.attack_when = gframeid; - e.attack_facing = fac; + e.when = gframeid; + e.facing = fac; e.length = len; e.cf = [len] (color_t& col, int t) { auto& alpha = part(col, 0); diff --git a/rogueviz/ru/render.cpp b/rogueviz/ru/render.cpp index 576788e3..4e648136 100644 --- a/rogueviz/ru/render.cpp +++ b/rogueviz/ru/render.cpp @@ -250,16 +250,16 @@ void man::draw() { auto efs = effects.begin(); for(auto& e: effects) { - ld t = gframeid - e.attack_when; - if(t < 50) { + ld t = gframeid - e.when; + if(t < e.length) { auto col = e.p->get_color(); - auto& alpha = part(col, 0); - alpha = max (0, alpha - 5 * t); + e.cf(col, t); auto box = e.f(t); asciiletter( box.minx, box.miny, // where.x + af * ds.x - ds.x/2, where.y - ds.y/2, box.maxx, box.maxy, // where.x + af * ds.x + ds.x/2, where.y + ds.y/2, - e.attack_facing == -1 ? "(" : ")", col + (e.p->flags & ARMOR) ? ( e.facing == -1 ? "[" : "]" ) : + e.facing == -1 ? "(" : ")", col ); *(efs++) = e; }