diff --git a/rogueviz/ru/cheat.txt b/rogueviz/ru/cheat.txt new file mode 100644 index 00000000..afdd895c --- /dev/null +++ b/rogueviz/ru/cheat.txt @@ -0,0 +1,4 @@ +START Central Cavern +ITEM dagger +GAIN 5 3 +POS 320 100 \ No newline at end of file diff --git a/rogueviz/ru/ru.cpp b/rogueviz/ru/ru.cpp index bf756deb..ad87bd05 100644 --- a/rogueviz/ru/ru.cpp +++ b/rogueviz/ru/ru.cpp @@ -407,6 +407,7 @@ void add_platf_hooks() { } auto chk = arg::add3("-ru", enable) + + arg::add3("-ru-cheat", [] { arg::shift(); load_cheat(arg::args()); }) + addHook(mapstream::hooks_loadmap, 100, [] (hstream& f, int id) { if(id == 67) { println(hlog, "loading platformer"); diff --git a/rogueviz/ru/save.cpp b/rogueviz/ru/save.cpp index ef3a89f8..0b3bced3 100644 --- a/rogueviz/ru/save.cpp +++ b/rogueviz/ru/save.cpp @@ -160,5 +160,45 @@ void load_map(string fname) { } } +void load_cheat(string fname) { + fhstream f(fname, "r"); + auto power_edited = &powers[0]; + while(!feof(f.f)) { + string s = scanline_noblank(f); + auto pos = s.find(" "); + if(pos != string::npos) { + string cap = s.substr(0, pos); + string param = s.substr(pos+1); + if(cap == "START") { + for(auto& [c,r]: rooms) if(r.roomname == param) current_room = &r; + } + else if(cap == "POS") { + sscanf(param.c_str(), "%lf%lf", &m.where_x, &m.where_y); + } + else if(cap == "ITEM") { + bool found = false; + for(int i=0; iqty_owned += a; + power_edited->qty_filled += b; + println(hlog, "gain ", power_edited->name, " qty ", tie(a,b)); + } + else println(hlog, "unrecognized cheat: ", s); + } + else if(s == "IDENTIFY") { + power_edited->flags |= IDENTIFIED; + } + else if(s == "ACTIVATE") { + power_edited->flags |= ACTIVE; + } + else if(s == "") {} + else println(hlog, "unrecognized cheat: ", s); + } + } + }