short SoundAngle(int x, int y) { extern short screenpeek; short angle, delta_angle; angle = getangle(x - Player[screenpeek].posx, y - Player[screenpeek].posy); delta_angle = GetDeltaAngle(angle, Player[screenpeek].pang); // convert a delta_angle to a real angle if negative if (delta_angle < 0) delta_angle = NORM_ANGLE((1024 + delta_angle) + 1024); // convert 2048 degree angle to 32 degree angle return delta_angle >> 6; }
int WallBreakPosition(short hitwall, short *sectnum, long *x, long *y, long *z, short *ang) { short w,nw; WALLp wp; long nx,ny; short wall_ang; long ret=0; w = hitwall; wp = &wall[w]; nw = wall[w].point2; wall_ang = NORM_ANGLE(getangle(wall[nw].x - wall[w].x, wall[nw].y - wall[w].y)+512); *sectnum = SectorOfWall(w); ASSERT(*sectnum >= 0); // midpoint of wall *x = DIV2(wall[w].x + wall[w].x); *y = DIV2(wall[w].y + wall[w].y); //getzsofsector(*sectnum, *x, *y, cz, fz); if (wp->nextwall < 0) { // white wall *z = DIV2(sector[*sectnum].floorz + sector[*sectnum].ceilingz); } else { short next_sectnum = wp->nextsector; // red wall ASSERT(wp->nextsector >= 0); // floor and ceiling meet if (sector[next_sectnum].floorz == sector[next_sectnum].ceilingz) *z = DIV2(sector[*sectnum].floorz + sector[*sectnum].ceilingz); else // floor is above other sector if (sector[next_sectnum].floorz < sector[*sectnum].floorz) *z = DIV2(sector[next_sectnum].floorz + sector[*sectnum].floorz); else // ceiling is below other sector if (sector[next_sectnum].ceilingz > sector[*sectnum].ceilingz) *z = DIV2(sector[next_sectnum].ceilingz + sector[*sectnum].ceilingz); } *ang = wall_ang; nx = MOVEx(128, wall_ang); ny = MOVEy(128, wall_ang); *x += nx; *y += ny; updatesectorz(*x,*y,*z,sectnum); if (*sectnum < 0) { *x = MAXLONG; // don't spawn shrap, just change wall return(FALSE); } return(TRUE); }