mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-22 23:17:04 +00:00
sword:: accurate sword angles
This commit is contained in:
parent
7a4ee025d8
commit
13a044154b
19
complex.cpp
19
complex.cpp
@ -2620,8 +2620,25 @@ namespace dragon {
|
||||
}
|
||||
|
||||
namespace sword {
|
||||
int angle[MAXPLAYER];
|
||||
array<int, MAXPLAYER> angle;
|
||||
int sword_angles;
|
||||
|
||||
void possible_divisor(int s) { sword_angles *= s / gcd(sword_angles, s); }
|
||||
|
||||
void determine_sword_angles() {
|
||||
sword_angles = 2;
|
||||
if(IRREGULAR) sword_angles = 840;
|
||||
else if(binarytiling) sword_angles = 42;
|
||||
else if(archimedean) {
|
||||
if(!PURE) possible_divisor((BITRUNCATED ? 2 : 1) * isize(arcm::current.faces));
|
||||
if(!DUAL) for(int f: arcm::current.faces) possible_divisor(f);
|
||||
}
|
||||
else {
|
||||
possible_divisor(S7);
|
||||
if(BITRUNCATED) possible_divisor(S3);
|
||||
}
|
||||
}
|
||||
|
||||
cell *pos(cell *c, int s) {
|
||||
int t = c->type;
|
||||
s *= 2;
|
||||
|
4
game.cpp
4
game.cpp
@ -5264,8 +5264,8 @@ void sideAttack(cell *mf, int dir, eMonster who, int bonuskill) {
|
||||
|
||||
template<class T> void do_swords(cell *mf, cell *mt, eMonster who, const T& f) {
|
||||
for(int bb=0; bb<2; bb++) if(who == moPlayer && sword::orbcount(bb)) {
|
||||
cell *sf = sword::pos(mf, sword::angle[multi::cpid] + (bb?sword_angles/2:0));
|
||||
cell *st = sword::pos(mt, sword::shift(mf, mt, sword::angle[multi::cpid]) + (bb?sword_angles/2:0));
|
||||
cell *sf = sword::pos(mf, sword::angle[multi::cpid] + (bb?sword::sword_angles/2:0));
|
||||
cell *st = sword::pos(mt, sword::shift(mf, mt, sword::angle[multi::cpid]) + (bb?sword::sword_angles/2:0));
|
||||
f(st, bb);
|
||||
if(sf != st && !isNeighbor(sf,st)) {
|
||||
// also attack the in-transit cell
|
||||
|
15
graph.cpp
15
graph.cpp
@ -383,35 +383,36 @@ void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) {
|
||||
|
||||
else {
|
||||
int& ang = angle[multi::cpid];
|
||||
ang %= sword_angles;
|
||||
ang %= sword::sword_angles;
|
||||
|
||||
#if CAP_QUEUE || CAP_SHAPES
|
||||
transmatrix Vnow = gmatrix[c] * rgpushxto0(inverse(gmatrix[c]) * tC0(V)) * ddspin(c,0,M_PI); // (IRREGULAR ? ddspin(c,0,M_PI) : spin(-hexshiftat(c)));
|
||||
#endif
|
||||
|
||||
int adj = 1 - ((sword_angles/cwt.at->type)&1);
|
||||
|
||||
#if CAP_QUEUE
|
||||
if(!euclid) for(int a=0; a<sword_angles; a++) {
|
||||
int dda = sword_angles + (-1-2*a);
|
||||
if(a == ang && items[itOrbSword]) continue;
|
||||
if(PURE && a%3 != ang%3) continue;
|
||||
if((a+sword_angles/2)%sword_angles == ang && items[itOrbSword2]) continue;
|
||||
bool longer = sword::pos(cwt.at, a-1) != sword::pos(cwt.at, a+1);
|
||||
if(sword_angles > 48 && !longer) continue;
|
||||
color_t col = darkena(0xC0C0C0, 0, 0xFF);
|
||||
ld l0 = PURE ? 0.6 * cgi.scalefactor : longer ? 0.36 : 0.4;
|
||||
ld l1 = PURE ? 0.7 * cgi.scalefactor : longer ? 0.44 : 0.42;
|
||||
hyperpoint h0 = DIM == 3 ? xpush(l0) * zpush(cgi.FLOOR - cgi.human_height/50) * C0 : xpush0(l0);
|
||||
hyperpoint h1 = DIM == 3 ? xpush(l1) * zpush(cgi.FLOOR - cgi.human_height/50) * C0 : xpush0(l1);
|
||||
transmatrix T = Vnow*spin(dda * M_PI / sword_angles);
|
||||
hyperpoint h1 = DIM == 3 ? xpush(l1) * zpush(cgi.FLOOR - cgi.human_height/50) * C0 : xpush0(l1);
|
||||
transmatrix T = Vnow*spin((sword_angles + (-adj-2*a)) * M_PI / sword_angles);
|
||||
queueline(T*h0, T*h1, col, 1, PPR::SUPERLINE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CAP_SHAPES
|
||||
if(items[itOrbSword])
|
||||
queuepoly(Vnow*spin(M_PI+(-1-2*ang)*M_PI/sword_angles), (peace::on ? cgi.shMagicShovel : cgi.shMagicSword), darkena(iinf[itOrbSword].color, 0, 0x80 + 0x70 * sintick(200)));
|
||||
queuepoly(Vnow*spin(M_PI+(-adj-2*ang)*M_PI/sword_angles), (peace::on ? cgi.shMagicShovel : cgi.shMagicSword), darkena(iinf[itOrbSword].color, 0, 0x80 + 0x70 * sintick(200)));
|
||||
|
||||
if(items[itOrbSword2])
|
||||
queuepoly(Vnow*spin((-1-2*ang)*M_PI/sword_angles), (peace::on ? cgi.shMagicShovel : cgi.shMagicSword), darkena(iinf[itOrbSword2].color, 0, 0x80 + 0x70 * sintick(200)));
|
||||
queuepoly(Vnow*spin((-adj-2*ang)*M_PI/sword_angles), (peace::on ? cgi.shMagicShovel : cgi.shMagicSword), darkena(iinf[itOrbSword2].color, 0, 0x80 + 0x70 * sintick(200)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
4
hyper.h
4
hyper.h
@ -1833,11 +1833,9 @@ namespace tortoise {
|
||||
int getRandomBits();
|
||||
}
|
||||
|
||||
#define sword_angles (S7*S3*2)
|
||||
|
||||
namespace sword {
|
||||
|
||||
extern int angle[MAXPLAYER];
|
||||
extern array<int, MAXPLAYER> angle;
|
||||
|
||||
cell *pos(cell *c, int s);
|
||||
cell *pos(int id);
|
||||
|
@ -208,7 +208,8 @@ void initgame() {
|
||||
createMov(cwt.at, 0)->land = laCrossroads2;
|
||||
}
|
||||
|
||||
for(int i=0; i<numplayers(); i++) sword::angle[i] = PURE ? 10 : 11;
|
||||
sword::determine_sword_angles();
|
||||
for(int i=0; i<numplayers(); i++) sword::angle[i] = (sword::sword_angles / cwt.at->type + 1) / 2;
|
||||
|
||||
#if CAP_DAILY
|
||||
daily::split();
|
||||
|
Loading…
Reference in New Issue
Block a user