diff --git a/complex.cpp b/complex.cpp index 52bbde4b..fdf0919c 100644 --- a/complex.cpp +++ b/complex.cpp @@ -2620,8 +2620,25 @@ namespace dragon { } namespace sword { - int angle[MAXPLAYER]; + array 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; diff --git a/game.cpp b/game.cpp index 0fab8492..f4542d1a 100644 --- a/game.cpp +++ b/game.cpp @@ -5264,8 +5264,8 @@ void sideAttack(cell *mf, int dir, eMonster who, int bonuskill) { template 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 diff --git a/graph.cpp b/graph.cpp index b04db21e..0b963e37 100644 --- a/graph.cpp +++ b/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 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 } } diff --git a/hyper.h b/hyper.h index 112ec97b..3d4b7ffd 100644 --- a/hyper.h +++ b/hyper.h @@ -1833,11 +1833,9 @@ namespace tortoise { int getRandomBits(); } -#define sword_angles (S7*S3*2) - namespace sword { - extern int angle[MAXPLAYER]; + extern array angle; cell *pos(cell *c, int s); cell *pos(int id); diff --git a/system.cpp b/system.cpp index ce2a86ed..1ed26640 100644 --- a/system.cpp +++ b/system.cpp @@ -208,7 +208,8 @@ void initgame() { createMov(cwt.at, 0)->land = laCrossroads2; } - for(int i=0; itype + 1) / 2; #if CAP_DAILY daily::split();