void A_Tracer2 (AActor *self) { AActor *dest; angle_t exact; fixed_t dist; fixed_t slope; dest = self->tracer; if (dest == NULL || dest->health <= 0 || self->Speed == 0) return; // change angle exact = R_PointToAngle2 (self->x, self->y, dest->x, dest->y); if (exact != self->angle) { if (exact - self->angle > 0x80000000) { self->angle -= TRACEANGLE; if (exact - self->angle < 0x80000000) self->angle = exact; } else { self->angle += TRACEANGLE; if (exact - self->angle > 0x80000000) self->angle = exact; } } exact = self->angle >> ANGLETOFINESHIFT; self->momx = FixedMul (self->Speed, finecosine[exact]); self->momy = FixedMul (self->Speed, finesine[exact]); // change slope dist = P_AproxDistance (dest->x - self->x, dest->y - self->y); dist /= self->Speed; if (dist < 1) { dist = 1; } if (dest->height >= 56*FRACUNIT) { slope = (dest->z+40*FRACUNIT - self->z) / dist; } else { slope = (dest->z + self->height*2/3 - self->z) / dist; } if (slope < self->momz) { self->momz -= FRACUNIT/8; } else { self->momz += FRACUNIT/8; } }
//============================================================================= static void HW3S_FillSourceParameters (const mobj_t *origin, source3D_data_t *data, channel_type_t c_type) { fixed_t x = 0, y = 0, z = 0; data->max_distance = MAX_DISTANCE; data->min_distance = MIN_DISTANCE; if (origin && origin != players[displayplayer].mo) { data->head_relative = false; data->pos.momx = TPS(FIXED_TO_FLOAT(origin->momx)); data->pos.momy = TPS(FIXED_TO_FLOAT(origin->momy)); data->pos.momz = TPS(FIXED_TO_FLOAT(origin->momz)); x = origin->x; y = origin->y; z = origin->z; if (c_type == CT_ATTACK) { const angle_t an = origin->angle >> ANGLETOFINESHIFT; x += FixedMul(16*FRACUNIT, FINECOSINE(an)); y += FixedMul(16*FRACUNIT, FINESINE(an)); z += origin->height >> 1; } else if (c_type == CT_SCREAM)
DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump) { fixed_t dist; fixed_t speed; angle_t an; if (self->target == NULL) return; S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM); self->AddZ(64*FRACUNIT); A_FaceTarget (self); an = self->angle >> ANGLETOFINESHIFT; speed = self->Speed * 2/3; self->velx += FixedMul (speed, finecosine[an]); self->vely += FixedMul (speed, finesine[an]); dist = self->AproxDistance (self->target); dist /= speed; if (dist < 1) { dist = 1; } self->velz = (self->target->Z() - self->Z()) / dist; self->reactiontime = 60; self->flags |= MF_NOGRAVITY; }
// // P_GetZAt // // Returns the height of the sloped plane at (x, y) as a fixed_t // fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y) { fixed_t dist = FixedMul(x - slope->o.x, slope->d.x) + FixedMul(y - slope->o.y, slope->d.y); return slope->o.z + FixedMul(dist, slope->zdelta); }
// // PTR_chaseTraverse // // go til you hit a wall // set the chasecam target x and ys if you hit one // originally based on the shooting traverse function in p_maputl.c // static bool PTR_chaseTraverse(intercept_t *in) { fixed_t dist, frac; subsector_t *ss; int x, y; int z; sector_t *othersector; if(in->isaline) { line_t *li = in->d.line; dist = FixedMul(trace.attackrange, in->frac); frac = in->frac - FixedDiv(12*FRACUNIT, trace.attackrange); // hit line // position a bit closer x = trace.dl.x + FixedMul(trace.dl.dx, frac); y = trace.dl.y + FixedMul(trace.dl.dy, frac); // ioanch 20160225: portal lines are currently not crossed if(li->flags & ML_TWOSIDED && !(li->pflags & PS_PASSABLE)) { // crosses a two sided line // sf: find which side it hit ss = R_PointInSubsector (x, y); othersector = li->backsector; if(ss->sector==li->backsector) // other side othersector = li->frontsector; // interpolate, find z at the point of intersection z = zi(dist, trace.attackrange, targetz, playermobj->z+28*FRACUNIT); // found which side, check for intersections if((li->flags & ML_BLOCKING) || (othersector->floorheight>z) || (othersector->ceilingheight<z) || (othersector->ceilingheight-othersector->floorheight < 40*FRACUNIT)); // hit else { return true; // continue } } targetx = x; // point the new chasecam target at the intersection targety = y; targetz = zi(dist, trace.attackrange, targetz, playermobj->z+28*FRACUNIT); // don't go any farther return false; } return true; }
fixed_t FV_Magnitude(const vector_t *a_normal) { INT32 xs = FixedMul(a_normal->x,a_normal->x); INT32 ys = FixedMul(a_normal->y,a_normal->y); INT32 zs = FixedMul(a_normal->z,a_normal->z); return FixedSqrt(xs+ys+zs); }
// // CreateObjectMatrix // // Creates a matrix that can be used for // adjusting the position of an object // void FM_CreateObjectMatrix(matrix_t *matrix, fixed_t x, fixed_t y, fixed_t z, fixed_t anglex, fixed_t angley, fixed_t anglez, fixed_t upx, fixed_t upy, fixed_t upz, fixed_t radius) { vector_t upcross; vector_t upvec; vector_t basevec; FV_Load(&upvec, upx, upy, upz); FV_Load(&basevec, anglex, angley, anglez); FV_Cross(&upvec, &basevec, &upcross); FV_Normalize(&upcross); FM_LoadIdentity(matrix); matrix->m[0] = upcross.x; matrix->m[1] = upcross.y; matrix->m[2] = upcross.z; matrix->m[3] = 0*FRACUNIT; matrix->m[4] = upx; matrix->m[5] = upy; matrix->m[6] = upz; matrix->m[7] = 0; matrix->m[8] = anglex; matrix->m[9] = angley; matrix->m[10] = anglez; matrix->m[11] = 0; matrix->m[12] = x - FixedMul(upx,radius); matrix->m[13] = y - FixedMul(upy,radius); matrix->m[14] = z - FixedMul(upz,radius); matrix->m[15] = FRACUNIT; }
vector_t *FV_MulEx(const vector_t *a_i, fixed_t a_c, vector_t *a_o) { a_o->x = FixedMul(a_i->x, a_c); a_o->y = FixedMul(a_i->y, a_c); a_o->z = FixedMul(a_i->z, a_c); return a_o; }
fixed_t FV_Distance(const vector_t *p1, const vector_t *p2) { INT32 xs = FixedMul(p2->x-p1->x,p2->x-p1->x); INT32 ys = FixedMul(p2->y-p1->y,p2->y-p1->y); INT32 zs = FixedMul(p2->z-p1->z,p2->z-p1->z); return FixedSqrt(xs+ys+zs); }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack1) { AActor *missile; angle_t an; if (!self->target) return; ACTION_PARAM_START(1); ACTION_PARAM_CLASS(spawntype, 0); if (spawntype == NULL) spawntype = PClass::FindClass("FatShot"); A_FaceTarget (self); // Change direction to ... self->angle += FATSPREAD; P_SpawnMissile (self, self->target, spawntype); missile = P_SpawnMissile (self, self->target, spawntype); if (missile != NULL) { missile->angle += FATSPREAD; an = missile->angle >> ANGLETOFINESHIFT; missile->velx = FixedMul (missile->Speed, finecosine[an]); missile->vely = FixedMul (missile->Speed, finesine[an]); }
fixed_t FixedHypot(fixed_t x, fixed_t y) { #ifdef HAVE_HYPOT const float fx = FIXED_TO_FLOAT(x); const float fy = FIXED_TO_FLOAT(y); float fz; #ifdef HAVE_HYPOTF fz = hypotf(fx, fy); #else fz = (float)hypot(fx, fy); #endif return FLOAT_TO_FIXED(fz); #else // !HAVE_HYPOT fixed_t ax, yx, yx2, yx1; if (abs(y) > abs(x)) // |y|>|x| { ax = abs(y); // |y| => ax yx = FixedDiv(x, y); // (x/y) } else // |x|>|y| { ax = abs(x); // |x| => ax yx = FixedDiv(y, x); // (x/y) } yx2 = FixedMul(yx, yx); // (x/y)^2 yx1 = FixedSqrt(1+FRACUNIT + yx2); // (1 + (x/y)^2)^1/2 return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2) #endif }
// // [Toke - CTF] CTF_MoveFlag // Moves the flag that is linked to a player // void CTF_MoveFlags () { // denis - flag is now a boolean for(size_t i = 0; i < NUMFLAGS; i++) { if(CTFdata[i].flagger && CTFdata[i].actor) { player_t &player = idplayer(CTFdata[i].flagger); AActor *flag = CTFdata[i].actor; if(!player.mo) { flag->UnlinkFromWorld (); return; } extern fixed_t tmfloorz; extern fixed_t tmceilingz; unsigned an = player.mo->angle >> ANGLETOFINESHIFT; fixed_t x = (player.mo->x + FixedMul (-2*FRACUNIT, finecosine[an])); fixed_t y = (player.mo->y + FixedMul (-2*FRACUNIT, finesine[an])); P_CheckPosition (player.mo, player.mo->x, player.mo->y); flag->UnlinkFromWorld (); flag->x = x; flag->y = y; flag->z = player.mo->z; flag->floorz = tmfloorz; flag->ceilingz = tmceilingz; flag->LinkToWorld (); } }
void A_VolcBallImpact (AActor *ball) { int i; AActor *tiny; angle_t angle; if (ball->z <= ball->floorz) { ball->flags |= MF_NOGRAVITY; ball->gravity = FRACUNIT; ball->z += 28*FRACUNIT; //ball->momz = 3*FRACUNIT; } P_RadiusAttack (ball, ball->target, 25, 25, NAME_Fire, true); for (i = 0; i < 4; i++) { tiny = Spawn<AVolcanoTBlast> (ball->x, ball->y, ball->z, ALLOW_REPLACE); tiny->target = ball; angle = i*ANG90; tiny->angle = angle; angle >>= ANGLETOFINESHIFT; tiny->momx = FixedMul (FRACUNIT*7/10, finecosine[angle]); tiny->momy = FixedMul (FRACUNIT*7/10, finesine[angle]); tiny->momz = FRACUNIT + (pr_impact() << 9); P_CheckMissileSpawn (tiny); } }
DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact) { unsigned int i; AActor *tiny; angle_t angle; if (self->z <= self->floorz) { self->flags |= MF_NOGRAVITY; self->gravity = FRACUNIT; self->z += 28*FRACUNIT; //self->velz = 3*FRACUNIT; } P_RadiusAttack (self, self->target, 25, 25, NAME_Fire, RADF_HURTSOURCE); for (i = 0; i < 4; i++) { tiny = Spawn("VolcanoTBlast", self->x, self->y, self->z, ALLOW_REPLACE); tiny->target = self; angle = i*ANG90; tiny->angle = angle; angle >>= ANGLETOFINESHIFT; tiny->velx = FixedMul (FRACUNIT*7/10, finecosine[angle]); tiny->vely = FixedMul (FRACUNIT*7/10, finesine[angle]); tiny->velz = FRACUNIT + (pr_volcimpact() << 9); P_CheckMissileSpawn (tiny, self->radius); } }
int EV_BuildPillar(line_t *line, byte *args, boolean crush) { int secnum; sector_t *sec; pillar_t *pillar; int newHeight; int rtn; rtn = 0; secnum = -1; while((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0) { sec = §ors[secnum]; if(sec->specialdata) continue; // already moving if(sec->floorheight == sec->ceilingheight) { // pillar is already closed continue; } rtn = 1; if(!args[2]) { newHeight = sec->floorheight+ ((sec->ceilingheight-sec->floorheight)/2); } else { newHeight = sec->floorheight+(args[2]<<FRACBITS); } pillar = Z_Malloc(sizeof(*pillar), PU_LEVSPEC, 0); sec->specialdata = pillar; P_AddThinker(&pillar->thinker); pillar->thinker.function = T_BuildPillar; pillar->sector = sec; if(!args[2]) { pillar->ceilingSpeed = pillar->floorSpeed = args[1]*(FRACUNIT/8); } else if(newHeight-sec->floorheight > sec->ceilingheight-newHeight) { pillar->floorSpeed = args[1]*(FRACUNIT/8); pillar->ceilingSpeed = FixedMul(sec->ceilingheight-newHeight, FixedDiv(pillar->floorSpeed, newHeight-sec->floorheight)); } else { pillar->ceilingSpeed = args[1]*(FRACUNIT/8); pillar->floorSpeed = FixedMul(newHeight-sec->floorheight, FixedDiv(pillar->ceilingSpeed, sec->ceilingheight-newHeight)); } pillar->floordest = newHeight; pillar->ceilingdest = newHeight; pillar->direction = 1; pillar->crush = crush*args[3]; SN_StartSequence((mobj_t *)&pillar->sector->soundorg, SEQ_PLATFORM+pillar->sector->seqType); } return rtn; }
void A_ImpMsAttack (AActor *self) { AActor *dest; angle_t an; int dist; if (!self->target || pr_impmsatk() > 64) { self->SetState (self->SeeState); return; } dest = self->target; self->flags |= MF_SKULLFLY; S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); A_FaceTarget (self); an = self->angle >> ANGLETOFINESHIFT; self->momx = FixedMul (12*FRACUNIT, finecosine[an]); self->momy = FixedMul (12*FRACUNIT, finesine[an]); dist = P_AproxDistance (dest->x - self->x, dest->y - self->y); dist = dist/(12*FRACUNIT); if (dist < 1) { dist = 1; } self->momz = (dest->z + (dest->height>>1) - self->z)/dist; }
void P_ChaseTicker() { int xdist, ydist, zdist; // backup current position for interpolation chasecam.backupPosition(); // find the target P_GetChasecamTarget(); // find distance to target.. xdist = targetx - chasecam.x; ydist = targety - chasecam.y; zdist = targetz - chasecam.z; // haleyjd: patched these lines with cph's fix // for overflow occuring in the multiplication // now move chasecam chasecam.x += FixedMul(xdist, chasecam_speed*(FRACUNIT/100)); chasecam.y += FixedMul(ydist, chasecam_speed*(FRACUNIT/100)); chasecam.z += FixedMul(zdist, chasecam_speed*(FRACUNIT/100)); chasecam.pitch = players[displayplayer].pitch; chasecam.angle = playerangle; }
static void R_DoAnInterpolation (int i, fixed_t smoothratio) { fixed_t pos; fixed_t *adr1 = NULL; fixed_t *adr2 = NULL; switch (curipos[i].type) { case INTERP_SectorFloor: adr1 = &((sector_t*)curipos[i].address)->floorheight; break; case INTERP_SectorCeiling: adr1 = &((sector_t*)curipos[i].address)->ceilingheight; break; case INTERP_Vertex: adr1 = &((vertex_t*)curipos[i].address)->x; //// adr2 = &((vertex_t*)curipos[i].Address)->y; break; case INTERP_WallPanning: adr1 = &((side_t*)curipos[i].address)->rowoffset; adr2 = &((side_t*)curipos[i].address)->textureoffset; break; case INTERP_FloorPanning: adr1 = &((sector_t*)curipos[i].address)->floor_xoffs; adr2 = &((sector_t*)curipos[i].address)->floor_yoffs; break; case INTERP_CeilingPanning: adr1 = &((sector_t*)curipos[i].address)->ceiling_xoffs; adr2 = &((sector_t*)curipos[i].address)->ceiling_yoffs; break; default: return; } if (adr1) { pos = bakipos[i][0] = *adr1; *adr1 = oldipos[i][0] + FixedMul (pos - oldipos[i][0], smoothratio); } if (adr2) { pos = bakipos[i][1] = *adr2; *adr2 = oldipos[i][1] + FixedMul (pos - oldipos[i][1], smoothratio); } #ifdef GL_DOOM if (gl_seamless) { switch (curipos[i].type) { case INTERP_SectorFloor: case INTERP_SectorCeiling: gld_UpdateSplitData(((sector_t*)curipos[i].address)); break; } } #endif }
void R_InterpolateView (player_t *player, fixed_t frac) { if (movement_smooth) { if (NoInterpolateView) { NoInterpolateView = false; original_view_vars.viewx = player->mo->x; original_view_vars.viewy = player->mo->y; original_view_vars.viewz = player->viewz; original_view_vars.viewangle = player->mo->angle + viewangleoffset; } viewx = original_view_vars.viewx + FixedMul (frac, player->mo->x - original_view_vars.viewx); viewy = original_view_vars.viewy + FixedMul (frac, player->mo->y - original_view_vars.viewy); viewz = original_view_vars.viewz + FixedMul (frac, player->viewz - original_view_vars.viewz); viewangle = original_view_vars.viewangle + FixedMul (frac, R_SmoothPlaying_Get(player->mo->angle) + viewangleoffset - original_view_vars.viewangle); } else { viewx = player->mo->x; viewy = player->mo->y; viewz = player->viewz; viewangle = R_SmoothPlaying_Get(player->mo->angle); } }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FatAttack1) { AActor *missile; angle_t an; if (!self->target) return; ACTION_PARAM_START(1); ACTION_PARAM_CLASS(spawntype, 0); if (spawntype == NULL) spawntype = PClass::FindClass("FatShot"); A_FaceTarget (self); // Change direction to ... self->angle += FATSPREAD; missile = P_SpawnMissile (self, self->target, spawntype); // [BC] If we're the server, tell clients to spawn the missile. if (( NETWORK_GetState( ) == NETSTATE_SERVER ) && ( missile )) SERVERCOMMANDS_SpawnMissile( missile ); missile = P_SpawnMissile (self, self->target, spawntype); if (missile != NULL) { missile->angle += FATSPREAD; an = missile->angle >> ANGLETOFINESHIFT; missile->velx = FixedMul (missile->Speed, finecosine[an]); missile->vely = FixedMul (missile->Speed, finesine[an]); // [BC] If we're the server, tell clients to spawn the missile. if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVERCOMMANDS_SpawnMissile( missile ); }
BOOL R_AlignFlat (int linenum, int side, int fc) { line_t *line = lines + linenum; sector_t *sec = side ? line->backsector : line->frontsector; if (!sec) return false; fixed_t x = line->v1->x; fixed_t y = line->v1->y; angle_t angle = R_PointToAngle2 (x, y, line->v2->x, line->v2->y); angle_t norm = (angle-ANG90) >> ANGLETOFINESHIFT; fixed_t dist = -FixedMul (finecosine[norm], x) - FixedMul (finesine[norm], y); if (side) { angle = angle + ANG180; dist = -dist; } if (fc) { sec->base_ceiling_angle = 0-angle; sec->base_ceiling_yoffs = dist & ((1<<(FRACBITS+8))-1); } else { sec->base_floor_angle = 0-angle; sec->base_floor_yoffs = dist & ((1<<(FRACBITS+8))-1); } return true; }
void R_InitSkyMap () { if (textureheight == NULL) return; if (textureheight[skytexture] <= (128 << FRACBITS)) { skytexturemid = 100*FRACUNIT; skystretch = (r_stretchsky && allowfreelook); } else { skytexturemid = 100*FRACUNIT; skystretch = 0; } skyheight = textureheight[skytexture] << skystretch; if (viewwidth && viewheight) { skyiscale = (200*FRACUNIT) / (((freelookviewheight<<detailxshift) * viewwidth) / (viewwidth<<detailxshift)); skyscale = ((((freelookviewheight<<detailxshift) * viewwidth) / (viewwidth<<detailxshift)) << FRACBITS) /(200); skyiscale = FixedMul (skyiscale, FixedDiv (clipangle, ANG45)); skyscale = FixedMul (skyscale, FixedDiv (ANG45, clipangle)); } // The sky map is 256*128*4 maps. skyshift = 22+skystretch-16; if (texturewidthmask[skytexture] >= 256*2-1) skyshift -= skystretch; }
// // [Toke - CTF] CTF_MoveFlag // Moves the flag that is linked to a player // void CTF_MoveFlags () { // denis - flag is now a boolean for(size_t i = 0; i < NUMFLAGS; i++) { if(CTFdata[i].flagger && CTFdata[i].actor) { player_t &player = idplayer(CTFdata[i].flagger); AActor *flag = CTFdata[i].actor; if (!validplayer(player) || !player.mo) { // [SL] 2012-12-13 - Remove a flag if it's being carried but // there's not a valid player carrying it (should not happen) CTFdata[i].flagger = 0; CTFdata[i].state = flag_home; if(CTFdata[i].actor) CTFdata[i].actor->Destroy(); continue; } unsigned an = player.mo->angle >> ANGLETOFINESHIFT; fixed_t x = (player.mo->x + FixedMul (-2*FRACUNIT, finecosine[an])); fixed_t y = (player.mo->y + FixedMul (-2*FRACUNIT, finesine[an])); CL_MoveThing(flag, x, y, player.mo->z); } }
void R_RotatePoint(fixed_t x, fixed_t y, angle_t ang, fixed_t &tx, fixed_t &ty) { int index = ang >> ANGLETOFINESHIFT; tx = FixedMul(x, finecosine[index]) - FixedMul(y, finesine[index]); ty = FixedMul(x, finesine[index]) + FixedMul(y, finecosine[index]); }
// // P_SpawnBrokenGlass // villsa [STRIFE] new function // static void P_SpawnBrokenGlass(line_t* line) { fixed_t x1; fixed_t x2; fixed_t y1; fixed_t y2; int i; mobj_t* glass; angle_t an; x1 = (line->v2->x + line->v1->x) / 2; y1 = (line->v2->y + line->v1->y) / 2; x2 = ((line->frontsector->soundorg.x - x1) / 5) + x1; y2 = ((line->frontsector->soundorg.y - y1) / 5) + y1; for(i = 0; i < 7; i++) { glass = P_SpawnMobj(x2, y2, ONFLOORZ, MT_JUNK); glass->z += (24*FRACUNIT); glass->flags |= (MF_SHADOW|MF_MVIS); P_SetMobjState(glass, P_Random() % 3 + S_SHRD_03); // 284 an = ((P_Random() << 13) / 255); glass->angle = (an << ANGLETOFINESHIFT); glass->momx = FixedMul(finecosine[an], (P_Random() & 3) << FRACBITS); glass->momy = FixedMul(finesine[an], (P_Random() & 3) << FRACBITS); glass->momz = (P_Random() & 7) << FRACBITS; glass->tics += (P_Random() + 7) & 7; } }
void A_InquisitorJump (AActor *self) { fixed_t dist; fixed_t speed; angle_t an; if (self->target == NULL) return; S_LoopedSound (self, CHAN_ITEM, "inquisitor/jump", 1, ATTN_NORM); self->z += 64*FRACUNIT; A_FaceTarget (self); an = self->angle >> ANGLETOFINESHIFT; speed = self->Speed * 2/3; self->momx += FixedMul (speed, finecosine[an]); self->momy += FixedMul (speed, finesine[an]); dist = P_AproxDistance (self->target->x - self->x, self->target->y - self->y); dist /= speed; if (dist < 1) { dist = 1; } self->momz = (self->target->z - self->z) / dist; self->reactiontime = 60; self->flags |= MF_NOGRAVITY; }
void FTextureManager::AddHiresTextures (int wadnum) { int firsttx = Wads.GetFirstLump(wadnum); int lasttx = Wads.GetLastLump(wadnum); char name[9]; TArray<FTextureID> tlist; if (firsttx == -1 || lasttx == -1) { return; } name[8] = 0; for (;firsttx <= lasttx; ++firsttx) { if (Wads.GetLumpNamespace(firsttx) == ns_hires) { Wads.GetLumpName (name, firsttx); if (Wads.CheckNumForName (name, ns_hires) == firsttx) { tlist.Clear(); int amount = ListTextures(name, tlist); if (amount == 0) { // A texture with this name does not yet exist FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any); if (newtex != NULL) { newtex->UseType=FTexture::TEX_Override; AddTexture(newtex); } } else { for(unsigned int i = 0; i < tlist.Size(); i++) { FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any); if (newtex != NULL) { FTexture * oldtex = Textures[tlist[i].GetIndex()].Texture; // Replace the entire texture and adjust the scaling and offset factors. newtex->bWorldPanning = true; newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight()); newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale); newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale); ReplaceTexture(tlist[i], newtex, true); } } } //StartScreen->Progress(); } } } }
// // P_Teleport from Heretic, but made to be more generic and Eternity-ready // FIXME: This should be made more generic, so that other stuff can benefit from it // bool P_HereticTeleport(Mobj *thing, fixed_t x, fixed_t y, angle_t angle) { fixed_t oldx, oldy, oldz, aboveFloor, fogDelta; player_t *player; unsigned an; oldx = thing->x; oldy = thing->y; oldz = thing->z; aboveFloor = thing->z - thing->floorz; if(!P_TeleportMove(thing, x, y, false)) return false; if((player = thing->player)) { if(player->powers[pw_flight] && aboveFloor) { thing->z = thing->floorz + aboveFloor; if(thing->z + thing->height > thing->ceilingz) thing->z = thing->ceilingz - thing->height; player->prevviewz = player->viewz = thing->z + player->viewheight; } else { P_dropToFloor(thing, player); player->prevpitch = player->pitch = 0; } } else if(thing->flags & MF_MISSILE) { thing->z = thing->floorz + aboveFloor; if(thing->z + thing->height > thing->ceilingz) thing->z = thing->ceilingz - thing->height; } else P_dropToFloor(thing, nullptr); // Spawn teleport fog at source and destination const int fogNum = E_SafeThingName(GameModeInfo->teleFogType); fogDelta = thing->flags & MF_MISSILE ? 0 : GameModeInfo->teleFogHeight; S_StartSound(P_SpawnMobj(oldx, oldy, oldz + fogDelta, fogNum), GameModeInfo->teleSound); an = angle >> ANGLETOFINESHIFT; S_StartSound(P_SpawnMobj(x + 20 * finecosine[an], y + 20 * finesine[an], thing->z + fogDelta, fogNum), GameModeInfo->teleSound); // Freeze player for ~.5s, but only if they don't have tome active if(thing->player && !thing->player->powers[pw_weaponlevel2]) thing->reactiontime = 18; thing->angle = angle; if(thing->flags & MF_MISSILE) { angle >>= ANGLETOFINESHIFT; thing->momx = FixedMul(thing->info->speed, finecosine[angle]); thing->momy = FixedMul(thing->info->speed, finesine[angle]); }
void GLSkyboxPortal::DrawContents() { int old_pm=PlaneMirrorMode; int saved_extralight = extralight; if (skyboxrecursion>=3) { ClearScreen(); return; } skyboxrecursion++; origin->flags|=MF_JUSTHIT; extralight = 0; PlaneMirrorMode=0; glDisable(GL_DEPTH_CLAMP_NV); viewx = origin->PrevX + FixedMul(r_TicFrac, origin->x - origin->PrevX); viewy = origin->PrevY + FixedMul(r_TicFrac, origin->y - origin->PrevY); viewz = origin->PrevZ + FixedMul(r_TicFrac, origin->z - origin->PrevZ); viewangle += origin->PrevAngle + FixedMul(r_TicFrac, origin->angle - origin->PrevAngle); // Don't let the viewpoint be too close to a floor or ceiling! fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin->x, origin->y); fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin->x, origin->y); if (viewz<floorh+4*FRACUNIT) viewz=floorh+4*FRACUNIT; if (viewz>ceilh-4*FRACUNIT) viewz=ceilh-4*FRACUNIT; GLRenderer->mViewActor = origin; validcount++; inskybox=true; GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); GLRenderer->SetViewArea(); ClearClipper(); int mapsection = R_PointInSubsector(viewx, viewy)->mapsection; SaveMapSection(); currentmapsection[mapsection>>3] |= 1 << (mapsection & 7); GLRenderer->DrawScene(); origin->flags&=~MF_JUSTHIT; inskybox=false; glEnable(GL_DEPTH_CLAMP_NV); skyboxrecursion--; PlaneMirrorMode=old_pm; extralight = saved_extralight; RestoreMapSection(); }
// // A_WeaponReady // The player can fire the weapon // or change to another weapon at this time. // Follows after getting weapon up, // or after previous attack/fire sequence. // void A_WeaponReady(player_t *player, pspdef_t *psp) { // get out of attack state if (player->mo->state == &states[S_PLAY_ATK1] || player->mo->state == &states[S_PLAY_ATK2]) P_SetMobjState(player->mo, S_PLAY); if (player->readyweapon == wp_chainsaw && psp->state == &states[S_SAW]) S_StartSound(player->mo, sfx_sawidl); // check for change // if player is dead, put the weapon away if (player->pendingweapon != wp_nochange || !player->health) { // change weapon (pending weapon should already be validated) P_SetPsprite(player, ps_weapon, (statenum_t)weaponinfo[player->readyweapon].downstate); return; } // check for fire // the missile launcher and bfg do not auto fire if (player->cmd.buttons & BT_ATTACK) { if (!player->attackdown || (player->readyweapon != wp_missile && player->readyweapon != wp_bfg)) { player->attackdown = true; P_FireWeapon(player); return; } } else player->attackdown = false; if (player->mo->momx || player->mo->momy || player->mo->momz) { // bob the weapon based on movement speed int angle = (128 * leveltime) & FINEMASK; int bob = player->bob; if (bob < FRACUNIT / 2) bob = 0; psp->sx = FixedMul(bob, finecosine[angle]); psp->sy = WEAPONTOP + FixedMul(bob, finesine[angle & FINEANGLES / 2 - 1]); } else { psp->sx = 0; psp->sy = WEAPONTOP; } }