mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 14:10:27 -04:00
console portal jump
This commit is contained in:
parent
ce3e42f66b
commit
93caf370e4
4 changed files with 106 additions and 9 deletions
|
@ -6,6 +6,7 @@
|
||||||
#define console_max_characters 120
|
#define console_max_characters 120
|
||||||
#define console_max_lines 16
|
#define console_max_lines 16
|
||||||
|
|
||||||
|
void macro_drop_item(int sector,int smer,short item);
|
||||||
|
|
||||||
/****/
|
/****/
|
||||||
|
|
||||||
|
@ -454,6 +455,25 @@ static PARSED_COMMAND parse_command(const char *cmd) {
|
||||||
extern int ghost_walls;
|
extern int ghost_walls;
|
||||||
extern int nofloors;
|
extern int nofloors;
|
||||||
|
|
||||||
|
static int add_file_to_console(const char *name, LIST_FILE_TYPE , size_t, void *ctx) {
|
||||||
|
int *cnt = (void *)ctx;
|
||||||
|
char buff[20] = "";
|
||||||
|
for (int i = 0; i < 19; ++i) buff[i] = ' ';
|
||||||
|
buff[19] = 0;
|
||||||
|
int l = strlen(name);
|
||||||
|
if (l > 3 && stricmp(name+l-4,".MAP") == 0) {
|
||||||
|
if (l>19) l = 19;
|
||||||
|
memcpy(buff, name, l);
|
||||||
|
wzprintf("%s", buff);
|
||||||
|
if (++(*cnt) == 6) {
|
||||||
|
wzprintf("\n");
|
||||||
|
*cnt = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static int process_on_off_command(const char *cmd, char on) {
|
static int process_on_off_command(const char *cmd, char on) {
|
||||||
if (stricmp(cmd, "inner-eye") == 0) {
|
if (stricmp(cmd, "inner-eye") == 0) {
|
||||||
show_debug = on;
|
show_debug = on;
|
||||||
|
@ -538,6 +558,46 @@ static int process_actions(const char *command) {
|
||||||
play_fx_at(FX_MAP);
|
play_fx_at(FX_MAP);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (stricmp(command, "rise-and-shine") == 0) {
|
||||||
|
int r = 0;
|
||||||
|
for (int i = 0; i < POCET_POSTAV; ++i) {
|
||||||
|
THUMAN *p = postavy+i;
|
||||||
|
if (p->used && p->inmaphash == current_map_hash) {
|
||||||
|
p->lives=p->vlastnosti[VLS_MAXHIT];
|
||||||
|
p->mana=p->vlastnosti[VLS_MAXMANA];
|
||||||
|
p->kondice=p->vlastnosti[VLS_KONDIC];
|
||||||
|
p->sektor = viewsector;
|
||||||
|
r = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bott_draw(0);
|
||||||
|
return r;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (stricmp(command, "ascent") == 0) {
|
||||||
|
int lev = postavy[0].exp;
|
||||||
|
for (int i = 0; i < POCET_POSTAV; ++i) {
|
||||||
|
THUMAN *p = postavy+i;
|
||||||
|
if (p->used) lev = MAX(lev,p->level);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < POCET_POSTAV; ++i) {
|
||||||
|
THUMAN *p = postavy+i;
|
||||||
|
p->exp = level_map[lev-1];
|
||||||
|
check_player_new_level(p);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (stricmp(command, "by-the-power-of-grayskull") == 0) {
|
||||||
|
memset(runes,0xFF, sizeof(runes));
|
||||||
|
play_fx_at(FX_MAGIC);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (stricmp(command, "world-list") == 0) {
|
||||||
|
int cnt = 0;
|
||||||
|
list_files(gpathtable[SR_MAP], file_type_normal|file_type_just_name, add_file_to_console, &cnt);
|
||||||
|
printf("\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,6 +632,20 @@ static int process_with_params(const char *cmd, const char *args) {
|
||||||
console_add_line("");
|
console_add_line("");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (stricmp(cmd, "summon") == 0) {
|
||||||
|
if (args[0] == 'i') {
|
||||||
|
char *end;
|
||||||
|
unsigned long id = strtoul(args+1, &end, 10);
|
||||||
|
if (*end == 0) {
|
||||||
|
if (id < (unsigned long)item_count) {
|
||||||
|
macro_drop_item(viewsector,viewdir,id);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (stricmp(cmd, "say") == 0) {
|
if (stricmp(cmd, "say") == 0) {
|
||||||
console_add_line(args);
|
console_add_line(args);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -581,6 +655,16 @@ static int process_with_params(const char *cmd, const char *args) {
|
||||||
if (v > 0) timerspeed_val = v;
|
if (v > 0) timerspeed_val = v;
|
||||||
return v > 0;
|
return v > 0;
|
||||||
}
|
}
|
||||||
|
if (stricmp(cmd, "portal-jump") == 0) {
|
||||||
|
if (check_file_exists(build_pathname(2,gpathtable[SR_MAP], args))) {
|
||||||
|
TMA_LOADLEV lev;
|
||||||
|
strncpy(lev.name,args,12);
|
||||||
|
lev.start_pos = 0;
|
||||||
|
macro_load_another_map(&lev);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -538,6 +538,7 @@ void zmen_vlastnost(int num,int cil,int what,int how)
|
||||||
if (p->lives>p->vlastnosti[VLS_MAXHIT]) p->lives=p->vlastnosti[VLS_MAXHIT];
|
if (p->lives>p->vlastnosti[VLS_MAXHIT]) p->lives=p->vlastnosti[VLS_MAXHIT];
|
||||||
//if (p->mana>p->vlastnosti[VLS_MAXMANA]) p->lives=p->vlastnosti[VLS_MAXMANA];
|
//if (p->mana>p->vlastnosti[VLS_MAXMANA]) p->lives=p->vlastnosti[VLS_MAXMANA];
|
||||||
if (p->kondice>p->vlastnosti[VLS_KONDIC]) p->lives=p->vlastnosti[VLS_KONDIC];
|
if (p->kondice>p->vlastnosti[VLS_KONDIC]) p->lives=p->vlastnosti[VLS_KONDIC];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,7 +753,13 @@ void spell_hit(int cil,int min,int max,int owner)
|
||||||
vysl=min+rnd(max-min+1);
|
vysl=min+rnd(max-min+1);
|
||||||
if (vysl<0)
|
if (vysl<0)
|
||||||
{
|
{
|
||||||
h->lives-=vysl>h->vlastnosti[VLS_MAXHIT]?h->vlastnosti[VLS_MAXHIT]:vysl;
|
if (vysl < 0 && h->lives == 0 && h->sektor == 0) {
|
||||||
|
h->sektor = viewsector;
|
||||||
|
h->inmaphash = current_map_hash;
|
||||||
|
}
|
||||||
|
h->lives-=vysl;
|
||||||
|
if (h->lives < 0) h->lives = 0;
|
||||||
|
if (h->lives > h->vlastnosti[VLS_MAXHIT]) h->lives = h->vlastnosti[VLS_MAXHIT];
|
||||||
if (h->groupnum==0) h->groupnum=cur_group;
|
if (h->groupnum==0) h->groupnum=cur_group;
|
||||||
}
|
}
|
||||||
else player_hit(h,vysl,1);
|
else player_hit(h,vysl,1);
|
||||||
|
@ -898,7 +905,7 @@ void spell_pripojenia(int owner)
|
||||||
THUMAN *h=NULL;
|
THUMAN *h=NULL;
|
||||||
char more=0;
|
char more=0;
|
||||||
destroy_player_map();
|
destroy_player_map();
|
||||||
for(i=0;i<POCET_POSTAV;i++) if (postavy[i].used && postavy[i].lives)
|
for(i=0;i<POCET_POSTAV;i++) if (postavy[i].used)
|
||||||
{
|
{
|
||||||
int sect;
|
int sect;
|
||||||
sect=postavy[i].sektor;
|
sect=postavy[i].sektor;
|
||||||
|
@ -1820,8 +1827,9 @@ void cast(int num,THUMAN *p,int owner, char backfire)
|
||||||
{
|
{
|
||||||
THUMAN *h1=postavy+cil-1;
|
THUMAN *h1=postavy+cil-1;
|
||||||
char s[256];
|
char s[256];
|
||||||
if ((abs(map_coord[h1->sektor].x-map_coord[p->sektor].x)>5) ||
|
if ((h1->lives)
|
||||||
(abs(map_coord[h1->sektor].y-map_coord[p->sektor].y)>5) )
|
&& ((abs(map_coord[h1->sektor].x-map_coord[p->sektor].x)>5) ||
|
||||||
|
(abs(map_coord[h1->sektor].y-map_coord[p->sektor].y)>5) ))
|
||||||
{
|
{
|
||||||
sprintf(s,texty[37+(h1->female==1)],h1->jmeno,p->jmeno);
|
sprintf(s,texty[37+(h1->female==1)],h1->jmeno,p->jmeno);
|
||||||
bott_disp_text(s);
|
bott_disp_text(s);
|
||||||
|
|
|
@ -111,17 +111,21 @@ int list_files(const char *directory, int type, LIST_FILES_CALLBACK cb, void *ct
|
||||||
while (iter != std::filesystem::directory_iterator()) {
|
while (iter != std::filesystem::directory_iterator()) {
|
||||||
int r = 0;
|
int r = 0;
|
||||||
const auto &entry = *iter;
|
const auto &entry = *iter;
|
||||||
|
const char *name;
|
||||||
|
if (type & file_type_just_name) name = entry.path().filename().c_str();
|
||||||
|
else name = entry.path().filename().c_str();
|
||||||
if (entry.is_regular_file(ec) && (type & file_type_normal)) {
|
if (entry.is_regular_file(ec) && (type & file_type_normal)) {
|
||||||
r = cb(entry.path().c_str(), file_type_normal, entry.file_size(ec), ctx);
|
r = cb(name, file_type_normal, entry.file_size(ec), ctx);
|
||||||
} else if (entry.is_directory(ec)) {
|
} else if (entry.is_directory(ec)) {
|
||||||
int dot = entry.path().filename() == "." || entry.path().filename() == "..";
|
int dot = entry.path().filename() == "." || entry.path().filename() == "..";
|
||||||
if (!dot && (type & file_type_directory)) {
|
if (!dot && (type & file_type_directory)) {
|
||||||
r = cb(entry.path().c_str(), file_type_directory, 0, ctx);
|
r = cb(name, file_type_directory, 0, ctx);
|
||||||
} else if (dot & (type & file_type_dot)) {
|
} else if (dot & (type & file_type_dot)) {
|
||||||
r = cb(entry.path().c_str(), file_type_dot, 0, ctx);
|
r = cb(name, file_type_dot, 0, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (r) return r;
|
if (r) return r;
|
||||||
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -86,7 +86,8 @@ void sleep_ms(uint32_t);
|
||||||
typedef enum {
|
typedef enum {
|
||||||
file_type_normal = 1,
|
file_type_normal = 1,
|
||||||
file_type_directory = 2,
|
file_type_directory = 2,
|
||||||
file_type_dot = 4
|
file_type_dot = 4,
|
||||||
|
file_type_just_name = 8
|
||||||
} LIST_FILE_TYPE;
|
} LIST_FILE_TYPE;
|
||||||
|
|
||||||
typedef int (*LIST_FILES_CALLBACK)(const char *, LIST_FILE_TYPE , size_t, void *);
|
typedef int (*LIST_FILES_CALLBACK)(const char *, LIST_FILE_TYPE , size_t, void *);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue