2016-08-26 09:58:03 +00:00
|
|
|
// Hyperbolic Rogue
|
|
|
|
|
2018-02-08 23:40:26 +00:00
|
|
|
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
// implementation of the shoot'em up mode
|
|
|
|
|
2018-06-10 23:58:31 +00:00
|
|
|
namespace hr {
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
extern int mousex, mousey;
|
|
|
|
extern bool clicked;
|
|
|
|
|
|
|
|
// joysticks for controlling the mobile shmup mode
|
|
|
|
namespace shmupballs {
|
|
|
|
int xmove, xfire, yb, rad;
|
|
|
|
|
2017-11-07 12:40:56 +00:00
|
|
|
void calc() {
|
2017-11-13 10:08:06 +00:00
|
|
|
int rr = int(realradius());
|
|
|
|
rad = int(rr * (vid.mobilecompasssize ? vid.mobilecompasssize : 14) / 100);
|
2018-11-17 18:24:02 +00:00
|
|
|
xmove = max(current_display->xcenter - rr - rad, rad);
|
|
|
|
xfire = min(current_display->xcenter + rr + rad, vid.xres - rad);
|
|
|
|
yb = current_display->ycenter + rr - rad;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace multi {
|
|
|
|
|
2017-10-29 11:46:57 +00:00
|
|
|
charstyle scs[MAXPLAYER];
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int players = 1;
|
|
|
|
cellwalker player[MAXPLAYER];
|
|
|
|
vector<int> revive_queue; // queue for revival
|
|
|
|
|
|
|
|
cell *origpos[MAXPLAYER], *origtarget[MAXPLAYER];
|
|
|
|
|
|
|
|
bool flipped[MAXPLAYER];
|
|
|
|
|
|
|
|
int treasures[MAXPLAYER], kills[MAXPLAYER], deaths[MAXPLAYER];
|
|
|
|
|
|
|
|
bool alwaysuse = false;
|
|
|
|
|
|
|
|
void recall() {
|
|
|
|
for(int i=0; i<numplayers(); i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
int idir = (3 * i) % cwt.at->type;
|
|
|
|
cell *c2 = cwt.at->move(idir);
|
2017-03-23 10:53:57 +00:00
|
|
|
makeEmpty(c2);
|
2018-08-17 22:46:45 +00:00
|
|
|
if(!passable(c2, NULL, P_ISPLAYER)) c2 = cwt.at;
|
|
|
|
multi::player[i].at = c2;
|
2017-03-23 10:53:57 +00:00
|
|
|
multi::player[i].spin = 0;
|
|
|
|
|
|
|
|
multi::flipped[i] = true;
|
|
|
|
multi::whereto[i].d = MD_UNDECIDED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
transmatrix whereis[MAXPLAYER];
|
|
|
|
transmatrix crosscenter[MAXPLAYER];
|
|
|
|
double ccdist[MAXPLAYER];
|
|
|
|
cell *ccat[MAXPLAYER];
|
|
|
|
|
|
|
|
bool combo[MAXPLAYER];
|
|
|
|
|
|
|
|
int cpid; // player id -- an extra parameter for player-related functions
|
|
|
|
int cpid_edit; // cpid currently being edited
|
|
|
|
|
|
|
|
movedir whereto[MAXPLAYER]; // player's target cell
|
|
|
|
|
|
|
|
double mdx[MAXPLAYER], mdy[MAXPLAYER]; // movement vector for the next move
|
2017-07-16 21:00:55 +00:00
|
|
|
|
|
|
|
static const int CMDS = 15;
|
|
|
|
static const int CMDS_PAN = 11;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
vector<string> playercmds_shmup = {
|
2017-03-23 10:53:57 +00:00
|
|
|
"forward", "backward", "turn left", "turn right",
|
|
|
|
"move up", "move right", "move down", "move left",
|
|
|
|
"throw a knife", "face the pointer", "throw at the pointer",
|
|
|
|
"drop Dead Orb", "center the map on me", "Orb power (target: mouse)",
|
|
|
|
"Orb power (target: facing)"
|
|
|
|
};
|
2019-02-25 17:42:17 +00:00
|
|
|
|
|
|
|
vector<string> playercmds_shmup3 = {
|
|
|
|
"rotate up", "rotate down", "rotate left", "rotate right",
|
2019-02-27 12:35:15 +00:00
|
|
|
"move forward", "strafe right", "move backward", "strafe left",
|
2019-02-25 17:42:17 +00:00
|
|
|
"throw a knife", "face the pointer", "throw at the pointer",
|
|
|
|
"drop Dead Orb", "center the map on me", "Orb power (target: mouse)",
|
|
|
|
"Orb power (target: facing)"
|
|
|
|
};
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
vector<string> playercmds_turn = {
|
2017-03-23 10:53:57 +00:00
|
|
|
"move up-right", "move up-left", "move down-right", "move down-left",
|
|
|
|
"move up", "move right", "move down", "move left",
|
|
|
|
"stay in place (left + right)", "cancel move", "leave the game",
|
|
|
|
"drop Dead Orb (up + down)", "center the map on me", "",
|
|
|
|
""
|
|
|
|
};
|
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
vector<string> pancmds = {
|
2017-03-23 10:53:57 +00:00
|
|
|
"pan up", "pan right", "pan down", "pan left",
|
2017-07-16 21:00:55 +00:00
|
|
|
"rotate left", "rotate right", "home",
|
|
|
|
"world overview", "review your quest", "inventory", "main menu"
|
2017-03-23 10:53:57 +00:00
|
|
|
};
|
|
|
|
|
2019-02-25 17:42:17 +00:00
|
|
|
vector<string> pancmds3 = {
|
|
|
|
"look up", "look right", "look down", "look left",
|
|
|
|
"rotate left", "rotate right", "home",
|
|
|
|
"world overview", "review your quest", "inventory", "main menu",
|
|
|
|
"scroll forward", "scroll backward"
|
|
|
|
};
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
#define SHMUPAXES_BASE 4
|
|
|
|
#define SHMUPAXES ((SHMUPAXES_BASE) + 4 * (MAXPLAYER))
|
2018-11-18 02:18:11 +00:00
|
|
|
#define SHMUPAXES_CUR ((SHMUPAXES_BASE) + 4 * playercfg)
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
const char* axemodes[SHMUPAXES] = {
|
|
|
|
"do nothing",
|
|
|
|
"rotate view",
|
|
|
|
"panning X",
|
|
|
|
"panning Y",
|
|
|
|
"player 1 X",
|
|
|
|
"player 1 Y",
|
|
|
|
"player 1 go",
|
|
|
|
"player 1 spin",
|
|
|
|
"player 2 X",
|
|
|
|
"player 2 Y",
|
|
|
|
"player 2 go",
|
|
|
|
"player 2 spin",
|
|
|
|
"player 3 X",
|
|
|
|
"player 3 Y",
|
|
|
|
"player 3 go",
|
|
|
|
"player 3 spin",
|
|
|
|
"player 4 X",
|
|
|
|
"player 4 Y",
|
|
|
|
"player 4 go",
|
|
|
|
"player 4 spin",
|
|
|
|
"player 5 X",
|
|
|
|
"player 5 Y",
|
|
|
|
"player 5 go",
|
|
|
|
"player 5 spin",
|
|
|
|
"player 6 X",
|
|
|
|
"player 6 Y",
|
|
|
|
"player 6 go",
|
|
|
|
"player 6 spin",
|
|
|
|
"player 7 X",
|
|
|
|
"player 7 Y",
|
|
|
|
"player 7 go",
|
|
|
|
"player 7 spin"
|
|
|
|
};
|
|
|
|
|
|
|
|
int centerplayer = -1;
|
|
|
|
|
|
|
|
char* axeconfigs[24]; int numaxeconfigs;
|
|
|
|
int* dzconfigs[24];
|
|
|
|
|
|
|
|
string listkeys(int id) {
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_SDL
|
2017-03-23 10:53:57 +00:00
|
|
|
string lk = "";
|
|
|
|
for(int i=0; i<512; i++)
|
|
|
|
if(vid.scfg.keyaction[i] == id)
|
|
|
|
lk = lk + " " + SDL_GetKeyName(SDLKey(i));
|
2017-10-15 23:22:24 +00:00
|
|
|
#if CAP_SDLJOY
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int i=0; i<numsticks; i++) for(int k=0; k<SDL_JoystickNumButtons(sticks[i]) && k<MAXBUTTON; k++)
|
|
|
|
if(vid.scfg.joyaction[i][k] == id) {
|
|
|
|
lk = lk + " " + cts('A'+i)+"-B"+its(k);
|
|
|
|
}
|
|
|
|
for(int i=0; i<numsticks; i++) for(int k=0; k<SDL_JoystickNumHats(sticks[i]) && k<MAXHAT; k++)
|
|
|
|
for(int d=0; d<4; d++)
|
|
|
|
if(vid.scfg.hataction[i][k][d] == id) {
|
|
|
|
lk = lk + " " + cts('A'+i)+"-"+"URDL"[d];
|
|
|
|
}
|
2017-08-13 18:49:38 +00:00
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
return lk;
|
2017-07-22 23:33:27 +00:00
|
|
|
#else
|
2017-03-23 10:53:57 +00:00
|
|
|
return "";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SCJOY 16
|
|
|
|
|
|
|
|
string dsc(int id) {
|
|
|
|
char buf[64];
|
|
|
|
sprintf(buf, " (%d $$$, %d kills, %d deaths)",
|
|
|
|
multi::treasures[id],
|
|
|
|
multi::kills[id],
|
|
|
|
multi::deaths[id]
|
|
|
|
);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void resetScores() {
|
|
|
|
for(int i=0; i<MAXPLAYER; i++)
|
|
|
|
multi::treasures[i] = multi::kills[i] = multi::deaths[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool configdead;
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
void handleConfig(int sym, int uni);
|
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
string player_count_name(int p) {
|
|
|
|
return XLAT(
|
|
|
|
p == 2 ? "two players" :
|
|
|
|
p == 3 ? "three players" :
|
|
|
|
p == 4 ? "four players" :
|
|
|
|
p == 5 ? "five players" :
|
|
|
|
p == 6 ? "six players" :
|
|
|
|
p == 7 ? "seven players" :
|
|
|
|
"one player");
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
struct key_configurer {
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
int sc;
|
|
|
|
vector<string>& shmupcmdtable;
|
|
|
|
int setwhat;
|
|
|
|
|
|
|
|
key_configurer(int sc, vector<string>& sct) : sc(sc), shmupcmdtable(sct), setwhat(0) {}
|
|
|
|
|
|
|
|
void operator() () {
|
|
|
|
|
|
|
|
dialog::init(
|
|
|
|
XLAT(sc == 1 ? "configure player 1" :
|
|
|
|
sc == 2 ? "configure player 2" :
|
|
|
|
sc == 3 ? "configure panning" :
|
|
|
|
sc == 4 ? "configure player 3" :
|
|
|
|
sc == 5 ? "configure player 4" :
|
|
|
|
sc == 6 ? "configure player 5" :
|
|
|
|
sc == 7 ? "configure player 6" :
|
|
|
|
sc == 8 ? "configure player 7" : ""
|
|
|
|
));
|
|
|
|
|
|
|
|
getcstat = ' ';
|
|
|
|
|
|
|
|
for(int i=0; i<isize(shmupcmdtable); i++) if(shmupcmdtable[i][0])
|
|
|
|
dialog::addSelItem(XLAT(shmupcmdtable[i]), listkeys(16*sc+i),
|
|
|
|
setwhat ? (setwhat>1 && i == (setwhat&15) ? '?' : 0) : 'a'+i);
|
|
|
|
else dialog::addBreak(100);
|
|
|
|
|
|
|
|
if(setwhat == 1)
|
|
|
|
dialog::addItem(XLAT("press a key to unassign"), 0);
|
|
|
|
else if(setwhat)
|
|
|
|
dialog::addItem(XLAT("press a key for '%1'", XLAT(shmupcmdtable[setwhat&15])), 0);
|
|
|
|
else
|
|
|
|
dialog::addItem(XLAT("unassign a key"), 'z');
|
|
|
|
|
|
|
|
dialog::display();
|
|
|
|
|
|
|
|
keyhandler = [this] (int sym, int uni) {
|
|
|
|
if(!setwhat) dialog::handleNavigation(sym, uni);
|
|
|
|
if(sym) {
|
|
|
|
if(setwhat) {
|
|
|
|
vid.scfg.keyaction[sym] = setwhat;
|
|
|
|
setwhat = 0;
|
|
|
|
}
|
|
|
|
else if(uni >= 'a' && uni < 'a' + isize(shmupcmdtable) && shmupcmdtable[uni-'a'][0])
|
|
|
|
setwhat = 16*sc+uni - 'a';
|
|
|
|
else if(uni == 'z')
|
|
|
|
setwhat = 1;
|
|
|
|
else if(doexiton(sym, uni))
|
|
|
|
popScreen();
|
|
|
|
}
|
|
|
|
};
|
2018-12-15 14:17:06 +00:00
|
|
|
|
|
|
|
#if CAP_SDLJOY
|
2018-11-18 02:18:11 +00:00
|
|
|
joyhandler = [this] (SDL_Event& ev) {
|
|
|
|
if(ev.type == SDL_JOYBUTTONDOWN && setwhat) {
|
|
|
|
int joyid = ev.jbutton.which;
|
|
|
|
int button = ev.jbutton.button;
|
|
|
|
if(joyid < 8 && button < 32)
|
|
|
|
vid.scfg.joyaction[joyid][button] = setwhat;
|
|
|
|
setwhat = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(ev.type == SDL_JOYHATMOTION && setwhat) {
|
|
|
|
int joyid = ev.jhat.which;
|
|
|
|
int hat = ev.jhat.hat;
|
|
|
|
int dir = 4;
|
|
|
|
if(ev.jhat.value == SDL_HAT_UP) dir = 0;
|
|
|
|
if(ev.jhat.value == SDL_HAT_RIGHT) dir = 1;
|
|
|
|
if(ev.jhat.value == SDL_HAT_DOWN) dir = 2;
|
|
|
|
if(ev.jhat.value == SDL_HAT_LEFT) dir = 3;
|
|
|
|
printf("%d %d %d\n", joyid, hat, dir);
|
|
|
|
if(joyid < 8 && hat < 4 && dir < 4) {
|
|
|
|
vid.scfg.hataction[joyid][hat][dir] = setwhat;
|
|
|
|
setwhat = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2018-12-15 14:17:06 +00:00
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2018-11-18 02:18:11 +00:00
|
|
|
};
|
|
|
|
|
2017-10-15 23:22:24 +00:00
|
|
|
#if CAP_SDLJOY
|
2018-11-18 02:18:11 +00:00
|
|
|
struct joy_configurer {
|
|
|
|
|
|
|
|
bool shmupcfg, racecfg;
|
|
|
|
int playercfg;
|
|
|
|
joy_configurer(int playercfg) : playercfg(playercfg) {}
|
|
|
|
|
|
|
|
void operator() () {
|
2017-03-23 10:53:57 +00:00
|
|
|
dialog::init();
|
|
|
|
getcstat = ' ';
|
|
|
|
numaxeconfigs = 0;
|
|
|
|
for(int j=0; j<numsticks; j++) {
|
|
|
|
for(int ax=0; ax<SDL_JoystickNumAxes(sticks[j]) && ax < MAXAXE; ax++) if(numaxeconfigs<24) {
|
|
|
|
int y = SDL_JoystickGetAxis(sticks[j], ax);
|
|
|
|
string buf = " ";
|
|
|
|
if(configdead)
|
|
|
|
buf += its(y);
|
|
|
|
else {
|
|
|
|
while(y > 10000) buf += "+", y -= 10000;
|
|
|
|
while(y < -10000) buf += "-", y += 10000;
|
|
|
|
if(y>0) buf += "+";
|
|
|
|
if(y<0) buf += "-";
|
|
|
|
}
|
|
|
|
axeconfigs[numaxeconfigs] = &(vid.scfg.axeaction[j][ax]);
|
|
|
|
dzconfigs[numaxeconfigs] = &(vid.scfg.deadzoneval[j][ax]);
|
|
|
|
char aa = *axeconfigs[numaxeconfigs];
|
|
|
|
string what = configdead ? its(vid.scfg.deadzoneval[j][ax]) : XLAT(axemodes[aa%SHMUPAXES]);
|
|
|
|
dialog::addSelItem(XLAT("Joystick %1, axis %2", cts('A'+j), its(ax)) + buf,
|
|
|
|
what, 'a'+numaxeconfigs);
|
|
|
|
numaxeconfigs++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog::addBoolItem(XLAT("Configure dead zones"), (configdead), 'z');
|
|
|
|
dialog::display();
|
2018-11-18 02:18:11 +00:00
|
|
|
|
|
|
|
keyhandler = [this] (int sym, int uni) {
|
|
|
|
dialog::handleNavigation(sym, uni);
|
|
|
|
if(sym) {
|
|
|
|
char xuni = uni | 96;
|
|
|
|
if(xuni >= 'a' && xuni < 'a' + numaxeconfigs) {
|
|
|
|
if(configdead) {
|
|
|
|
int& dz = (*dzconfigs[xuni - 'a']);
|
|
|
|
dz += int(shiftmul * 100);
|
|
|
|
if(dz < 0) dz = 0;
|
|
|
|
if(dz > 65000) dz = 65000;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int v = (*axeconfigs[xuni - 'a']);
|
|
|
|
v += (shiftmul>0?1:-1);
|
|
|
|
v += SHMUPAXES_CUR;
|
|
|
|
v %= SHMUPAXES_CUR;
|
|
|
|
(*axeconfigs[xuni - 'a']) = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(xuni == 'z')
|
|
|
|
configdead = !configdead;
|
|
|
|
else if(doexiton(sym, uni))
|
|
|
|
popScreen();
|
|
|
|
}
|
|
|
|
};
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2018-11-18 02:18:11 +00:00
|
|
|
};
|
2017-08-13 18:49:38 +00:00
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
struct shmup_configurer {
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
void operator()() {
|
|
|
|
#if CAP_SDL
|
|
|
|
cmode = sm::SHMUPCONFIG;
|
2019-03-30 22:45:28 +00:00
|
|
|
gamescreen(3);
|
|
|
|
dialog::init(XLAT("keyboard & joysticks"));
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2019-03-30 22:45:28 +00:00
|
|
|
bool haveconfig = shmup::on || players > 1 || multi::alwaysuse;
|
2018-11-18 02:18:11 +00:00
|
|
|
|
2019-03-30 22:45:28 +00:00
|
|
|
if(haveconfig)
|
|
|
|
dialog::addItem(XLAT("configure player 1"), '1');
|
2017-03-23 10:53:57 +00:00
|
|
|
else
|
|
|
|
dialog::addBreak(100);
|
2019-03-30 22:45:28 +00:00
|
|
|
if(players > 1)
|
|
|
|
dialog::addItem(XLAT("configure player 2"), '2');
|
|
|
|
else if(players == 1 && !shmup::on)
|
2017-03-23 10:53:57 +00:00
|
|
|
dialog::addSelItem(XLAT("input"), XLAT(multi::alwaysuse ? "config" : "default"), 'a');
|
|
|
|
else
|
|
|
|
dialog::addBreak(100);
|
2019-03-30 22:45:28 +00:00
|
|
|
if(players > 2)
|
|
|
|
dialog::addItem(XLAT("configure player 3"), '3');
|
2018-11-18 02:18:11 +00:00
|
|
|
#if CAP_SDLJOY
|
2019-03-30 22:45:28 +00:00
|
|
|
else if(!haveconfig)
|
2017-03-23 10:53:57 +00:00
|
|
|
dialog::addItem(XLAT("old style joystick configuration"), 'b');
|
2018-11-18 02:18:11 +00:00
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
else dialog::addBreak(100);
|
2019-03-30 22:45:28 +00:00
|
|
|
if(players > 3)
|
|
|
|
dialog::addItem(XLAT("configure player 4"), '4');
|
2019-02-25 17:39:36 +00:00
|
|
|
else if(!shmup::on && !multi::alwaysuse) {
|
|
|
|
dialog::addBoolItem(XLAT("smooth scrolling"), smooth_scrolling, 'c');
|
|
|
|
}
|
2019-03-30 22:45:28 +00:00
|
|
|
else if(alwaysuse)
|
|
|
|
dialog::addInfo(XLAT("note: configured input is designed for"));
|
2017-03-23 10:53:57 +00:00
|
|
|
else dialog::addBreak(100);
|
|
|
|
|
2019-03-30 22:45:28 +00:00
|
|
|
if(players > 4)
|
|
|
|
dialog::addItem(XLAT("configure player 5"), '5');
|
|
|
|
else if(!shmup::on && !multi::alwaysuse) {
|
|
|
|
const char *axmodes[5] = {"OFF", "auto", "light", "heavy", "arrows"};
|
|
|
|
dialog::addSelItem(XLAT("help for keyboard users"), XLAT(axmodes[vid.axes]), 'h');
|
|
|
|
dialog::add_action([] {vid.axes += 60 + (shiftmul > 0 ? 1 : -1); vid.axes %= 5; } );
|
|
|
|
}
|
|
|
|
else if(alwaysuse)
|
|
|
|
dialog::addInfo(XLAT("multiplayer and shmup mode; some features"));
|
2017-03-23 10:53:57 +00:00
|
|
|
else dialog::addBreak(100);
|
2018-11-18 02:18:11 +00:00
|
|
|
|
2019-03-30 22:45:28 +00:00
|
|
|
if(players > 5)
|
|
|
|
dialog::addItem(XLAT("configure player 6"), '6');
|
|
|
|
else if(alwaysuse)
|
|
|
|
dialog::addInfo(XLAT("work worse if you use it."));
|
2017-03-23 10:53:57 +00:00
|
|
|
else dialog::addBreak(100);
|
2018-11-18 02:18:11 +00:00
|
|
|
|
2019-03-30 22:45:28 +00:00
|
|
|
if(players > 6)
|
|
|
|
dialog::addItem(XLAT("configure player 7"), '7');
|
2017-03-23 10:53:57 +00:00
|
|
|
else dialog::addBreak(100);
|
|
|
|
|
2019-03-30 22:45:28 +00:00
|
|
|
if(shmup::on || multi::alwaysuse || players > 1)
|
2017-07-16 21:00:55 +00:00
|
|
|
dialog::addItem(XLAT("configure panning and general keys"), 'p');
|
2017-03-23 10:53:57 +00:00
|
|
|
else dialog::addBreak(100);
|
2018-11-18 02:18:11 +00:00
|
|
|
|
|
|
|
#if CAP_SDLJOY
|
2017-03-23 10:53:57 +00:00
|
|
|
if(numsticks > 0) {
|
2019-03-30 22:45:28 +00:00
|
|
|
if(shmup::on || multi::alwaysuse || players > 1)
|
2017-03-23 10:53:57 +00:00
|
|
|
dialog::addItem(XLAT("configure joystick axes"), 'j');
|
|
|
|
else dialog::addBreak(100);
|
|
|
|
}
|
2018-11-18 02:18:11 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
dialog::addBreak(50);
|
2018-11-18 02:18:11 +00:00
|
|
|
|
2018-06-12 22:00:01 +00:00
|
|
|
dialog::addHelp();
|
2018-11-18 02:18:11 +00:00
|
|
|
|
2018-06-12 22:00:01 +00:00
|
|
|
dialog::addBack();
|
2017-03-23 10:53:57 +00:00
|
|
|
dialog::display();
|
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
keyhandler = [this] (int sym, int uni) { return handleConfig(sym, uni); };
|
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
void handleConfig(int sym, int uni) {
|
2019-05-08 20:48:59 +00:00
|
|
|
auto& cmdlist = shmup::on ? (WDIM == 3 ? playercmds_shmup3 : playercmds_shmup) : playercmds_turn;
|
2018-11-18 02:18:11 +00:00
|
|
|
|
|
|
|
#if CAP_SDL
|
|
|
|
if(uni == '1') pushScreen(key_configurer(1, cmdlist));
|
|
|
|
else if(uni == '2') pushScreen(key_configurer(2, cmdlist));
|
2019-05-08 20:48:59 +00:00
|
|
|
else if(uni == 'p') pushScreen(key_configurer(3, WDIM == 3 ? pancmds3 : pancmds));
|
2018-11-18 02:18:11 +00:00
|
|
|
else if(uni == '3') pushScreen(key_configurer(4, cmdlist));
|
|
|
|
else if(uni == '4') pushScreen(key_configurer(5, cmdlist));
|
|
|
|
else if(uni == '5') pushScreen(key_configurer(6, cmdlist));
|
|
|
|
else if(uni == '6') pushScreen(key_configurer(7, cmdlist));
|
|
|
|
else if(uni == '7') pushScreen(key_configurer(8, cmdlist));
|
|
|
|
#if CAP_SDLJOY
|
2019-03-30 22:45:28 +00:00
|
|
|
else if(uni == 'j') pushScreen(joy_configurer(players));
|
2018-11-18 02:18:11 +00:00
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(uni == 'a') multi::alwaysuse = !multi::alwaysuse;
|
2018-11-18 02:18:11 +00:00
|
|
|
#if CAP_SDLJOY
|
2017-07-10 18:47:38 +00:00
|
|
|
else if(uni == 'b') pushScreen(showJoyConfig);
|
2018-11-18 02:18:11 +00:00
|
|
|
#endif
|
2019-02-25 17:39:36 +00:00
|
|
|
else if(uni == 'c') smooth_scrolling = !smooth_scrolling;
|
2018-11-18 02:18:11 +00:00
|
|
|
#endif
|
2019-03-30 22:45:28 +00:00
|
|
|
else if(doexiton(sym, uni)) popScreen();
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2018-11-18 02:18:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void configure() {
|
|
|
|
pushScreen(shmup_configurer());
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
2019-03-30 22:45:28 +00:00
|
|
|
void showConfigureMultiplayer() {
|
|
|
|
gamescreen(1);
|
|
|
|
dialog::init("multiplayer");
|
|
|
|
|
|
|
|
for(int i=1; i <= MAXPLAYER; i++) {
|
|
|
|
string s = player_count_name(i);
|
|
|
|
if(i <= players) s += dsc(i-1);
|
|
|
|
dialog::addBoolItem(s, '1', i == multi::players);
|
|
|
|
dialog::add_action([i] {
|
|
|
|
dialog::do_if_confirmed([i] {
|
|
|
|
stop_game();
|
|
|
|
players = i;
|
|
|
|
start_game();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if(multi::players > 1) {
|
|
|
|
dialog::addItem(XLAT("reset per-player statistics"), 'r');
|
|
|
|
dialog::add_action([] {
|
|
|
|
for(int i=0; i<MAXPLAYER; i++)
|
|
|
|
kills[i] = deaths[i] = treasures[i] = 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else dialog::addBreak(100);
|
|
|
|
|
|
|
|
dialog::addBack();
|
|
|
|
dialog::display();
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
#define NUMACT 128
|
|
|
|
|
|
|
|
enum pcmds {
|
|
|
|
pcForward, pcBackward, pcTurnLeft, pcTurnRight,
|
|
|
|
pcMoveUp, pcMoveRight, pcMoveDown, pcMoveLeft,
|
|
|
|
pcFire, pcFace, pcFaceFire,
|
|
|
|
pcDrop, pcCenter, pcOrbPower, pcOrbKey
|
|
|
|
};
|
|
|
|
|
|
|
|
int actionspressed[NUMACT], axespressed[SHMUPAXES], lactionpressed[NUMACT];
|
|
|
|
|
|
|
|
void pressaction(int id) {
|
|
|
|
if(id >= 0 && id < NUMACT)
|
|
|
|
actionspressed[id]++;
|
|
|
|
}
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
bool notremapped(int sym) {
|
|
|
|
int k = vid.scfg.keyaction[sym];
|
2017-06-18 16:52:15 +00:00
|
|
|
if(k == 0) return true;
|
2017-05-31 16:33:50 +00:00
|
|
|
k /= 16;
|
2017-06-18 16:52:15 +00:00
|
|
|
if(k > 3) k--; else if(k==3) k = 0;
|
|
|
|
return k > multi::players;
|
2017-05-31 16:33:50 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void initConfig() {
|
|
|
|
|
|
|
|
char* t = vid.scfg.keyaction;
|
|
|
|
|
2018-05-07 18:11:29 +00:00
|
|
|
t[(int)'w'] = 16 + 4;
|
|
|
|
t[(int)'d'] = 16 + 5;
|
|
|
|
t[(int)'s'] = 16 + 6;
|
|
|
|
t[(int)'a'] = 16 + 7;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISMOBILE==0
|
2017-03-23 10:53:57 +00:00
|
|
|
t[SDLK_KP8] = 16 + 4;
|
|
|
|
t[SDLK_KP6] = 16 + 5;
|
|
|
|
t[SDLK_KP2] = 16 + 6;
|
|
|
|
t[SDLK_KP4] = 16 + 7;
|
|
|
|
#endif
|
|
|
|
|
2018-05-07 18:11:29 +00:00
|
|
|
t[(int)'f'] = 16 + pcFire;
|
|
|
|
t[(int)'g'] = 16 + pcFace;
|
|
|
|
t[(int)'h'] = 16 + pcFaceFire;
|
|
|
|
t[(int)'r'] = 16 + pcDrop;
|
|
|
|
t[(int)'t'] = 16 + pcOrbPower;
|
|
|
|
t[(int)'y'] = 16 + pcCenter;
|
|
|
|
|
|
|
|
t[(int)'i'] = 32 + 4;
|
2018-11-17 18:31:22 +00:00
|
|
|
t[(int)'l'] = 32 + 5;
|
|
|
|
t[(int)'k'] = 32 + 6;
|
|
|
|
t[(int)'j'] = 32 + 7;
|
2018-05-07 18:11:29 +00:00
|
|
|
t[(int)';'] = 32 + 8;
|
|
|
|
t[(int)'\''] = 32 + 9;
|
|
|
|
t[(int)'p'] = 32 + 10;
|
|
|
|
t[(int)'['] = 32 + pcCenter;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISMOBILE==0
|
2017-03-23 10:53:57 +00:00
|
|
|
t[SDLK_UP] = 48 ;
|
|
|
|
t[SDLK_RIGHT] = 48 + 1;
|
|
|
|
t[SDLK_DOWN] = 48 + 2;
|
|
|
|
t[SDLK_LEFT] = 48 + 3;
|
|
|
|
t[SDLK_PAGEUP] = 48 + 4;
|
|
|
|
t[SDLK_PAGEDOWN] = 48 + 5;
|
|
|
|
t[SDLK_HOME] = 48 + 6;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
vid.scfg.joyaction[0][0] = 16 + pcFire;
|
|
|
|
vid.scfg.joyaction[0][1] = 16 + pcOrbPower;
|
|
|
|
vid.scfg.joyaction[0][2] = 16 + pcDrop;
|
|
|
|
vid.scfg.joyaction[0][3] = 16 + pcCenter;
|
|
|
|
vid.scfg.joyaction[0][4] = 16 + pcFace;
|
|
|
|
vid.scfg.joyaction[0][5] = 16 + pcFaceFire;
|
|
|
|
|
|
|
|
vid.scfg.joyaction[1][0] = 32 + pcFire;
|
|
|
|
vid.scfg.joyaction[1][1] = 32 + pcOrbPower;
|
|
|
|
vid.scfg.joyaction[1][2] = 32 + pcDrop;
|
|
|
|
vid.scfg.joyaction[1][3] = 32 + pcCenter;
|
|
|
|
vid.scfg.joyaction[1][4] = 32 + pcFace;
|
|
|
|
vid.scfg.joyaction[1][5] = 32 + pcFaceFire;
|
|
|
|
|
|
|
|
vid.scfg.axeaction[0][0] = 4;
|
|
|
|
vid.scfg.axeaction[0][1] = 5;
|
|
|
|
vid.scfg.axeaction[0][3] = 2;
|
|
|
|
vid.scfg.axeaction[0][4] = 3;
|
|
|
|
|
|
|
|
vid.scfg.axeaction[1][0] = 8;
|
|
|
|
vid.scfg.axeaction[1][1] = 9;
|
|
|
|
|
|
|
|
// ULRD
|
|
|
|
vid.scfg.hataction[0][0][0] = 16 + 0;
|
|
|
|
vid.scfg.hataction[0][0][1] = 16 + 3;
|
|
|
|
vid.scfg.hataction[0][0][2] = 16 + 1;
|
|
|
|
vid.scfg.hataction[0][0][3] = 16 + 2;
|
|
|
|
vid.scfg.hataction[0][1][0] = 16 + 4;
|
|
|
|
vid.scfg.hataction[0][1][1] = 16 + 7;
|
|
|
|
vid.scfg.hataction[0][1][2] = 16 + 5;
|
|
|
|
vid.scfg.hataction[0][1][3] = 16 + 6;
|
|
|
|
|
|
|
|
vid.scfg.hataction[1][0][0] = 32 + 0;
|
|
|
|
vid.scfg.hataction[1][0][1] = 32 + 3;
|
|
|
|
vid.scfg.hataction[1][0][2] = 32 + 1;
|
|
|
|
vid.scfg.hataction[1][0][3] = 32 + 2;
|
|
|
|
vid.scfg.hataction[1][1][0] = 32 + 4;
|
|
|
|
vid.scfg.hataction[1][1][1] = 32 + 7;
|
|
|
|
vid.scfg.hataction[1][1][2] = 32 + 5;
|
|
|
|
vid.scfg.hataction[1][1][3] = 32 + 6;
|
|
|
|
|
|
|
|
int charidtable[MAXPLAYER] = {0, 1, 4, 6, 2, 3, 0};
|
|
|
|
|
|
|
|
for(int i=0; i<MAXPLAYER; i++) {
|
|
|
|
initcs(multi::scs[i]);
|
|
|
|
multi::scs[i].charid = charidtable[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
multi::scs[0].uicolor = 0xC00000FF;
|
|
|
|
multi::scs[1].uicolor = 0x00C000FF;
|
|
|
|
multi::scs[2].uicolor = 0x0000C0FF;
|
|
|
|
multi::scs[3].uicolor = 0xC0C000FF;
|
|
|
|
multi::scs[4].uicolor = 0xC000C0FF;
|
|
|
|
multi::scs[5].uicolor = 0x00C0C0FF;
|
|
|
|
multi::scs[6].uicolor = 0xC0C0C0FF;
|
2017-07-16 21:00:55 +00:00
|
|
|
|
2018-11-18 02:18:11 +00:00
|
|
|
addsaver(multi::players, "mode-number of players");
|
2017-07-16 21:00:55 +00:00
|
|
|
addsaver(alwaysuse, "use configured keys");
|
|
|
|
// unfortunately we cannot use key names here because SDL is not yet initialized
|
|
|
|
for(int i=0; i<512; i++)
|
|
|
|
addsaver(vid.scfg.keyaction[i], string("key:")+its(i));
|
|
|
|
for(int i=0; i<MAXJOY; i++) {
|
|
|
|
string pre = "joystick "+cts('A'+i);
|
|
|
|
for(int j=0; j<MAXBUTTON; j++)
|
|
|
|
addsaver(vid.scfg.joyaction[i][j], pre+"-B"+its(j));
|
|
|
|
for(int j=0; j<MAXAXE; j++) {
|
|
|
|
addsaver(vid.scfg.axeaction[i][j], pre+" axis "+its(j));
|
|
|
|
addsaver(vid.scfg.deadzoneval[i][j], pre+" deadzone "+its(j));
|
|
|
|
}
|
|
|
|
for(int j=0; j<MAXHAT; j++) for(int k=0; k<4; k++) {
|
|
|
|
addsaver(vid.scfg.hataction[i][j][k], pre+" hat "+its(j)+" "+"URDL"[k]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int i=0; i<7; i++) addsaver(multi::scs[i], "player"+its(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
void handleInput(int delta) {
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_SDL
|
2017-07-16 21:00:55 +00:00
|
|
|
double d = delta / 500.;
|
|
|
|
|
|
|
|
Uint8 *keystate = SDL_GetKeyState(NULL);
|
|
|
|
|
|
|
|
for(int i=0; i<NUMACT; i++)
|
|
|
|
lactionpressed[i] = actionspressed[i],
|
|
|
|
actionspressed[i] = 0;
|
|
|
|
|
|
|
|
for(int i=0; i<SHMUPAXES; i++) axespressed[i] = 0;
|
|
|
|
|
|
|
|
for(int i=0; i<SDLK_LAST; i++) if(keystate[i])
|
|
|
|
pressaction(vid.scfg.keyaction[i]);
|
2017-08-13 18:49:38 +00:00
|
|
|
|
2017-10-15 23:22:24 +00:00
|
|
|
#if CAP_SDLJOY
|
2017-07-16 21:00:55 +00:00
|
|
|
for(int j=0; j<numsticks; j++) {
|
|
|
|
|
|
|
|
for(int b=0; b<SDL_JoystickNumButtons(sticks[j]) && b<MAXBUTTON; b++)
|
|
|
|
if(SDL_JoystickGetButton(sticks[j], b))
|
|
|
|
pressaction(vid.scfg.joyaction[j][b]);
|
|
|
|
|
|
|
|
for(int b=0; b<SDL_JoystickNumHats(sticks[j]) && b<MAXHAT; b++) {
|
|
|
|
int stat = SDL_JoystickGetHat(sticks[j], b);
|
|
|
|
if(stat & SDL_HAT_UP) pressaction(vid.scfg.hataction[j][b][0]);
|
|
|
|
if(stat & SDL_HAT_RIGHT) pressaction(vid.scfg.hataction[j][b][1]);
|
|
|
|
if(stat & SDL_HAT_DOWN) pressaction(vid.scfg.hataction[j][b][2]);
|
|
|
|
if(stat & SDL_HAT_LEFT) pressaction(vid.scfg.hataction[j][b][3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int b=0; b<SDL_JoystickNumAxes(sticks[j]) && b<MAXAXE; b++) {
|
|
|
|
int value = SDL_JoystickGetAxis(sticks[j], b);
|
|
|
|
int dz = vid.scfg.deadzoneval[j][b];
|
|
|
|
if(value > dz) value -= dz; else if(value < -dz) value += dz;
|
|
|
|
else value = 0;
|
|
|
|
axespressed[vid.scfg.axeaction[j][b] % SHMUPAXES] += value;
|
|
|
|
}
|
|
|
|
}
|
2017-08-13 18:49:38 +00:00
|
|
|
#endif
|
2017-07-16 21:00:55 +00:00
|
|
|
|
|
|
|
if(keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL]) d /= 5;
|
|
|
|
|
|
|
|
double panx =
|
|
|
|
actionspressed[49] - actionspressed[51] + axespressed[2] / 32000.0;
|
|
|
|
double pany =
|
|
|
|
actionspressed[50] - actionspressed[48] + axespressed[3] / 20000.0;
|
|
|
|
|
|
|
|
double panspin = actionspressed[52] - actionspressed[53] + axespressed[1] / 20000.0;
|
|
|
|
|
2019-02-25 13:51:51 +00:00
|
|
|
double panmove = actionspressed[59] - actionspressed[60] + axespressed[4] / 20000.0;
|
|
|
|
|
2017-07-16 21:00:55 +00:00
|
|
|
if(actionspressed[54]) { centerplayer = -1, playermoved = true; centerpc(100); }
|
|
|
|
|
|
|
|
if(actionspressed[55] && !lactionpressed[55])
|
2018-11-17 18:24:02 +00:00
|
|
|
get_o_key().second();
|
2017-07-16 21:00:55 +00:00
|
|
|
|
|
|
|
if(actionspressed[56] && !lactionpressed[56])
|
|
|
|
showMissionScreen();
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_INV
|
2017-10-15 22:20:32 +00:00
|
|
|
if(actionspressed[57] && !lactionpressed[57] && inv::on)
|
2017-07-16 21:00:55 +00:00
|
|
|
pushScreen(inv::show);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(actionspressed[58] && !lactionpressed[58])
|
|
|
|
pushScreen(showMainMenu);
|
2019-02-26 01:35:30 +00:00
|
|
|
|
|
|
|
panx *= d;
|
|
|
|
pany *= d;
|
|
|
|
panspin *= d;
|
|
|
|
panmove *= d;
|
|
|
|
|
|
|
|
if(lctrlclick) {
|
|
|
|
panx += mouseaim_x / 2;
|
|
|
|
pany += mouseaim_y / 2;
|
|
|
|
mouseaim_x = mouseaim_y = 0;
|
|
|
|
}
|
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
if(panx || pany || panspin || (WDIM == 3 && panmove)) {
|
2019-02-25 13:51:51 +00:00
|
|
|
if(DIM == 2)
|
2019-02-26 01:35:30 +00:00
|
|
|
View = xpush(-panx) * ypush(-pany) * spin(panspin) * View;
|
2019-02-25 13:51:51 +00:00
|
|
|
else
|
2019-02-26 01:35:30 +00:00
|
|
|
View = cspin(0, 2, panx*2) * cspin(0, 1, pany*2) * spin(panspin) * cpush(2, panmove*2) * View;
|
2017-07-16 21:00:55 +00:00
|
|
|
playermoved = false;
|
|
|
|
}
|
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
2017-07-16 21:00:55 +00:00
|
|
|
int tableid[7] = {1, 2, 4, 5, 6, 7, 8};
|
|
|
|
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void leaveGame(int i) {
|
2018-08-17 22:46:45 +00:00
|
|
|
multi::player[i].at = NULL;
|
2017-03-23 10:53:57 +00:00
|
|
|
multi::deaths[i]++;
|
|
|
|
revive_queue.push_back(i);
|
|
|
|
checklastmove();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool playerActive(int p) {
|
|
|
|
if(multi::players == 1 || shmup::on) return true;
|
2018-08-17 22:46:45 +00:00
|
|
|
return player[p].at;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int activePlayers() {
|
|
|
|
int q = 0;
|
|
|
|
for(int i=0; i<players; i++) if(playerActive(i)) q++;
|
|
|
|
return q;
|
|
|
|
}
|
|
|
|
|
|
|
|
cell *multiPlayerTarget(int i) {
|
|
|
|
cellwalker cwti = multi::player[i];
|
2018-08-17 22:46:45 +00:00
|
|
|
if(!cwti.at) return NULL;
|
2017-03-23 10:53:57 +00:00
|
|
|
int dir = multi::whereto[i].d;
|
|
|
|
if(dir == MD_UNDECIDED) return NULL;
|
|
|
|
if(dir == MD_USE_ORB) return multi::whereto[i].tgt;
|
2018-03-24 11:59:01 +00:00
|
|
|
if(dir >= 0)
|
|
|
|
cwti = cwti + dir + wstep;
|
2018-08-17 22:46:45 +00:00
|
|
|
return cwti.at;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void checklastmove() {
|
|
|
|
for(int i=0; i<numplayers(); i++) if(playerActive(i)) {
|
|
|
|
multi::cpid = i;
|
|
|
|
cwt = multi::player[i]; break;
|
|
|
|
}
|
|
|
|
if(multi::activePlayers() == 1) {
|
|
|
|
multi::checkonly = true;
|
|
|
|
checkmove();
|
|
|
|
multi::checkonly = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool needinput = true;
|
|
|
|
|
|
|
|
void handleMulti(int delta) {
|
|
|
|
multi::handleInput(delta);
|
|
|
|
|
|
|
|
transmatrix bcwtV = cwtV;
|
|
|
|
cellwalker bcwt = cwt;
|
|
|
|
|
|
|
|
bool alldecided = !needinput;
|
|
|
|
|
|
|
|
if(multi::players == 1) {
|
|
|
|
multi::cpid = 0;
|
|
|
|
multi::whereis[0] = cwtV;
|
|
|
|
multi::player[0] = cwt;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<numplayers(); i++) if(playerActive(i)) {
|
|
|
|
|
|
|
|
using namespace multi;
|
|
|
|
|
|
|
|
// todo refactor
|
|
|
|
|
|
|
|
cpid = i;
|
|
|
|
|
|
|
|
int b = 16*tableid[cpid];
|
|
|
|
for(int ik=0; ik<8; ik++) if(actionspressed[b+ik]) playermoved = true;
|
|
|
|
for(int ik=0; ik<16; ik++) if(actionspressed[b+ik] && !lactionpressed[b+ik])
|
|
|
|
multi::combo[i] = false;
|
|
|
|
|
|
|
|
bool anypressed = false;
|
|
|
|
|
|
|
|
int jb = 4*tableid[cpid];
|
|
|
|
for(int ik=0; ik<4; ik++)
|
|
|
|
if(axespressed[jb+ik])
|
|
|
|
anypressed = true, playermoved = true, multi::combo[i] = false;
|
|
|
|
|
|
|
|
double mdx =
|
|
|
|
(actionspressed[b+0] + actionspressed[b+2] - actionspressed[b+1] - actionspressed[b+3]) * .7 +
|
|
|
|
actionspressed[b+pcMoveRight] - actionspressed[b+pcMoveLeft] + axespressed[jb]/30000.;
|
|
|
|
double mdy =
|
|
|
|
(actionspressed[b+3] + actionspressed[b+2] - actionspressed[b+1] - actionspressed[b+0]) * .7 +
|
|
|
|
actionspressed[b+pcMoveDown] - actionspressed[b+pcMoveUp] + axespressed[jb+1]/30000.;
|
|
|
|
|
|
|
|
if((actionspressed[b+pcMoveRight] && actionspressed[b+pcMoveLeft]) ||
|
|
|
|
(actionspressed[b+pcMoveUp] && actionspressed[b+pcMoveDown]))
|
|
|
|
multi::mdx[i] = multi::mdy[i] = 0;
|
|
|
|
|
|
|
|
multi::mdx[i] = multi::mdx[i] * (1 - delta / 1000.) + mdx * delta / 2000.;
|
|
|
|
multi::mdy[i] = multi::mdy[i] * (1 - delta / 1000.) + mdy * delta / 2000.;
|
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 2) {
|
2019-02-24 18:40:01 +00:00
|
|
|
if(mdx != 0 || mdy != 0) if(!multi::combo[i]) {
|
|
|
|
cwtV = multi::whereis[i]; cwt = multi::player[i];
|
|
|
|
flipplayer = multi::flipped[i];
|
|
|
|
multi::whereto[i] = vectodir(hpxy(multi::mdx[i], multi::mdy[i]));
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(multi::actionspressed[b+pcFire] ||
|
|
|
|
(multi::actionspressed[b+pcMoveLeft] && multi::actionspressed[b+pcMoveRight]))
|
|
|
|
multi::combo[i] = true, multi::whereto[i].d = MD_WAIT;
|
|
|
|
|
|
|
|
if(multi::actionspressed[b+pcFace])
|
|
|
|
multi::whereto[i].d = MD_UNDECIDED;
|
|
|
|
|
2018-08-17 22:46:45 +00:00
|
|
|
cwt.at = multi::player[i].at;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(multi::ccat[i] && !multi::combo[i] && targetRangedOrb(multi::ccat[i], roMultiCheck)) {
|
|
|
|
multi::whereto[i].d = MD_USE_ORB;
|
|
|
|
multi::whereto[i].tgt = multi::ccat[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(multi::actionspressed[b+pcFaceFire] && activePlayers() > 1) {
|
|
|
|
addMessage(XLAT("Left the game."));
|
|
|
|
multi::leaveGame(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(actionspressed[b+pcDrop] ||
|
|
|
|
(multi::actionspressed[b+pcMoveUp] && multi::actionspressed[b+pcMoveDown]))
|
|
|
|
multi::combo[i] = true, multi::whereto[i].d = MD_DROP;
|
|
|
|
|
|
|
|
if(actionspressed[b+pcCenter]) {
|
|
|
|
centerplayer = cpid; centerpc(100); playermoved = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(multi::whereto[i].d == MD_UNDECIDED) alldecided = false;
|
|
|
|
|
|
|
|
for(int ik=0; ik<16; ik++) if(actionspressed[b+ik]) anypressed = true;
|
|
|
|
|
|
|
|
if(anypressed) alldecided = false, needinput = false;
|
|
|
|
else multi::mdx[i] = multi::mdy[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cwtV = bcwtV;
|
|
|
|
cwt = bcwt;
|
|
|
|
|
|
|
|
if(alldecided) {
|
|
|
|
flashMessages();
|
|
|
|
// check for crashes
|
|
|
|
needinput = true;
|
|
|
|
|
|
|
|
for(int i=0; i<numplayers(); i++) if(playerActive(i)) {
|
2018-08-17 22:46:45 +00:00
|
|
|
origpos[i] = player[i].at;
|
2017-03-23 10:53:57 +00:00
|
|
|
origtarget[i] = multiPlayerTarget(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<numplayers(); i++) if(playerActive(i))
|
|
|
|
for(int j=0; j<numplayers(); j++) if(playerActive(j)) if(i != j) {
|
|
|
|
if(origtarget[i] == origtarget[j]) {
|
|
|
|
addMessage("Two players cannot move/attack the same location!");
|
|
|
|
return;
|
|
|
|
}
|
2018-08-17 22:46:45 +00:00
|
|
|
/* if(multiPlayerTarget(i) == multi::player[j].at) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage("Cannot move into the current location of another player!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(celldistance(multiPlayerTarget(i), multiPlayerTarget(j)) > 8) {
|
|
|
|
addMessage("Players cannot get that far away!");
|
|
|
|
return;
|
|
|
|
} */
|
|
|
|
}
|
|
|
|
|
|
|
|
if(multi::players == 1) {
|
|
|
|
if(movepcto(multi::whereto[0]))
|
|
|
|
multi::whereto[0].d = MD_UNDECIDED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
multi::cpid = 0;
|
|
|
|
if(multimove()) {
|
|
|
|
multi::aftermove = false;
|
|
|
|
monstersTurn();
|
|
|
|
checklastmove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mousemovement(cell *c) {
|
|
|
|
if(!c) return;
|
|
|
|
int countplayers = 0;
|
|
|
|
int countplayers_undecided = 0;
|
|
|
|
for(int i=0; i<multi::players; i++)
|
|
|
|
if(multi::playerActive(i) && (playerpos(i) == c || isNeighbor(c, playerpos(i)))) {
|
|
|
|
countplayers++;
|
|
|
|
if(multi::whereto[i].d == MD_UNDECIDED) countplayers_undecided++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<multi::players; i++)
|
|
|
|
if(multi::playerActive(i) && (playerpos(i) == c || isNeighbor(c, playerpos(i)))) {
|
|
|
|
int& cdir = multi::whereto[i].d;
|
|
|
|
int scdir = cdir;
|
|
|
|
bool isUndecided = cdir == MD_UNDECIDED;
|
|
|
|
if(countplayers_undecided > 0 && ! isUndecided) continue;
|
|
|
|
if(playerpos(i) == c)
|
|
|
|
multi::whereto[i].d = MD_WAIT;
|
|
|
|
else {
|
|
|
|
for(int d=0; d<playerpos(i)->type; d++) {
|
|
|
|
cdir = d;
|
|
|
|
if(multi::multiPlayerTarget(i) == c) break;
|
|
|
|
cdir = scdir;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
needinput =
|
|
|
|
((countplayers == 2 && !countplayers_undecided) || countplayers_undecided >= 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-08-26 09:58:03 +00:00
|
|
|
const char *lastprofile = "";
|
|
|
|
int lt = 0;
|
|
|
|
|
|
|
|
void profile(const char *buf) {
|
|
|
|
int gt = SDL_GetTicks();
|
|
|
|
printf("%4d %s\n", gt - lt, lastprofile);
|
|
|
|
lt = gt;
|
|
|
|
lastprofile = buf;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
*/
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-02-28 02:38:22 +00:00
|
|
|
#define SCALE scalefactor
|
2016-08-26 09:58:03 +00:00
|
|
|
#define SCALE2 (SCALE*SCALE)
|
|
|
|
|
|
|
|
namespace shmup {
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
using namespace multi;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
eItem targetRangedOrbKey(orbAction a);
|
|
|
|
eItem keyresult[MAXPLAYER];
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
ld fabsl(ld x) { return x>0?x:-x; }
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-04-28 10:09:57 +00:00
|
|
|
bool on = false;
|
|
|
|
bool delayed_safety = false;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
bool lastdead = false;
|
|
|
|
|
|
|
|
struct monster;
|
|
|
|
|
|
|
|
multimap<cell*, monster*> monstersAt;
|
|
|
|
|
|
|
|
typedef multimap<cell*, monster*>::iterator mit;
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
vector<monster*> active, nonvirtual, additional;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-03-17 03:08:17 +00:00
|
|
|
cell *findbaseAround(hyperpoint p, cell *around) {
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *best = around;
|
2019-04-30 01:35:23 +00:00
|
|
|
horo_distance d0(p, ggmatrix(around));
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<around->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = around->move(i);
|
2017-07-24 00:02:32 +00:00
|
|
|
if(c2) {
|
2019-04-30 01:35:23 +00:00
|
|
|
horo_distance d1(p, ggmatrix(c2));
|
2016-08-26 09:58:03 +00:00
|
|
|
if(d1 < d0) { best = c2; d0 = d1; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
cell *findbaseAround(const transmatrix& H, cell *around) {
|
|
|
|
return findbaseAround(tC0(H), around);
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
cell *findbaseAroundRepeat(hyperpoint p, cell *around) {
|
|
|
|
while(true) {
|
|
|
|
cell *c = findbaseAround(p, around);
|
|
|
|
if(c == around) return c;
|
|
|
|
around = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
cell *findbaseAroundRepeat(const transmatrix& H, cell *around) {
|
|
|
|
return findbaseAroundRepeat(tC0(H), around);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
/* double distance(hyperpoint h) {
|
|
|
|
h = spintox(h) * h;
|
2017-03-23 10:53:57 +00:00
|
|
|
return asinh(h[2]);
|
2016-08-26 09:58:03 +00:00
|
|
|
} */
|
|
|
|
|
2017-12-01 23:31:36 +00:00
|
|
|
void monster::store() {
|
|
|
|
monstersAt.insert(make_pair(base, this));
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-12-01 23:31:36 +00:00
|
|
|
void monster::findpat() {
|
|
|
|
isVirtual = !gmatrix.count(base);
|
|
|
|
if(!isVirtual) pat = gmatrix[base] * at;
|
|
|
|
else pat = at;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-12-01 23:31:36 +00:00
|
|
|
cell *monster::findbase(const transmatrix& T) {
|
|
|
|
if(isVirtual) {
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c = base;
|
2017-12-01 23:31:36 +00:00
|
|
|
auto cT = T;
|
|
|
|
virtualRebase(c, cT, true);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
else return findbaseAround(T, base);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-12-01 23:31:36 +00:00
|
|
|
void monster::rebasePat(const transmatrix& new_pat) {
|
2018-06-21 23:48:46 +00:00
|
|
|
if(isVirtual) {
|
2017-12-01 23:31:36 +00:00
|
|
|
at = new_pat;
|
2018-06-21 23:48:46 +00:00
|
|
|
virtualRebase(this, true);
|
2017-12-01 23:31:36 +00:00
|
|
|
fixmatrix(at); pat = at;
|
|
|
|
return;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2019-04-03 18:37:31 +00:00
|
|
|
if(quotient) {
|
2017-12-01 23:31:36 +00:00
|
|
|
at = inverse(gmatrix[base]) * new_pat;
|
|
|
|
virtualRebase(this, true);
|
|
|
|
fixmatrix(at);
|
2019-04-03 18:37:31 +00:00
|
|
|
fixelliptic(at);
|
2017-12-01 23:31:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
pat = new_pat;
|
|
|
|
cell *c2 = findbase(pat);
|
|
|
|
// if(c2 != base) printf("rebase %p -> %p\n", base, c2);
|
|
|
|
base = c2;
|
|
|
|
at = inverse(gmatrix[c2]) * pat;
|
2019-05-08 20:48:59 +00:00
|
|
|
if(GDIM == 3 && WDIM == 2) {
|
|
|
|
for(int i=0; i<4; i++) at[i][2] = 0, at[2][i] = 0;
|
|
|
|
at[2][2] = 1;
|
|
|
|
}
|
2017-12-01 23:31:36 +00:00
|
|
|
fixmatrix(at);
|
|
|
|
fixelliptic(at);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-12-01 23:31:36 +00:00
|
|
|
bool trackroute(monster *m, transmatrix goal, double spd) {
|
|
|
|
cell *c = m->base;
|
|
|
|
|
|
|
|
// queuepoly(goal, shGrail, 0xFFFFFFC0);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-12-01 23:31:36 +00:00
|
|
|
transmatrix mat = inverse(m->pat) * goal;
|
|
|
|
|
|
|
|
transmatrix mat2 = spintox(mat*C0) * mat;
|
|
|
|
|
|
|
|
double d = 0, dist = asinh(mat2[0][2]);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-12-01 23:31:36 +00:00
|
|
|
while(d < dist) {
|
|
|
|
d += spd;
|
|
|
|
transmatrix nat = m->pat * rspintox(mat * C0) * xpush(d);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-12-01 23:31:36 +00:00
|
|
|
// queuepoly(nat, shKnife, 0xFFFFFFC0);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-12-01 23:31:36 +00:00
|
|
|
cell *c2 = findbaseAround(nat, c);
|
|
|
|
if(c2 != c && !passable_for(m->type, c2, c, P_CHAIN | P_ONPLAYER)) {
|
|
|
|
return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-12-01 23:31:36 +00:00
|
|
|
c = c2;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-12-01 23:31:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
monster *pc[MAXPLAYER], *mousetarget, *lmousetarget;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
int curtime, nextmove, nextdragon;
|
|
|
|
|
|
|
|
bool isBullet(monster *m) {
|
|
|
|
return isBulletType(m->type);
|
|
|
|
}
|
|
|
|
bool isPlayer(monster *m) { return m->type == moPlayer; }
|
|
|
|
bool isMonster(monster *m) { return m->type != moPlayer && m->type != moBullet; }
|
|
|
|
|
2018-07-09 17:32:34 +00:00
|
|
|
hookset<bool(shmup::monster*)> *hooks_kill;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void killMonster(monster* m, eMonster who_kills, int flags = 0) {
|
|
|
|
int tk = tkills();
|
2018-07-09 17:32:34 +00:00
|
|
|
if(callhandlers(false, hooks_kill, m)) return;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->dead) return;
|
|
|
|
m->dead = true;
|
|
|
|
if(isBullet(m) || isPlayer(m)) return;
|
|
|
|
m->stk = m->base->monst;
|
|
|
|
if(m->inBoat && isWatery(m->base)) {
|
|
|
|
m->base->wall = waBoat;
|
|
|
|
m->base->mondir = 0;
|
|
|
|
m->inBoat = false;
|
|
|
|
}
|
|
|
|
else if(m->inBoat && m->base->wall == waNone && (
|
|
|
|
(m->base->land == laOcean || m->base->land == laLivefjord))) {
|
|
|
|
m->base->wall = waStrandedBoat;
|
|
|
|
m->base->mondir = 0;
|
|
|
|
m->inBoat = false;
|
|
|
|
}
|
|
|
|
m->base->monst = m->type;
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(m->base, who_kills, flags);
|
2016-08-26 09:58:03 +00:00
|
|
|
m->base->monst = m->stk;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(multi::cpid >= 0)
|
|
|
|
multi::kills[multi::cpid] += tkills() - tk;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pushmonsters() {
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m: nonvirtual) {
|
2017-03-23 10:53:57 +00:00
|
|
|
m->notpushed = isPlayer(m) || m->dead || (m->base->monst && m->base->monst != m->type);
|
|
|
|
if(!m->notpushed) {
|
2016-08-26 09:58:03 +00:00
|
|
|
m->stk = m->base->monst;
|
|
|
|
m->base->monst = m->type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void popmonsters() {
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=isize(nonvirtual)-1; i>=0; i--) {
|
2017-05-31 16:33:50 +00:00
|
|
|
monster *m = nonvirtual[i];
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!m->notpushed) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->type == m->base->monst)
|
|
|
|
m->base->monst = m->stk;
|
|
|
|
else {
|
|
|
|
m->dead = true; // already killed
|
2017-03-23 10:53:57 +00:00
|
|
|
// also kill all the other monsters pushed there
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int j=0; j<i; j++) {
|
|
|
|
monster *m2 = active[j];
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m2->base == m->base && !m2->notpushed)
|
|
|
|
killMonster(m2, moNone);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void degradeDemons() {
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster* m: nonvirtual) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->type == moGreater) m->type = moLesser;
|
|
|
|
if(m->stk == moGreater) m->type = moLesser;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// we need these for the Mimics!
|
2019-05-08 20:48:59 +00:00
|
|
|
double playerturn[MAXPLAYER], playergo[MAXPLAYER], playerstrafe[MAXPLAYER], playerturny[MAXPLAYER], playergoturn[MAXPLAYER], godir[MAXPLAYER];
|
2017-03-23 10:53:57 +00:00
|
|
|
bool playerfire[MAXPLAYER];
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
void awakenMimics(monster *m, cell *c2) {
|
2017-07-22 23:33:27 +00:00
|
|
|
for(auto& mi: mirror::mirrors) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c = mi.second.at;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
transmatrix mirrortrans = Id;
|
|
|
|
if(mi.second.mirrored) mirrortrans[0][0] = -1;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(!gmatrix.count(c)) continue;
|
|
|
|
monster *m2 = new monster;
|
|
|
|
m2->base = c;
|
|
|
|
|
|
|
|
if(isBullet(m)) {
|
|
|
|
m2->parenttype = m->parenttype;
|
|
|
|
m2->type = m->type;
|
|
|
|
m2->vel = m->vel;
|
|
|
|
m2->parent = m->parent;
|
|
|
|
m2->pid = m->pid;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m2->type = moMimic;
|
|
|
|
|
|
|
|
hyperpoint H = inverse(gmatrix[c2]) * gmatrix[c] * C0;
|
|
|
|
|
|
|
|
transmatrix xfer = rgpushxto0(H);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(mi.second.mirrored) {
|
|
|
|
hyperpoint H2 = spintox(H) * H;
|
|
|
|
xfer = rspintox(H) * rpushxto0(H2) * mirrortrans * spintox(H);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-07-22 23:33:27 +00:00
|
|
|
|
|
|
|
m2->pat = gmatrix[c2] * xfer * inverse(gmatrix[c2]) * m->pat;
|
|
|
|
|
|
|
|
m2->at = inverse(gmatrix[c]) * m2->pat;
|
|
|
|
m2->pid = cpid;
|
|
|
|
|
|
|
|
additional.push_back(m2);
|
|
|
|
|
|
|
|
// if you don't understand it, don't worry,
|
|
|
|
// I don't understand it either
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-07-22 23:33:27 +00:00
|
|
|
mirror::mirrors.clear();
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int visibleAt;
|
|
|
|
|
|
|
|
void visibleFor(int t) {
|
|
|
|
visibleAt = max(visibleAt, curtime + t);
|
|
|
|
}
|
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
ld bullet_velocity(eMonster t) {
|
|
|
|
switch(t) {
|
|
|
|
case moBullet:
|
|
|
|
return 1/300.;
|
|
|
|
case moFireball:
|
|
|
|
return 1/500.;
|
|
|
|
case moCrushball:
|
|
|
|
return 1/1000.;
|
|
|
|
case moAirball:
|
|
|
|
return 1/200.;
|
|
|
|
case moArrowTrap:
|
|
|
|
return 1/200.;
|
|
|
|
case moTongue:
|
|
|
|
return 1/1500.;
|
|
|
|
default:
|
|
|
|
return 1/300.;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
int frontdir() { return WDIM == 2 ? 0 : 2; }
|
2019-03-30 16:51:37 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void shootBullet(monster *m) {
|
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = m->base;
|
|
|
|
bullet->at = m->at;
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3) bullet->at = bullet->at * cpush(2, 0.15 * SCALE);
|
2016-08-26 09:58:03 +00:00
|
|
|
bullet->type = moBullet;
|
|
|
|
bullet->parent = m;
|
|
|
|
bullet->pid = m->pid;
|
|
|
|
bullet->parenttype = m->type;
|
2019-03-30 16:51:37 +00:00
|
|
|
bullet->inertia = m->inertia;
|
|
|
|
bullet->inertia[frontdir()] += bullet_velocity(m->type) * SCALE;
|
|
|
|
bullet->hitpoints = 0;
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(bullet);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-10-11 20:16:07 +00:00
|
|
|
eItem orbdir[8] = {
|
|
|
|
itNone, itOrbSide1, itOrbThorns, itOrbSide2, itOrbSide3, itOrbSide2, itOrbThorns, itOrbSide1
|
|
|
|
};
|
|
|
|
|
|
|
|
for(int i=1; i<8; i++) if(markOrb(orbdir[i])) {
|
2016-08-26 09:58:03 +00:00
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = m->base;
|
2017-10-11 20:16:07 +00:00
|
|
|
bullet->at = m->at * spin(M_PI/4*i);
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3) bullet->at = bullet->at * cpush(2, 0.15 * SCALE);
|
2016-08-26 09:58:03 +00:00
|
|
|
bullet->type = moBullet;
|
|
|
|
bullet->parent = m;
|
|
|
|
bullet->pid = m->pid;
|
|
|
|
bullet->parenttype = m->type;
|
2019-03-30 16:51:37 +00:00
|
|
|
bullet->hitpoints = 0;
|
|
|
|
using namespace hyperpoint_vec;
|
|
|
|
bullet->inertia = spin(-M_PI/4 * i) * m->inertia;
|
|
|
|
bullet->inertia[frontdir()] += bullet_velocity(m->type) * SCALE;
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(bullet);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void killThePlayer(eMonster m) {
|
2018-11-17 18:26:35 +00:00
|
|
|
if(cpid >= 0 && cpid < MAXPLAYER && pc[cpid])
|
|
|
|
pc[cpid]->dead = true;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
monster *playerCrash(monster *who, hyperpoint where) {
|
2017-05-31 16:33:50 +00:00
|
|
|
if(who->isVirtual) return NULL;
|
2018-11-17 18:30:50 +00:00
|
|
|
// in the racing mode, neither crashing nor getting too far away is a problem
|
|
|
|
if(racing::on) return NULL;
|
|
|
|
for(int j=0; j<players; j++) if(pc[j] && pc[j]!=who) {
|
2017-05-31 16:33:50 +00:00
|
|
|
if(pc[j]->isVirtual) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
double d = intval(pc[j]->pat*C0, where);
|
2019-05-08 20:48:59 +00:00
|
|
|
if(d < 0.1 * SCALE2 || d > 100 || (WDIM == 3 && hdist(tC0(pc[j]->pat), where) > sightranges[geometry]/2)) return pc[j];
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void oceanCurrents(transmatrix& nat, monster *m, int delta) {
|
|
|
|
cell *c = m->base;
|
|
|
|
if(c->land == laWhirlpool) {
|
|
|
|
for(int i=0; i<c->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = c->move(i);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!c2 || !gmatrix.count(c2)) continue;
|
|
|
|
|
|
|
|
double spd = 0;
|
|
|
|
|
|
|
|
if(celldistAlt(c2) < celldistAlt(c))
|
|
|
|
spd = SCALE * delta / 3000.;
|
|
|
|
else if(c2 == whirlpool::get(c, 1))
|
|
|
|
spd = SCALE * delta / 900.;
|
|
|
|
|
|
|
|
if(spd) {
|
|
|
|
transmatrix goal = gmatrix[c2];
|
|
|
|
|
|
|
|
// transmatrix t = spintox(H) * xpush(delta/300.) * rspintox(H);
|
|
|
|
|
|
|
|
hyperpoint H = inverse(m->pat) * goal * C0;
|
|
|
|
nat = nat * rspintox(H);
|
|
|
|
nat = nat * xpush(spd);
|
|
|
|
nat = nat * spintox(H);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-11 20:16:07 +00:00
|
|
|
bool airCurrents(transmatrix& nat, monster *m, int delta) {
|
|
|
|
bool carried = false;
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c = m->base;
|
2019-02-17 17:37:23 +00:00
|
|
|
#if CAP_COMPLEX2
|
2019-05-05 15:37:51 +00:00
|
|
|
if(false && c->land == laWestWall) {
|
2019-01-11 01:23:44 +00:00
|
|
|
cell *c2 = ts::left_of(c, westwall::coastvalEdge1);
|
|
|
|
|
|
|
|
double spd = SCALE * delta / 900.;
|
|
|
|
|
|
|
|
if(m->type == moVoidBeast) spd = -spd;
|
|
|
|
if(spd) {
|
|
|
|
transmatrix goal = gmatrix[c2];
|
|
|
|
|
|
|
|
// transmatrix t = spintox(H) * xpush(delta/300.) * rspintox(H);
|
|
|
|
|
|
|
|
hyperpoint H = inverse(m->pat) * goal * C0;
|
|
|
|
nat = nat * rspintox(H);
|
|
|
|
nat = nat * xpush(spd);
|
|
|
|
nat = nat * spintox(H);
|
|
|
|
carried = true;
|
|
|
|
}
|
|
|
|
}
|
2019-02-17 17:37:23 +00:00
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c->land == laWhirlwind) {
|
|
|
|
whirlwind::calcdirs(c);
|
|
|
|
for(int i=0; i<whirlwind::qdirs; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = c->move(whirlwind::dto[i]);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(!c2 || !gmatrix.count(c2)) continue;
|
|
|
|
|
|
|
|
double spd = SCALE * delta / 900.;
|
|
|
|
|
2017-10-11 20:16:07 +00:00
|
|
|
if(m->type == moVoidBeast) spd = -spd;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(spd) {
|
|
|
|
transmatrix goal = gmatrix[c2];
|
|
|
|
|
|
|
|
// transmatrix t = spintox(H) * xpush(delta/300.) * rspintox(H);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
hyperpoint H = inverse(m->pat) * goal * C0;
|
|
|
|
nat = nat * rspintox(H);
|
|
|
|
nat = nat * xpush(spd);
|
|
|
|
nat = nat * spintox(H);
|
2017-10-11 20:16:07 +00:00
|
|
|
carried = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
2019-02-17 17:33:15 +00:00
|
|
|
#if CAP_FIELD
|
2017-10-11 20:16:07 +00:00
|
|
|
if(c->land == laBlizzard) {
|
|
|
|
int wmc = windmap::at(c);
|
|
|
|
forCellEx(c2, c) {
|
|
|
|
if(!c2 || !gmatrix.count(c2)) continue;
|
|
|
|
int z = (windmap::at(c2) - wmc) & 255;
|
|
|
|
if(z >= 128) z -= 256;
|
|
|
|
if(m->type == moVoidBeast) z = -z;
|
|
|
|
if(z < windmap::NOWINDFROM && z > -windmap::NOWINDFROM) {
|
|
|
|
transmatrix goal = gmatrix[c2];
|
|
|
|
|
|
|
|
// transmatrix t = spintox(H) * xpush(delta/300.) * rspintox(H);
|
|
|
|
|
|
|
|
hyperpoint H = inverse(m->pat) * goal * C0;
|
|
|
|
nat = nat * rspintox(H);
|
|
|
|
nat = nat * xpush(z * SCALE * delta / 50000.);
|
|
|
|
nat = nat * spintox(H);
|
|
|
|
carried = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-17 17:33:15 +00:00
|
|
|
#endif
|
2017-10-11 20:16:07 +00:00
|
|
|
return carried;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void roseCurrents(transmatrix& nat, monster *m, int delta) {
|
|
|
|
if(ignoresSmell(m->type)) return;
|
|
|
|
cell *c = m->base;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int qty = 0;
|
|
|
|
|
|
|
|
for(int i=0; i<c->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = c->move(i);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2 && rosedist(c2) == 2) qty++;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int i=0; i<c->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = c->move(i);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!c2 || !gmatrix.count(c2)) continue;
|
|
|
|
if(rosedist(c2) != 2) continue;
|
|
|
|
|
|
|
|
double spd = SCALE * delta / 300. / qty;
|
|
|
|
|
|
|
|
if(spd) {
|
|
|
|
transmatrix goal = gmatrix[c2];
|
|
|
|
|
|
|
|
// transmatrix t = spintox(H) * xpush(delta/300.) * rspintox(H);
|
|
|
|
|
|
|
|
hyperpoint H = inverse(m->pat) * goal * C0;
|
|
|
|
nat = nat * rspintox(H);
|
|
|
|
nat = nat * xpush(spd);
|
|
|
|
nat = nat * spintox(H);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hyperpoint keytarget(int i) {
|
|
|
|
double d = 2 + sin(curtime / 350.);
|
2019-05-08 20:48:59 +00:00
|
|
|
return pc[i]->pat * cpush0(WDIM == 3 ? 2 : 0, d * scalefactor);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* int charidof(int pid) {
|
|
|
|
if(players == 1) return bak_charid;
|
|
|
|
if(players == 2 || players == 4) return pid;
|
|
|
|
if(players == 3) return pid < 2 ? pid : 2+(bak_charid&1);
|
|
|
|
return 0;
|
|
|
|
} */
|
|
|
|
|
2019-05-04 16:28:03 +00:00
|
|
|
ld getSwordSize() { return sword_size; }
|
|
|
|
ld getHornsSize() { return scalefactor * 0.33; }
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2019-03-09 16:38:23 +00:00
|
|
|
// used in 3D
|
|
|
|
transmatrix swordmatrix[MAXPLAYER];
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
hyperpoint swordpos(int id, bool rev, double frac) {
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3)
|
2019-03-09 16:38:23 +00:00
|
|
|
return pc[id]->pat * swordmatrix[id] * cpush0(2, (rev?-frac:frac) * getSwordSize());
|
|
|
|
else
|
|
|
|
return pc[id]->pat * xspinpush0(pc[id]->swordangle, (rev?-frac:frac) * getSwordSize());
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
hyperpoint hornpos(int id) {
|
2018-08-19 14:28:36 +00:00
|
|
|
return pc[id]->pat * xpush0(getHornsSize());
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define IGO 9
|
|
|
|
|
2017-08-13 17:14:16 +00:00
|
|
|
double igospan[IGO+1] = { 0,
|
2017-03-23 10:53:57 +00:00
|
|
|
M_PI/6, -M_PI/6,
|
|
|
|
M_PI/4, -M_PI/4,
|
|
|
|
M_PI/3, -M_PI/3,
|
2017-08-13 17:14:16 +00:00
|
|
|
M_PI/2.1, -M_PI/2.1,
|
|
|
|
0
|
2017-03-23 10:53:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool swordKills(eMonster m) {
|
|
|
|
return
|
|
|
|
m != moHedge && m != moMetalBeast && m != moMetalBeast2
|
|
|
|
&& m != moTortoise && m != moGreater && m != moRoseBeauty
|
2017-10-11 20:16:07 +00:00
|
|
|
&& m != moReptile && !isBull(m) && m != moButterfly &&
|
2019-01-11 01:23:44 +00:00
|
|
|
m != moSalamander && m != moTerraWarrior && m != moBrownBug;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool hornKills(eMonster m) {
|
|
|
|
return
|
|
|
|
m != moHedge && m != moMetalBeast && m != moMetalBeast2
|
|
|
|
&& m != moTortoise && m != moGreater && m != moSkeleton
|
|
|
|
&& m != moDraugr && m != moRoseBeauty
|
|
|
|
&& m != moReptile && !isBull(m) && m != moButterfly && !isBulletType(m)
|
2017-10-11 20:16:07 +00:00
|
|
|
&& m != moPalace && m != moFatGuard && m != moVizier &&
|
2019-01-11 01:23:44 +00:00
|
|
|
m != moSalamander && m != moTerraWarrior && m != moBrownBug;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 01:23:44 +00:00
|
|
|
queue<pair<int, cell*>> traplist, firetraplist;
|
2017-10-12 09:33:26 +00:00
|
|
|
|
|
|
|
void activateArrow(cell *c) {
|
|
|
|
if(isCentralTrap(c))
|
|
|
|
traplist.emplace(ticks + 500, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
monster arrowtrap_fakeparent;
|
|
|
|
|
|
|
|
void doTraps() {
|
|
|
|
while(true) {
|
2019-01-11 01:23:44 +00:00
|
|
|
if(traplist.empty()) break;
|
2017-10-12 09:33:26 +00:00
|
|
|
auto t = traplist.front();
|
2019-01-11 01:23:44 +00:00
|
|
|
if(t.first > ticks) break;
|
2017-10-12 09:33:26 +00:00
|
|
|
int d = t.second->wparam;
|
|
|
|
if(d == 2) {
|
|
|
|
auto tl = traplimits(t.second);
|
|
|
|
for(int i=1; i<4; i++) if(tl[i]) tl[i]->wparam = 3;
|
|
|
|
traplist.emplace(t.first + 500, t.second);
|
|
|
|
|
|
|
|
for(int i=0; i<5; i += 4) try {
|
|
|
|
transmatrix& tu = gmatrix.at(tl[i]);
|
|
|
|
transmatrix& tv = gmatrix.at(tl[4-i]);
|
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = tl[i];
|
|
|
|
bullet->at = rspintox(inverse(tu) * tC0(tv));
|
|
|
|
bullet->type = moArrowTrap;
|
|
|
|
bullet->parent = &arrowtrap_fakeparent;
|
|
|
|
bullet->pid = 0;
|
|
|
|
bullet->parenttype = moArrowTrap;
|
|
|
|
additional.push_back(bullet);
|
|
|
|
}
|
2018-06-07 11:58:00 +00:00
|
|
|
catch(out_of_range&) {}
|
2017-10-12 09:33:26 +00:00
|
|
|
}
|
|
|
|
else if(d == 3) {
|
|
|
|
auto tl = traplimits(t.second);
|
|
|
|
for(int i=1; i<4; i++) if(tl[i]) tl[i]->wparam = 0;
|
|
|
|
}
|
|
|
|
traplist.pop();
|
|
|
|
}
|
2019-01-11 01:23:44 +00:00
|
|
|
|
|
|
|
while(true) {
|
|
|
|
if(firetraplist.empty()) break;
|
|
|
|
auto t = firetraplist.front();
|
|
|
|
if(t.first > ticks) return;
|
|
|
|
int d = t.second->wparam;
|
|
|
|
if(d == 2) {
|
|
|
|
t.second->wparam = 0;
|
|
|
|
t.second->wall = waNone;
|
|
|
|
explosion(t.second, 5, 10);
|
|
|
|
}
|
|
|
|
firetraplist.pop();
|
|
|
|
}
|
2017-10-12 09:33:26 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool hornStuns(eMonster m) {
|
|
|
|
return !isBulletType(m) && m != moRoseBeauty;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool noncrashable(monster *m, monster *by) {
|
|
|
|
eMonster mt = m->type;
|
|
|
|
if(mt == moGreater) return true;
|
|
|
|
if(mt == moDraugr && by->type != moDraugr) return true;
|
|
|
|
if(isBull(mt)) return true;
|
|
|
|
if(mt == moReptile) return true;
|
2017-10-11 20:16:07 +00:00
|
|
|
if(mt == moSalamander) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(mt == moRoseBeauty && by->type != moRoseLady) return true;
|
|
|
|
if(mt == moTortoise) return true;
|
2017-10-11 20:16:07 +00:00
|
|
|
if(mt == moTerraWarrior) return true;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(mt == moSkeleton) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bulltime[MAXPLAYER];
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
// set to P_MIRRORWALL to allow the PCs to go through mirrors
|
|
|
|
static const int reflectflag = P_MIRRORWALL;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void movePlayer(monster *m, int delta) {
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2019-05-05 15:37:51 +00:00
|
|
|
bool falling = isGravityLand(m->base) && cellEdgeUnstable(m->base);
|
|
|
|
if(m->base->land == laWestWall) falling = true;
|
|
|
|
if(items[itOrbAether]) falling = false;
|
|
|
|
|
|
|
|
bool inertia_based = falling || m->base->land == laAsteroids;
|
2019-03-30 16:51:37 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
cpid = m->pid;
|
2018-11-17 18:30:50 +00:00
|
|
|
|
|
|
|
#if CAP_RACING
|
2019-03-09 15:20:06 +00:00
|
|
|
if(racing::on && cpid != subscreens::current_player) return;
|
2018-11-17 18:30:50 +00:00
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
double mturn = 0, mgo = 0, mdx = 0, mdy = 0;
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
bool shotkey = false, dropgreen = false, facemouse = false;
|
2017-05-31 16:33:50 +00:00
|
|
|
if(facemouse) {
|
|
|
|
// silence warning that facemouse unused
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
int b = 16*tableid[cpid];
|
2019-02-27 12:35:15 +00:00
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
for(int i=(WDIM == 3 ? 4 : 0); i<8; i++) if(actionspressed[b+i]) playermoved = true;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
int jb = 4*tableid[cpid];
|
|
|
|
for(int i=0; i<4; i++) if(axespressed[jb+i]) playermoved = true;
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if !ISMOBILE
|
2016-08-26 09:58:03 +00:00
|
|
|
mgo = actionspressed[b+pcForward] - actionspressed[b+pcBackward] + axespressed[jb+2]/30000.;
|
|
|
|
mturn = actionspressed[b+pcTurnLeft] - actionspressed[b+pcTurnRight] + axespressed[jb+3]/30000.;
|
|
|
|
mdx = actionspressed[b+pcMoveRight] - actionspressed[b+pcMoveLeft] + axespressed[jb]/30000.;
|
|
|
|
mdy = actionspressed[b+pcMoveDown] - actionspressed[b+pcMoveUp] + axespressed[jb+1]/30000.;
|
|
|
|
|
|
|
|
shotkey = actionspressed[b+pcFire] || actionspressed[b+pcFaceFire];
|
|
|
|
facemouse = actionspressed[b+pcFace] || actionspressed[b+pcFaceFire];
|
|
|
|
dropgreen = actionspressed[b+pcDrop];
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#else
|
2017-03-23 10:53:57 +00:00
|
|
|
mdx = mdy = mgo = mturn = 0;
|
|
|
|
facemouse = shotkey = false;
|
|
|
|
dropgreen = getcstat == 'g';
|
|
|
|
using namespace shmupballs;
|
|
|
|
|
|
|
|
if(clicked && hypot(mousex - xfire, mousey - yb) < rad) {
|
|
|
|
shotkey = true;
|
|
|
|
mdx = (mousex - xfire) / (rad/2.);
|
|
|
|
mdy = (mousey - yb) / (rad/2.);
|
|
|
|
}
|
|
|
|
if(clicked && hypot(mousex - xmove, mousey - yb) < rad) {
|
|
|
|
mdx = (mousex - xmove) / (rad/2.);
|
|
|
|
mdy = (mousey - yb) / (rad/2.);
|
|
|
|
}
|
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(actionspressed[b+pcOrbPower] && !lactionpressed[b+pcOrbPower] && mouseover) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cwt.at = m->base;
|
2016-08-26 09:58:03 +00:00
|
|
|
targetRangedOrb(mouseover, roKeyboard);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if !ISMOBILE
|
2016-08-26 09:58:03 +00:00
|
|
|
if(haveRangedOrb()) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cwt.at = m->base;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(actionspressed[b+pcOrbKey] && !lactionpressed[b+pcOrbKey])
|
|
|
|
keyresult[cpid] = targetRangedOrbKey(roKeyboard);
|
|
|
|
else
|
|
|
|
keyresult[cpid] = targetRangedOrbKey(roCheck);
|
|
|
|
}
|
|
|
|
else
|
2017-03-23 10:53:57 +00:00
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
keyresult[cpid] = itNone;
|
2018-11-18 02:44:23 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(actionspressed[b+pcCenter]) {
|
2018-11-18 02:44:23 +00:00
|
|
|
if(!racing::on) {
|
|
|
|
centerplayer = cpid; centerpc(100); playermoved = true;
|
|
|
|
}
|
|
|
|
#if CAP_RACING
|
|
|
|
if(racing::on)
|
|
|
|
racing::player_relative = !racing::player_relative;
|
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
transmatrix nat = m->pat;
|
|
|
|
|
|
|
|
// if(ka == b+pcOrbPower) dropgreen = true;
|
|
|
|
|
|
|
|
// if(mturn > 1) mturn = 1;
|
|
|
|
// if(mturn < -1) mturn = -1;
|
|
|
|
|
2018-11-17 18:30:50 +00:00
|
|
|
#if CAP_RACING
|
|
|
|
if(racing::on) {
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 2) {
|
2019-02-27 12:34:52 +00:00
|
|
|
if(abs(mdy) > abs(mgo)) mgo = -mdy;
|
|
|
|
if(abs(mdx) > abs(mturn)) mturn = -mdx;
|
|
|
|
mdx = mdy = 0;
|
|
|
|
}
|
2018-11-18 02:44:23 +00:00
|
|
|
facemouse = shotkey = dropgreen = false;
|
2019-05-08 20:48:59 +00:00
|
|
|
if(ticks < racing::race_start_tick || !racing::race_start_tick) (WDIM == 2 ? mgo : mdy) = 0;
|
2018-11-17 18:30:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
playerturn[cpid] = mturn * delta / 150.0;
|
2019-05-08 20:48:59 +00:00
|
|
|
|
|
|
|
godir[cpid] = 0;
|
|
|
|
|
|
|
|
if(WDIM == 2 && GDIM == 3) {
|
|
|
|
double mdd = hypot(mdx, mdy);
|
2019-05-09 19:55:17 +00:00
|
|
|
godir[cpid] = -atan2(mdx, -mdy);
|
2019-05-08 20:48:59 +00:00
|
|
|
mgo += mdd;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
else if(WDIM == 2) {
|
2019-02-24 18:40:01 +00:00
|
|
|
double mdd = hypot(mdx, mdy);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-02-24 18:40:01 +00:00
|
|
|
if(mdd > 1e-6) {
|
|
|
|
hyperpoint jh = hpxy(mdx/100.0, mdy/100.0);
|
|
|
|
hyperpoint ctr = m->pat * C0;
|
|
|
|
|
|
|
|
if(sphere && vid.alpha > 1.001) for(int i=0; i<3; i++) ctr[i] = -ctr[i];
|
|
|
|
|
|
|
|
hyperpoint h = inverse(m->pat) * rgpushxto0(ctr) * jh;
|
|
|
|
|
|
|
|
playerturn[cpid] = -atan2(h[1], h[0]);
|
|
|
|
mgo += mdd;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_SDL
|
2016-08-26 09:58:03 +00:00
|
|
|
Uint8 *keystate = SDL_GetKeyState(NULL);
|
|
|
|
bool forcetarget = (keystate[SDLK_RSHIFT] | keystate[SDLK_LSHIFT]);
|
2019-05-08 20:48:59 +00:00
|
|
|
if(((mousepressed && !forcetarget) || facemouse) && delta > 0 && !mouseout() && !racing::on && GDIM == 2) {
|
2016-08-26 09:58:03 +00:00
|
|
|
// playermoved = true;
|
|
|
|
hyperpoint h = inverse(m->pat) * mouseh;
|
|
|
|
playerturn[cpid] = -atan2(h[1], h[0]);
|
|
|
|
// nat = nat * spin(alpha);
|
|
|
|
// mturn += alpha * 150. / delta;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
bool blown = m->blowoff > curtime;
|
2019-05-08 20:48:59 +00:00
|
|
|
|
|
|
|
if(WDIM == 2 && GDIM == 3 && !lctrlclick && cpid == 0 && !racing::on) {
|
2019-05-09 19:55:17 +00:00
|
|
|
playerturn[cpid] -= mouseaim_x;
|
|
|
|
playerturny[cpid] -= mouseaim_y;
|
2019-05-08 20:48:59 +00:00
|
|
|
mouseaim_x = 0;
|
|
|
|
mouseaim_y = 0;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
if(playerturn[cpid] && canmove && !blown && WDIM == 2) {
|
2017-03-23 10:53:57 +00:00
|
|
|
m->swordangle -= playerturn[cpid];
|
|
|
|
nat = nat * spin(playerturn[cpid]);
|
2019-03-30 16:51:37 +00:00
|
|
|
if(inertia_based) m->inertia = spin(-playerturn[cpid]) * m->inertia;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
transmatrix nat0 = nat;
|
|
|
|
|
|
|
|
if(m->base->land == laWhirlpool && !markOrb(itOrbWater))
|
|
|
|
oceanCurrents(nat, m, delta);
|
|
|
|
|
2017-10-11 20:16:07 +00:00
|
|
|
airCurrents(nat, m, delta);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(rosedist(m->base) == 1)
|
|
|
|
roseCurrents(nat, m, delta);
|
|
|
|
|
|
|
|
if(!canmove) mgo = 0;
|
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 2) {
|
2019-02-27 12:34:52 +00:00
|
|
|
if(mgo > 1) mgo = 1;
|
|
|
|
if(mgo < -1) mgo = -1;
|
|
|
|
if(racing::on) {
|
|
|
|
// braking is more efficient
|
|
|
|
if(m->vel * mgo < 0) mgo *= 3;
|
|
|
|
m->vel += mgo * delta / 600;
|
|
|
|
playergo[cpid] = m->vel * SCALE * delta / 600;
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
playergo[cpid] = mgo * SCALE * delta / 600;
|
|
|
|
}
|
2018-11-17 18:30:50 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
else if(WDIM == 3) {
|
2019-02-27 12:34:52 +00:00
|
|
|
if(mdy > 1) mdy = 1;
|
|
|
|
if(mdy < -1) mdy = -1;
|
|
|
|
if(mdx > 1) mdx = 1;
|
2019-03-30 16:51:37 +00:00
|
|
|
|
2019-02-27 12:34:52 +00:00
|
|
|
if(mdx < -1) mdx = -1;
|
|
|
|
if(racing::on) {
|
|
|
|
if(m->vel * -mdy < 0) mdy *= 3;
|
|
|
|
m->vel += -mdy * delta / 600;
|
|
|
|
playergo[cpid] = m->vel * SCALE * delta / 600;
|
|
|
|
playerstrafe[cpid] = m->vel * mdx * SCALE * delta / 600;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
playergo[cpid] = -mdy * SCALE * delta / 600;
|
|
|
|
playerstrafe[cpid] = mdx * SCALE * delta / 600;
|
|
|
|
}
|
2019-02-26 01:36:19 +00:00
|
|
|
playerturn[cpid] = mgo * SCALE * delta / 200;
|
|
|
|
playerturny[cpid] = mturn * SCALE * delta / 200;
|
2019-02-26 01:35:30 +00:00
|
|
|
|
2019-03-09 15:20:06 +00:00
|
|
|
if(!lctrlclick && cpid == 0) {
|
2019-02-26 01:35:30 +00:00
|
|
|
playerturn[cpid] += mouseaim_x;
|
|
|
|
playerturny[cpid] += mouseaim_y;
|
|
|
|
mouseaim_x = mouseaim_y = 0;
|
|
|
|
}
|
2019-02-25 13:51:51 +00:00
|
|
|
}
|
|
|
|
|
2017-10-11 20:16:07 +00:00
|
|
|
if(playergo[cpid] && markOrb(itOrbDash)) playergo[cpid] *= 1.5;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool go = false;
|
|
|
|
|
|
|
|
cell *c2 = m->base;
|
|
|
|
|
|
|
|
if(blown) {
|
|
|
|
playergo[cpid] = -SCALE * delta / 1000.;
|
|
|
|
playerturn[cpid] = 0;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
m->footphase += playergo[cpid];
|
|
|
|
|
|
|
|
if(isReptile(m->base->wall)) m->base->wparam = reptilemax();
|
2018-11-18 00:40:57 +00:00
|
|
|
|
|
|
|
int steps = 1 + abs(int(playergo[cpid] / (.2 * scalefactor)));
|
|
|
|
|
|
|
|
playergo[cpid] /= steps;
|
|
|
|
|
|
|
|
nextstep:
|
|
|
|
|
|
|
|
transmatrix nat1 = nat;
|
2019-03-30 16:51:37 +00:00
|
|
|
|
|
|
|
hyperpoint avg_inertia;
|
|
|
|
|
2019-04-20 23:02:31 +00:00
|
|
|
if(inertia_based && canmove) {
|
2019-05-05 15:37:51 +00:00
|
|
|
using namespace hyperpoint_vec;
|
2019-03-30 16:51:37 +00:00
|
|
|
avg_inertia = m->inertia;
|
2019-05-05 15:37:51 +00:00
|
|
|
ld coef = m->base->land == laWestWall ? 0.65 : falling ? 0.15 : 1;
|
|
|
|
coef /= 1000;
|
|
|
|
m->inertia[frontdir()] += coef * playergo[cpid];
|
|
|
|
avg_inertia[frontdir()] += coef * playergo[cpid] / 2;
|
|
|
|
if(falling) {
|
|
|
|
vector<cell*> below;
|
|
|
|
manual_celllister mcl;
|
|
|
|
mcl.add(m->base);
|
|
|
|
for(int i=0; i<isize(mcl.lst); i++) {
|
|
|
|
cell *c = mcl.lst[i];
|
|
|
|
bool go = false;
|
|
|
|
if(c->land == laMountain) {
|
|
|
|
int d = celldistAlt(c);
|
|
|
|
forCellEx(c2, c) if(celldistAlt(c2) > d && gmatrix.count(c2))
|
|
|
|
go = true, mcl.add(c2);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int d = coastvalEdge(c);
|
|
|
|
forCellEx(c2, c) if(coastvalEdge(c2) < d && gmatrix.count(c2))
|
|
|
|
go = true, mcl.add(c2);
|
|
|
|
}
|
|
|
|
if(!go) below.push_back(c);
|
|
|
|
}
|
2019-05-08 20:48:59 +00:00
|
|
|
ld cinertia = hypot_d(WDIM, m->inertia);
|
2019-05-05 15:37:51 +00:00
|
|
|
hyperpoint drag = m->inertia * cinertia * delta / -1. / SCALE;
|
|
|
|
m->inertia += drag;
|
|
|
|
avg_inertia += drag/2;
|
|
|
|
transmatrix T = inverse(m->pat);
|
|
|
|
ld xp = SCALE / 60000. / isize(below) * delta / 15;
|
|
|
|
ld yp = 0;
|
|
|
|
if(cwt.at->land == laDungeon) xp = -xp;
|
|
|
|
if(cwt.at->land == laWestWall) yp = xp * 1, xp *= 0.7;
|
|
|
|
for(cell *c2: below) if(c2 != m->base) {
|
|
|
|
|
|
|
|
hyperpoint h = rspintox(T * tC0(gmatrix[c2])) * hpxy(xp, yp);
|
|
|
|
|
|
|
|
m->inertia += h;
|
|
|
|
avg_inertia += h/2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if(inertia_based) m->inertia = spin(-playerturn[cpid]) * m->inertia;
|
2019-03-30 16:51:37 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
for(int igo=0; igo<IGO && !go; igo++) {
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
go = true;
|
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
playergoturn[cpid] = igospan[igo]+godir[cpid];
|
2019-03-09 17:14:38 +00:00
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
if(inertia_based) {
|
|
|
|
if(igo) { go = false; break; }
|
2019-05-08 20:48:59 +00:00
|
|
|
ld r = hypot_d(WDIM, avg_inertia);
|
2019-03-30 16:51:37 +00:00
|
|
|
nat = nat * rspintox(avg_inertia) * xpush(r * delta) * spintox(avg_inertia);
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3) nat = nat * cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]);
|
2019-03-30 16:51:37 +00:00
|
|
|
}
|
2019-05-08 20:48:59 +00:00
|
|
|
else if(WDIM == 3) {
|
2019-02-25 13:51:51 +00:00
|
|
|
nat = nat1 * cpush(0, playerstrafe[cpid]) * cpush(2, playergo[cpid]) * cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]);
|
2019-03-30 16:51:37 +00:00
|
|
|
m->inertia[0] = playerstrafe[cpid] / delta;
|
|
|
|
m->inertia[1] = 0;
|
|
|
|
m->inertia[2] = playergo[cpid] / delta;
|
|
|
|
}
|
|
|
|
else if(playergo[cpid]) {
|
2019-05-08 20:48:59 +00:00
|
|
|
nat = nat1 * spin(playergoturn[cpid]) * xpush(playergo[cpid]) * spin(-playergoturn[cpid]);
|
|
|
|
m->inertia = spin(playergoturn[cpid]) * xpush0(playergo[cpid] / delta);
|
2019-03-30 16:51:37 +00:00
|
|
|
}
|
2018-11-18 00:40:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// spin(span[igo]) * xpush(playergo[cpid]) * spin(-span[igo]);
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
c2 = m->findbase(nat);
|
2018-09-23 21:55:03 +00:00
|
|
|
if(reflectflag & P_MIRRORWALL) reflect(c2, m->base, nat);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
// don't have several players in one spot
|
|
|
|
// also don't let them run too far from each other!
|
2018-02-12 11:48:31 +00:00
|
|
|
monster* crashintomon = NULL;
|
|
|
|
|
|
|
|
if(!m->isVirtual) {
|
|
|
|
crashintomon = playerCrash(m, nat*C0);
|
|
|
|
for(monster *m2: nonvirtual) if(m2!=m && m2->type == passive_switch) {
|
|
|
|
double d = intval(m2->pat*C0, nat*C0);
|
|
|
|
if(d < SCALE2 * 0.2) crashintomon = m2;
|
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
if(crashintomon) go = false;
|
|
|
|
|
|
|
|
if(go && c2 != m->base) {
|
|
|
|
|
|
|
|
if(c2->wall == waLake && markOrb(itOrbWinter) && !nonAdjacent(c2, m->base)) {
|
|
|
|
c2->wall = waFrozenLake;
|
|
|
|
if(HEAT(c2) > .5) HEAT(c2) = .5;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(c2->wall == waBigStatue && canPushStatueOn(m->base) && !nonAdjacent(c2, m->base)) {
|
|
|
|
visibleFor(300);
|
|
|
|
c2->wall = m->base->wall;
|
2018-08-17 22:46:45 +00:00
|
|
|
if(cellUnstable(cwt.at))
|
2017-03-23 10:53:57 +00:00
|
|
|
m->base->wall = waChasm;
|
|
|
|
else {
|
2016-08-26 09:58:03 +00:00
|
|
|
m->base->wall = waBigStatue;
|
2018-06-17 15:51:26 +00:00
|
|
|
animateMovement(c2, m->base, LAYER_BOAT, NOHINT);
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-07-22 23:33:27 +00:00
|
|
|
else if(m->inBoat && !isWateryOrBoat(c2) && passable(c2, m->base, P_ISPLAYER | P_MIRROR | reflectflag)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(boatGoesThrough(c2) && markOrb(itOrbWater)) {
|
|
|
|
c2->wall = isIcyLand(m->base) ? waLake : waSea;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(isWatery(m->base))
|
|
|
|
m->base->wall = waBoat, m->base->mondir = dirfromto(m->base, c2);
|
|
|
|
else if(boatStrandable(m->base))
|
|
|
|
m->base->wall = waStrandedBoat;
|
|
|
|
else if(boatStrandable(c2))
|
|
|
|
m->base->wall = waStrandedBoat;
|
|
|
|
m->inBoat = false;
|
|
|
|
}
|
|
|
|
}
|
2019-01-11 01:23:44 +00:00
|
|
|
else if(isPushable(c2->wall) && !nonAdjacent(c2, m->base)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
int sd = dirfromto(c2, m->base);
|
|
|
|
int subdir = 1;
|
|
|
|
double bestd = 9999;
|
|
|
|
pushmonsters();
|
|
|
|
for(int di=-1; di<2; di+=2) {
|
|
|
|
cell *c = getMovR(c2, sd+di);
|
|
|
|
if(!c) continue;
|
2017-05-31 16:33:50 +00:00
|
|
|
if(m->isVirtual || !gmatrix.count(c)) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
double d = intval(gmatrix[c] * C0, m->pat * C0);
|
|
|
|
// printf("di=%d d=%lf\n", di, d);
|
|
|
|
if(d<bestd) bestd=d, subdir = di;
|
|
|
|
}
|
|
|
|
visibleFor(300);
|
|
|
|
cellwalker push(c2, dirfromto(c2, m->base));
|
2018-03-24 11:59:01 +00:00
|
|
|
push = push + 3 * (-subdir) + wstep;
|
2018-08-17 22:46:45 +00:00
|
|
|
if(!canPushThumperOn(push.at, c2, m->base) && c2->type == 7) {
|
2018-03-24 11:59:01 +00:00
|
|
|
push = push + wstep - subdir + wstep;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2018-08-17 22:46:45 +00:00
|
|
|
if(!canPushThumperOn(push.at, c2, m->base)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
go = false;
|
|
|
|
}
|
2018-08-17 22:46:45 +00:00
|
|
|
else pushThumper(c2, push.at);
|
2016-08-26 09:58:03 +00:00
|
|
|
popmonsters();
|
|
|
|
}
|
|
|
|
else if(c2->wall == waRose && !nonAdjacent(m->base, c2)) {
|
|
|
|
m->dead = true;
|
|
|
|
go = false;
|
|
|
|
}
|
|
|
|
else if(
|
2017-07-22 23:33:27 +00:00
|
|
|
(blown ? !passable(c2, m->base, P_ISPLAYER | P_BLOW) : !passable(c2, m->base, P_ISPLAYER | P_MIRROR | reflectflag)) &&
|
2016-08-26 09:58:03 +00:00
|
|
|
!(isWatery(c2) && m->inBoat && !nonAdjacent(m->base,c2)))
|
|
|
|
go = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!go || abs(playergo[cpid]) < 1e-3 || abs(playerturn[cpid]) > 1e-3) bulltime[cpid] = curtime;
|
|
|
|
|
2019-03-09 17:14:38 +00:00
|
|
|
if(!go) {
|
2019-05-05 15:37:51 +00:00
|
|
|
using namespace hyperpoint_vec;
|
2019-03-09 17:14:38 +00:00
|
|
|
playergo[cpid] = playergoturn[cpid] = playerstrafe[cpid] = 0;
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3) playerturn[cpid] = playerturny[cpid] = 0;
|
2019-05-05 15:37:51 +00:00
|
|
|
if(falling) m->inertia = m->inertia * -1;
|
|
|
|
else m->inertia = Hypc;
|
2019-03-09 17:14:38 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(go) {
|
2019-03-09 16:38:23 +00:00
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3) {
|
2019-03-09 16:38:23 +00:00
|
|
|
swordmatrix[cpid] =
|
|
|
|
cspin(1, 2, -playerturny[cpid]) * cspin(0, 2, -playerturn[cpid]) * swordmatrix[cpid];
|
2019-03-30 16:51:37 +00:00
|
|
|
m->inertia = cspin(1, 2, -playerturny[cpid]) * cspin(0, 2, -playerturn[cpid]) * m->inertia;
|
|
|
|
}
|
2019-03-09 16:38:23 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2 != m->base) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(cellUnstable(m->base) && !markOrb(itOrbAether))
|
|
|
|
doesFallSound(m->base);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(items[itOrbFire]) {
|
|
|
|
visibleFor(800);
|
|
|
|
if(makeflame(m->base, 10, false)) markOrb(itOrbFire);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isIcyLand(m->base) && m->base->wall == waNone && markOrb(itOrbWinter)) {
|
|
|
|
invismove = false;
|
|
|
|
m->base->wall = waIcewall;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(items[itOrbDigging]) {
|
|
|
|
visibleFor(400);
|
|
|
|
int d = dirfromto(m->base, c2);
|
|
|
|
if(d >= 0 && earthMove(m->base, d)) markOrb(itOrbDigging);
|
|
|
|
}
|
|
|
|
|
2018-08-17 22:46:45 +00:00
|
|
|
cwt.at = c2; afterplayermoved();
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2->item && c2->land == laAlchemist) c2->wall = m->base->wall;
|
|
|
|
if(m->base->wall == waRoundTable)
|
|
|
|
roundTableMessage(c2);
|
2017-07-22 23:33:27 +00:00
|
|
|
if(c2->wall == waCloud || c2->wall == waMirror) {
|
2016-08-26 09:58:03 +00:00
|
|
|
visibleFor(500);
|
2017-07-22 23:33:27 +00:00
|
|
|
cellwalker cw(c2, 0, false);
|
|
|
|
mirror::createHere(cw, cpid);
|
|
|
|
mirror::breakMirror(cw, cpid);
|
2016-08-26 09:58:03 +00:00
|
|
|
awakenMimics(m, c2);
|
2018-11-24 14:35:02 +00:00
|
|
|
#if CAP_RACING
|
|
|
|
if(racing::on) racing::race_won();
|
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2->wall == waGlass && items[itOrbAether]) {
|
|
|
|
items[itOrbAether] = 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
addMessage(XLAT("Your Aether powers are drained by %the1!", c2->wall));
|
|
|
|
}
|
2018-08-01 12:04:47 +00:00
|
|
|
movecost(m->base, c2, 1);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-01-24 13:51:24 +00:00
|
|
|
if(c2->wall == waMineMine && !markOrb(itOrbAether) && !markOrb(itOrbWinter)) {
|
|
|
|
items[itOrbLife] = 0;
|
|
|
|
m->dead = true;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2019-01-24 13:51:24 +00:00
|
|
|
uncoverMinesFull(c2);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(isWatery(c2) && isWatery(m->base) && m->inBoat)
|
|
|
|
moveItem(m->base, c2, true);
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
destroyWeakBranch(m->base, c2, moPlayer);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(c2->wall == waClosePlate || c2->wall == waOpenPlate)
|
2017-03-23 10:53:57 +00:00
|
|
|
toggleGates(c2, c2->wall);
|
2017-10-12 09:33:26 +00:00
|
|
|
|
|
|
|
if(c2->wall == waArrowTrap && c2->wparam == 0 && !markOrb(itOrbAether))
|
2019-01-11 01:23:44 +00:00
|
|
|
activateArrowTrap(c2);
|
|
|
|
|
|
|
|
if(c2->wall == waFireTrap && c2->wparam == 0 && !markOrb(itOrbAether)) {
|
|
|
|
c2->wparam = 2;
|
|
|
|
firetraplist.emplace(ticks + 800, c2);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-07-24 00:02:32 +00:00
|
|
|
if(c2->item == itOrbYendor && !peace::on) yendor::check(c2);
|
2017-03-23 10:53:57 +00:00
|
|
|
collectItem(c2);
|
2018-08-01 12:04:47 +00:00
|
|
|
movecost(m->base, c2, 2);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(go) m->rebasePat(nat);
|
|
|
|
else m->rebasePat(nat0);
|
|
|
|
|
|
|
|
if(m->base->wall == waBoat && !m->inBoat) {
|
|
|
|
m->inBoat = true; m->base->wall = waSea;
|
|
|
|
}
|
2017-05-27 19:40:40 +00:00
|
|
|
|
|
|
|
if(m->base->wall == waStrandedBoat && !m->inBoat && markOrb(itOrbWater)) {
|
|
|
|
m->inBoat = true; m->base->wall = waSea;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(m->inBoat && boatStrandable(c2)) {
|
|
|
|
c2->wall = waStrandedBoat;
|
|
|
|
m->inBoat = false;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!markOrb(itOrbAether)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->base->wall == waChasm || m->base->wall == waClosedGate)
|
|
|
|
m->dead = true;
|
|
|
|
|
|
|
|
if(isWatery(m->base) && !m->inBoat && !markOrb(itOrbFish))
|
|
|
|
m->dead = true;
|
|
|
|
|
2017-10-11 20:16:07 +00:00
|
|
|
if(isFireOrMagma(m->base) && !markOrb(itOrbWinter))
|
2016-08-26 09:58:03 +00:00
|
|
|
m->dead = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
landvisited[m->base->land] = true;
|
|
|
|
|
|
|
|
playerfire[cpid] = false;
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
if(items[itOrbHorns] && !m->isVirtual) {
|
2017-03-23 10:53:57 +00:00
|
|
|
hyperpoint H = hornpos(cpid);
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m2: nonvirtual) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m2 == m) continue;
|
|
|
|
|
|
|
|
double d = intval(m2->pat*C0, H);
|
|
|
|
|
|
|
|
if(d < SCALE2 * 0.1) {
|
|
|
|
if(hornKills(m2->type))
|
|
|
|
killMonster(m2, moPlayer);
|
|
|
|
else if(hornStuns(m2->type))
|
|
|
|
m2->stunoff = max(m2->stunoff, curtime + 150);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
for(int b=0; b<2; b++) if(sword::orbcount(b) && !m->isVirtual) {
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
for(double d=0; d<=1.001; d += .1) {
|
|
|
|
hyperpoint H = swordpos(cpid, b, d);
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m2: nonvirtual) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m2 == m) continue;
|
|
|
|
|
|
|
|
double d = intval(m2->pat*C0, H);
|
|
|
|
|
|
|
|
if(d < SCALE2 * 0.1) {
|
|
|
|
if(swordKills(m2->type) && !(isBullet(m2) && m2->pid == cpid))
|
|
|
|
killMonster(m2, moPlayer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cell *c3 = findbaseAroundRepeat(H, m->base);
|
|
|
|
if(c3->wall == waSmallTree || c3->wall == waBigTree || c3->wall == waBarrowDig || c3->wall == waCavewall ||
|
|
|
|
(c3->wall == waBarrowWall && items[itBarrow] >= 25))
|
|
|
|
c3->wall = waNone;
|
|
|
|
|
|
|
|
else if(isWall(c3)) break;
|
|
|
|
}
|
|
|
|
}
|
2018-11-18 00:40:57 +00:00
|
|
|
|
|
|
|
if(go) {
|
|
|
|
// printf("#%3d: at %s\n", steps, display(nat * C0));
|
|
|
|
steps--;
|
|
|
|
if(steps > 0) {
|
|
|
|
nat0 = nat;
|
|
|
|
go = false;
|
|
|
|
goto nextstep;
|
|
|
|
}
|
|
|
|
}
|
2018-11-18 00:44:13 +00:00
|
|
|
|
|
|
|
#if CAP_RACING
|
|
|
|
if(!go && racing::on) m->vel = 0;
|
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(shotkey && canmove && curtime >= m->nextshot) {
|
|
|
|
|
|
|
|
visibleFor(500);
|
|
|
|
if(items[itOrbFlash]) {
|
|
|
|
pushmonsters();
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(m->base, moNone);
|
2018-08-17 22:46:45 +00:00
|
|
|
cwt.at = m->base;
|
2016-08-26 09:58:03 +00:00
|
|
|
activateFlash();
|
|
|
|
popmonsters();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(items[itOrbLightning]) {
|
|
|
|
pushmonsters();
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(m->base, moLightningBolt);
|
2018-08-17 22:46:45 +00:00
|
|
|
cwt.at = m->base;
|
2016-08-26 09:58:03 +00:00
|
|
|
activateLightning();
|
|
|
|
popmonsters();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
playerfire[cpid] = true;
|
|
|
|
m->nextshot = curtime + (250 + 250 * players);
|
|
|
|
|
|
|
|
turncount++;
|
|
|
|
shootBullet(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dropgreen && m->base->item == itNone)
|
|
|
|
dropGreenStone(m->base);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
monster *getPlayer() {
|
|
|
|
return pc[cpid];
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
void virtualize(monster *m) {
|
2017-06-09 01:41:33 +00:00
|
|
|
if(doall) forCellCM(c2, m->base) if(!gmatrix.count(c2)) {
|
2017-05-31 16:33:50 +00:00
|
|
|
m->isVirtual = true;
|
|
|
|
m->pat = m->at;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
bool reflectmatrix(transmatrix& M, cell *c1, cell *c2, bool onlypos) {
|
|
|
|
if(!gmatrix.count(c1) || !gmatrix.count(c2)) return false;
|
|
|
|
transmatrix H = inverse(gmatrix[c1]) * gmatrix[c2];
|
|
|
|
transmatrix S = spintox(tC0(H));
|
|
|
|
ld d = hdist0(tC0(H));
|
|
|
|
transmatrix T = xpush(-d/2) * S * inverse(gmatrix[c1]) * M;
|
|
|
|
if(onlypos && tC0(T)[0] < 0) return false;
|
|
|
|
M = gmatrix[c1] * inverse(S) * xpush(d/2) * MirrorX * T;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:55:03 +00:00
|
|
|
int reflect(cell*& c2, cell*& mbase, transmatrix& nat) {
|
|
|
|
int reflections = 0;
|
|
|
|
if(c2 != mbase && c2->wall == waMirrorWall && inmirror(c2)) {
|
|
|
|
if(reflectmatrix(nat, mbase, c2, false)) {
|
|
|
|
c2 = mbase;
|
|
|
|
reflections++;
|
|
|
|
}
|
2017-07-22 23:33:27 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:55:03 +00:00
|
|
|
if(c2 == mbase && inmirror(c2)) {
|
2017-07-22 23:33:27 +00:00
|
|
|
forCellEx(c3, c2) if(c3->land == laMirrorWall) {
|
2018-09-23 21:55:03 +00:00
|
|
|
cell *c1 = mbase;
|
|
|
|
mbase = c3;
|
|
|
|
reflect(c3, mbase, nat);
|
|
|
|
mbase = c1;
|
2017-07-22 23:33:27 +00:00
|
|
|
c2 = c3;
|
2018-09-23 21:55:03 +00:00
|
|
|
reflections++;
|
2017-07-22 23:33:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:55:03 +00:00
|
|
|
if(c2 == mbase && c2->wall == waMirrorWall && c2->land == laMirrorWall) {
|
2017-07-22 23:33:27 +00:00
|
|
|
int d = mirror::mirrordir(c2);
|
|
|
|
if(d != -1) {
|
|
|
|
for(int k=0; k<7; k++) {
|
|
|
|
cell *ca = createMovR(c2, d-k);
|
|
|
|
cell *cb = createMovR(c2, d+k);
|
|
|
|
if(ca->land == laMirror && inmirror(cb)) {
|
|
|
|
reflectmatrix(nat, ca, cb, true);
|
2018-09-23 21:55:03 +00:00
|
|
|
reflections++;
|
2017-07-22 23:33:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for(int k=0; k<6; k++) {
|
|
|
|
cell *cb = createMovR(c2, k+1);
|
|
|
|
cell *cc = createMovR(c2, k+2);
|
|
|
|
if(cb->land != laMirrorWall || cc->land != laMirrorWall) continue;
|
|
|
|
cell *ca = createMovR(c2, k);
|
|
|
|
cell *cd = createMovR(c2, k+3);
|
2018-09-23 21:55:03 +00:00
|
|
|
if(reflectmatrix(nat, cc, ca, true)) reflections++;
|
|
|
|
for(int limit=0; limit<10 && reflectmatrix(nat, cb, cd, true) && (reflections++, reflectmatrix(nat, cc, ca, true)); limit++) reflections+=2;
|
2017-07-22 23:33:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-09-23 21:55:03 +00:00
|
|
|
return reflections;
|
2017-07-22 23:33:27 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void moveMimic(monster *m) {
|
2017-05-31 16:33:50 +00:00
|
|
|
virtualize(m);
|
2016-08-26 09:58:03 +00:00
|
|
|
transmatrix nat = m->pat;
|
|
|
|
cpid = m->pid;
|
2017-03-23 10:53:57 +00:00
|
|
|
m->footphase = getPlayer()->footphase;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
// no need to care about Mirror images, as they already have their 'at' matrix reversed :|
|
2019-03-09 17:14:38 +00:00
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3)
|
2019-03-09 17:14:38 +00:00
|
|
|
nat = nat * cpush(0, playerstrafe[cpid]) * cpush(2, playergo[cpid]) * cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]);
|
|
|
|
else
|
|
|
|
nat = nat * spin(playerturn[cpid] + playergoturn[cpid]) * xpush(playergo[cpid]) * spin(-playergoturn[cpid]);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
cell *c2 = m->findbase(nat);
|
2018-09-23 21:55:03 +00:00
|
|
|
reflect(c2, m->base, nat);
|
2017-07-22 23:33:27 +00:00
|
|
|
if(c2 != m->base && !passable(c2, m->base, P_ISPLAYER | P_MIRROR | P_MIRRORWALL))
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(m, moNone);
|
2016-08-26 09:58:03 +00:00
|
|
|
else {
|
|
|
|
m->rebasePat(nat);
|
|
|
|
if(playerfire[cpid]) shootBullet(m);
|
|
|
|
}
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(c2->wall == waCloud || c2->wall == waMirror) {
|
|
|
|
cellwalker cw(c2, 0, false);
|
|
|
|
mirror::createHere(cw, cpid);
|
|
|
|
mirror::breakMirror(cw, -1);
|
2016-08-26 09:58:03 +00:00
|
|
|
awakenMimics(m, c2);
|
|
|
|
}
|
|
|
|
|
2017-06-09 01:41:33 +00:00
|
|
|
if(!doall && c2->cpdist >= 6)
|
2016-08-26 09:58:03 +00:00
|
|
|
m->dead = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPlayerOrImage(eMonster m) {
|
|
|
|
return isMimic(m) || m == moPlayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
monster *parentOrSelf(monster *m) {
|
|
|
|
return m->parent ? m->parent : m;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool verifyTeleport() {
|
|
|
|
if(!on) return true;
|
|
|
|
if(playerCrash(pc[cpid], mouseh)) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void destroyMimics() {
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m: active)
|
|
|
|
if(isMimic(m->type))
|
|
|
|
m->dead = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void teleported() {
|
|
|
|
monster *m = pc[cpid];
|
2018-08-17 22:46:45 +00:00
|
|
|
m->base = cwt.at;
|
|
|
|
m->at = rgpushxto0(inverse(gmatrix[cwt.at]) * mouseh) * spin(rand() % 1000 * M_PI / 2000);
|
2016-08-26 09:58:03 +00:00
|
|
|
m->findpat();
|
2017-03-23 10:53:57 +00:00
|
|
|
destroyMimics();
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void shoot(eItem it, monster *m) {
|
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = m->base;
|
|
|
|
bullet->at = m->at * rspintox(inverse(m->pat) * mouseh);
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3) bullet->at = bullet->at * cpush(2, 0.15 * SCALE);
|
2016-08-26 09:58:03 +00:00
|
|
|
bullet->type = it == itOrbDragon ? moFireball : it == itOrbAir ? moAirball : moBullet;
|
|
|
|
bullet->parent = m;
|
|
|
|
bullet->pid = m->pid;
|
|
|
|
bullet->parenttype = m->type;
|
|
|
|
items[it]--;
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(bullet);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
eItem targetRangedOrbKey(orbAction a) {
|
|
|
|
hyperpoint h = mouseh;
|
|
|
|
cell *b = mouseover;
|
|
|
|
monster *mt = mousetarget;
|
|
|
|
|
|
|
|
mouseh = keytarget(cpid);
|
|
|
|
|
|
|
|
mouseover = pc[cpid]->base;
|
|
|
|
|
|
|
|
while(true) {
|
|
|
|
cell *c2 = findbaseAround(mouseh, mouseover);
|
|
|
|
if(c2 == mouseover) break;
|
|
|
|
mouseover = c2;
|
|
|
|
}
|
|
|
|
mousetarget = NULL;
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m2: nonvirtual) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m2->dead) continue;
|
2018-07-09 17:32:34 +00:00
|
|
|
if(m2->no_targetting) continue;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!mousetarget || intval(mouseh, mousetarget->pat*C0) > intval(mouseh, m2->pat*C0))
|
2016-08-26 09:58:03 +00:00
|
|
|
mousetarget = m2;
|
|
|
|
}
|
|
|
|
|
|
|
|
eItem r = targetRangedOrb(mouseover, a);
|
|
|
|
// printf("A%d i %d h %p t %p ov %s => %s\n", a, cpid, mouseover, mousetarget, display(mouseh), dnameof(r));
|
|
|
|
|
|
|
|
mouseh = h;
|
|
|
|
mousetarget = mt;
|
|
|
|
mouseover = b;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
eItem targetRangedOrb(orbAction a) {
|
|
|
|
if(!on) return itNone;
|
|
|
|
monster *wpc = pc[cpid];
|
|
|
|
if(a != roCheck && !wpc) return itNone;
|
|
|
|
|
|
|
|
if(items[itOrbPsi] && shmup::mousetarget && intval(mouseh, shmup::mousetarget->pat*C0) < SCALE2 * .1) {
|
|
|
|
if(a == roCheck) return itOrbPsi;
|
|
|
|
addMessage(XLAT("You kill %the1 with a mental blast!", mousetarget->type));
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(mousetarget, moNone);
|
2016-08-26 09:58:03 +00:00
|
|
|
items[itOrbPsi] -= 30;
|
|
|
|
if(items[itOrbPsi]<0) items[itOrbPsi] = 0;
|
|
|
|
return itOrbPsi;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(items[itOrbStunning] && shmup::mousetarget && intval(mouseh, shmup::mousetarget->pat*C0) < SCALE2 * .1) {
|
|
|
|
if(a == roCheck) return itOrbStunning;
|
|
|
|
mousetarget->stunoff = curtime + 1000;
|
|
|
|
items[itOrbStunning] -= 10;
|
|
|
|
if(items[itOrbStunning]<0) items[itOrbStunning] = 0;
|
|
|
|
return itOrbStunning;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(on && items[itOrbDragon]) {
|
|
|
|
if(a == roCheck) return itOrbDragon;
|
|
|
|
shoot(itOrbDragon, wpc);
|
|
|
|
return itOrbDragon;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(on && items[itOrbAir]) {
|
|
|
|
if(a == roCheck) return itOrbAir;
|
|
|
|
shoot(itOrbAir, wpc);
|
|
|
|
return itOrbAir;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(on && items[itOrbIllusion]) {
|
|
|
|
if(a == roCheck) return itOrbIllusion;
|
|
|
|
shoot(itOrbIllusion, wpc);
|
|
|
|
return itOrbIllusion;
|
|
|
|
}
|
|
|
|
|
|
|
|
return itNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
int speedfactor() {
|
|
|
|
return items[itOrbSpeed]?2:1;
|
|
|
|
}
|
|
|
|
|
2019-02-25 13:51:51 +00:00
|
|
|
transmatrix frontpush(ld x) {
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 2) return xpush(x);
|
2019-02-25 13:51:51 +00:00
|
|
|
else return cpush(2, x);
|
|
|
|
}
|
2019-03-30 16:51:37 +00:00
|
|
|
|
|
|
|
ld collision_distance(monster *bullet, monster *target) {
|
|
|
|
if(target->type == moAsteroid)
|
|
|
|
return SCALE * 0.15 + asteroid_size[target->hitpoints & 7];
|
|
|
|
return SCALE * 0.3;
|
|
|
|
}
|
|
|
|
|
|
|
|
void spawn_asteroids(monster *bullet, monster *target) {
|
|
|
|
if(target->hitpoints <= 1) return;
|
|
|
|
hyperpoint rnd = random_spin() * point2(SCALE/3000., 0);
|
2019-02-25 13:51:51 +00:00
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
hyperpoint bullet_inertia = inverse(target->pat) * bullet->pat * bullet->inertia;
|
|
|
|
|
|
|
|
for(int i=0; i<2; i++) {
|
|
|
|
using namespace hyperpoint_vec;
|
|
|
|
monster* child = new monster;
|
|
|
|
child->base = target->base;
|
|
|
|
child->at = target->at;
|
|
|
|
child->type = target->type;
|
|
|
|
child->parent = NULL;
|
|
|
|
child->pid = target->pid;
|
|
|
|
child->parenttype = target->type;
|
|
|
|
child->inertia = target->inertia;
|
|
|
|
child->inertia += bullet_inertia / 5;
|
|
|
|
child->hitpoints = target->hitpoints - 1;
|
|
|
|
if(i == 0) child->inertia += rnd;
|
|
|
|
if(i == 1) child->inertia -= rnd;
|
|
|
|
additional.push_back(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void moveBullet(monster *m, int delta) {
|
|
|
|
cpid = m->pid;
|
|
|
|
m->findpat();
|
2017-05-31 16:33:50 +00:00
|
|
|
virtualize(m);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
transmatrix nat0 = m->pat;
|
|
|
|
transmatrix nat = m->pat;
|
2017-05-31 16:33:50 +00:00
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
bool inertia_based = m->base->land == laAsteroids;
|
|
|
|
|
|
|
|
if(m->base->land == laAsteroids) {
|
|
|
|
m->hitpoints += delta;
|
2019-05-08 20:48:59 +00:00
|
|
|
if(m->hitpoints >= (WDIM == 3 ? 750 : 500)) m->dead = true;
|
2019-03-30 16:51:37 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
if(isReptile(m->base->wall)) m->base->wparam = reptilemax();
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->type == moFlailBullet) {
|
|
|
|
m->vel -= delta / speedfactor() / 600000.0;
|
|
|
|
if(m->vel < 0 && m->parent) {
|
|
|
|
// return to the flailer!
|
|
|
|
nat = nat * rspintox(inverse(m->pat) * m->parent->pat * C0) * spin(M_PI);
|
|
|
|
}
|
|
|
|
}
|
2019-03-30 16:51:37 +00:00
|
|
|
else m->vel = bullet_velocity(m->type);
|
|
|
|
|
|
|
|
if(m->type == moTongue && (m->isVirtual || !m->parent || intval(nat*C0, m->parent->pat*C0) > SCALE2 * 0.4))
|
|
|
|
m->dead = true;
|
|
|
|
|
|
|
|
if(inertia_based) {
|
2019-05-08 20:48:59 +00:00
|
|
|
ld r = hypot_d(WDIM, m->inertia);
|
2019-03-30 16:51:37 +00:00
|
|
|
nat = nat * rspintox(m->inertia) * xpush(r * delta) * spintox(m->inertia);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2019-03-30 16:51:37 +00:00
|
|
|
else
|
|
|
|
nat = nat * frontpush(delta * SCALE * m->vel / speedfactor());
|
2017-05-31 16:33:50 +00:00
|
|
|
cell *c2 = m->findbase(nat);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-10-11 20:16:07 +00:00
|
|
|
if(m->parent && isPlayer(m->parent) && markOrb(itOrbLava) && c2 != m->base && !isPlayerOn(m->base))
|
|
|
|
makeflame(m->base, 5, false);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isActivable(c2)) activateActiv(c2, true);
|
|
|
|
|
|
|
|
// knives break mirrors and clouds
|
2017-07-22 23:33:27 +00:00
|
|
|
if(c2->wall == waCloud || c2->wall == waMirror) {
|
|
|
|
cellwalker cw(c2, 0, false);
|
|
|
|
mirror::createHere(cw, cpid);
|
|
|
|
mirror::breakMirror(cw, -1);
|
2016-08-26 09:58:03 +00:00
|
|
|
awakenMimics(m, c2);
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:55:03 +00:00
|
|
|
reflect(c2, m->base, nat);
|
2017-07-22 23:33:27 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool godragon = m->type == moFireball && isDragon(c2->monst);
|
|
|
|
|
2017-10-12 09:33:26 +00:00
|
|
|
if(m->type != moTongue && !(godragon || (c2==m->base && m->type == moArrowTrap) || passable(c2, m->base, P_BULLET | P_MIRRORWALL))) {
|
2016-08-26 09:58:03 +00:00
|
|
|
m->dead = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m->type != moAirball) killMonster(c2, m->parent ? m->parent->type : moNone);
|
2016-08-26 09:58:03 +00:00
|
|
|
// cell *c = m->base;
|
|
|
|
if(m->parent && isPlayer(m->parent)) {
|
|
|
|
if(c2->wall == waBigTree) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You start chopping down the tree."));
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->wall = waSmallTree;
|
|
|
|
}
|
|
|
|
else if(c2->wall == waSmallTree) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT("You chop down the tree."));
|
2016-08-26 09:58:03 +00:00
|
|
|
c2->wall = waNone;
|
|
|
|
}
|
|
|
|
else if(isActivable(c2))
|
|
|
|
activateActiv(c2, true);
|
2019-01-11 01:23:44 +00:00
|
|
|
else if(c2->wall == waExplosiveBarrel)
|
|
|
|
explodeBarrel(c2);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2018-02-12 11:48:31 +00:00
|
|
|
if(m->type == moCrushball && c2->wall == waRuinWall)
|
|
|
|
c2->wall = waNone;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->type == moFireball) {
|
|
|
|
makeflame(c2, 20, false) || makeflame(m->base, 20, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m->rebasePat(nat);
|
|
|
|
|
|
|
|
// destroy stray bullets
|
2017-06-09 01:41:33 +00:00
|
|
|
if(!doall) for(int i=0; i<m->base->type; i++)
|
2018-08-17 22:46:45 +00:00
|
|
|
if(!m->base->move(i) || !gmatrix.count(m->base->move(i)))
|
2016-08-26 09:58:03 +00:00
|
|
|
m->dead = true;
|
|
|
|
|
|
|
|
// items[itOrbWinter] = 100; items[itOrbLife] = 100;
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
if(!m->isVirtual) for(monster* m2: nonvirtual) {
|
2017-10-12 09:33:26 +00:00
|
|
|
if(m2 == m || (m2 == m->parent && m->vel >= 0) || m2->parent == m->parent)
|
|
|
|
continue;
|
2019-03-30 16:51:37 +00:00
|
|
|
|
|
|
|
if(m2->dead) continue;
|
2018-02-12 11:48:31 +00:00
|
|
|
|
|
|
|
eMonster ptype = parentOrSelf(m)->type;
|
|
|
|
bool slayer = m->type == moCrushball ||
|
|
|
|
(markOrb(itOrbSlaying) && (markOrb(itOrbEmpathy) ? isPlayerOrImage(ptype) : ptype == moPlayer));
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
// Flailers only killable by themselves
|
|
|
|
if(m2->type == moFlailer && m2 != m->parent) continue;
|
|
|
|
// be nice to your images! would be too hard otherwise...
|
|
|
|
if(isPlayerOrImage(parentOrSelf(m)->type) && isPlayerOrImage(parentOrSelf(m2)->type) &&
|
|
|
|
m2->pid == m->pid)
|
|
|
|
continue;
|
|
|
|
// fireballs/airballs don't collide
|
|
|
|
if(m->type == moFireball && m2->type == moFireball) continue;
|
|
|
|
if(m->type == moAirball && m2->type == moAirball) continue;
|
2019-03-30 16:51:37 +00:00
|
|
|
double d = hdist(m2->pat*C0, m->pat*C0);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
if(d < collision_distance(m, m2)) {
|
2018-02-12 11:48:31 +00:00
|
|
|
|
|
|
|
if(m2->type == passive_switch) { m->dead = true; continue; }
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->type == moAirball && isBlowableMonster(m2->type)) {
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m2->blowoff < curtime) {
|
|
|
|
hyperpoint h = inverse(m2->pat) * nat0 * C0;
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3)
|
2019-03-09 16:38:23 +00:00
|
|
|
swordmatrix[m2->pid] = spintox(h) * swordmatrix[m2->pid];
|
|
|
|
else
|
|
|
|
m2->swordangle += atan2(h[1], h[0]);
|
2017-03-23 10:53:57 +00:00
|
|
|
m2->rebasePat(m2->pat * rspintox(h));
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
m2->blowoff = curtime + 1000;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Hedgehog Warriors only killable outside of the 45 degree angle
|
2018-02-12 11:48:31 +00:00
|
|
|
if(m2->type == moHedge && !peace::on && !slayer) {
|
2016-08-26 09:58:03 +00:00
|
|
|
hyperpoint h = inverse(m2->pat) * m->pat * C0;
|
|
|
|
if(h[0] > fabsl(h[1])) { m->dead = true; continue; }
|
|
|
|
}
|
2017-07-24 00:02:32 +00:00
|
|
|
if(peace::on && !isIvy(m2->type)) {
|
|
|
|
m->dead = true;
|
|
|
|
m2->stunoff = curtime + 600;
|
|
|
|
continue;
|
|
|
|
}
|
2018-02-12 11:48:31 +00:00
|
|
|
// multi-HP monsters
|
2016-08-26 09:58:03 +00:00
|
|
|
if((m2->type == moPalace || m2->type == moFatGuard || m2->type == moSkeleton ||
|
2019-01-11 01:23:44 +00:00
|
|
|
m2->type == moVizier || isMetalBeast(m2->type) || m2->type == moTortoise || m2->type == moBrownBug ||
|
2018-02-12 11:48:31 +00:00
|
|
|
m2->type == moReptile || m2->type == moSalamander || m2->type == moTerraWarrior) && m2->hitpoints > 1 && !slayer) {
|
2016-08-26 09:58:03 +00:00
|
|
|
m2->rebasePat(m2->pat * rspintox(inverse(m2->pat) * nat0 * C0));
|
2019-01-11 01:23:44 +00:00
|
|
|
if(m2->type != moSkeleton && !isMetalBeast(m2->type) && m2->type != moReptile && m2->type != moSalamander && m2->type != moBrownBug)
|
2016-08-26 09:58:03 +00:00
|
|
|
m2->hitpoints--;
|
|
|
|
m->dead = true;
|
|
|
|
if(m2->type == moVizier) ;
|
|
|
|
else if(m2->type == moFatGuard)
|
|
|
|
m2->stunoff = curtime + 600;
|
2017-10-11 20:16:07 +00:00
|
|
|
else if(m2->type == moTerraWarrior)
|
|
|
|
m2->stunoff = curtime + 300 * (6 - m2->hitpoints);
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(m2->type == moMetalBeast || m2->type == moMetalBeast2)
|
|
|
|
m2->stunoff = curtime + 3000;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(m2->type == moReptile)
|
|
|
|
m2->stunoff = curtime + 3000;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(m2->type == moTortoise)
|
|
|
|
m2->stunoff = curtime + 3000;
|
|
|
|
else if(m2->type == moSkeleton && m2->base->land != laPalace)
|
|
|
|
m2->stunoff = curtime + 2100;
|
|
|
|
else
|
|
|
|
m2->stunoff = curtime + 900;
|
|
|
|
continue;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
// conventional missiles cannot hurt some monsters
|
2018-02-12 11:48:31 +00:00
|
|
|
bool conv = (m->type == moBullet || m->type == moFlailBullet || m->type == moTongue || m->type == moArrowTrap) && !slayer;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2018-02-12 11:48:31 +00:00
|
|
|
// Raiders are unaffected
|
|
|
|
if((m2->type == moCrusher || m2->type == moPair || m2->type == moMonk ||
|
|
|
|
m2->type == moAltDemon || m2->type == moHexDemon) && conv) {
|
|
|
|
m->dead = true;
|
|
|
|
continue;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m2->type == moGreater && conv) {
|
|
|
|
m->dead = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(m2->type == moRoseBeauty && conv && !markOrb(itOrbBeauty)) {
|
2016-08-26 09:58:03 +00:00
|
|
|
m->dead = true;
|
|
|
|
continue;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m2->type == moDraugr && conv) {
|
2016-08-26 09:58:03 +00:00
|
|
|
m->dead = true;
|
|
|
|
continue;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isBull(m2->type) && conv) {
|
|
|
|
m->dead = true;
|
|
|
|
// enrage herd bulls, awaken sleeping bulls
|
|
|
|
m2->type = moRagingBull;
|
|
|
|
continue;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
// Knights reflect bullets
|
|
|
|
if(m2->type == moKnight) {
|
2017-10-12 09:33:26 +00:00
|
|
|
if(m->parent && m->parent != &arrowtrap_fakeparent) {
|
2016-08-26 09:58:03 +00:00
|
|
|
nat = nat * rspintox(inverse(m->pat) * m->parent->pat * C0);
|
|
|
|
m->rebasePat(nat);
|
|
|
|
}
|
|
|
|
m->parent = m2;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
m->dead = true;
|
|
|
|
if(m->type == moFireball) makeflame(m->base, 20, false);
|
|
|
|
// Orb of Winter protects from fireballs
|
|
|
|
if(m->type == moFireball && ((isPlayer(m2) && markOrb(itOrbWinter)) || m2->type == moWitchWinter))
|
|
|
|
continue;
|
2017-07-22 23:33:27 +00:00
|
|
|
bool revive = m2->type == moMirrorSpirit && !m2->dead;
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(m2, m->parent ? m->parent->type : moNone);
|
2017-07-22 23:33:27 +00:00
|
|
|
if(revive && m2->dead) {
|
2018-06-10 23:58:31 +00:00
|
|
|
hr::kills[moMirrorSpirit]--;
|
2017-07-22 23:33:27 +00:00
|
|
|
multi::kills[cpid]--;
|
|
|
|
mirrorspirits++;
|
|
|
|
}
|
2019-03-30 16:51:37 +00:00
|
|
|
if(m2->dead && m2->type == moAsteroid) {
|
|
|
|
gainItem(itAsteroid);
|
|
|
|
spawn_asteroids(m, m2);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hyperpoint closerTo;
|
|
|
|
|
|
|
|
bool closer(monster *m1, monster *m2) {
|
|
|
|
return intval(m1->pat*C0, closerTo) < intval(m2->pat*C0, closerTo);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool dragonbreath(cell *dragon) {
|
2017-03-23 10:53:57 +00:00
|
|
|
int randplayer = hrand(numplayers());
|
2016-08-26 09:58:03 +00:00
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = dragon;
|
2017-03-23 10:53:57 +00:00
|
|
|
bullet->at = rspintox(inverse(gmatrix[dragon]) * pc[randplayer]->pat * C0);
|
2016-08-26 09:58:03 +00:00
|
|
|
bullet->type = moFireball;
|
|
|
|
bullet->parent = bullet;
|
2017-03-23 10:53:57 +00:00
|
|
|
bullet->pid = randplayer;
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(bullet);
|
2016-08-26 09:58:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
#define CHARGING (-777)
|
|
|
|
#define BULLSTUN (1500)
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void moveMonster(monster *m, int delta) {
|
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
bool inertia_based = m->type == moAsteroid;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool stunned = m->stunoff > curtime || m->blowoff > curtime;
|
|
|
|
|
|
|
|
if(stunned && cellUnstable(m->base))
|
2017-03-23 10:53:57 +00:00
|
|
|
doesFallSound(m->base);
|
|
|
|
|
|
|
|
if(isReptile(m->base->wall)) m->base->wparam = reptilemax();
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m->base->wall == waChasm && !survivesChasm(m->type) && m->type != moReptile)
|
|
|
|
killMonster(m, moNone, AF_FALL);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(m->base->wall == waRose && !survivesThorns(m->type))
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(m, moNone);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(isWatery(m->base) && !survivesWater(m->type) && !m->inBoat && m->type != moReptile)
|
|
|
|
killMonster(m, moNone);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-10-11 20:16:07 +00:00
|
|
|
if(isFireOrMagma(m->base)) {
|
|
|
|
if(m->type == moSalamander)
|
|
|
|
m->stunoff = max(ticks+500, m->stunoff);
|
|
|
|
else if(!survivesFire(m->type))
|
|
|
|
killMonster(m, moNone);
|
|
|
|
}
|
2018-02-12 11:48:31 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->base->wall == waClosedGate && !survivesWall(m->type))
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(m, moNone);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(m->dead) return;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c = m->base;
|
|
|
|
transmatrix goal = gmatrix[c];
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool direct = false; // is there a direct path to the target?
|
|
|
|
int directi = 0; // which player has direct path (to set as pid in missiles)
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
double step = SCALE * delta/1000.0;
|
|
|
|
if(m->type == moWitchSpeed)
|
|
|
|
step *= 2;
|
|
|
|
else if(m->type == moEagle)
|
|
|
|
step *= 1.6;
|
2017-10-11 20:16:07 +00:00
|
|
|
else if(m->type == moHunterDog)
|
2017-12-03 19:14:38 +00:00
|
|
|
step *= (1 + .5 / numplayers());
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(m->type == moLancer)
|
|
|
|
step *= 1.25;
|
|
|
|
else if(isDemon(m->type)) {
|
|
|
|
if(m->type == moLesserM) m->type = moLesser;
|
|
|
|
if(m->type == moGreaterM) m->type = moGreater;
|
|
|
|
step /= 2;
|
|
|
|
}
|
|
|
|
else if(m->type == moMetalBeast || m->type == moMetalBeast2)
|
|
|
|
step /= 2;
|
2017-07-24 22:21:36 +00:00
|
|
|
else if(m->type == moTortoise && peace::on)
|
|
|
|
step = 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(m->type == moTortoise)
|
|
|
|
step /= 3;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(isBull(m->type))
|
|
|
|
step *= 1.5;
|
2018-02-12 11:48:31 +00:00
|
|
|
else if(m->type == moAltDemon || m->type == moHexDemon || m->type == moCrusher || m->type == moMonk)
|
|
|
|
step *= 1.4;
|
|
|
|
|
|
|
|
if(m->type == passive_switch) step = 0;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
if(items[itOrbBeauty] && !m->isVirtual) {
|
2017-03-23 10:53:57 +00:00
|
|
|
bool nearplayer = false;
|
2017-05-31 16:33:50 +00:00
|
|
|
for(int pid=0; pid<players; pid++) if(!pc[pid]->isVirtual) {
|
2017-03-23 10:53:57 +00:00
|
|
|
double dist = intval(pc[pid]->pat*C0, m->pat*C0);
|
|
|
|
if(dist < SCALE2) nearplayer = true;
|
|
|
|
}
|
|
|
|
if(nearplayer) markOrb(itOrbBeauty), step /= 2;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
if(m->isVirtual) {
|
|
|
|
if(m->type == moAsteroid) {
|
2019-05-08 20:48:59 +00:00
|
|
|
ld r = hypot_d(WDIM, m->inertia);
|
2019-03-30 16:51:37 +00:00
|
|
|
transmatrix nat = m->pat * rspintox(m->inertia) * xpush(r * delta) * spintox(m->inertia);
|
|
|
|
m->rebasePat(nat);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
transmatrix nat = m->pat;
|
|
|
|
|
|
|
|
if(stunned) {
|
|
|
|
if(m->blowoff > curtime) {
|
|
|
|
step = SCALE * -delta / 1000.;
|
|
|
|
}
|
2017-10-11 20:16:07 +00:00
|
|
|
else if(m->type == moFatGuard || m->type == moTortoise || m->type == moRagingBull || m->type == moTerraWarrior)
|
2016-08-26 09:58:03 +00:00
|
|
|
step = 0;
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(m->type == moReptile)
|
|
|
|
step = SCALE * -delta / 1000. * (m->stunoff - curtime) / 3000.;
|
2017-10-11 20:16:07 +00:00
|
|
|
else if(m->type == moSalamander) {
|
|
|
|
if(isFireOrMagma(m->base)) step = 0;
|
|
|
|
else
|
|
|
|
step = SCALE * -delta / 2000.;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
else step = SCALE * -delta/2000.;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
else if(m->type == moRagingBull && m->stunoff == CHARGING) ;
|
2019-03-30 16:51:37 +00:00
|
|
|
|
|
|
|
else if(m->type == moAsteroid) ;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
else {
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
if(m->type == moSleepBull && !m->isVirtual) {
|
2017-10-12 09:33:26 +00:00
|
|
|
for(monster *m2: nonvirtual) if(m2!=m && m2->type != moBullet && m2->type != moArrowTrap) {
|
2017-03-23 10:53:57 +00:00
|
|
|
double d = intval(m2->pat*C0, nat*C0);
|
|
|
|
if(d < SCALE2*3 && m2->type == moPlayer) m->type = moRagingBull;
|
|
|
|
}
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(m->type == moWitchFlash) for(int pid=0; pid<players; pid++) {
|
2017-05-31 16:33:50 +00:00
|
|
|
if(pc[pid]->isVirtual) continue;
|
|
|
|
if(m->isVirtual) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
bool okay = intval(pc[pid]->pat*C0, m->pat*C0) < 2 * SCALE2;
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m2: nonvirtual) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m2 != m && isWitch(m2->type) && intval(m2->pat*C0, m->pat*C0) < 2 * SCALE2)
|
|
|
|
okay = false;
|
|
|
|
}
|
|
|
|
if(okay) {
|
|
|
|
addMessage(XLAT("%The1 activates her Flash spell!", m->type));
|
|
|
|
pushmonsters();
|
2017-03-23 10:53:57 +00:00
|
|
|
activateFlashFrom(m->base, moWitchFlash, AF_MAGIC | AF_GETPLAYER | AF_MSG);
|
2016-08-26 09:58:03 +00:00
|
|
|
popmonsters();
|
|
|
|
m->type = moWitch;
|
|
|
|
pc[pid]->dead = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(isBug(m->type)) {
|
|
|
|
vector<monster*> bugtargets;
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m2: nonvirtual)
|
|
|
|
if(!isBullet(m2))
|
|
|
|
if(m2->type != m->type)
|
|
|
|
if(!isPlayer(m2) || !invismove)
|
|
|
|
if(!m2->dead)
|
|
|
|
bugtargets.push_back(m2);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
closerTo = m->pat * C0;
|
|
|
|
sort(bugtargets.begin(), bugtargets.end(), closer);
|
|
|
|
|
2018-02-12 11:48:31 +00:00
|
|
|
if(step) for(monster *m2: bugtargets)
|
2017-12-01 23:31:36 +00:00
|
|
|
if(trackroute(m, m2->pat, step)) {
|
2017-05-31 16:33:50 +00:00
|
|
|
goal = m2->pat;
|
2016-08-26 09:58:03 +00:00
|
|
|
direct = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-07-24 00:02:32 +00:00
|
|
|
else if(m->type == moWolf && !peace::on) {
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *cnext = c;
|
|
|
|
for(int i=0; i<c->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = c->move(i);
|
2017-10-11 20:16:07 +00:00
|
|
|
if(c2 && gmatrix.count(c2) && (c2->land == laVolcano || (isIcyLand(c2) && HEAT(c2) > HEAT(c))) && passable(c2, c, 0))
|
2016-08-26 09:58:03 +00:00
|
|
|
cnext = c2;
|
|
|
|
}
|
|
|
|
goal = gmatrix[cnext];
|
|
|
|
direct = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
directi = 0;
|
|
|
|
}
|
2019-02-17 17:33:15 +00:00
|
|
|
#if CAP_FIELD
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(m->type == moHerdBull) {
|
|
|
|
cell *cnext = prairie::next(c);
|
|
|
|
if(cnext && gmatrix.count(cnext)) {
|
|
|
|
goal = gmatrix[cnext];
|
|
|
|
direct = true;
|
|
|
|
directi = 0;
|
|
|
|
}
|
|
|
|
else m->dead = true;
|
|
|
|
}
|
2019-02-17 17:33:15 +00:00
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
else if(m->type == moButterfly) {
|
|
|
|
int d = neighborId(m->base, m->torigin);
|
|
|
|
cell *cnext = NULL;
|
|
|
|
for(int u=2; u<m->base->type; u++) {
|
|
|
|
cell *c2 = createMov(m->base, (d+u) % m->base->type);
|
|
|
|
if(passable_for(m->type, c2, m->base, P_ONPLAYER)) {
|
|
|
|
cnext = c2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cnext && gmatrix.count(cnext)) {
|
|
|
|
goal = gmatrix[cnext];
|
|
|
|
direct = true;
|
|
|
|
directi = 0;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-07-24 00:02:32 +00:00
|
|
|
else if(!direct && !invismove && !peace::on) {
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<players; i++)
|
2018-02-12 11:48:31 +00:00
|
|
|
if(step && trackroute(m, pc[i]->pat, step) && (!direct || intval(pc[i]->pat*C0, m->pat*C0) < intval(goal*C0,m->pat*C0))) {
|
2016-08-26 09:58:03 +00:00
|
|
|
goal = pc[i]->pat;
|
|
|
|
direct = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
directi = i;
|
2016-08-26 09:58:03 +00:00
|
|
|
// m->trackrouteView(pc->pat, step);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-24 00:02:32 +00:00
|
|
|
if(!direct && !peace::on) while(true) {
|
2018-02-12 11:48:31 +00:00
|
|
|
if(step && trackroute(m, gmatrix[c], step))
|
2016-08-26 09:58:03 +00:00
|
|
|
goal = gmatrix[c];
|
|
|
|
cell *cnext = c;
|
|
|
|
for(int i=0; i<c->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = c->move(i);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2 && gmatrix.count(c2) && c2->pathdist < c->pathdist &&
|
|
|
|
passable_for(m->type, c2, c, P_CHAIN | P_ONPLAYER))
|
|
|
|
cnext = c2;
|
|
|
|
}
|
|
|
|
if(cnext == c) break;
|
|
|
|
c = cnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m->type == moHedge) {
|
|
|
|
hyperpoint h = inverse(m->pat) * goal * C0;
|
|
|
|
if(h[1] < 0)
|
|
|
|
nat = nat * spin(M_PI * delta / 3000 / speedfactor());
|
|
|
|
else
|
|
|
|
nat = nat * spin(M_PI * -delta / 3000 / speedfactor());
|
|
|
|
m->rebasePat(nat);
|
|
|
|
// at most 45 degrees
|
|
|
|
if(h[0] < fabsl(h[1])) return;
|
|
|
|
}
|
2017-07-24 00:02:32 +00:00
|
|
|
else if(!peace::on) {
|
2016-08-26 09:58:03 +00:00
|
|
|
nat = nat * rspintox(inverse(m->pat) * goal * C0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
if(m->type == moVampire && !m->isVirtual) for(int i=0; i<players; i++)
|
|
|
|
if(!pc[i]->isVirtual && intval(m->pat*C0, pc[i]->pat*C0) < SCALE2 * 2) {
|
2017-03-23 10:53:57 +00:00
|
|
|
for(int i=0; i<ittypes; i++)
|
|
|
|
if(itemclass(eItem(i)) == IC_ORB && items[i] && items[itOrbTime] && !orbused[i])
|
|
|
|
orbused[i] = true;
|
|
|
|
step = 0;
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
bool carried = false;
|
|
|
|
|
|
|
|
if(c->land == laWhirlpool && (m->type == moShark || m->type == moCShark || m->type == moPirate))
|
|
|
|
oceanCurrents(nat, m, delta), carried = true;
|
|
|
|
|
2017-10-11 20:16:07 +00:00
|
|
|
if(m->type != moGhost && m->type != moFriendlyGhost && m->type != moAirElemental)
|
|
|
|
carried |= airCurrents(nat, m, delta);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(rosedist(m->base) == 1)
|
|
|
|
roseCurrents(nat, m, delta), carried = true;
|
|
|
|
|
|
|
|
step /= speedfactor();
|
2019-02-28 15:28:41 +00:00
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3) step /= 3;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int igo = 0;
|
|
|
|
|
|
|
|
transmatrix nat0 = nat;
|
|
|
|
|
|
|
|
igo_retry:
|
|
|
|
|
2017-07-24 00:02:32 +00:00
|
|
|
if(igo == IGO && peace::on)
|
|
|
|
nat0 = nat0 * spin(rand() % 16);
|
|
|
|
|
|
|
|
else if(igo >= IGO) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m->type == moHerdBull) m->type = moRagingBull;
|
2016-08-26 09:58:03 +00:00
|
|
|
return;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(igo == 1 && m->type == moRagingBull && m->stunoff == CHARGING) {
|
|
|
|
m->stunoff = curtime + BULLSTUN;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
if(inertia_based) {
|
|
|
|
if(igo) return;
|
2019-05-08 20:48:59 +00:00
|
|
|
ld r = hypot_d(WDIM, m->inertia);
|
2019-03-30 16:51:37 +00:00
|
|
|
nat = nat * rspintox(m->inertia) * xpush(r * delta) * spintox(m->inertia);
|
|
|
|
}
|
2019-05-08 20:48:59 +00:00
|
|
|
else if(WDIM == 3 && igo) {
|
2019-03-09 17:17:58 +00:00
|
|
|
ld fspin = rand() % 1000;
|
|
|
|
nat = nat0 * cspin(1,2,fspin) * spin(igospan[igo]) * xpush(step) * spin(-igospan[igo]) * cspin(2,1,fspin);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nat = nat0 * spin(igospan[igo]) * xpush(step) * spin(-igospan[igo]); // * spintox(wherePC);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-07-24 00:02:32 +00:00
|
|
|
if(m->type != moRagingBull && !peace::on)
|
2019-03-30 16:51:37 +00:00
|
|
|
if(intval(nat*C0, goal*C0) >= intval(m->pat*C0, goal*C0) && !stunned && !carried && !inertia_based) {
|
2017-03-23 10:53:57 +00:00
|
|
|
igo++; goto igo_retry; }
|
|
|
|
|
|
|
|
for(int i=0; i<multi::players; i++) for(int b=0; b<2; b++) if(sword::orbcount(b)) {
|
2017-05-31 16:33:50 +00:00
|
|
|
if(pc[i]->isVirtual) continue;
|
2017-03-23 10:53:57 +00:00
|
|
|
hyperpoint H = swordpos(i, b, 1);
|
|
|
|
double d = intval(H, nat*C0);
|
|
|
|
if(d < SCALE2 * 0.12) { igo++; goto igo_retry; }
|
|
|
|
}
|
|
|
|
|
|
|
|
m->footphase += step;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
monster* crashintomon = NULL;
|
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
if(!m->isVirtual && m->type != moAsteroid) for(monster *m2: nonvirtual) if(m2!=m && m2->type != moBullet && m2->type != moArrowTrap) {
|
2016-08-26 09:58:03 +00:00
|
|
|
double d = intval(m2->pat*C0, nat*C0);
|
2017-05-31 16:33:50 +00:00
|
|
|
if(d < SCALE2 * 0.1) crashintomon = m2;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
if(m->type == moAsteroid) for(int i=0; i<players; i++) if(pc[i] && hdist(tC0(pc[i]->pat), tC0(m->pat)) < collision_distance(pc[i], m))
|
|
|
|
crashintomon = pc[i];
|
|
|
|
|
2017-07-24 00:02:32 +00:00
|
|
|
if(!peace::on)
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<players; i++)
|
|
|
|
if(crashintomon == pc[i])
|
|
|
|
pc[i]->dead = true;
|
|
|
|
|
2017-07-24 00:02:32 +00:00
|
|
|
if(peace::on) ;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
else if(crashintomon && isMimic(crashintomon->type)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(crashintomon, m->type);
|
2016-08-26 09:58:03 +00:00
|
|
|
crashintomon = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(crashintomon && (
|
2017-03-23 10:53:57 +00:00
|
|
|
items[itOrbDiscord] || isBull(m->type) ||
|
2016-08-26 09:58:03 +00:00
|
|
|
((isBug(m->type) || isBug(crashintomon->type)) && m->type != crashintomon->type))
|
|
|
|
&& !isBullet(crashintomon)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(noncrashable(crashintomon, m)) {
|
|
|
|
if(isBull(crashintomon->type)) crashintomon->type = moRagingBull;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
killMonster(crashintomon, m->type, isBull(m->type) ? AF_BULL : 0);
|
|
|
|
crashintomon = NULL;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2019-03-30 16:51:37 +00:00
|
|
|
if(crashintomon && m->type != moAsteroid) { igo++; goto igo_retry; }
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
cell *c2 = m->findbase(nat);
|
2018-09-23 21:55:03 +00:00
|
|
|
if(reflectflag & P_MIRRORWALL) reflect(c2, m->base, nat);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(m->type == moButterfly && !passable_for(m->type, c2, m->base, P_CHAIN | reflectflag)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
igo++; goto igo_retry;
|
|
|
|
}
|
|
|
|
|
2017-07-24 00:02:32 +00:00
|
|
|
if(isPlayerOn(c2) && !peace::on) {
|
2016-08-26 09:58:03 +00:00
|
|
|
bool usetongue = false;
|
|
|
|
if(isSlimeMover(m->type) || m->type == moWaterElemental) usetongue = true;
|
|
|
|
if(isWatery(c2) && !survivesWater(m->type) && !m->inBoat) usetongue = true;
|
|
|
|
if(c2->wall == waChasm && !survivesChasm(m->type)) usetongue = true;
|
2017-10-11 20:16:07 +00:00
|
|
|
if(isFireOrMagma(c2) && !survivesFire(m->type) && !m->inBoat) usetongue = true;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isBird(m->type) && !passable_for(moEagle, c2, c, 0)) usetongue = true;
|
2018-02-12 11:48:31 +00:00
|
|
|
if((m->type == moMonk || m->type == moAltDemon || m->type == moHexDemon) && !passable_for(m->type, c2, c, 0))
|
|
|
|
usetongue = true;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(usetongue) {
|
|
|
|
if(curtime < m->nextshot) return;
|
|
|
|
// m->nextshot = curtime + 25;
|
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = m->base;
|
|
|
|
bullet->at = m->at;
|
|
|
|
bullet->type = moTongue;
|
|
|
|
bullet->parent = m;
|
|
|
|
bullet->parenttype = m->type;
|
2017-03-23 10:53:57 +00:00
|
|
|
bullet->pid = whichPlayerOn(c2);
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(bullet);
|
2016-08-26 09:58:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!ignoresPlates(m->type)) destroyWeakBranch(m->base, c2, m->type);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(c2 != m->base && (c2->wall == waClosePlate || c2->wall == waOpenPlate) && !ignoresPlates(m->type))
|
|
|
|
toggleGates(c2, c2->wall, 3);
|
2017-10-12 09:33:26 +00:00
|
|
|
|
|
|
|
if(c2 != m->base && c2->wall == waArrowTrap && c2->wparam == 0 && !ignoresPlates(m->type))
|
|
|
|
activateArrowTrap(c2);
|
|
|
|
|
2019-01-11 01:23:44 +00:00
|
|
|
if(c2 != m->base && c2->wall == waFireTrap && c2->wparam == 0 && !ignoresPlates(m->type)) {
|
|
|
|
c2->wparam = 2;
|
|
|
|
firetraplist.emplace(ticks + 800, c2);
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2 != m->base && mayExplodeMine(c2, m->type))
|
|
|
|
killMonster(m, moNone);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2 != m->base && c2->wall == waRose && !nonAdjacent(m->base, c2) && !survivesThorns(m->type))
|
2017-03-23 10:53:57 +00:00
|
|
|
killMonster(m, moNone);
|
|
|
|
|
|
|
|
if(c2 != m->base && cellUnstable(m->base) && !ignoresPlates(m->type))
|
|
|
|
doesFallSound(m->base);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-10-11 20:16:07 +00:00
|
|
|
if(m->type == moWolf && c2->land == laVolcano) m->type = moLavaWolf;
|
|
|
|
if(m->type == moLavaWolf && isIcyLand(c2)) m->type = moWolf;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2 != m->base && m->type == moWitchFire) makeflame(m->base, 10, false);
|
|
|
|
if(c2 != m->base && m->type == moFireElemental) makeflame(m->base, 20, false);
|
|
|
|
if(c2 != m->base && m->type == moWaterElemental) placeWater(c2, m->base);
|
|
|
|
if(c2 != m->base && m->type == moEarthElemental) {
|
|
|
|
int d = dirfromto(m->base, c2);
|
|
|
|
if(d >= 0) earthMove(m->base, d);
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m->type == moReptile && c2 != m->base) {
|
|
|
|
if(c2->wall == waChasm) {
|
|
|
|
c2->wall = waReptile;
|
|
|
|
c2->wparam = reptilemax();
|
|
|
|
playSound(c, "click");
|
|
|
|
m->dead = true;
|
|
|
|
}
|
|
|
|
else if(isChasmy(c2) || isWatery(c2)) {
|
|
|
|
c2->wall = waReptileBridge;
|
|
|
|
c2->item = itNone;
|
|
|
|
c2->wparam = reptilemax();
|
|
|
|
playSound(c, "click");
|
|
|
|
m->dead = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(c2 != m->base && m->type == moNecromancer && !c2->monst) {
|
|
|
|
for(int i=0; i<m->base->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c3 = m->base->move(i);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(dirfromto(c3, c2) != -1 && c3->wall == waFreshGrave && gmatrix.count(c3)) {
|
|
|
|
bool monstersNear = false;
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m2: nonvirtual) {
|
|
|
|
if(m2 != m && intval(m2->pat*C0, gmatrix[c3]*C0) < SCALE2 * .3)
|
2016-08-26 09:58:03 +00:00
|
|
|
monstersNear = true;
|
2017-05-31 16:33:50 +00:00
|
|
|
if(m2 != m && intval(m2->pat*C0, gmatrix[c2]*C0) < SCALE2 * .3)
|
2016-08-26 09:58:03 +00:00
|
|
|
monstersNear = true;
|
|
|
|
}
|
|
|
|
if(!monstersNear) {
|
|
|
|
|
|
|
|
monster* undead = new monster;
|
|
|
|
undead->base = c2;
|
|
|
|
undead->at = Id;
|
|
|
|
undead->type = moZombie;
|
|
|
|
undead->parent = m;
|
|
|
|
undead->parenttype = m->type;
|
2017-03-23 10:53:57 +00:00
|
|
|
undead->pid = 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
undead->findpat();
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(undead);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
undead = new monster;
|
|
|
|
undead->base = c3;
|
|
|
|
undead->at = Id;
|
|
|
|
undead->type = moGhost;
|
|
|
|
undead->parent = m;
|
|
|
|
undead->parenttype = m->type;
|
|
|
|
undead->findpat();
|
2017-03-23 10:53:57 +00:00
|
|
|
undead->pid = 0;
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(undead);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
c3->wall = waAncientGrave;
|
|
|
|
addMessage(XLAT("%The1 raises some undead!", m->type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(m->type == moGreaterShark) {
|
|
|
|
if(c2->wall == waBoat)
|
|
|
|
c2->wall = waNone;
|
|
|
|
if(c2->wall == waFrozenLake)
|
|
|
|
c2->wall = waLake;
|
|
|
|
}
|
|
|
|
if(m->type == moDarkTroll && c2->wall == waCavefloor) {
|
|
|
|
m->type = moTroll;
|
|
|
|
}
|
|
|
|
if(isLeader(m->type)) {
|
|
|
|
if(c2 != m->base) {
|
|
|
|
if(c2->wall == waBigStatue && canPushStatueOn(m->base)) {
|
|
|
|
c2->wall = m->base->wall;
|
|
|
|
if(cellUnstable(m->base))
|
|
|
|
m->base->wall = waChasm;
|
|
|
|
else
|
|
|
|
m->base->wall = waBigStatue;
|
2018-06-17 15:51:26 +00:00
|
|
|
animateMovement(c2, m->base, LAYER_BOAT, NOHINT);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-07-22 23:33:27 +00:00
|
|
|
if(passable_for(m->type, c2, m->base, P_CHAIN | P_ONPLAYER | reflectflag) && !isWatery(c2) && m->inBoat) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isWatery(m->base))
|
|
|
|
m->base->wall = waBoat, m->base->mondir = dirfromto(m->base, c2);
|
|
|
|
else if(boatStrandable(c2)) c2->wall = waStrandedBoat;
|
|
|
|
else if(boatStrandable(m->base)) m->base->wall = waStrandedBoat;
|
|
|
|
m->inBoat = false;
|
|
|
|
}
|
|
|
|
if(isWatery(c2) && isWatery(m->base) && m->inBoat)
|
|
|
|
moveItem(m->base, c2, true);
|
|
|
|
}
|
|
|
|
if(c2->wall == waBoat && !m->inBoat) {
|
|
|
|
m->inBoat = true; c2->wall = waSea;
|
|
|
|
m->base = c2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-24 00:02:32 +00:00
|
|
|
if(peace::on && c2->mpdist > 7) return;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(!(m->type == moRoseBeauty && c2->land != laRose)) {
|
2017-07-22 23:33:27 +00:00
|
|
|
if(stunned ? passable(c2, m->base, P_BLOW | reflectflag) : passable_for(m->type, c2, m->base, P_CHAIN | reflectflag)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2 != m->base && m->type == moButterfly)
|
|
|
|
m->torigin = m->base;
|
|
|
|
m->rebasePat(nat);
|
|
|
|
if(m->type == moRagingBull && step > 1e-6) m->stunoff = CHARGING;
|
|
|
|
}
|
2017-07-24 00:02:32 +00:00
|
|
|
else {
|
|
|
|
if(peace::on) { igo++; goto igo_retry; }
|
|
|
|
if(m->type == moRagingBull && m->stunoff == CHARGING)
|
|
|
|
m->stunoff = curtime + BULLSTUN;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
if(direct) {
|
|
|
|
if((m->type == moPyroCultist || m->type == moCrystalSage) && curtime >= m->nextshot) {
|
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = m->base;
|
|
|
|
bullet->at = m->at;
|
|
|
|
bullet->type = moFireball;
|
|
|
|
bullet->parent = m;
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(bullet);
|
2017-03-23 10:53:57 +00:00
|
|
|
bullet->pid = directi;
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->type == moPyroCultist)
|
|
|
|
m->type = moCultist;
|
|
|
|
else
|
|
|
|
m->nextshot = curtime + 100;
|
|
|
|
}
|
|
|
|
if(m->type == moOutlaw && curtime >= m->nextshot) {
|
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = m->base;
|
|
|
|
bullet->at = m->at;
|
|
|
|
bullet->type = moBullet;
|
|
|
|
bullet->parent = m;
|
|
|
|
bullet->parenttype = moOutlaw;
|
2017-03-23 10:53:57 +00:00
|
|
|
bullet->pid = directi;
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(bullet);
|
2016-08-26 09:58:03 +00:00
|
|
|
m->nextshot = curtime + 1500;
|
|
|
|
}
|
2017-05-31 16:33:50 +00:00
|
|
|
for(int i=0; i<players; i++) if(!pc[i]->isVirtual)
|
2016-08-26 09:58:03 +00:00
|
|
|
if((m->type == moAirElemental) && curtime >= m->nextshot && intval(m->pat*C0, pc[i]->pat*C0) < SCALE2 * 2) {
|
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = m->base;
|
|
|
|
bullet->at = m->at;
|
|
|
|
bullet->type = moAirball;
|
|
|
|
bullet->parent = m;
|
2017-03-23 10:53:57 +00:00
|
|
|
bullet->pid = i;
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(bullet);
|
2016-08-26 09:58:03 +00:00
|
|
|
m->nextshot = curtime + 1500;
|
|
|
|
}
|
2017-05-31 16:33:50 +00:00
|
|
|
for(int i=0; i<players; i++) if(!pc[i]->isVirtual)
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m->type == moTortoise && tortoise::seek() && !tortoise::diff(getBits(m->torigin)) && intval(m->pat*C0, pc[i]->pat*C0) < SCALE2) {
|
2016-08-26 09:58:03 +00:00
|
|
|
items[itBabyTortoise] += 4;
|
|
|
|
m->dead = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(XLAT(playergender() == GEN_F ? "You are now a tortoise heroine!" : "You are now a tortoise hero!"));
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-05-31 16:33:50 +00:00
|
|
|
for(int i=0; i<players; i++) if(!pc[i]->isVirtual)
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->type == moFlailer && curtime >= m->nextshot &&
|
|
|
|
intval(m->pat*C0, pc[i]->pat*C0) < SCALE2 * 2) {
|
|
|
|
m->nextshot = curtime + 3500;
|
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = m->base;
|
|
|
|
bullet->at = m->at;
|
|
|
|
bullet->type = moFlailBullet;
|
|
|
|
bullet->parent = m;
|
|
|
|
bullet->vel = 1/400.0;
|
2017-03-23 10:53:57 +00:00
|
|
|
bullet->pid = i;
|
2017-05-31 16:33:50 +00:00
|
|
|
additional.push_back(bullet);
|
2016-08-26 09:58:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-02-12 11:48:31 +00:00
|
|
|
for(int i=0; i<players; i++) if(!pc[i]->isVirtual)
|
|
|
|
if(m->type == moCrusher && intval(m->pat*C0, pc[i]->pat*C0) < SCALE2 * .75) {
|
|
|
|
m->stunoff = curtime + 1500;
|
|
|
|
monster* bullet = new monster;
|
|
|
|
bullet->base = m->base;
|
|
|
|
bullet->at = m->at;
|
|
|
|
bullet->type = moCrushball;
|
|
|
|
bullet->parent = m;
|
|
|
|
bullet->pid = i;
|
|
|
|
additional.push_back(bullet);
|
|
|
|
break;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
void activateMonstersAt(cell *c) {
|
|
|
|
pair<mit, mit> p =
|
|
|
|
monstersAt.equal_range(c);
|
|
|
|
for(mit it = p.first; it != p.second;) {
|
|
|
|
mit itplus = it;
|
|
|
|
itplus++;
|
|
|
|
active.push_back(it->second);
|
|
|
|
monstersAt.erase(it);
|
|
|
|
it = itplus;
|
|
|
|
}
|
|
|
|
if(c->monst && isMimic(c->monst)) c->monst = moNone;
|
|
|
|
// mimics are awakened by awakenMimics
|
2017-10-11 20:16:07 +00:00
|
|
|
if(c->monst && !isIvy(c) && !isWorm(c) && !isMutantIvy(c) && !isKraken(c->monst) && c->monst != moPrincess && c->monst != moHunterGuard) {
|
2017-05-31 16:33:50 +00:00
|
|
|
// awaken as a monster
|
|
|
|
monster *enemy = new monster;
|
|
|
|
enemy->at = Id;
|
|
|
|
enemy->base = c;
|
|
|
|
if(enemy->type == moButterfly)
|
|
|
|
enemy->torigin = createMov(c, (c->mondir + 419) % c->type);
|
|
|
|
enemy->torigin = c;
|
|
|
|
enemy->type = c->monst;
|
|
|
|
enemy->hitpoints = c->hitpoints;
|
|
|
|
if(c->wall == waBoat && isLeader(c->monst))
|
|
|
|
enemy->inBoat = true, c->wall = waSea;
|
2019-03-30 16:51:37 +00:00
|
|
|
if(c->monst == moAsteroid) {
|
|
|
|
enemy->inertia = random_spin() * point2(SCALE/3000., 0);
|
|
|
|
}
|
2017-05-31 16:33:50 +00:00
|
|
|
c->monst = moNone;
|
|
|
|
active.push_back(enemy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-09 01:41:33 +00:00
|
|
|
void fixStorage() {
|
2018-05-22 18:40:52 +00:00
|
|
|
|
2017-06-09 01:41:33 +00:00
|
|
|
vector<monster*> restore;
|
2018-05-22 18:40:52 +00:00
|
|
|
|
|
|
|
for(auto it = monstersAt.begin(); it != monstersAt.end(); it++)
|
|
|
|
restore.push_back(it->second);
|
|
|
|
|
|
|
|
monstersAt.clear();
|
|
|
|
|
2017-06-09 01:41:33 +00:00
|
|
|
for(monster *m: restore) m->store();
|
|
|
|
}
|
|
|
|
|
2018-07-09 17:32:34 +00:00
|
|
|
hookset<bool(int)> *hooks_turn;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
void turn(int delta) {
|
|
|
|
|
2019-03-09 15:20:06 +00:00
|
|
|
if(racing::on && subscreens::split( [delta] () { turn(delta); })) return;
|
2018-11-17 18:30:50 +00:00
|
|
|
|
2018-07-09 17:32:34 +00:00
|
|
|
if(callhandlers(false, hooks_turn, delta)) return;
|
2018-07-09 18:38:20 +00:00
|
|
|
if(!shmup::on) return;
|
2019-01-03 18:59:10 +00:00
|
|
|
|
|
|
|
if(!(cmode & sm::NORMAL)) {
|
|
|
|
#if CAP_RACING
|
|
|
|
if(racing::on) {
|
|
|
|
if(racing::race_start_tick) racing::race_start_tick += delta;
|
|
|
|
for(int& i: racing::race_finish_tick) if(i) i += delta;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
2018-11-17 18:30:50 +00:00
|
|
|
|
2018-07-09 18:38:20 +00:00
|
|
|
timetowait = 0;
|
2018-07-09 17:32:34 +00:00
|
|
|
|
2018-02-12 11:48:31 +00:00
|
|
|
passive_switch = (gold() & 1) ? moSwitch1 : moSwitch2;
|
2017-03-23 10:53:57 +00:00
|
|
|
lmousetarget = NULL;
|
2017-05-31 16:33:50 +00:00
|
|
|
if(mousetarget && !mousetarget->isVirtual && intval(mouseh, mousetarget->pat*C0) < 0.1)
|
2017-03-23 10:53:57 +00:00
|
|
|
lmousetarget = mousetarget;
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
if(delta > 1000) delta = 1000;
|
|
|
|
|
|
|
|
if(delta > 200) { turn(200); delta -= 200; if(!delta) return; }
|
|
|
|
|
|
|
|
curtime += delta;
|
|
|
|
|
|
|
|
handleInput(delta);
|
|
|
|
|
|
|
|
invismove = (curtime >= visibleAt) && markOrb(itOrbInvis);
|
|
|
|
|
|
|
|
// detect active monsters
|
2017-06-09 01:41:33 +00:00
|
|
|
if(doall)
|
2017-05-31 16:33:50 +00:00
|
|
|
for(cell *c: currentmap->allcells()) activateMonstersAt(c);
|
|
|
|
else
|
|
|
|
for(unordered_map<cell*, transmatrix>::iterator it = gmatrix.begin(); it != gmatrix.end(); it++)
|
|
|
|
activateMonstersAt(it->first);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
/* printf("size: gmatrix = %ld, active = %ld, monstersAt = %ld, delta = %d\n",
|
|
|
|
gmatrix.size(), active.size(), monstersAt.size(),
|
|
|
|
delta); */
|
|
|
|
|
|
|
|
bool exists[motypes];
|
|
|
|
|
|
|
|
for(int i=0; i<motypes; i++) exists[i] = false;
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
nonvirtual.clear();
|
|
|
|
for(monster *m: active) {
|
2016-08-26 09:58:03 +00:00
|
|
|
m->findpat();
|
2017-05-31 16:33:50 +00:00
|
|
|
if(m->isVirtual) continue;
|
|
|
|
else nonvirtual.push_back(m);
|
2016-08-26 09:58:03 +00:00
|
|
|
exists[movegroup(m->type)] = true;
|
|
|
|
}
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m: active) {
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
switch(m->type) {
|
|
|
|
case moPlayer:
|
|
|
|
movePlayer(m, delta);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case moBullet: case moFlailBullet: case moFireball: case moTongue: case moAirball:
|
2018-02-12 11:48:31 +00:00
|
|
|
case moArrowTrap: case moCrushball:
|
2016-08-26 09:58:03 +00:00
|
|
|
moveBullet(m, delta);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m: active) {
|
2016-08-26 09:58:03 +00:00
|
|
|
if(isMimic(m->type))
|
|
|
|
moveMimic(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int t=1; t<motypes; t++) if(exists[t]) {
|
|
|
|
|
2018-06-28 09:42:25 +00:00
|
|
|
pathdata pd(1);
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// build the path data
|
|
|
|
|
2018-06-28 09:42:25 +00:00
|
|
|
for(cell *c: targets)
|
|
|
|
onpath(c, isPlayerOn(c) ? 0 : 1);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
int qb = 0;
|
2018-06-22 12:47:24 +00:00
|
|
|
for(qb=0; qb < isize(pathq); qb++) {
|
2016-08-26 09:58:03 +00:00
|
|
|
cell *c = pathq[qb];
|
|
|
|
int d = c->pathdist;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(d == PINFD-1) continue;
|
2016-08-26 09:58:03 +00:00
|
|
|
for(int i=0; i<c->type; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
cell *c2 = c->move(i);
|
|
|
|
// printf("i=%d cd=%d\n", i, c->move(i)->cpdist);
|
2017-03-23 10:53:57 +00:00
|
|
|
if(c2 && c2->pathdist == PINFD && gmatrix.count(c2) &&
|
2016-08-26 09:58:03 +00:00
|
|
|
(passable_for(eMonster(t), c, c2, P_CHAIN | P_ONPLAYER) || c->wall == waThumperOn)) {
|
2018-06-28 09:42:25 +00:00
|
|
|
onpath(c2, d+1);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// printf("time %d, t=%d, q=%d\n", curtime, t, qb);
|
|
|
|
|
|
|
|
// move monsters of this type
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m: nonvirtual)
|
|
|
|
if(movegroup(m->type) == t)
|
|
|
|
moveMonster(m, delta);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(shmup::on) {
|
|
|
|
|
2017-10-12 09:33:26 +00:00
|
|
|
doTraps();
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool tick = curtime >= nextmove;
|
|
|
|
keepLightning = ticks <= lightat + 1000;
|
2018-08-17 22:46:45 +00:00
|
|
|
cwt.at = pc[0]->base;
|
2017-03-23 10:53:57 +00:00
|
|
|
bfs(); moverefresh(tick);
|
|
|
|
countLocalTreasure();
|
|
|
|
pushmonsters();
|
|
|
|
if(items[itOrbFreedom])
|
|
|
|
for(int i=0; i<players; i++)
|
|
|
|
checkFreedom(pc[i]->base);
|
2017-09-02 22:33:35 +00:00
|
|
|
heat::processheat(delta / 350.0);
|
2017-03-23 10:53:57 +00:00
|
|
|
markOrb(itOrbSpeed);
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if((havewhat&HF_DRAGON) && curtime >= nextdragon) {
|
|
|
|
groupmove(moDragonHead, 0);
|
|
|
|
nextdragon = curtime + 1500;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(tick) {
|
|
|
|
nextmove += 1000;
|
|
|
|
flashMessages();
|
|
|
|
reduceOrbPowers();
|
|
|
|
if(items[itOrbBull]) for(int p=0; p<players; p++)
|
|
|
|
if(bulltime[p] < curtime - 600) orbbull::gainBullPowers();
|
|
|
|
|
|
|
|
if(!((items[itOrbSpeed]/players) & 1)) {
|
|
|
|
if(havewhat&HF_KRAKEN) kraken::attacks(), groupmove(moKrakenH, 0);
|
|
|
|
moveworms();
|
|
|
|
moveivy();
|
|
|
|
movemutant();
|
2017-12-05 18:43:45 +00:00
|
|
|
if(havewhat&HF_HEX) movehex_all();
|
2017-03-23 10:53:57 +00:00
|
|
|
wandering();
|
|
|
|
livecaves();
|
2017-10-12 09:33:26 +00:00
|
|
|
terracotta();
|
2017-09-02 22:33:35 +00:00
|
|
|
heat::processfires();
|
2017-03-23 10:53:57 +00:00
|
|
|
if(havewhat&HF_WHIRLPOOL) whirlpool::move();
|
|
|
|
if(havewhat&HF_WHIRLWIND) whirlwind::move();
|
2019-02-17 17:37:23 +00:00
|
|
|
#if CAP_COMPLEX2
|
2019-01-24 13:51:52 +00:00
|
|
|
if(havewhat & HF_WESTWALL) westwall::move();
|
2019-02-17 17:37:23 +00:00
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
buildRosemap();
|
|
|
|
if(havewhat&HF_RIVER) prairie::move();
|
|
|
|
}
|
|
|
|
if(recallCell && !markOrb(itOrbRecall)) activateRecall();
|
2018-01-26 00:45:49 +00:00
|
|
|
save_memory();
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
if(elec::havecharge) elec::act();
|
|
|
|
popmonsters();
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
bool lastcanmove = canmove;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
canmove = true;
|
|
|
|
|
|
|
|
for(int i=0; i<players; i++) {
|
|
|
|
if(pc[i]->dead && items[itOrbShield]) {
|
|
|
|
pc[i]->dead = false;
|
|
|
|
orbused[itOrbShield] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pc[i]->dead && items[itOrbFlash]) {
|
|
|
|
pc[i]->dead = false;
|
|
|
|
pushmonsters();
|
|
|
|
killMonster(pc[i]->base, moNone);
|
|
|
|
activateFlash();
|
|
|
|
popmonsters();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pc[i]->dead && items[itOrbLightning]) {
|
|
|
|
pc[i]->dead = false;
|
|
|
|
pushmonsters();
|
|
|
|
killMonster(pc[i]->base, moLightningBolt);
|
|
|
|
activateLightning();
|
|
|
|
popmonsters();
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(pc[i]->dead && items[itOrbShell]) {
|
|
|
|
pc[i]->dead = false;
|
|
|
|
useupOrb(itOrbShell, 10);
|
|
|
|
items[itOrbShield] = 1;
|
|
|
|
orbused[itOrbShield] = true;
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(pc[i]->dead && items[itOrbLife]) {
|
|
|
|
multi::deaths[i]++;
|
|
|
|
items[itOrbLife]--;
|
|
|
|
items[itOrbShield] += 3;
|
|
|
|
items[itOrbAether] += 3;
|
|
|
|
pc[i]->dead = false;
|
|
|
|
orbused[itOrbShield] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pc[i]->dead && !lastdead) {
|
|
|
|
multi::deaths[i]++;
|
|
|
|
achievement_final(true);
|
|
|
|
}
|
|
|
|
lastdead = pc[i]->dead;
|
2017-07-22 23:33:27 +00:00
|
|
|
|
|
|
|
if(lastcanmove && pc[i]->dead) showMissionScreen();
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
canmove = canmove && !pc[i]->dead;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
for(monster *m: additional)
|
|
|
|
active.push_back(m);
|
|
|
|
additional.clear();
|
2017-05-31 16:33:50 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
// deactivate all monsters
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m: active)
|
|
|
|
if(m->dead && m->type != moPlayer) {
|
|
|
|
for(monster *m2: active) if(m2->parent == m)
|
|
|
|
m2->parent = m->parent;
|
2017-09-04 18:43:17 +00:00
|
|
|
if(m == mousetarget) mousetarget = NULL;
|
|
|
|
if(m == lmousetarget) lmousetarget = NULL;
|
2017-05-31 16:33:50 +00:00
|
|
|
delete m;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m->store();
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
active.clear();
|
|
|
|
|
2019-04-28 10:09:57 +00:00
|
|
|
if(delayed_safety) {
|
2016-08-26 09:58:03 +00:00
|
|
|
activateSafety(pc[0]->base->land);
|
2019-04-28 10:09:57 +00:00
|
|
|
delayed_safety = false;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void recall() {
|
|
|
|
for(int i=0; i<players; i++) {
|
2018-08-17 22:46:45 +00:00
|
|
|
pc[i]->base = cwt.at;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(players == 1)
|
|
|
|
pc[i]->at = Id;
|
|
|
|
else
|
|
|
|
pc[i]->at = spin(2*M_PI*i/players) * xpush(firstland == laMotion ? .5 : .3) * Id;
|
2018-08-17 22:46:45 +00:00
|
|
|
/* ggmatrix(cwt.at);
|
|
|
|
display(gmatrix[cwt.at]);
|
2017-03-23 10:53:57 +00:00
|
|
|
pc[i]->findpat(); */
|
|
|
|
}
|
|
|
|
destroyMimics();
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void init() {
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
for(int i=0; i<players; i++) pc[i] = NULL;
|
|
|
|
|
|
|
|
for(int i=0; i<players; i++) {
|
|
|
|
pc[i] = new monster;
|
|
|
|
pc[i]->type = moPlayer;
|
|
|
|
pc[i]->pid = i;
|
|
|
|
if(players == 1)
|
|
|
|
pc[i]->at = Id;
|
|
|
|
else
|
|
|
|
pc[i]->at = spin(2*M_PI*i/players) * xpush(firstland == laMotion ? .5 : .3) * Id;
|
2018-08-17 22:46:45 +00:00
|
|
|
pc[i]->base = cwt.at;
|
2018-11-24 14:35:02 +00:00
|
|
|
pc[i]->vel = 0;
|
2016-08-26 09:58:03 +00:00
|
|
|
pc[i]->inBoat = (firstland == laCaribbean || firstland == laOcean || firstland == laLivefjord ||
|
|
|
|
firstland == laWhirlpool);
|
|
|
|
pc[i]->store();
|
2019-03-09 16:38:23 +00:00
|
|
|
swordmatrix[i] = Id;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!safety) {
|
|
|
|
items[itOrbLife] = 3;
|
2019-01-17 13:19:28 +00:00
|
|
|
if(!racing::on)
|
|
|
|
addMessage(XLAT("Welcome to the Shoot'em Up mode!"));
|
2016-08-26 09:58:03 +00:00
|
|
|
// addMessage(XLAT("F/;/Space/Enter/KP5 = fire, WASD/IJKL/Numpad = move"));
|
|
|
|
}
|
2019-04-28 10:09:57 +00:00
|
|
|
delayed_safety = false;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
bool boatAt(cell *c) {
|
|
|
|
pair<mit, mit> p =
|
|
|
|
monstersAt.equal_range(c);
|
|
|
|
for(mit it = p.first; it != p.second; it++) {
|
|
|
|
monster* m = it->second;
|
|
|
|
if(m->inBoat) return true;
|
|
|
|
}
|
|
|
|
return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2018-07-09 17:32:34 +00:00
|
|
|
hookset<bool(const transmatrix&, cell*, shmup::monster*)> *hooks_draw;
|
|
|
|
|
2018-07-09 18:38:20 +00:00
|
|
|
bool drawMonster(const transmatrix& V, cell *c, const transmatrix*& Vboat, transmatrix& Vboat0, const transmatrix *Vdp) {
|
2019-02-17 18:39:44 +00:00
|
|
|
#if CAP_SHAPES
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2018-07-09 18:38:20 +00:00
|
|
|
pair<mit, mit> p =
|
2016-08-26 09:58:03 +00:00
|
|
|
monstersAt.equal_range(c);
|
2018-07-09 18:38:20 +00:00
|
|
|
|
|
|
|
if(p.first == p.second) return false;
|
|
|
|
ld zlev = -geom3::factor_to_lev(zlevel(tC0((*Vdp))));
|
2017-05-27 19:40:40 +00:00
|
|
|
|
|
|
|
vector<monster*> monsters;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
|
|
|
for(mit it = p.first; it != p.second; it++) {
|
|
|
|
monster* m = it->second;
|
2017-05-27 19:40:40 +00:00
|
|
|
if(c != m->base) continue; // may happen in RogueViz Collatz
|
2017-03-23 10:53:57 +00:00
|
|
|
m->pat = ggmatrix(m->base) * m->at;
|
|
|
|
transmatrix view = V * m->at;
|
2016-08-26 09:58:03 +00:00
|
|
|
|
2017-06-09 01:41:33 +00:00
|
|
|
if(!mouseout()) {
|
2018-07-09 17:32:34 +00:00
|
|
|
if(m->no_targetting) ; else
|
2017-03-23 10:53:57 +00:00
|
|
|
if(mapeditor::drawplayer || m->type != moPlayer)
|
|
|
|
if(!mousetarget || intval(mouseh, mousetarget->pat*C0) > intval(mouseh, m->pat*C0))
|
2016-08-26 09:58:03 +00:00
|
|
|
mousetarget = m;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(m->inBoat) {
|
2017-03-23 10:53:57 +00:00
|
|
|
view = m->pat;
|
2019-03-04 17:02:38 +00:00
|
|
|
Vboat = &Vboat0;
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 2) Vboat0 = view;
|
|
|
|
if(WDIM == 3) Vboat0 = view * spin(-M_PI/2);
|
2019-03-04 17:02:38 +00:00
|
|
|
|
|
|
|
bool magic = m->type == moPlayer && items[itOrbWater];
|
|
|
|
color_t outcolor = magic ? watercolor(0) : 0xC06000FF;
|
|
|
|
color_t incolor = magic ? 0x0060C0FF : 0x804000FF;
|
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 2) {
|
2019-03-04 17:02:38 +00:00
|
|
|
queuepoly(Vboat0, shBoatOuter, outcolor);
|
|
|
|
queuepoly(Vboat0, shBoatInner, incolor);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3) {
|
2019-03-04 17:02:38 +00:00
|
|
|
queuepoly(mscale(Vboat0, scalefactor/2), shBoatOuter, outcolor);
|
|
|
|
queuepoly(mscale(Vboat0, scalefactor/2-0.01), shBoatInner, incolor);
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(doHighlight())
|
|
|
|
poly_outline =
|
|
|
|
isBullet(m) ? 0x00FFFFFF :
|
|
|
|
(isFriendly(m->type) || m->type == moPlayer) ? 0x00FF00FF : 0xFF0000FF;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
int q = ptds.size();
|
2018-06-22 12:47:24 +00:00
|
|
|
if(q != isize(ptds) && !m->inBoat) pushdown(c, q, view, zlev, true, false);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2018-07-09 19:14:52 +00:00
|
|
|
if(callhandlers(false, hooks_draw, V, c, m)) continue;
|
2018-07-09 17:32:34 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
switch(m->type) {
|
2019-03-30 16:54:54 +00:00
|
|
|
case moPlayer: {
|
2018-08-30 16:18:54 +00:00
|
|
|
playerfound = true;
|
2019-03-09 14:31:02 +00:00
|
|
|
|
2019-03-30 16:54:54 +00:00
|
|
|
dynamicval<int> d(cpid, m->pid);
|
2019-03-09 15:20:06 +00:00
|
|
|
if(!hide_player() || !subscreens::is_current_player(m->pid)) {
|
2019-03-09 14:31:02 +00:00
|
|
|
drawPlayerEffects(view, c, true);
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3) view = view * spin(-M_PI/2) * cspin(0, 2, -M_PI/2);
|
2019-03-09 14:31:02 +00:00
|
|
|
if(m->inBoat) m->footphase = 0;
|
|
|
|
if(mapeditor::drawplayer) drawMonsterType(moPlayer, c, view, 0xFFFFFFC0, m->footphase);
|
|
|
|
}
|
|
|
|
|
2019-05-08 20:48:59 +00:00
|
|
|
if(subscreens::is_current_player(m->pid) && hide_player() && WDIM == 3) {
|
2019-03-09 16:38:23 +00:00
|
|
|
if(items[itOrbSword])
|
|
|
|
queuechr(swordpos(m->pid, false, 1), vid.fsize * 2, '+', iinf[itOrbSword].color);
|
|
|
|
if(items[itOrbSword2])
|
|
|
|
queuechr(swordpos(m->pid, true, 1), vid.fsize * 2, '+', iinf[itOrbSword2].color);
|
|
|
|
}
|
|
|
|
|
2019-03-09 15:20:06 +00:00
|
|
|
if(subscreens::is_current_player(m->pid) && keyresult[cpid]) {
|
2016-08-26 09:58:03 +00:00
|
|
|
hyperpoint h = keytarget(cpid);
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 2)
|
2019-03-09 14:31:35 +00:00
|
|
|
queuechr(h, vid.fsize, '+', iinf[keyresult[cpid]].color);
|
|
|
|
else {
|
|
|
|
dynamicval<color_t> p(poly_outline, darkena(iinf[keyresult[cpid]].color, 0, 255));
|
|
|
|
queuepoly(rgpushxto0(h) * cspin(0, 1, ticks / 140.), shGem[1], 0);
|
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
2017-06-09 01:41:33 +00:00
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
break;
|
2019-03-30 16:54:54 +00:00
|
|
|
}
|
2016-08-26 09:58:03 +00:00
|
|
|
case moBullet: {
|
2018-09-04 17:53:42 +00:00
|
|
|
color_t col;
|
2016-08-26 09:58:03 +00:00
|
|
|
cpid = m->pid;
|
|
|
|
if(m->parenttype == moPlayer)
|
|
|
|
col = getcs().swordcolor;
|
2017-07-22 23:33:27 +00:00
|
|
|
else if(m->parenttype == moMimic)
|
|
|
|
col = (mirrorcolor(det(view) < 0) << 8) | 0xFF;
|
2016-08-26 09:58:03 +00:00
|
|
|
else
|
|
|
|
col = (minf[m->parenttype].color << 8) | 0xFF;
|
2017-03-23 10:53:57 +00:00
|
|
|
if(getcs().charid >= 4) {
|
|
|
|
queuepoly(mmscale(view, 1.15), shPHead, col);
|
|
|
|
ShadowV(view, shPHead);
|
|
|
|
}
|
2017-07-24 00:02:32 +00:00
|
|
|
else if(peace::on) {
|
2018-08-28 12:27:23 +00:00
|
|
|
queuepolyat(mmscale(view, 1.15), shDisk, col, PPR::MISSILE);
|
2017-07-24 00:02:32 +00:00
|
|
|
ShadowV(view, shPHead);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
else {
|
|
|
|
transmatrix t = view * spin(curtime / 50.0);
|
2019-05-08 20:48:59 +00:00
|
|
|
queuepoly(WDIM == 3 ? t : DIM == 3 ? mscale(t, geom3::BODY) : mmscale(t, 1.15), shKnife, col);
|
2017-03-23 10:53:57 +00:00
|
|
|
ShadowV(t, shKnife);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2017-10-12 09:33:26 +00:00
|
|
|
case moArrowTrap: {
|
|
|
|
queuepoly(mmscale(view, 1.15), shTrapArrow, 0xFFFFFFFF);
|
|
|
|
ShadowV(view, shTrapArrow);
|
|
|
|
break;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
case moTongue: {
|
|
|
|
queuepoly(mmscale(view, 1.15), shTongue, (minf[m->parenttype].color << 8) | 0xFF);
|
|
|
|
ShadowV(view, shTongue);
|
2016-08-26 09:58:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
case moFireball: case moAirball: { // case moLightningBolt:
|
|
|
|
queuepoly(mmscale(view, 1.15), shPHead, (minf[m->type].color << 8) | 0xFF);
|
|
|
|
ShadowV(view, shPHead);
|
2016-08-26 09:58:03 +00:00
|
|
|
break;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2018-02-12 11:48:31 +00:00
|
|
|
case moFlailBullet: case moCrushball: {
|
2017-03-23 10:53:57 +00:00
|
|
|
transmatrix t = view * spin(curtime / 50.0);
|
|
|
|
queuepoly(mmscale(t, 1.15), shFlailMissile, (minf[m->type].color << 8) | 0xFF);
|
|
|
|
ShadowV(view, shFlailMissile);
|
2019-03-30 16:51:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case moAsteroid: {
|
2019-05-11 13:47:34 +00:00
|
|
|
if(DIM == 3) addradar(view, '*', 0xFFFFFF, 0xC0C0C0FF);
|
2019-03-30 19:06:35 +00:00
|
|
|
transmatrix t = view;
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 3) t = face_the_player(t);
|
2019-03-30 19:06:35 +00:00
|
|
|
t = t * spin(curtime / 500.0);
|
2019-03-30 16:51:37 +00:00
|
|
|
ShadowV(t, shAsteroid[m->hitpoints & 7]);
|
2019-05-08 20:48:59 +00:00
|
|
|
if(WDIM == 2) t = mmscale(t, 1.15);
|
|
|
|
color_t col = WDIM == 3 ? 0xFFFFFF : minf[m->type].color;
|
2019-03-30 19:06:35 +00:00
|
|
|
col <<= 8;
|
|
|
|
queuepoly(t, shAsteroid[m->hitpoints & 7], col | 0xFF);
|
2016-08-26 09:58:03 +00:00
|
|
|
break;
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
2016-08-26 09:58:03 +00:00
|
|
|
default:
|
2017-03-23 10:53:57 +00:00
|
|
|
if(m->inBoat) m->footphase = 0;
|
2018-09-04 17:53:42 +00:00
|
|
|
color_t col = minf[m->type].color;
|
2017-07-22 23:33:27 +00:00
|
|
|
if(m->type == moMimic)
|
|
|
|
col = mirrorcolor(det(view) < 0);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->type == moSlime) {
|
|
|
|
col = winf[c->wall].color;
|
|
|
|
col |= (col >> 1);
|
|
|
|
}
|
|
|
|
cpid = m->pid;
|
|
|
|
if(m->stunoff > curtime)
|
|
|
|
c->stuntime = 1 + (m->stunoff - curtime-1)/300;
|
|
|
|
if(hasHitpoints(m->type))
|
|
|
|
c->hitpoints = m->hitpoints;
|
2019-01-16 23:48:55 +00:00
|
|
|
if(m->type == moTortoise) tortoise::emap[c] = getBits(m->torigin);
|
2019-04-20 23:08:27 +00:00
|
|
|
/* if(m->type == moMimic && DIM == 3)
|
|
|
|
drawMonsterType(m->type, c, view * spin(-M_PI/2), col, m->footphase); */
|
|
|
|
/* else if(DIM == 3)
|
|
|
|
drawMonsterType(m->type, c, view * cspin(0, 2, M_PI/2), col, m->footphase); */
|
|
|
|
/* else */
|
2019-02-25 13:51:51 +00:00
|
|
|
drawMonsterType(m->type, c, view, col, m->footphase);
|
2016-08-26 09:58:03 +00:00
|
|
|
if(m->type == moTortoise) tortoise::emap.erase(c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:41:40 +00:00
|
|
|
#endif
|
2016-08-26 09:58:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-14 18:12:23 +00:00
|
|
|
void clearMonsters() {
|
2016-08-26 09:58:03 +00:00
|
|
|
for(mit it = monstersAt.begin(); it != monstersAt.end(); it++)
|
|
|
|
delete(it->second);
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m: active) delete m;
|
2017-09-04 18:43:17 +00:00
|
|
|
mousetarget = NULL;
|
|
|
|
lmousetarget = NULL;
|
2016-08-26 09:58:03 +00:00
|
|
|
monstersAt.clear();
|
2017-04-14 18:12:23 +00:00
|
|
|
active.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void clearMemory() {
|
|
|
|
clearMonsters();
|
2016-08-26 09:58:03 +00:00
|
|
|
gmatrix.clear();
|
2017-10-17 18:36:36 +00:00
|
|
|
while(!traplist.empty()) traplist.pop();
|
2016-08-26 09:58:03 +00:00
|
|
|
curtime = 0;
|
|
|
|
nextmove = 0;
|
|
|
|
nextdragon = 0;
|
|
|
|
visibleAt = 0;
|
2018-11-17 18:26:35 +00:00
|
|
|
for(int i=0; i<MAXPLAYER; i++) pc[i] = NULL;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cell *playerpos(int i) {
|
2018-11-17 18:26:35 +00:00
|
|
|
if(!pc[i]) return NULL;
|
2016-08-26 09:58:03 +00:00
|
|
|
return pc[i]->base;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool playerInBoat(int i) {
|
2018-11-17 18:26:35 +00:00
|
|
|
if(!pc[i]) return false;
|
2016-08-26 09:58:03 +00:00
|
|
|
return pc[i]->inBoat;
|
|
|
|
}
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void destroyBoats(cell *c) {
|
2017-05-31 16:33:50 +00:00
|
|
|
for(monster *m: active)
|
|
|
|
if(m->base == c && m->inBoat)
|
|
|
|
m->inBoat = false;
|
2016-08-26 09:58:03 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 16:33:50 +00:00
|
|
|
void virtualRebase(shmup::monster *m, bool tohex) {
|
|
|
|
virtualRebase(m->base, m->at, tohex);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2018-07-09 17:32:34 +00:00
|
|
|
hookset<bool(shmup::monster*, string&)> *hooks_describe;
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
void addShmupHelp(string& out) {
|
|
|
|
if(shmup::mousetarget && intval(mouseh, tC0(shmup::mousetarget->pat)) < .1) {
|
2018-07-09 17:32:34 +00:00
|
|
|
if(callhandlers(false, hooks_describe, shmup::mousetarget, out)) return;
|
|
|
|
out += XLAT1(minf[shmup::mousetarget->type].name);
|
|
|
|
help = generateHelpForMonster(shmup::mousetarget->type);
|
2017-07-10 18:47:38 +00:00
|
|
|
}
|
2018-07-09 17:32:34 +00:00
|
|
|
}
|
2017-07-10 18:47:38 +00:00
|
|
|
|
2018-01-26 00:45:49 +00:00
|
|
|
auto hooks = addHook(clearmemory, 0, shmup::clearMemory) +
|
|
|
|
addHook(hooks_removecells, 0, [] () {
|
|
|
|
for(mit it = monstersAt.begin(); it != monstersAt.end();) {
|
|
|
|
if(is_cell_removed(it->first)) {
|
|
|
|
monstersAt.insert(make_pair(nullptr, it->second));
|
|
|
|
auto it0 = it; it++;
|
|
|
|
monstersAt.erase(it0);
|
|
|
|
}
|
|
|
|
else it++;
|
|
|
|
}
|
|
|
|
});
|
2019-03-30 22:45:28 +00:00
|
|
|
|
|
|
|
void switch_shmup() {
|
|
|
|
stop_game();
|
|
|
|
switch_game_mode(rg::shmup);
|
|
|
|
resetScores();
|
|
|
|
start_game();
|
|
|
|
configure();
|
|
|
|
}
|
2019-05-08 20:48:59 +00:00
|
|
|
|
|
|
|
#if MAXMDIM >= 4
|
|
|
|
auto hooksw = addHook(hooks_swapdim, 100, [] {
|
|
|
|
for(auto& p: monstersAt) swapmatrix(p.second->at);
|
|
|
|
});
|
|
|
|
#endif
|
2018-01-26 00:45:49 +00:00
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
}
|
2018-06-10 23:58:31 +00:00
|
|
|
}
|