1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-26 03:17:39 +00:00

ru:: bats

This commit is contained in:
Zeno Rogue
2025-05-04 10:34:02 +02:00
parent 0096f5f12b
commit 24222a41a5
4 changed files with 62 additions and 0 deletions

View File

@@ -394,6 +394,26 @@ void kestrel::act() {
}
}
void bat::act() {
if(gframeid >= next_change && gframeid > invinc_end + 300) {
next_change = gframeid + 300 + rand() % 300;
int angle = rand() % 360;
auto dat = get_dat();
ld v = dat.d * dat.modv;
vel.x = v * cos(angle);
vel.y = v * sin(angle);
}
apply_walls_reflect();
apply_vel();
if(intersect(get_pixel_bbox(), m.get_pixel_bbox())) {
if(m.reduce_hp(15)) addMessage("The bat bites you!");
}
}
void kestrel::attacked(int dmg) {
current_target = this;
reduce_hp(dmg);
@@ -402,4 +422,14 @@ void kestrel::attacked(int dmg) {
if(where.x > m.where.x) vel.x = +abs(vel.x);
}
void bat::attacked(int dmg) {
current_target = this;
reduce_hp(dmg);
if(!existing) addMessage("You kill the bat."); else addMessage("You hit the bat.");
if(where.x < m.where.x) vel.x = -abs(vel.x);
if(where.x > m.where.x) vel.x = +abs(vel.x);
if(where.y < m.where.y) vel.y = -abs(vel.y);
if(where.y > m.where.y) vel.y = +abs(vel.y);
}
}