diff --git a/rogueviz/ru/classes.cpp b/rogueviz/ru/classes.cpp index 9f1db6d7..726a0c4f 100644 --- a/rogueviz/ru/classes.cpp +++ b/rogueviz/ru/classes.cpp @@ -67,6 +67,7 @@ struct room { bool fov[room_y][room_x]; bool which_map_rendered; bool infile, need_rerender; + int timed_orb_end; vector> entities; @@ -327,6 +328,20 @@ struct pendulum_platform : public moving_platform { string get_help() override { return "These pendulum platforms go back and forth between two locations, taking the shortest path possible."; } }; +struct timed_orb : public entity { + int duration; + xy siz() override { return {18, 18}; } + string glyph() override { return "O"; } + color_t color() override { + println(hlog, tie(gframeid, current_room->timed_orb_end)); + if(gframeid > current_room->timed_orb_end) return 0x8080FFFF; + return gradient(0x404080FF, 0x8080FFFF, -1, cos((gframeid - current_room->timed_orb_end) * TAU * 5 / game_fps), 1); + } + void act() override; + string get_name() override { return "time orb"; } + string get_help() override { return "These orbs activate mechanisms for a limited time."; } + }; + struct npc_or_trader : public entity { string text; string name; diff --git a/rogueviz/ru/entity.cpp b/rogueviz/ru/entity.cpp index 2233624a..846bae2e 100644 --- a/rogueviz/ru/entity.cpp +++ b/rogueviz/ru/entity.cpp @@ -268,6 +268,19 @@ extern int gold_id; string shopitem::glyph() { if(bought) return powers[gold_id].get_glyph(); else return item::glyph(); } color_t shopitem::color() { if(bought) return powers[gold_id].get_color(); else return item::color(); } +void timed_orb::act() { + if(gframeid > current_room->timed_orb_end) { + walls[wTimeDoor].glyph = '+'; + walls[wTimeDoor].flags = W_BLOCK | W_BLOCKBIRD; + } + else { + walls[wTimeDoor].glyph = '\''; + walls[wTimeDoor].flags = W_TRANS; + } + if(intersect(get_pixel_bbox(), m.get_pixel_bbox())) + current_room->timed_orb_end = gframeid + duration; + } + void trader::act() { bool any_purchases = false; for(auto& e: current_room->entities) if(auto si = e->as_shopitem()) if(!si->existing) any_purchases = true; diff --git a/rogueviz/ru/globals.cpp b/rogueviz/ru/globals.cpp index 224ed1bb..97e4997b 100644 --- a/rogueviz/ru/globals.cpp +++ b/rogueviz/ru/globals.cpp @@ -58,7 +58,7 @@ struct ruwall { enum eWall { wAir, wWall, wBouncy, wSpike, wWater, wFrozen, wDoor, wSmashedDoor, wLockedDoor, wFountain, wBluePortal, wOrangePortal, wPlatform, wStaircase, - wColumn, wForge, wWoodWall, wShopDoor, wSecretPassage, wSign, wWallSign, wGUARD }; + wColumn, wForge, wWoodWall, wShopDoor, wSecretPassage, wSign, wWallSign, wTimeDoor, wGUARD }; flagtype W_BLOCK = 1; flagtype W_TRANS = 2; @@ -94,6 +94,7 @@ ruwall walls[qwall] = { {"secret passage", "#", 0xFFFF40FF, W_PLATFORM | W_BLOCKBIRD, "You have discovered a secret passage from the other side."}, {"sign", "X", 0xFFFF40FF, W_TRANS, "You need to wait close to this sign to read it."}, {"wall sign", "X", 0xFFFFC0FF, W_BLOCK, "You need to wait close to this sign to read it."}, + {"time door", "#", 0x8080FFFF, W_BLOCK | W_STABLE, "A powerful door, opened by a mechanism."}, }; int sel = 1; diff --git a/rogueviz/ru/map.ru b/rogueviz/ru/map.ru index c7505434..acd2ac7a 100644 --- a/rogueviz/ru/map.ru +++ b/rogueviz/ru/map.ru @@ -1400,10 +1400,10 @@ MAP ####....XXX..................................................................... ####.....|...................................................................... ####.....|...................................................................... -####--########################################################################## -####--########################################################################## -####-b............................................^^^^^......^.................. -####--.................................^^.........^..........^.................. +####--##################################################################--###### +####--##################################################################--###### +####-b............................................^^^^^......^..........--...... +####--.................................^^.........^..........^..........--...... ####-b................^...........................^..........^.................. ####--#########--.............................^...^..........^.....--########### ####-b##########-.................................^..........^.....-############ @@ -1451,3 +1451,60 @@ VTRAP 410 56 VTRAP 420 56 VTRAP 430 56 OK + +MOVE 4 Bouncy Spike Maze +ROOM Timed Passage +# wall +' shop door ++ time door +- platform +. air +A staircase +MAP +################################################################################ +################################################################################ +################################################################################ +################################################################################ +..........................##..................################################## +..........................##..................################################## +..........................##..................################################## +..........................##..--..--..--..--..################################## +..........................''..................#####################....#####..## +..........................'b..................#####################....####....# +........................###########################################............# +######################--###########################################............# +######################--####################################################--## +##....................-b...................................................+-b.. +##.........................................................................+.... +##.........................................................................+.... +####----#############################################################-------#### +#####A...##########################################################......A###### +######A...#######################################################......A######## +#######A.....#################################################.......A########## +########A.......############################################......A############# +#########A.............#################################........A############### +###########A....................##################............A################# +#############A.......................########...............A################### +#################A........................................A##################### +#####################AA.................................A####################### +############################A........................A########################## +##################################A............A################################ +################################################################################ +################################################################################ +################################################################################ +################################################################################ +################################################################################ +################################################################################ +################################################################################ +#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b +################################################################################ +#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b +################################################################################ +#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b#b +TIMEORB 30 117 3.9 +TIMEORB 560 79 20 +TRADER 236 67 +Jack the trader +Do you want to buy anthing?\n\nSorry for the traps, last week a thief stole my stuff and escaped through some secret door. So I installed some for protection.\n\nNo idea where it is... +OK + diff --git a/rogueviz/ru/save.cpp b/rogueviz/ru/save.cpp index e5e3763e..903f09f2 100644 --- a/rogueviz/ru/save.cpp +++ b/rogueviz/ru/save.cpp @@ -180,6 +180,13 @@ void load_room(fhstream& f, cell *c) { b->respawn = b->where; b->postfix(); r.entities.emplace_back(std::move(b)); } + else if(cap == "TIMEORB") { + auto b = std::make_unique(); + ld dur = 0; + sscanf(param.c_str(), "%lf%lf%lf", &b->where.x, &b->where.y, &dur); + b->duration = dur * game_fps; + r.entities.emplace_back(std::move(b)); + } else if(cap == "BAT") { auto b = std::make_unique(); sscanf(param.c_str(), "%lf%lf", &b->where.x, &b->where.y);