1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2026-05-17 19:52:06 +00:00

ru:: 'effect' are now more general, not only attacks

This commit is contained in:
Zeno Rogue
2026-03-15 16:55:30 +01:00
parent b455587e11
commit e4dc58b61f
4 changed files with 19 additions and 11 deletions
+4 -2
View File
@@ -378,8 +378,10 @@ using boxfun = hr::function<bbox(int)>;
struct effect {
power *p;
int attack_facing;
int attack_when;
int facing;
int when;
int length;
hr::function<void(color_t&, int)> cf;
boxfun f;
};
+8 -2
View File
@@ -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<int> (0, alpha - 5 * t);
};
auto pb = f(0);
auto bb = pixel_to_block(pb);
for(auto& e: current_room->entities)
+2 -2
View File
@@ -115,8 +115,8 @@ power& power::be_armor(const vector<vector<string>>& 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);
+5 -5
View File
@@ -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<int> (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;
}