1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2026-03-15 09:39:44 +00:00
Files
hyperrogue/rogueviz/ru/hallucinate.cpp
2025-12-13 00:42:03 +01:00

26 lines
612 B
C++

namespace rogue_unlike {
void prepare_hallucination() {
set<string> names_seen;
vector<entity*> visions;
for(auto& [c, r]: rooms) for(auto& e: r.entities) {
if(!e->can_be_hallucinated()) continue;
string s = e->get_name();
if(names_seen.count(s)) continue;
names_seen.insert(s);
visions.push_back(&*e);
}
for(auto& e: rogue_unlike::visions) visions.push_back(&*e);
for(auto& [c, r]: rooms) for(auto& e: r.entities) {
e->hallucinated = hrand_elt(visions);
}
}
entity *entity::hal() {
return (m.current.hallucinating && hallucinated) ? hallucinated : this;
}
}