mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-06-27 07:22:51 +00:00
ru:: loot
This commit is contained in:
parent
5bff1f9ef4
commit
742f5f02b7
@ -212,6 +212,8 @@ struct entity {
|
|||||||
void apply_portal_grav();
|
void apply_portal_grav();
|
||||||
bool stay_on_screen(); /* returns true if flipped */
|
bool stay_on_screen(); /* returns true if flipped */
|
||||||
virtual void act() { kino(); }
|
virtual void act() { kino(); }
|
||||||
|
/* for things which can act while not existing */
|
||||||
|
virtual void unact() { }
|
||||||
|
|
||||||
double get_scale() { return get_scale_at(where.y); }
|
double get_scale() { return get_scale_at(where.y); }
|
||||||
virtual bool freezing() { return false; }
|
virtual bool freezing() { return false; }
|
||||||
@ -465,6 +467,7 @@ struct item : public entity {
|
|||||||
string glyph() override { return powers[id].get_glyph(); }
|
string glyph() override { return powers[id].get_glyph(); }
|
||||||
color_t color() override { return powers[id].get_color(); }
|
color_t color() override { return powers[id].get_color(); }
|
||||||
void act() override {
|
void act() override {
|
||||||
|
stay_on_screen();
|
||||||
kino();
|
kino();
|
||||||
if(intersect(get_pixel_bbox(), m.get_pixel_bbox())) {
|
if(intersect(get_pixel_bbox(), m.get_pixel_bbox())) {
|
||||||
addMessage(pickup_message);
|
addMessage(pickup_message);
|
||||||
@ -499,6 +502,25 @@ struct shopitem : public item {
|
|||||||
shopitem* as_shopitem() override { return this; }
|
shopitem* as_shopitem() override { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct loot : public item {
|
||||||
|
entity *owner;
|
||||||
|
bool dropped;
|
||||||
|
void act() {
|
||||||
|
item::act();
|
||||||
|
if(on_floor) {
|
||||||
|
auto dat = get_dat();
|
||||||
|
if(vel.x > 0) vel.x = max<ld>(vel.x - dat.d * dat.moda * 0.02, 0);
|
||||||
|
if(vel.x < 0) vel.x = min<ld>(vel.x + dat.d * dat.moda * 0.02, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void unact() override {
|
||||||
|
if(!dropped && !owner->existing) {
|
||||||
|
where = owner->where, vel = owner->vel;
|
||||||
|
dropped = true; existing = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct missile : public entity {
|
struct missile : public entity {
|
||||||
missile() { destroyed = false; }
|
missile() { destroyed = false; }
|
||||||
xy siz() override { return {4, 4}; }
|
xy siz() override { return {4, 4}; }
|
||||||
|
@ -100,7 +100,7 @@ void playing_frame() {
|
|||||||
|
|
||||||
auto& ents = current_room->entities;
|
auto& ents = current_room->entities;
|
||||||
|
|
||||||
for(auto& e: ents) if(e->existing) e->act();
|
for(auto& e: ents) if(e->existing) e->act(); else e->unact();
|
||||||
|
|
||||||
auto mb = ents.begin();
|
auto mb = ents.begin();
|
||||||
for(auto& e: ents) if(!e->destroyed) *(mb++) = std::move(e);
|
for(auto& e: ents) if(!e->destroyed) *(mb++) = std::move(e);
|
||||||
|
@ -120,6 +120,21 @@ void load_room(fhstream& f, cell *c) {
|
|||||||
b->pickup_message = scanline_noblank(f);
|
b->pickup_message = scanline_noblank(f);
|
||||||
r.entities.emplace_back(std::move(b));
|
r.entities.emplace_back(std::move(b));
|
||||||
}
|
}
|
||||||
|
else if(cap == "LOOT") {
|
||||||
|
auto b = std::make_unique<loot>();
|
||||||
|
b->qty = 1;
|
||||||
|
b->owner = &*r.entities.back();
|
||||||
|
sscanf(param.c_str(), "%d", &b->qty);
|
||||||
|
s = scanline_noblank(f);
|
||||||
|
b->id = -1;
|
||||||
|
b->where = xy(320, 200);
|
||||||
|
for(int i=0; i<isize(powers); i++) if(powers[i].name == s) b->id = i;
|
||||||
|
if(b->id == -1) println(hlog, "error: unknown loot name ", s), b->id = 0;
|
||||||
|
b->pickup_message = scanline_noblank(f);
|
||||||
|
b->existing = false; b->dropped = false;
|
||||||
|
r.entities.emplace_back(std::move(b));
|
||||||
|
println(hlog, "loot pushed");
|
||||||
|
}
|
||||||
else if(cap == "SHOPITEM") {
|
else if(cap == "SHOPITEM") {
|
||||||
auto b = std::make_unique<shopitem>();
|
auto b = std::make_unique<shopitem>();
|
||||||
b->qty = 1; b->qty1 = 0;
|
b->qty = 1; b->qty1 = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user