// [28/7/2012] Added Monster_StepDirection ~hogsy bool Monster_StepDirection(edict_t *ent,float yaw,float dist) { vec3_t move,oldorg; float delta; ent->v.ideal_yaw = yaw; ChangeYaw(ent); yaw *= (float)pMath_PI*2/360; move[0] = (vec_t)cos(yaw)*dist; move[1] = (vec_t)sin(yaw)*dist; move[2] = 0; Math_VectorCopy(ent->v.origin,oldorg); if(Monster_MoveStep(ent,move,false)) { delta = ent->v.angles[YAW]-ent->v.ideal_yaw; if(delta > 45 && delta < 315) Math_VectorCopy(oldorg,ent->v.origin); Engine.LinkEntity(ent,true); return true; } Engine.LinkEntity(ent,true); return false; }
void Select_Inside (void) { brush_t *b, *next; int i; vec3_t mins, maxs; if (!QE_SingleBrush ()) return; g_qeglobals.d_select_mode = sel_brush; Math_VectorCopy (selected_brushes.next->mins, mins); Math_VectorCopy (selected_brushes.next->maxs, maxs); Select_Delete (); for (b=active_brushes.next ; b != &active_brushes ; b=next) { next = b->next; for (i=0 ; i<3 ; i++) if (b->maxs[i] > maxs[i] || b->mins[i] < mins[i]) break; if (i == 3) { Brush_RemoveFromList (b); Brush_AddToList (b, &selected_brushes); } } Sys_UpdateWindows (W_ALL); }
void Select_AplyMatrix (void) { brush_t *b; face_t *f; int i, j; vec3_t temp; for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (f=b->brush_faces ; f ; f=f->next) { for (i=0 ; i<3 ; i++) { Math_VectorSubtract(f->planepts[i],select_origin, temp); for (j=0 ; j<3 ; j++) f->planepts[i][j] = Math_DotProduct(temp,select_matrix[j]) + select_origin[j]; } if (select_fliporder) { Math_VectorCopy(f->planepts[0],temp); Math_VectorCopy(f->planepts[2],f->planepts[0]); Math_VectorCopy(temp,f->planepts[2]); } } Brush_Build( b ); } Sys_UpdateWindows (W_ALL); }
/* Player has come to a dead stop, possibly due to the problem with limited float precision at some angle joins in the BSP hull. Try fixing by pushing one pixel in each direction. This is a hack, but in the interest of good gameplay... */ int SV_TryUnstick (edict_t *ent, vec3_t oldvel) { int i; vec3_t oldorg; vec3_t dir; int clip; trace_t steptrace; Math_VectorCopy (ent->v.origin, oldorg); Math_VectorCopy (mv3Origin, dir); for (i=0 ; i<8 ; i++) { // try pushing a little in an axial direction switch (i) { case 0: dir[0] = 2; dir[1] = 0; break; case 1: dir[0] = 0; dir[1] = 2; break; case 2: dir[0] = -2; dir[1] = 0; break; case 3: dir[0] = 0; dir[1] = -2; break; case 4: dir[0] = 2; dir[1] = 2; break; case 5: dir[0] = -2; dir[1] = 2; break; case 6: dir[0] = 2; dir[1] = -2; break; case 7: dir[0] = -2; dir[1] = -2; break; } SV_PushEntity (ent, dir); // Retry the original move ent->v.velocity[0] = oldvel[0]; ent->v.velocity[1] = oldvel[1]; ent->v.velocity[2] = 0; clip = SV_FlyMove(ent,0.1f,&steptrace); if ( fabs(oldorg[1] - ent->v.origin[1]) > 4 || fabs(oldorg[0] - ent->v.origin[0]) > 4 ) return clip; // Go back to the original pos and try again Math_VectorCopy (oldorg, ent->v.origin); } Math_VectorCopy(mv3Origin,ent->v.velocity); return 7; // still not moving }
// TODO: stay at least 8 units away from all walls in this leaf void Chase_UpdateForDrawing (void) { int i; vec3_t forward, up, right; vec3_t ideal, crosshair, temp; Math_AngleVectors(cl.viewangles, forward, right, up); // calc ideal camera location before checking for walls for (i=0 ; i<3 ; i++) ideal[i] = cl.viewent.origin[i] - forward[i]*chase_back.value + right[i]*chase_right.value; //+ up[i]*chase_up.value; ideal[2] = cl.viewent.origin[2] + chase_up.value; // make sure camera is not in or behind a wall TraceLine(r_refdef.vieworg, ideal, temp); if(Math_Length(temp) != 0) Math_VectorCopy(temp, ideal); // place camera Math_VectorCopy(ideal, r_refdef.vieworg); // find the spot the player is looking at Math_VectorMA(cl.viewent.origin, 4096, forward, temp); TraceLine(cl.viewent.origin, temp, crosshair); // calculate camera angles to look at the same spot Math_VectorSubtract(crosshair,r_refdef.vieworg,temp); Math_VectorAngles (temp, r_refdef.viewangles); if (r_refdef.viewangles[PITCH] == 90 || r_refdef.viewangles[PITCH] == -90) r_refdef.viewangles[YAW] = cl.viewangles[YAW]; }
// [4/8/2012] Renamed to SideWinder_SpawnMissle ~hogsy void SideWinder_SpawnMissle(edict_t *ent,float fSpeed,float ox) { // [26/2/2012] Revised and fixed ~hogsy vec3_t vOrg; edict_t *eMissile = Entity_Spawn(); /* TODO: Spawn a flare at our position too ~hogsy */ eMissile->v.cClassname = "sidewindermissile"; eMissile->v.movetype = MOVETYPE_FLYMISSILE; eMissile->v.effects = EF_PARTICLE_SMOKE|EF_DIMLIGHT; eMissile->Physics.iSolid = SOLID_BBOX; eMissile->Physics.eIgnore = ent; eMissile->local.speed = SIDEWINDER_MAXSPEED; eMissile->local.eOwner = ent; eMissile->local.count = 0; // [4/8/2012] Change our speed depending on what contents we're within ~hogsy eMissile->local.speed = fSpeed; Math_VectorScale(Engine.Aim(ent),eMissile->local.speed,eMissile->v.velocity); Math_AngleVectors(ent->v.v_angle, // [4/8/2012] Set up our angle vectors ~hogsy eMissile->v.vForward, eMissile->local.vRight, eMissile->local.vUp); Math_VectorCopy(ent->v.v_angle,eMissile->v.angles); Entity_SetModel(eMissile,"models/sidewinder_missile.md2"); Math_VectorCopy(ent->v.origin,vOrg); vOrg[0] += eMissile->v.vForward[0]*8+eMissile->local.vRight[0]*ox; vOrg[1] += eMissile->v.vForward[1]*8+eMissile->local.vRight[1]*ox; vOrg[2] += eMissile->v.vForward[2]*24; Entity_SetSizeVector(eMissile,mv3Origin,mv3Origin); Entity_SetOrigin(eMissile,vOrg); // [4/8/2012] Time at which we'll be removed if nothing hit ~hogsy eMissile->local.fSpawnDelay = (float)(Server.dTime+8.0); eMissile->v.TouchFunction = SideWinder_MissileExplode; eMissile->v.dNextThink = Server.dTime+0.05; eMissile->v.think = SideWinder_Think; // [4/8/2012] Moved so we do this last! ~hogsy Engine.LinkEntity(eMissile,false); }
/* TODO: - Firstly save each iteration of our water, so we can keep track of colour etc. - Recalc colour for different dynamic moving lights. */ void Warp_DrawWaterPoly(glpoly_t *p) { VideoObject_t *voWaterPoly; vec3_t vWave,vLightColour; float *v; int i; voWaterPoly = malloc(p->numverts*sizeof(VideoObject_t)); if(!voWaterPoly) { Sys_Error("Failed to allocate water poly!\n"); return; } v = p->verts[0]; for(i = 0; i < p->numverts; i++,v += VERTEXSIZE) { voWaterPoly[i].vTextureCoord[0][0] = WARPCALC(v[3],v[4]); voWaterPoly[i].vTextureCoord[0][1] = WARPCALC(v[4],v[3]); voWaterPoly[i].vColour[3] = Math_Clamp(0, r_wateralpha.value, 1.0f); Math_VectorCopy(v,vWave); // Shitty lit water, use dynamic light points in the future... { MathVector_t mvLightColour; // Use vWave position BEFORE we move it, otherwise the water will flicker. mvLightColour = Light_GetSample(vWave); Math_MVToVector(mvLightColour,vLightColour); Math_VectorScale(vLightColour,1.0f/200.0f,vLightColour); Math_VectorDivide(vLightColour,0.2f,vLightColour); } Math_VectorCopy(vLightColour,voWaterPoly[i].vColour); // [20/1/2013] Added in subtle water bobbing, based on this code http://www.quake-1.com/docs/quakesrc.org/26.html ~hogsy vWave[2] = v[2]+ 2.0f*(float)sin(v[0]*0.025f+cl.time)*(float)sin(v[2]*0.05f+cl.time)+ 2.0f*(float)sin(v[1]*0.025f+cl.time*2.0f)*(float)sin(v[2]*0.05f+cl.time); Math_VectorCopy(vWave,voWaterPoly[i].vVertex); } Video_DrawObject(voWaterPoly,VIDEO_PRIMITIVE_TRIANGLE_FAN,p->numverts); free(voWaterPoly); }
/* Toss, bounce, and fly movement. When onground, do nothing. */ void Physics_Toss(edict_t *ent) { trace_t trace; vec3_t move; float backoff; // Regular thinking if(!Server_RunThink(ent) || (ent->v.flags & FL_ONGROUND)) return; Game->Physics_CheckVelocity(ent); // Add gravity if(ent->v.movetype != MOVETYPE_FLY && ent->v.movetype != MOVETYPE_FLYMISSILE && ent->v.movetype != MOVETYPE_FLYBOUNCE) Game->Physics_SetGravity(ent); // Move angles Math_VectorMA(ent->v.angles,host_frametime,ent->v.avelocity,ent->v.angles); // Move origin Math_VectorScale(ent->v.velocity,host_frametime,move); trace = SV_PushEntity(ent, move); if(trace.fraction == 1.0f || ent->free) return; if(ent->v.movetype == MOVETYPE_FLYBOUNCE) backoff = 2.0f; else if (ent->v.movetype == MOVETYPE_BOUNCE) backoff = 1.5f; else backoff = 1.0f; ClipVelocity (ent->v.velocity, trace.plane.normal, ent->v.velocity, backoff); // Stop if on ground if(trace.plane.normal[2] > 0.7 || (ent->v.movetype != MOVETYPE_BOUNCE && ent->v.movetype != MOVETYPE_FLYBOUNCE)) if(ent->v.velocity[2] < 60.0f) { ent->v.flags = ent->v.flags | FL_ONGROUND; ent->v.groundentity = trace.ent; Math_VectorCopy(mv3Origin,ent->v.velocity); Math_VectorCopy(mv3Origin,ent->v.avelocity); } Game->Physics_CheckWaterTransition(ent); }
void GreekFire_Throw(edict_t *ent) { float *dir; edict_t *greekfire = Entity_Spawn(); greekfire->v.cClassname = "greekfire"; greekfire->v.movetype = MOVETYPE_BOUNCE; greekfire->v.effects = EF_DIMLIGHT; greekfire->Physics.iSolid = SOLID_BBOX; greekfire->local.eOwner = ent; dir = Engine.Aim(ent); greekfire->v.velocity[0] = dir[0]*800; greekfire->v.velocity[1] = dir[1]*800; greekfire->v.velocity[2] = dir[2]*800; Engine.MakeVectors(greekfire->v.v_angle); Entity_SetModel(greekfire,"models/w_greekfire.md2"); Math_MVToVector(Math_VectorToAngles(greekfire->v.velocity),greekfire->v.angles); // [4/7/2012] Simplified ~hogsy Math_VectorCopy(ent->v.origin,greekfire->v.origin); Entity_SetSizeVector(greekfire,mv3Origin,mv3Origin); Engine.LinkEntity(greekfire,false); greekfire->v.TouchFunction = GreekfireTouch; }
void SetAngle(edict_t *ent,vec3_t vAngle) { // [21/3/2012] Updated ~hogsy Math_VectorCopy(vAngle,ent->v.angles); Engine.LinkEntity(ent,false); }
bool Entity_DropToFloor(ServerEntity_t *eEntity) { MathVector3f_t vEnd; trace_t trGround; Math_VectorCopy(eEntity->v.origin, vEnd); vEnd[2] -= 256; trGround = Engine.Server_Move(eEntity->v.origin, eEntity->v.mins, eEntity->v.maxs, vEnd, false, eEntity); if (trGround.fraction == 1 || trGround.bAllSolid) { Engine.Con_Warning("Entity is stuck in world! (%s) (%i %i %i)\n", eEntity->v.cClassname, (int)eEntity->v.origin[0], (int)eEntity->v.origin[1], (int)eEntity->v.origin[2]); return false; } // Use SetOrigin so that it's automatically linked. Entity_SetOrigin(eEntity, trGround.endpos); Entity_AddFlags(eEntity, FL_ONGROUND); eEntity->v.groundentity = trGround.ent; return true; }
void Shockwave_SpawnProjectile(ServerEntity_t *ent) { ServerEntity_t *eLaser; Sound(ent,CHAN_WEAPON,"weapons/shockwave/fire.wav",255,ATTN_NORM); ent->v.punchangle[0] -= 10.0f; eLaser = Entity_Spawn(); if(eLaser) { Weapon_Projectile(ent, eLaser, 2000.0f); Math_VectorCopy(ent->v.origin,eLaser->v.origin); Math_MVToVector(plVectorToAngles(eLaser->v.velocity),eLaser->v.angles); eLaser->local.owner = ent; eLaser->v.movetype = MOVETYPE_FLY; eLaser->v.TouchFunction = ShockLaser_Touch; eLaser->v.origin[2] += 25.0f; eLaser->Physics.solid = SOLID_BBOX; Entity_SetModel(eLaser,"models/slaser.md2"); Entity_SetSizeVector(eLaser, pl_origin3f, pl_origin3f); } ent->local.shockwave_ammo--; ent->v.primary_ammo = ent->local.shockwave_ammo; }
void Crossbow_Projectile(ServerEntity_t *ent) { // [11/2/2012] Revised and fixed ~hogsy MathVector3f_t mvDirection; ServerEntity_t *eArrow; eArrow = Entity_Spawn(); if(eArrow) { eArrow->local.eOwner = ent; eArrow->v.movetype = MOVETYPE_FLY; eArrow->Physics.iSolid = SOLID_BBOX; Math_MVToVector(Weapon_Aim(ent), mvDirection); Math_VectorScale(mvDirection, 2000.0f, eArrow->v.velocity); Entity_SetModel(eArrow,"models/arrow.md2"); Entity_SetSizeVector(eArrow,g_mvOrigin3f,g_mvOrigin3f); // [25/6/2012] Simplified ~hogsy Math_VectorCopy(ent->v.origin,eArrow->v.origin); eArrow->v.origin[2] += 15.0f; Math_MVToVector(Math_VectorToAngles(ent->v.velocity),ent->v.angles); eArrow->v.TouchFunction = arrow_touch; } }
/* The mouse click did not hit the brush, so grab one or more side planes for dragging */ void Brush_SideSelect(brush_t *b,vec3_t origin,vec3_t dir,bool shear) { face_t *f, *f2; vec3_t p1, p2; for(f = b->brush_faces; f; f = f->next) { Math_VectorCopy(origin,p1); Math_VectorMA(origin,16384,dir,p2); for (f2=b->brush_faces ; f2 ; f2=f2->next) { if (f2 == f) continue; Brush_ClipLineToFace(p1,p2,f2); } if(f2) continue; if(Math_VectorCompare(p1,origin)) continue; if(Brush_ClipLineToFace(p1,p2,f)) continue; Brush_SelectFaceForDragging (b, f, shear); } }
void Area_RotateSpawn(ServerEntity_t *area) { if(!area->local.speed) { area->local.speed = 100; } #if 0 // [26/7/2012] Check our spawn flags ~hogsy if(area->local.style == STYLE_ROTATE_DOOR) { if(area->v.spawnflags & SPAWNFLAG_ROTATE_REVERSE) { } if(area->v.spawnflags & SPAWNFLAG_ROTATE_X) area->v.movedir[0] = 1.0f; else if(area->v.spawnflags & SPAWNFLAG_ROTATE_Y) area->v.movedir[1] = 1.0f; else area->v.movedir[2] = 1.0f; Math_VectorCopy(area->v.angles,area->local.pos1); area->local.pos2[0] = area->local.pos1[0]+area->v.movedir[0]*area->local.distance; area->v.TouchFunction = Area_RotateTouch; area->local.dMoveFinished = 0; } else #endif { if(area->v.spawnflags & SPAWNFLAG_ROTATE_REVERSE) { area->local.speed *= -1; } if(area->v.spawnflags & SPAWNFLAG_ROTATE_X) { area->v.avelocity.x = area->local.speed; } if(area->v.spawnflags & SPAWNFLAG_ROTATE_Y) { area->v.avelocity.y = area->local.speed; } if(area->v.spawnflags & SPAWNFLAG_ROTATE_Z) { area->v.avelocity.z = area->local.speed; } } Entity_SetBlockedFunction(area, Area_RotateBlocked); area->v.movetype = MOVETYPE_PUSH; area->v.think = Area_RotateThink; area->v.nextthink = Server.time + 1000000000.0; // TODO: This is a hack. A dirty filthy hack. Curse it and its family! area->Physics.solid = SOLID_BSP; Entity_SetModel(area,area->v.model); Entity_SetSizeVector(area,area->v.mins,area->v.maxs); Entity_SetOrigin(area,area->v.origin); }
/* ============== TraceLine TODO: impact on bmodels, monsters ============== */ void TraceLine (MathVector3f_t start, MathVector3f_t end, MathVector3f_t impact) { trace_t trace; memset (&trace, 0, sizeof(trace)); SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace); Math_VectorCopy (trace.endpos, impact); }
/* Sets the size of the given entity; requires that the model has been applied first. Alternative to SetSize. */ void Entity_SetSizeVector(ServerEntity_t *eEntity, MathVector3f_t vMin, MathVector3f_t vMax) { int i; // Check if the model is set yet, if not give us a little warning. if(!eEntity->v.model) Engine.Con_Warning("Setting entity size before model! (%s)\n",eEntity->v.cClassname); for(i = 0; i < 3; i++) if(vMin[i] > vMax[i]) { Engine.Con_Warning("Backwards mins/maxs! (%s)\n",eEntity->v.cClassname); return; } Math_VectorCopy(vMin,eEntity->v.mins); Math_VectorCopy(vMax,eEntity->v.maxs); Math_VectorSubtract(vMax,vMin,eEntity->v.size); Entity_Link(eEntity, false); }
/* Alternative to SetSize. */ void Entity_SetSizeVector(edict_t *eEntity,vec3_t vMin,vec3_t vMax) { int i; // [13/9/2013] Check if the model is set yet, if not give us a little warning ~hogsy if(!eEntity->v.model) Engine.Con_Warning("Setting entity size before model! (%s)\n",eEntity->v.cClassname); for(i = 0; i < 3; i++) if(vMin[i] > vMax[i]) { Engine.Con_Warning("Backwards mins/maxs! (%s)\n",eEntity->v.cClassname); return; } Math_VectorCopy(vMin,eEntity->v.mins); Math_VectorCopy(vMax,eEntity->v.maxs); Math_VectorSubtract(vMax,vMin,eEntity->v.size); Engine.LinkEntity(eEntity,false); }
void TextureAxisFromPlane(plane_t *pln,vec3_t xv,vec3_t yv) { int bestaxis,i; float dot,best; best = 0; bestaxis = 0; for(i = 0; i < 6; i++) { dot = Math_DotProduct(pln->normal,baseaxis[i*3]); if (dot > best) { best = dot; bestaxis = i; } } Math_VectorCopy(baseaxis[bestaxis*3+1],xv); Math_VectorCopy(baseaxis[bestaxis*3+2],yv); }
void R_SetupView (void) { Fog_SetupFrame (); //johnfitz // build the transformation matrix for the given view angles Math_VectorCopy(r_refdef.vieworg,r_origin); Math_AngleVectors(r_refdef.viewangles,vpn,vright,vup); // Current viewleaf r_oldviewleaf = r_viewleaf; r_viewleaf = Mod_PointInLeaf (r_origin, cl.worldmodel); V_SetContentsColor(r_viewleaf->contents); View_CalculateBlend(); //johnfitz -- calculate r_fovx and r_fovy here r_fovx = r_refdef.fov_x; r_fovy = r_refdef.fov_y; if (r_waterwarp.value) { int contents = Mod_PointInLeaf (r_origin, cl.worldmodel)->contents; if (contents == BSP_CONTENTS_WATER || contents == BSP_CONTENTS_SLIME || contents == BSP_CONTENTS_LAVA) { //variance is a percentage of width, where width = 2 * tan(fov / 2) otherwise the effect is too dramatic at high FOV and too subtle at low FOV. what a mess! r_fovx = atan(tan(pMath_DEG2RAD(r_refdef.fov_x) / 2) * (0.97 + sin(cl.time * 1.5) * 0.03)) * 2 / pMath_PI_DIV180; r_fovy = atan(tan(pMath_DEG2RAD(r_refdef.fov_y) / 2) * (1.03 - sin(cl.time * 1.5) * 0.03)) * 2 / pMath_PI_DIV180; } } //johnfitz R_SetFrustum(r_fovx, r_fovy); //johnfitz -- use r_fov* vars R_MarkSurfaces(); //johnfitz -- create texture chains from PVS R_CullSurfaces(); //johnfitz -- do after R_SetFrustum and R_MarkSurfaces R_UpdateWarpTextures(); //johnfitz -- do this before R_Clear //johnfitz -- cheat-protect some draw modes r_drawflat_cheatsafe = r_fullbright_cheatsafe = r_lightmap_cheatsafe = false; r_drawworld_cheatsafe = true; if (cl.maxclients == 1) { if (!r_drawworld.value) r_drawworld_cheatsafe = false; if (r_drawflat.value) r_drawflat_cheatsafe = true; else if (r_fullbright.value || !cl.worldmodel->lightdata) r_fullbright_cheatsafe = true; else if (r_lightmap.value) r_lightmap_cheatsafe = true; } //johnfitz }
void Sky_ReadCameraPosition(void) { MathVector3f_t campos; sky_camera = MSG_ReadByte(); if (!sky_camera) return; campos[0] = MSG_ReadCoord(); campos[1] = MSG_ReadCoord(); campos[2] = MSG_ReadCoord(); Math_VectorCopy(campos, sky_camerapos); }
/* Marks the edict as free FIXME: walk all entities and NULL out references to this entity */ void ED_Free(ServerEntity_t *ed) { SV_UnlinkEdict(ed); // unlink from world bsp ed->free = true; ed->v.model = 0; ed->v.bTakeDamage = false; ed->v.modelindex = 0; ed->v.colormap = 0; ed->Model.iSkin = 0; ed->v.frame = 0; ed->v.dNextThink = -1; ed->Physics.iSolid = SOLID_NOT; ed->Model.fScale = 1.0f; ed->alpha = ENTALPHA_DEFAULT; //johnfitz -- reset alpha for next entity Math_VectorCopy(g_mvOrigin3f,ed->v.origin); Math_VectorCopy(g_mvOrigin3f,ed->v.angles); ed->fFreeTime = sv.time; }
/* This is a big hack to try and fix the rare case of getting stuck in the world clipping hull. */ void SV_CheckStuck (edict_t *ent) { int i,j,z; vec3_t org; if(!SV_TestEntityPosition(ent)) { Math_VectorCopy(ent->v.origin,ent->v.oldorigin); return; } Math_VectorCopy(ent->v.origin,org); Math_VectorCopy(ent->v.oldorigin,ent->v.origin); if (!SV_TestEntityPosition(ent)) { //Con_DPrintf("Unstuck.\n"); SV_LinkEdict(ent,true); return; } for(z = 0; z < 18; z++) for (i=-1 ; i <= 1 ; i++) for (j=-1 ; j <= 1 ; j++) { ent->v.origin[0] = org[0]+i; ent->v.origin[1] = org[1]+j; ent->v.origin[2] = org[2]+z; if(!SV_TestEntityPosition(ent)) { //Con_DPrintf("Unstuck.\n"); SV_LinkEdict(ent,true); return; } } Math_VectorCopy(org,ent->v.origin); }
void GL_SubdivideSurface(msurface_t *fa) { vec3_t verts[64]; int i; warpface = fa; //the first poly in the chain is the undivided poly for newwater rendering. //grab the verts from that. for (i=0; i<fa->polys->numverts; i++) Math_VectorCopy (fa->polys->verts[i], verts[i]); SubdividePolygon (fa->polys->numverts, verts[0]); }
void R_SetupGenericView(void) { Fog_SetupFrame(); // Build the transformation matrix for the given view angles Math_VectorCopy(r_refdef.vieworg, r_origin); Math_AngleVectors(r_refdef.viewangles, vpn, vright, vup); r_fovx = r_refdef.fov_x; r_fovy = r_refdef.fov_y; R_SetFrustum(r_fovx, r_fovy); Video_ClearBuffer(); }
void Point_SkyCameraSpawn(ServerEntity_t *entity) { if (Server.skycam) { Engine.Con_Warning("Multiple sky cameras on level! (%i %i %i)\n", (int)entity->v.origin[0], (int)entity->v.origin[1], (int)entity->v.origin[2]); return; } Math_VectorCopy(entity->v.origin, Server.skycam_position); // Enable skycam, which in turn will let us know to inform the client about it. Server.skycam = true; Entity_Remove(entity); }
void Select_FlipAxis (int axis) { int i; Select_GetMid (select_origin); for (i=0 ; i<3 ; i++) { Math_VectorCopy (vec3_origin, select_matrix[i]); select_matrix[i][i] = 1; } select_matrix[axis][axis] = -1; select_fliporder = TRUE; Select_AplyMatrix (); }
void C4Vizatergo_PrimaryAttack(ServerEntity_t *eOwner) { MathVector3f_t vOrigin; MathVector3f_t mvDirection; ServerEntity_t *c4ball = Entity_Spawn(); Sound(eOwner,CHAN_AUTO,"weapons/c4/c4fire.wav",255,ATTN_NORM); Sound(eOwner,CHAN_AUTO,"weapons/c4/c4cock.wav",255,ATTN_NORM); Weapon_Animate(eOwner,C4Animation_Fire1); Weapon_ViewPunch(eOwner, 7, true); eOwner->v.iPrimaryAmmo = eOwner->local.iC4Ammo -= 1; c4ball->v.cClassname = "c4ball"; c4ball->v.movetype = MOVETYPE_BOUNCE; c4ball->local.style = AMMO_C4BOMBS; // Cleaner way to tell if this can explode or not :V ~hogsy c4ball->local.iC4Ammo = 1; // [11/8/2013] Since style is used for other shit too LAWL ~hogsy c4ball->local.eOwner = eOwner; // Set the physical properties. c4ball->Physics.iSolid = SOLID_BBOX; c4ball->Physics.fMass = 0.9f; c4ball->Physics.eIgnore = eOwner; c4ball->Physics.fGravity = SERVER_GRAVITY; Math_MVToVector(Weapon_Aim(eOwner), mvDirection); Math_VectorScale(mvDirection, C4VIZATERGO_MAX_RANGE, c4ball->v.velocity); c4ball->v.velocity[pY] += 20.0f; Math_MVToVector(Math_VectorToAngles(c4ball->v.velocity),c4ball->v.angles); Math_VectorCopy(eOwner->v.origin,vOrigin); c4ball->v.TouchFunction = C4Vizatergo_C4BallTouch; c4ball->v.think = C4Vizatergo_Think; c4ball->v.dNextThink = Server.dTime + 2.5; Entity_SetModel(c4ball,"models/c4ammo.md2"); Entity_SetSizeVector(c4ball,g_mvOrigin3f,g_mvOrigin3f); Entity_SetOrigin(c4ball,vOrigin); if(eOwner->local.attackb_finished > Server.dTime) // No attack boost... eOwner->local.dAttackFinished = Server.dTime+0.6; else eOwner->local.dAttackFinished = Server.dTime+1.2; }
/* Itersects a ray with a brush Returns the face hit and the distance along the ray the intersection occured at Returns NULL and 0 if not hit at all */ face_t *Brush_Ray (vec3_t origin, vec3_t dir, brush_t *b, float *dist) { face_t *f, *firstface=NULL; vec3_t p1, p2; float frac, d1, d2; int i; Math_VectorCopy(origin,p1); for (i=0 ; i<3 ; i++) p2[i] = p1[i] + dir[i]*16384; for (f=b->brush_faces ; f ; f=f->next) { d1 = Math_DotProduct(p1,f->plane.normal)-f->plane.dist; d2 = Math_DotProduct(p2,f->plane.normal)-f->plane.dist; if (d1 >= 0 && d2 >= 0) { *dist = 0; return NULL; // ray is on front side of face } if (d1 <=0 && d2 <= 0) continue; // clip the ray to the plane frac = d1 / (d1 - d2); if (d1 > 0) { firstface = f; for (i=0 ; i<3 ; i++) p1[i] = p1[i] + frac *(p2[i] - p1[i]); } else { for (i=0 ; i<3 ; i++) p2[i] = p1[i] + frac *(p2[i] - p1[i]); } } // find distance p1 is along dir Math_VectorSubtract(p1,origin,p1); d1 = Math_DotProduct(p1,dir); *dist = d1; return firstface; }
void GreekfireTouch(ServerEntity_t *ent, ServerEntity_t *other) { vec3_t vel; if (other == ent->local.eOwner) return; if(other->v.bTakeDamage) Entity_Damage(other, ent, 50, 0); Math_VectorCopy(ent->v.velocity,vel); Math_VectorInverse(vel); Engine.Particle(ent->v.origin,vel,5,"spark",17); Math_VectorClear(ent->v.velocity); Entity_Remove(ent); }