mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 05:52:59 +00:00 
			
		
		
		
	findbase now gets a parameter which tells how many steps to make
This commit is contained in:
		
							
								
								
									
										62
									
								
								shmup.cpp
									
									
									
									
									
								
							
							
						
						
									
										62
									
								
								shmup.cpp
									
									
									
									
									
								
							| @@ -84,7 +84,7 @@ struct monster { | |||||||
|      |      | ||||||
|   void findpat(); |   void findpat(); | ||||||
|  |  | ||||||
|   cell *findbase(const transmatrix& T); |   cell *findbase(const transmatrix& T, int maxsteps); | ||||||
|  |  | ||||||
|   void rebasePat(const transmatrix& new_pat, cell *tgt); |   void rebasePat(const transmatrix& new_pat, cell *tgt); | ||||||
|  |  | ||||||
| @@ -111,33 +111,25 @@ typedef multimap<cell*, monster*>::iterator mit; | |||||||
|  |  | ||||||
| vector<monster*> active, nonvirtual, additional; | vector<monster*> active, nonvirtual, additional; | ||||||
|  |  | ||||||
| cell *findbaseAround(hyperpoint p, cell *around) { | cell *findbaseAround(hyperpoint p, cell *around, int maxsteps) { | ||||||
|   cell *best = around; |   for(int k=0; k<maxsteps; k++) { | ||||||
|   horo_distance d0(p, ggmatrix(around)); |     cell *best = around; | ||||||
|   for(int i=0; i<around->type; i++) { |     horo_distance d0(p, ggmatrix(around)); | ||||||
|     cell *c2 = around->move(i); |     for(int i=0; i<around->type; i++) { | ||||||
|     if(c2) { |       cell *c2 = around->move(i); | ||||||
|       horo_distance d1(p, ggmatrix(c2)); |       if(c2) { | ||||||
|       if(d1 < d0) { best = c2; d0 = d1; } |         horo_distance d1(p, ggmatrix(c2)); | ||||||
|  |         if(d1 < d0) { best = c2; d0 = d1; } | ||||||
|  |         } | ||||||
|       } |       } | ||||||
|  |     if(best == around) return best; | ||||||
|  |     around = best; | ||||||
|     } |     } | ||||||
|   return best; |   return around; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| cell *findbaseAround(const transmatrix& H, cell *around) { | cell *findbaseAround(const transmatrix& H, cell *around, int maxsteps) { | ||||||
|   return findbaseAround(tC0(H), around); |   return findbaseAround(tC0(H), around, maxsteps); | ||||||
|   } |  | ||||||
|  |  | ||||||
| cell *findbaseAroundRepeat(hyperpoint p, cell *around) { |  | ||||||
|   while(true) { |  | ||||||
|     cell *c = findbaseAround(p, around); |  | ||||||
|     if(c == around) return c; |  | ||||||
|     around = c; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
| cell *findbaseAroundRepeat(const transmatrix& H, cell *around) { |  | ||||||
|   return findbaseAroundRepeat(tC0(H), around); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
| /* double distance(hyperpoint h) { | /* double distance(hyperpoint h) { | ||||||
| @@ -155,14 +147,14 @@ void monster::findpat() { | |||||||
|   else pat = at; |   else pat = at; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| cell *monster::findbase(const transmatrix& T) { | cell *monster::findbase(const transmatrix& T, int maxsteps) { | ||||||
|   if(isVirtual) { |   if(isVirtual) { | ||||||
|     cell *c = base; |     cell *c = base; | ||||||
|     auto cT = T; |     auto cT = T; | ||||||
|     virtualRebase(c, cT, true); |     virtualRebase(c, cT, true); | ||||||
|     return c; |     return c; | ||||||
|     } |     } | ||||||
|   else return findbaseAround(T, base); |   else return findbaseAround(T, base, maxsteps); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| void fix_to_2(transmatrix& T) { | void fix_to_2(transmatrix& T) { | ||||||
| @@ -218,7 +210,7 @@ bool trackroute(monster *m, transmatrix goal, double spd) { | |||||||
|  |  | ||||||
|     // queuepoly(nat, cgi.shKnife, 0xFFFFFFC0); |     // queuepoly(nat, cgi.shKnife, 0xFFFFFFC0); | ||||||
|  |  | ||||||
|     cell *c2 = findbaseAround(nat, c); |     cell *c2 = findbaseAround(nat, c, 1); | ||||||
|     if(c2 != c && !passable_for(m->type, c2, c, P_CHAIN | P_ONPLAYER)) { |     if(c2 != c && !passable_for(m->type, c2, c, P_CHAIN | P_ONPLAYER)) { | ||||||
|       return false; |       return false; | ||||||
|       } |       } | ||||||
| @@ -1012,7 +1004,7 @@ void movePlayer(monster *m, int delta) { | |||||||
|      |      | ||||||
|     // spin(span[igo]) * xpush(playergo[cpid]) * spin(-span[igo]); |     // spin(span[igo]) * xpush(playergo[cpid]) * spin(-span[igo]); | ||||||
|    |    | ||||||
|     c2 = m->findbase(nat); |     c2 = m->findbase(nat, 1); | ||||||
|     if(reflectflag & P_MIRRORWALL) reflect(c2, m->base, nat); |     if(reflectflag & P_MIRRORWALL) reflect(c2, m->base, nat); | ||||||
|      |      | ||||||
|     // don't have several players in one spot |     // don't have several players in one spot | ||||||
| @@ -1245,7 +1237,7 @@ void movePlayer(monster *m, int delta) { | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|    |    | ||||||
|       cell *c3 = findbaseAroundRepeat(H, m->base); |       cell *c3 = findbaseAround(H, m->base, 999); | ||||||
|       if(c3->wall == waSmallTree || c3->wall == waBigTree || c3->wall == waBarrowDig || c3->wall == waCavewall || |       if(c3->wall == waSmallTree || c3->wall == waBigTree || c3->wall == waBarrowDig || c3->wall == waCavewall || | ||||||
|         (c3->wall == waBarrowWall && items[itBarrow] >= 25)) |         (c3->wall == waBarrowWall && items[itBarrow] >= 25)) | ||||||
|         c3->wall = waNone; |         c3->wall = waNone; | ||||||
| @@ -1384,7 +1376,7 @@ void moveMimic(monster *m) { | |||||||
|   else |   else | ||||||
|     nat = nat * spin(playerturn[cpid] + playergoturn[cpid]) * xpush(playergo[cpid]) * spin(-playergoturn[cpid]); |     nat = nat * spin(playerturn[cpid] + playergoturn[cpid]) * xpush(playergo[cpid]) * spin(-playergoturn[cpid]); | ||||||
|  |  | ||||||
|   cell *c2 = m->findbase(nat); |   cell *c2 = m->findbase(nat, 1); | ||||||
|   reflect(c2, m->base, nat); |   reflect(c2, m->base, nat); | ||||||
|   if(c2 != m->base && !passable(c2, m->base, P_ISPLAYER | P_MIRROR | P_MIRRORWALL)) |   if(c2 != m->base && !passable(c2, m->base, P_ISPLAYER | P_MIRROR | P_MIRRORWALL)) | ||||||
|     killMonster(m, moNone); |     killMonster(m, moNone); | ||||||
| @@ -1455,11 +1447,7 @@ eItem targetRangedOrbKey(orbAction a) { | |||||||
|    |    | ||||||
|   mouseover = pc[cpid]->base; |   mouseover = pc[cpid]->base; | ||||||
|    |    | ||||||
|   while(true) { |   mouseover = findbaseAround(mouseh, mouseover, 999); | ||||||
|     cell *c2 = findbaseAround(mouseh, mouseover); |  | ||||||
|     if(c2 == mouseover) break; |  | ||||||
|     mouseover = c2; |  | ||||||
|     } |  | ||||||
|   mousetarget = NULL; |   mousetarget = NULL; | ||||||
|  |  | ||||||
|   for(monster *m2: nonvirtual) { |   for(monster *m2: nonvirtual) { | ||||||
| @@ -1598,7 +1586,7 @@ void moveBullet(monster *m, int delta) { | |||||||
|     } |     } | ||||||
|   else  |   else  | ||||||
|     nat = parallel_transport(nat, m->ori, fronttangent(delta * SCALE * m->vel / speedfactor())); |     nat = parallel_transport(nat, m->ori, fronttangent(delta * SCALE * m->vel / speedfactor())); | ||||||
|   cell *c2 = m->findbase(nat); |   cell *c2 = m->findbase(nat, 1); | ||||||
|  |  | ||||||
|   if(m->parent && isPlayer(m->parent) && markOrb(itOrbLava) && c2 != m->base && !isPlayerOn(m->base))  |   if(m->parent && isPlayer(m->parent) && markOrb(itOrbLava) && c2 != m->base && !isPlayerOn(m->base))  | ||||||
|     makeflame(m->base, 5, false); |     makeflame(m->base, 5, false); | ||||||
| @@ -2131,7 +2119,7 @@ void moveMonster(monster *m, int delta) { | |||||||
|    |    | ||||||
|   if(crashintomon && !inertia_based) { igo++; goto igo_retry; } |   if(crashintomon && !inertia_based) { igo++; goto igo_retry; } | ||||||
|  |  | ||||||
|   cell *c2 = m->findbase(nat); |   cell *c2 = m->findbase(nat, 1); | ||||||
|   if(reflectflag & P_MIRRORWALL) reflect(c2, m->base, nat); |   if(reflectflag & P_MIRRORWALL) reflect(c2, m->base, nat); | ||||||
|  |  | ||||||
|   if(m->type == moButterfly && !passable_for(m->type, c2, m->base, P_CHAIN | reflectflag)) { |   if(m->type == moButterfly && !passable_for(m->type, c2, m->base, P_CHAIN | reflectflag)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue