diff --git a/hyper.h b/hyper.h index 81f0b7d2..80930465 100644 --- a/hyper.h +++ b/hyper.h @@ -5538,6 +5538,8 @@ namespace dual { void disable(); void enable(); + + transmatrix get_orientation(); inline reaction_t mayboth(reaction_t what) { return [=] { may_split_or_do(what); }; } } diff --git a/hypgraph.cpp b/hypgraph.cpp index f1178a06..aaa852ce 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1076,7 +1076,7 @@ transmatrix eumovedir(int d) { void spinEdge(ld aspd) { ld downspin = 0; if(dual::state == 2 && dual::currently_loaded != dual::main_side) { - transmatrix our = gpushxto0(tC0(cwtV)) * cwtV; + transmatrix our = dual::get_orientation(); transmatrix their = dual::player_orientation[dual::main_side]; fixmatrix(our); fixmatrix(their); diff --git a/multigame.cpp b/multigame.cpp index 078b4adb..3374e710 100644 --- a/multigame.cpp +++ b/multigame.cpp @@ -82,11 +82,39 @@ namespace dual { gamedata dgd[2]; transmatrix player_orientation[2]; + hyperpoint which_dir; + + int remap_direction(int d, int cg) { + if(WDIM == 2 || cg == currently_loaded) return d; + + hyperpoint h = sword::dir[0].T * which_dir; + + h = hpxy3(h[0]/10, h[1]/10, h[2]/10); + ld b = HUGE_VAL; + for(int i=0; irelative_matrix(cwt.at->cmove(i)->master, cwt.at->master)); + ld dist = hdist(checked, h); + if(dist < b) { b = dist; d = i; } + } + d = gmod(d - cwt.spin, S7); + + return d; + } + + transmatrix get_orientation() { + if(WDIM == 2) + return gpushxto0(tC0(cwtV)) * cwtV; + else if(cwt.at) + return gpushxto0(tC0(ggmatrix(cwt.at))) * ggmatrix(cwt.at) * sword::dir[0].T; + else + return Id; + } + void switch_to(int k) { if(k != currently_loaded) { // gamedata has shmup::on because tutorial needs changing it, but dual should keep it fixed dynamicval smon(shmup::on); - player_orientation[currently_loaded] = gpushxto0(tC0(cwtV)) * cwtV; + player_orientation[currently_loaded] = get_orientation(); dgd[currently_loaded].storegame(); currently_loaded = k; dgd[currently_loaded].restoregame(); @@ -129,13 +157,15 @@ namespace dual { return ok; } + which_dir = inverse(sword::dir[0].T) * tC0(currentmap->relative_matrix((cwt+d).cpeek()->master, cwt.at->master)); + bool lms[2][5]; eLastmovetype lmt[2][5]; for(int k=0; k<2; k++) { switch_to(k); for(eForcemovetype fm: { fmMove, fmAttack, fmInstant, fmActivate }) { forcedmovetype = fm; - lms[k][fm] = movepcto(fm == fmMove ? d : 0, subdir, true); + lms[k][fm] = movepcto(fm == fmMove ? remap_direction(d, cg) : 0, subdir, true); lmt[k][fm] = nextmovetype; forcedmovetype = fmSkip; for(int i=0; i