示例#1
0
//-------------------------------------------------------------------------
// Called from the editor... does one instance of the object dialog box
//-------------------------------------------------------------------------
int do_object_dialog()
{
	char	Xmessage[MATT_LEN], Ymessage[MATT_LEN], Zmessage[MATT_LEN];
	dxxobject *obj=&Objects[Cur_object_index];
	object_dialog *o;

	if (obj->type == OBJ_ROBOT)		//don't do this for robots
		return 0;

	// Only open 1 instance of this window...
	if ( MattWindow != NULL )
		return 0;
	
	MALLOC(o, object_dialog, 1);
	if (!o)
		return 0;
	
	Cur_goody_count = 0;

	// Open a window with a quit button
	MattWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, (int (*)(UI_DIALOG *, d_event *, void *))object_dialog_handler, o );
	o->quitButton = ui_add_gadget_button( MattWindow, 20, 286, 40, 32, "Done", NULL );

	o->quitButton->hotkey = KEY_ENTER;

	// These are the radio buttons for each mode
	o->initialMode[0] = ui_add_gadget_radio( MattWindow, 10, 50, 16, 16, 0, "None" );
	o->initialMode[1] = ui_add_gadget_radio( MattWindow, 80, 50, 16, 16, 0, "Spinning" );

	o->initialMode[obj->movement_type == MT_SPINNING?1:0]->flag = 1;

	sprintf(Xmessage,"%.2f",f2fl(obj->mtype.spin_rate.x));
	sprintf(Ymessage,"%.2f",f2fl(obj->mtype.spin_rate.y));
	sprintf(Zmessage,"%.2f",f2fl(obj->mtype.spin_rate.z));

	o->xtext = ui_add_gadget_inputbox( MattWindow, 30, 132, MATT_LEN, MATT_LEN, Xmessage );

	o->ytext = ui_add_gadget_inputbox( MattWindow, 30, 162, MATT_LEN, MATT_LEN, Ymessage );

	o->ztext = ui_add_gadget_inputbox( MattWindow, 30, 192, MATT_LEN, MATT_LEN, Zmessage );

	ui_gadget_calc_keys(MattWindow);

	MattWindow->keyboard_focus_gadget = (UI_GADGET *) o->initialMode[0];

	return 1;

}
示例#2
0
文件: sphere.c 项目: paud/d2x-xl
void DrawShieldSphere (tObject *objP, float red, float green, float blue, float alpha)
{
if (!CreateShieldSphere ())
	return;
#if !SIMPLE_SPHERE
if (gameData.render.shield.nFaces > 0) 
#endif
	{
	if ((gameOpts->render.bDepthSort > 0) || (gameOpts->render.nPath && !gameOpts->render.bDepthSort))
		RIAddSphere (riSphereShield, red, green, blue, alpha, objP);
	else {
		tOOF_vector	p;
		fix nSize = gameData.models.polyModels [objP->rType.polyObjInfo.nModel].rad;
		float	fScale, r = f2fl (nSize) * 1.05f;
		tPosition *posP = OBJPOS (objP);
		vmsVector vPos;
		gameStates.ogl.bUseTransform = 1;
		G3StartInstanceMatrix (&posP->vPos, &posP->mOrient);
		RenderSphere (&gameData.render.shield, (tOOF_vector *) OOF_VecVms2Oof (&p, gameData.models.offsets + objP->rType.polyObjInfo.nModel),
						  r, r, r, red, green, blue, alpha, bmpShield, 1);
		G3DoneInstance ();
		gameStates.ogl.bUseTransform = 0;
		fScale = gameData.render.shield.pPulse->fScale;
		VmVecRotate (&vPos, gameData.models.offsets + objP->rType.polyObjInfo.nModel, ObjectView (objP));
		VmVecInc (&vPos, &posP->vPos);
		RenderObjectHalo (&vPos, 3 * nSize / 2, red * fScale, green * fScale, blue * fScale, alpha * fScale, 0);
		}
	}
}
示例#3
0
文件: sphere.cpp 项目: paud/d2x-xl
void DrawMonsterball (tObject *objP, float red, float green, float blue, float alpha)
{
#if !SIMPLE_SPHERE
    if (!gameData.render.monsterball.pSphere) {
        gameData.render.monsterball.nTessDepth = 3;
        gameData.render.monsterball.nFaces = CreateSphere (&gameData.render.monsterball);
    }
    if (gameData.render.monsterball.nFaces > 0)
#endif
    {
        if ((gameOpts->render.bDepthSort > 0) || (gameOpts->render.nPath && !gameOpts->render.bDepthSort))
            RIAddSphere (riMonsterball, red, green, blue, alpha, objP);
        else {
            static tOOF_vector p = {0,0,0};
            float r = f2fl (objP->size);
            gameStates.ogl.bUseTransform = 1;
            OglSetupTransform (0);
            G3StartInstanceMatrix (&objP->position.vPos, &objP->position.mOrient);
            RenderSphere (&gameData.render.monsterball, &p,
                          r, r, r, red, green, blue, gameData.hoard.monsterball.bm.bmTexBuf ? 1.0f : alpha,
                          &gameData.hoard.monsterball.bm, 4);
            G3DoneInstance ();
            OglResetTransform (1);
            gameStates.ogl.bUseTransform = 0;
        }
    }
}
示例#4
0
文件: glare.c 项目: paud/d2x-xl
float ComputeCoronaSprite (fVector *sprite, fVector *vCenter, short nSegment, short nSide)
{
	tSide		*sideP = gameData.segs.segments [nSegment].sides + nSide;
	short		sideVerts [4];
	int		i;
	float		fLight = 0;
	fVector	v;

GetSideVertIndex (sideVerts, nSegment, nSide);
for (i = 0; i < 4; i++) {
	fLight += f2fl (sideP->uvls [i].l);
	if (gameOpts->render.nPath)
		G3TransformPointf (sprite + i, gameData.segs.fVertices + sideVerts [i], 0);
	else
		sprite [i] = gameData.segs.fVertices [sideVerts [i]];	//already transformed
	}
VmVecFixToFloat (&v, SIDE_CENTER_I (nSegment, nSide));
G3TransformPointf (vCenter, &v, 0);
#if 0
if (gameStates.render.bQueryCoronas) {
	for (i = 0; i < 4; i++) {
		VmVecSubf (&v, sprite + i, vCenter);
		VmVecScaleAddf (sprite + i, vCenter, &v, 0.5f);
		}
}
#endif
return fLight;
}
示例#5
0
//	direction = -1 or 1 depending on direction
int	TexStretchCommon(int direction)
{
	fix	*sptr;

	if ((Curedge == 0) || (Curedge == 2))
		sptr = &Stretch_scale_x;
	else
		sptr = &Stretch_scale_y;

	*sptr += direction*F1_0/64;

	if (*sptr < F1_0/16)
		*sptr = F1_0/16;

	if (*sptr > 2*F1_0)
		*sptr = 2*F1_0;

	stretch_uvs_from_curedge(Cursegp, Curside);

	editor_status("Stretch scale = %7.4f, use Set Default to return to 1.0", f2fl(*sptr));

	Update_flags |= UF_GAME_VIEW_CHANGED;
	return	1;

}
示例#6
0
void HudGaugeRadarOrb::drawContactHtl(vec3d *pnt, int rad)
{
    vec3d p;

    p=*pnt;

    vm_vec_normalize(&p);

    float size = fl_sqrt(vm_vec_dist(&Orb_eye_position, pnt) * 8.0f);
    if (size < i2fl(rad))	size = i2fl(rad);

    if (rad == Radar_blip_radius_target)
    {
        if (radar_target_id_flags & RTIF_PULSATE) {
            // use mask to make the darn thing work faster
            size *= 1.3f + (sinf(10 * f2fl(Missiontime)) * 0.3f);
        }
        if (radar_target_id_flags & RTIF_BLINK) {
            if (Missiontime & 8192)
                return;
        }
        g3_render_sphere(pnt,size/100.0f);
    }
    else
    {
        g3_render_sphere(pnt,size/300.0f);
    }

    //g3_draw_htl_line(&p,pnt);
    g3_render_line_3d(false, &p, pnt);
}
示例#7
0
void gr_print_timestamp(int x, int y, fix timestamp)
{
	char h[2], m[3], s[3];
	int w, c;

	int time = (int)f2fl(timestamp);  // convert to seconds

	// format the time information into strings
	sprintf(h, "%.1d", (time / 3600));
	sprintf(m, "%.2d", (time / 60) % 60);
	sprintf(s, "%.2d", time % 60);

	gr_get_string_size(&w, NULL, "0");
	gr_get_string_size(&c, NULL, ":");

	gr_string(x + w, y, ":");
	gr_string(x + w * 3 + c, y, ":");

	x += w / 2;
	gr_char_centered(x, y, h[0]);
	x += w + c;
	gr_char_centered(x, y, m[0]);
	x += w;
	gr_char_centered(x, y, m[1]);
	x += w + c;
	gr_char_centered(x, y, s[0]);
	x += w;
	gr_char_centered(x, y, s[1]);
}
示例#8
0
//-------------------------------------------------------------------------
// Called from the editor... does one instance of the object dialog box
//-------------------------------------------------------------------------
int do_object_dialog()
{
	char	Xmessage[MATT_LEN], Ymessage[MATT_LEN], Zmessage[MATT_LEN];
	object *obj=&Objects[Cur_object_index];

	if (obj->type == OBJ_ROBOT)		//don't do this for robots
		return 0;

	// Only open 1 instance of this window...
	if ( MattWindow != NULL )
		return 0;
	
	Cur_goody_count = 0;

	// Open a window with a quit button
	MattWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
	QuitButton = ui_add_gadget_button( MattWindow, 20, 286, 40, 32, "Done", NULL );

	QuitButton->hotkey = KEY_ENTER;

	// These are the radio buttons for each mode
	InitialMode[0] = ui_add_gadget_radio( MattWindow, 10, 50, 16, 16, 0, "None" );
	InitialMode[1] = ui_add_gadget_radio( MattWindow, 80, 50, 16, 16, 0, "Spinning" );

	InitialMode[obj->movement_type == MT_SPINNING?1:0]->flag = 1;

	sprintf(Xmessage,"%.2f",f2fl(obj->mtype.spin_rate.x));
	sprintf(Ymessage,"%.2f",f2fl(obj->mtype.spin_rate.y));
	sprintf(Zmessage,"%.2f",f2fl(obj->mtype.spin_rate.z));

	ui_wprintf_at( MattWindow, 10, 132,"&X:" );
	Xtext = ui_add_gadget_inputbox( MattWindow, 30, 132, MATT_LEN, MATT_LEN, Xmessage );

	ui_wprintf_at( MattWindow, 10, 162,"&Y:" );
	Ytext = ui_add_gadget_inputbox( MattWindow, 30, 162, MATT_LEN, MATT_LEN, Ymessage );

	ui_wprintf_at( MattWindow, 10, 192,"&Z:" );
	Ztext = ui_add_gadget_inputbox( MattWindow, 30, 192, MATT_LEN, MATT_LEN, Zmessage );

	ui_gadget_calc_keys(MattWindow);

	MattWindow->keyboard_focus_gadget = (UI_GADGET *) InitialMode[0];

	return 1;

}
示例#9
0
void garage_tweak_ship()
{
	int r;
	newmenu_item m[20];
	char mass[10],drag[10];
	char low_thrust[10],high_thrust[10],reverse_thrust[10];
	char rot_speed[10];		//arbitary units

	sprintf( mass, "%.1f", f2fl(Player_ship->mass) );
	sprintf( drag, "%.1f", f2fl(Player_ship->drag) );
	sprintf( low_thrust, "%.1f", f2fl(Player_ship->low_thrust) );
	sprintf( high_thrust, "%.1f", f2fl(Player_ship->high_thrust) );
	sprintf( reverse_thrust, "%.1f", f2fl(Player_ship->reverse_thrust) );
	sprintf( rot_speed, "%d", Player_ship->rot_speed );
	
	m[0].type=NM_TYPE_TEXT; m[0].text = "Mass (Default:4.0)"; 
	m[1].type=NM_TYPE_INPUT; m[1].text = mass; m[1].text_len = 10;

	m[2].type=NM_TYPE_TEXT; m[2].text = "Drag (Default:2.0)"; 
	m[3].type=NM_TYPE_INPUT; m[3].text = drag; m[3].text_len = 10;

	m[4].type=NM_TYPE_TEXT; m[4].text = "Low thrust (Default:200.0)"; 
	m[5].type=NM_TYPE_INPUT; m[5].text = low_thrust; m[5].text_len = 10;

	m[6].type=NM_TYPE_TEXT; m[6].text = "High thrust (Default:500.0)"; 
	m[7].type=NM_TYPE_INPUT; m[7].text = high_thrust; m[7].text_len = 10;

	m[8].type=NM_TYPE_TEXT; m[8].text = "Reverse thrust (Default:300.0)"; 
	m[9].type=NM_TYPE_INPUT; m[9].text = reverse_thrust; m[9].text_len = 10;

	m[10].type=NM_TYPE_TEXT; m[10].text = "Rotation speed (Default:20)"; 
	m[11].type=NM_TYPE_INPUT; m[11].text = rot_speed; m[11].text_len = 10;

	r = newmenu_do( "Garage", NULL, 12, m, NULL );

	if ( r < 0 ) return;

	Player_ship->mass = fl2f(atof(mass));
	Player_ship->drag = fl2f(atof(drag));
	Player_ship->low_thrust = fl2f(atof(low_thrust));
	Player_ship->high_thrust = fl2f(atof(high_thrust));
	Player_ship->reverse_thrust = fl2f(atof(reverse_thrust));
	Player_ship->rot_speed = (int)atof(rot_speed);

}
示例#10
0
文件: digiobj.cpp 项目: paud/d2x-xl
void DigiGetSoundLoc (
	vmsMatrix *mListener, vmsVector *vListenerPos, short nListenerSeg, vmsVector *vSoundPos, 
	short nSoundSeg, fix maxVolume, int *volume, int *pan, fix maxDistance, int nDecay)
{	  
	vmsVector	vecToSound;
	fix 			angleFromEar, cosang, sinang;
	fix			distance, pathDistance;
	float			fDecay;

*volume = 0;
*pan = 0;
if (nDecay)
	maxDistance *= 2;
else
	maxDistance = (5 * maxDistance) / 4;	// Make all sounds travel 1.25 times as far.
distance = VmVecNormalizedDir (&vecToSound, vSoundPos, vListenerPos);
if (distance < maxDistance) {
	int nSearchSegs = f2i (maxDistance / 10);
	if (nSearchSegs < 1)
		nSearchSegs = 1;
	pathDistance = FindConnectedDistance (vListenerPos, nListenerSeg, vSoundPos, nSoundSeg, nSearchSegs, WID_RENDPAST_FLAG | WID_FLY_FLAG, 0);
	if (pathDistance > -1) {
		if (!nDecay) 
			*volume = maxVolume - FixDiv (pathDistance, maxDistance);
		else if (nDecay == 1) { 
			fDecay = (float) exp (-log (2.0f) * 4.0f * f2fl (pathDistance) / f2fl (maxDistance / 2));
			*volume = (int) (maxVolume * fDecay);
			}
		else {
			fDecay = 1.0f - f2fl (pathDistance) / f2fl (maxDistance);
			*volume = (int) (maxVolume * fDecay * fDecay * fDecay);
			}

		if (*volume <= 0) 
			*volume = 0;
		else {
			angleFromEar = VmVecDeltaAngNorm (&mListener->rVec, &vecToSound, &mListener->uVec);
			FixSinCos (angleFromEar, &sinang, &cosang);
			if (gameConfig.bReverseChannels || gameOpts->sound.bHires) 
				cosang = -cosang;
			*pan = (cosang + F1_0) / 2;
			}
		}
	}																					  
}
示例#11
0
/**
 * Stores profile data in in the profile history lookup. This is used internally by the profiling code and should
 * not be called outside of it.
 * @param name The globally unique name for this profile (see profile_begin()/profile_end())
 * @param percent How much time the profiled section took to execute (as a percentage of overall frametime)
 */
void store_profile_in_history(SCP_string &name, float percent, uint64_t time)
{
    float old_ratio;
    float new_ratio = 0.8f * f2fl(Frametime);

    if(new_ratio > 1.0f) {
        new_ratio = 1.0f;
    }

    old_ratio = 1.0f - new_ratio;

    for(int i = 0; i < (int)history.size(); i++) {
        if( history[i].valid && history[i].name == name ) {
            // found the sample
            history[i].avg = (history[i].avg * old_ratio) + (percent * new_ratio);
            history[i].avg_micro_sec = fl2i((history[i].avg_micro_sec * old_ratio) + (time * new_ratio));

            if( percent < history[i].min ) {
                history[i].min = percent;
            } else {
                history[i].min = (history[i].min*old_ratio) + (percent*new_ratio);
            }

            if( time < history[i].min_micro_sec ) {
                history[i].min_micro_sec = time;
            } else {
                history[i].min_micro_sec = fl2i((history[i].min_micro_sec*old_ratio) + (time*new_ratio));
            }

            if( percent > history[i].max) {
                history[i].max = percent;
            } else {
                history[i].max = (history[i].max * old_ratio) + (percent * new_ratio);
            }

            if( time > history[i].max_micro_sec) {
                history[i].max_micro_sec = time;
            } else {
                history[i].max_micro_sec = fl2i((history[i].max_micro_sec * old_ratio) + (time * new_ratio));
            }

            return;
        }
    }

    // add to history
    profile_sample_history new_history;

    new_history.name = name;
    new_history.valid = true;
    new_history.avg = new_history.min = new_history.max = percent;
    new_history.avg_micro_sec = new_history.min_micro_sec = new_history.max_micro_sec = time;

    history.push_back(new_history);
}
示例#12
0
// evaluate a pong return on the given struct
void multi_ping_eval_pong(ping_struct* ps)
{
	int idx;
	float ping_sum;

	// if the ping technically hasn't started,
	if (ps->ping_start < 0.0f)
	{
		nprintf(("Network", "Processing pong for ping which hasn't started yet!\n"));
		return;
	}

	// if we still have room to add a ping
	if (ps->num_pings < MAX_PINGS)
	{
		ps->ping_times[ps->ping_add++] = f2fl(timer_get_fixed_seconds()) - ps->ping_start;
		ps->num_pings++;
	}
		// otherwise if we've wrapped around
	else
	{
		// increment the place to add the ping time
		if (ps->ping_add >= MAX_PINGS - 1)
		{
			ps->ping_add = 0;
		}
		else
		{
			ps->ping_add++;
		}

		ps->ping_times[ps->ping_add] = f2fl(timer_get_fixed_seconds()) - ps->ping_start;
	}

	// calculate the average ping time
	ping_sum = 0.0f;
	for (idx = 0; idx < ps->num_pings; idx++)
	{
		ping_sum += ps->ping_times[idx];
	}
	ps->ping_avg = (int)(1000.0f * (ping_sum / (float)ps->num_pings));
}
示例#13
0
int get_centered_x_scaled(char *s, fix scale_x)
{
	int w,w2,s2;
	
	for (w=0;*s!=0 && *s!='\n';s++) {
		get_char_width(s[0],s[1],&w2,&s2);
		w += s2;
	}
	
	return ((grd_curcanv->cv_bitmap.bm_w - w * f2fl(scale_x)) / 2);
}
示例#14
0
文件: digi.c 项目: Ringdingcoder/d1x
int D1vol2DSvol(fix d1v){
//multiplying by 1.5 doesn't help.  DirectSound uses dB for volume, rather than a linear scale like d1 wants.
//I had to pull out a math book, but here is the code to fix it :)  -Matt Mueller
//log x=y  <==>  x=a^y  
//   a
	 if (d1v<=0)
		 return -10000;
	 else
//		 return log2(f2fl(d1v))*1000;//no log2? hm.
		 return (int) (log(f2fl(d1v))/log(2)*1000.0);
}
示例#15
0
文件: objsmoke.cpp 项目: paud/d2x-xl
void DoRobotSmoke (tObject *objP)
{
	int			h = -1, i, nShields = 0, nParts;
	float			nScale;
	vmsVector	pos;

i = OBJ_IDX (objP);
if (!(SHOW_SMOKE && gameOpts->render.smoke.bRobots)) {
	if (gameData.smoke.objects [i] >= 0)
		KillObjectSmoke (i);
	return;
	}
if ((objP->shields < 0) || (objP->flags & (OF_SHOULD_BE_DEAD | OF_DESTROYED)))
	nParts = 0;
else {
	nShields = f2ir (RobotDefaultShields (objP));
	h = f2ir (objP->shields) * 100 / nShields;
	}
if (h < 0)
	return;
nParts = 10 - h / 5;
if (nParts > 0) {
	if (nShields > 4000)
		nShields = 4000;
	else if (nShields < 1000)
		nShields = 1000;
	CreateDamageExplosion (nParts, i);
	//nParts *= nShields / 10;
	nParts = BOT_MAX_PARTS;
	nScale = (float) sqrt (8.0 / f2fl (objP->size));
	nScale *= 1.0f + h / 25.0f;
	if (!gameOpts->render.smoke.bSyncSizes) {
		nParts = -MAX_PARTICLES (nParts, gameOpts->render.smoke.nDens [2]);
		nScale = PARTICLE_SIZE (gameOpts->render.smoke.nSize [2], nScale);
		}
	if (gameData.smoke.objects [i] < 0) {
		//PrintLog ("creating robot %d smoke\n", i);
		SetSmokeObject (i, CreateSmoke (&objP->position.vPos, NULL, NULL, objP->nSegment, 1, nParts, nScale,
												  gameOpts->render.smoke.bSyncSizes ? -1 : gameOpts->render.smoke.nSize [2],
												  1, BOT_PART_LIFE, BOT_PART_SPEED, 0, i, NULL, 1, -1));
		}
	else {
		SetSmokePartScale (gameData.smoke.objects [i], nScale);
		SetSmokeDensity (gameData.smoke.objects [i], nParts, gameOpts->render.smoke.bSyncSizes ? -1 : gameOpts->render.smoke.nSize [2]);
		SetSmokeSpeed (gameData.smoke.objects [i], 
							(objP->mType.physInfo.velocity.p.x || objP->mType.physInfo.velocity.p.y || objP->mType.physInfo.velocity.p.z) ?
							BOT_PART_SPEED : BOT_PART_SPEED * 2 / 3);
		}
	VmVecScaleAdd (&pos, &objP->position.vPos, &objP->position.mOrient.fVec, -objP->size / 2);
	SetSmokePos (gameData.smoke.objects [i], &pos, NULL, objP->nSegment);
	}
else 
	KillObjectSmoke (i);
}
示例#16
0
文件: draw.c 项目: paud/d2x-xl
//draw a sortof sphere - i.e., the 2d radius is proportional to the 3d
//radius, but not to the distance from the eye
int G3DrawSphere (g3sPoint *pnt, fix rad)
{
	if (! (pnt->p3_codes & CC_BEHIND)) {

		if (! (pnt->p3Flags & PF_PROJECTED))
			G3ProjectPoint (pnt);

		if (! (pnt->p3_codes & PF_OVERFLOW)) {
			fix r2, t;

			r2 = FixMul (rad, viewInfo.scale.x);
#ifndef __powerc
			if (CheckMulDiv (&t, r2, xCanvW2, pnt->p3_z))
				return gr_disk (pnt->p3_sx, pnt->p3_sy, t);
#else
			if (pnt->p3_z == 0)
				return 0;
			return gr_disk (pnt->p3_sx, pnt->p3_sy, fl2f (( (f2fl (r2) * fxCanvW2) / f2fl (pnt->p3_z)));
#endif
		}
	}
// backout the score for a mission.  This function gets called when the player chooses to refly a misison
// after debriefing
void scoring_backout_accept( scoring_struct *score )
{
	int idx;

	// if a badge was earned, take it back
	if ( score->m_badge_earned.size() ){
		for (size_t medal = 0; medal < score->m_badge_earned.size(); medal++) {
			score->medal_counts[score->m_badge_earned[medal]] = 0;
		}
	}

	// return when in training mission.  We can grant a medal in training, but don't
	// want to calculate any other statistics.
	if (The_mission.game_type == MISSION_TYPE_TRAINING){
		return;
	}

	score->kill_count -= score->m_kill_count;
	score->kill_count_ok -= score->m_kill_count_ok;

	score->score -= score->m_score;
	score->assists -= score->m_assists;
	score->p_shots_fired -= score->mp_shots_fired;
	score->s_shots_fired -= score->ms_shots_fired;

	score->p_shots_hit -= score->mp_shots_hit;
	score->s_shots_hit -= score->ms_shots_hit;

	score->p_bonehead_hits -= score->mp_bonehead_hits;
	score->s_bonehead_hits -= score->ms_bonehead_hits;
	score->bonehead_kills -= score->m_bonehead_kills;

	for(idx=0;idx<MAX_SHIP_CLASSES;idx++){
		score->kills[idx] = (unsigned short)(score->kills[idx] - score->m_okKills[idx]);
	}

	// if the player was given a medal, take it back
	if ( score->m_medal_earned != -1 ) {
		score->medal_counts[score->m_medal_earned]--;
		Assert( score->medal_counts[score->m_medal_earned] >= 0 );
	}

	// if the player was promoted, take it back
	if ( score->m_promotion_earned != -1) {
		score->rank--;
		Assert( score->rank >= 0 );
	}	

	score->flight_time -= (unsigned int)f2fl(Missiontime);
	score->last_flown = score->last_backup;	
	score->missions_flown--;
}
示例#18
0
文件: sphere.c 项目: paud/d2x-xl
void DrawMonsterball (tObject *objP, float red, float green, float blue, float alpha)
{
if (!gameData.render.monsterball.pSphere) {
	gameData.render.monsterball.nTessDepth = 3;
	gameData.render.monsterball.nFaces = CreateSphere (&gameData.render.monsterball);
	}
if (gameData.render.monsterball.nFaces > 0) {
	tOOF_vector	p;
	G3StartInstanceMatrix (&objP->pos, &objP->orient);
	RenderSphere (&gameData.render.monsterball, (tOOF_vector *) OOF_VecVms2Oof (&p, &objP->pos), 
					  f2fl (objP->size), red, green, blue, alpha, &gameData.hoard.monsterball.bm);
	G3DoneInstance ();
	}
}
示例#19
0
void scores_rprintf(int x, int y, unsigned char * format, ...)
{
	va_list args;
	unsigned char buffer[128];
	int w, h, aw;
	unsigned char *p;

	x *= f2fl(Scale_x);
	y *= f2fl(Scale_y);

	va_start(args, format);
	vsprintf(buffer, format, args);
	va_end(args);

	//replace the digit '1' with special wider 1
	for (p = buffer; *p; p++)
		if (*p == '1') *p = 132;

	gr_get_string_size(buffer, &w, &h, &aw);
	w *= f2fl(Scale_factor);

	gr_scale_string(x - w, y, Scale_factor, Scale_factor, buffer);
}
示例#20
0
文件: draw.c 项目: jihnsius/d2r
//draw a sortof sphere - i.e., the 2d radius is proportional to the 3d
//radius, but not to the distance from the eye
int g3_draw_sphere(g3s_point *pnt,fix rad)
{
	if (! (pnt->p3_codes & CC_BEHIND)) {

		if (! (pnt->p3_flags & PF_PROJECTED))
			g3_project_point(pnt);

		if (! (pnt->p3_codes & PF_OVERFLOW)) {
			fix r2,t;

			r2 = fixmul(rad,Matrix_scale.x);
#ifndef __powerc
			if (checkmuldiv(&t,r2,Canv_w2,pnt->p3_z))
				return gr_disk(pnt->p3_sx,pnt->p3_sy,t);
#else
			if (pnt->p3_z == 0)
				return 0;
			return gr_disk(pnt->p3_sx, pnt->p3_sy, fl2f(((f2fl(r2) * fCanv_w2) / f2fl(pnt->p3_z))));
#endif
		}
	}

	return 0;
}
示例#21
0
文件: sphere.c 项目: paud/d2x-xl
void DrawObjectSphere (object *objP, float red, float green, float blue, float alpha)
{
    if (gameData.render.sphere.nTessDepth != gameOpts->render.textures.nQuality + 2) {
        if (gameData.render.sphere.pSphere)
            DestroySphere ();
        gameData.render.sphere.nTessDepth = gameOpts->render.textures.nQuality + 2;
    }
    if (!gameData.render.sphere.pSphere)
        gameData.render.sphere.nFaces = CreateSphere (&gameData.render.sphere.pSphere);
    if (gameData.render.sphere.nFaces > 0) {
        tOOF_vector	p;
        RenderSphere ((tOOF_vector *) OOF_VecVms2Oof (&p, &objP->pos), gameData.render.sphere.pSphere,
                      gameData.render.sphere.nFaces, f2fl (objP->size) * 1.1f,
                      red, green, blue, alpha);
    }
}
// central point for dealing with accepting the score for a misison.
void scoring_do_accept(scoring_struct *score)
{
	int idx;

	// do rank, badges, and medals first since they require the alltime stuff
	// to not be updated yet.	

	// do medal stuff
	if ( score->m_medal_earned != -1 ){
		score->medal_counts[score->m_medal_earned]++;
	}

	// return when in training mission.  We can grant a medal in training, but don't
	// want to calculate any other statistics.
	if (The_mission.game_type == MISSION_TYPE_TRAINING){
		return;
	}	

	scoring_eval_rank(score);
	scoring_eval_badges(score);

	score->kill_count += score->m_kill_count;
	score->kill_count_ok += score->m_kill_count_ok;

	score->score += score->m_score;
	score->assists += score->m_assists;
	score->p_shots_fired += score->mp_shots_fired;
	score->s_shots_fired += score->ms_shots_fired;

	score->p_shots_hit += score->mp_shots_hit;
	score->s_shots_hit += score->ms_shots_hit;

	score->p_bonehead_hits += score->mp_bonehead_hits;
	score->s_bonehead_hits += score->ms_bonehead_hits;
	score->bonehead_kills += score->m_bonehead_kills;

	for(idx=0;idx<MAX_SHIP_CLASSES;idx++){
		score->kills[idx] = (int)(score->kills[idx] + score->m_okKills[idx]);
	}

	// add in mission time
	score->flight_time += (unsigned int)f2fl(Missiontime);
	score->last_backup = score->last_flown;
	score->last_flown = (_fs_time_t)time(NULL);
	score->missions_flown++;
}
示例#23
0
//	blob_vertices has 3 vertices in it, 4th must be computed
void draw_blob_outline(void)
{
	fix	v3x, v3y;

	v3x = blob_vertices[4] - blob_vertices[2] + blob_vertices[0];
	v3y = blob_vertices[5] - blob_vertices[3] + blob_vertices[1];

	gr_setcolor(BM_XRGB(63, 63, 63));

	mprintf((0, "[%7.3f %7.3f]  [%7.3f %7.3f]  [%7.3f %7.3f]\n", f2fl(blob_vertices[0]), f2fl(blob_vertices[1]), f2fl(blob_vertices[2]), f2fl(blob_vertices[3]), f2fl(blob_vertices[4]), f2fl(blob_vertices[5]) ));

	gr_line(blob_vertices[0], blob_vertices[1], blob_vertices[2], blob_vertices[3]);
	gr_line(blob_vertices[2], blob_vertices[3], blob_vertices[4], blob_vertices[5]);
	gr_line(blob_vertices[4], blob_vertices[5], v3x, v3y);

	gr_line(v3x, v3y, blob_vertices[0], blob_vertices[1]);
}
示例#24
0
文件: sphere.c 项目: paud/d2x-xl
void DrawShieldSphere (tObject *objP, float red, float green, float blue, float alpha)
{
if (gameData.render.shield.nTessDepth != gameOpts->render.textures.nQuality + 2) {
	if (gameData.render.shield.pSphere)
		DestroySphere (&gameData.render.shield);
	gameData.render.shield.nTessDepth = gameOpts->render.textures.nQuality + 2;
	}
if (!gameData.render.shield.pSphere)
	gameData.render.shield.nFaces = CreateSphere (&gameData.render.shield);
if (gameData.render.shield.nFaces > 0) {
	tOOF_vector	p;
	G3StartInstanceMatrix (&objP->pos, &objP->orient);
	RenderSphere (&gameData.render.shield, (tOOF_vector *) OOF_VecVms2Oof (&p, &objP->pos),
					  f2fl (objP->size) * 1.1f, red, green, blue, alpha, NULL);
	G3DoneInstance ();
	}
}
示例#25
0
文件: physics.c 项目: paud/d2x-xl
void UnstickObject (tObject *objP)
{
	fvi_info			hi;
	fvi_query		fq;
	int				fate;
	short				nSegment;
	fix				xSideDist, xSideDists [6];

if ((objP->nType == OBJ_PLAYER) && 
	 (objP->id == gameData.multi.nLocalPlayer) && 
	 (gameStates.app.cheats.bPhysics == 0xBADA55))
	return;
fq.p0 = fq.p1 = &objP->pos;
fq.startSeg = objP->nSegment;
fq.rad = objP->size;
fq.thisObjNum = OBJ_IDX (objP);
fq.ignoreObjList = NULL;
fq.flags = 0;
fate = FindVectorIntersection (&fq, &hi);
if (fate != HIT_WALL)
	return;
GetSideDistsAll (&objP->pos, hi.hit.nSideSegment, xSideDists);
if ((xSideDist = xSideDists [hi.hit.nSide]) && (xSideDist < objP->size - objP->size / 100)) {
#if 1
	float r = 0.25f;
#else
	float r;
	xSideDist = objP->size - xSideDist;
	r = ((float) xSideDist / (float) objP->size) * f2fl (objP->size);
#endif
	objP->pos.x += (fix) ((float) hi.hit.vNormal.x * r);
	objP->pos.y += (fix) ((float) hi.hit.vNormal.y * r);
	objP->pos.z += (fix) ((float) hi.hit.vNormal.z * r);
	nSegment = FindSegByPoint (&objP->pos, objP->nSegment);
	if (nSegment != objP->nSegment)
		RelinkObject (OBJ_IDX (objP), nSegment);
#if 0//def _DEBUG
	if (objP->nType == OBJ_PLAYER)
		HUDMessage (0, "PENETRATING WALL (%d, %1.4f)", objP->size - xSideDists [nWallHitSide], r);
#endif
	}
}
示例#26
0
文件: objsmoke.cpp 项目: paud/d2x-xl
void DoMissileSmoke (tObject *objP)
{
	int				nParts, nSpeed, nLife, i;
	float				nScale = 1.5f;
	tThrusterInfo	ti;

i = OBJ_IDX (objP);
if (!(SHOW_SMOKE && gameOpts->render.smoke.bMissiles)) {
	if (gameData.smoke.objects [i] >= 0)
		KillObjectSmoke (i);
	return;
	}
if ((objP->shields < 0) || (objP->flags & (OF_SHOULD_BE_DEAD | OF_DESTROYED)))
	nParts = 0;
else {
	nSpeed = WI_speed (objP->id, gameStates.app.nDifficultyLevel);
	nLife = gameOpts->render.smoke.nLife [3] + 1;
#if 1
	nParts = (int) (MSL_MAX_PARTS * f2fl (nSpeed) / (40.0f * (4 - nLife)));
#else
	nParts = (objP->id == EARTHSHAKER_ID) ? 1500 : 
				(objP->id == MEGAMSL_ID) ? 1400 : 
				(objP->id == SMARTMSL_ID) ? 1300 : 
				1200;
#endif
	}
if (nParts) {
	if (gameData.smoke.objects [i] < 0) {
		if (!gameOpts->render.smoke.bSyncSizes) {
			nParts = -MAX_PARTICLES (nParts, gameOpts->render.smoke.nDens [3]);
			nScale = PARTICLE_SIZE (gameOpts->render.smoke.nSize [3], nScale);
			}
		SetSmokeObject (i, CreateSmoke (&objP->position.vPos, NULL, NULL, objP->nSegment, 1, nParts, nScale,
												  gameOpts->render.smoke.bSyncSizes ? -1 : gameOpts->render.smoke.nSize [3],
												  1, nLife * MSL_PART_LIFE, MSL_PART_SPEED, 1, i, NULL, 1, -1));
		}
	CalcThrusterPos (objP, &ti, 0);
	SetSmokePos (gameData.smoke.objects [i], ti.vPos, NULL, objP->nSegment);
	}
else 
	KillObjectSmoke (i);
}
示例#27
0
void multi_pause_close(int end_mission)
{
	if ( !Multi_paused )
		return;

	// set the standalonest
	if (Game_mode & GM_STANDALONE_SERVER) {
		std_debug_set_standalone_state_string("Game play");
	} else {
		// free the screen up
		if ( end_mission && (Multi_paused_screen_id >= 0) ) {
			gr_free_screen(Multi_paused_screen_id);
			Multi_paused_screen_id = -1;
		}

		if (Multi_paused_background >= 0) {
			bm_release(Multi_paused_background);
			Multi_paused_background = -1;
		}

		Multi_paused_window.destroy();		
		game_flush();

		// unpause all the music
		audiostream_unpause_all();	
	}

	// unpause beam weapon sounds
	weapon_unpause_sounds();

	// eat keys timestamp
	Multi_pause_eat = f2fl(timer_get_fixed_seconds());
	
	// reset timestamps
	multi_reset_timestamps();

	// clear out control config and keypress info
	control_config_clear_used_status();
	key_flush();

	Multi_paused = 0;
}
示例#28
0
文件: sphere.c 项目: paud/d2x-xl
void DrawMonsterball (tObject *objP, float red, float green, float blue, float alpha)
{
if (!gameData.render.monsterball.pSphere) {
	gameData.render.monsterball.nTessDepth = 3;
	gameData.render.monsterball.nFaces = CreateSphere (&gameData.render.monsterball);
	}
if (gameData.render.monsterball.nFaces > 0) {
	if ((gameOpts->render.bDepthSort > 0) || (gameOpts->render.nPath && !gameOpts->render.bDepthSort))
		RIAddSphere (riMonsterball, red, green, blue, alpha, objP);
	else {
		tOOF_vector	p;
		float r = f2fl (objP->size);
		G3StartInstanceMatrix (&objP->position.vPos, &objP->position.mOrient);
		RenderSphere (&gameData.render.monsterball, (tOOF_vector *) OOF_VecVms2Oof (&p, &objP->position.vPos), 
						  r, r, r, red, green, blue, gameData.hoard.monsterball.bm.bmTexBuf ? 1.0f : alpha, 
						  &gameData.hoard.monsterball.bm, 4);
		G3DoneInstance ();
		}
	}
}
示例#29
0
文件: interp.c 项目: paud/d2x-xl
void GetThrusterPos (int nModel, vmsVector *vNormal, vmsVector *vOffset, grsBitmap *bmP, int nPoints)
{
	int					h, i, nSize;
	vmsVector			v, vForward = {{0,0,F1_0}};
	tModelThrusters	*mtP = gameData.models.thrusters + nModel;

if (mtP->nCount >= 2)
	return;
if (bmP) {
	i = (int) (bmP - gameData.pig.tex.bitmaps [0]);
	if ((i != 24) && ((i < 1741) || (i > 1745)))
		return;
	}
#if 1
if (VmVecDot (vNormal, &vForward) > -F1_0 / 3)
#else
if (vNormal->p.x || vNormal->p.y || (vNormal->p.z != -F1_0))
#endif
	return;
for (i = 1, v = pointList [0]->p3_src; i < nPoints; i++)
	VmVecInc (&v, &pointList [i]->p3_src);
v.p.x /= nPoints;
v.p.y /= nPoints;
v.p.z /= nPoints;
v.p.z -= F1_0 / 8;
if (vOffset)
	VmVecInc (&v, vOffset);
if (mtP->nCount && (v.p.x == mtP->vPos [0].p.x) && (v.p.y == mtP->vPos [0].p.y) && (v.p.z == mtP->vPos [0].p.z))
	return;
mtP->vPos [mtP->nCount] = v;
if (vOffset)
	VmVecDec (&v, vOffset);
mtP->vDir [mtP->nCount] = *vNormal;
VmVecNegate (mtP->vDir + mtP->nCount);
if (!mtP->nCount++) {
	for (i = 0, nSize = 0x7fffffff; i < nPoints; i++)
		if (nSize > (h = VmVecDist (&v, &pointList [i]->p3_src)))
			nSize = h;
	mtP->fSize = f2fl (nSize);// * 1.25f;
	}
}
示例#30
0
文件: fireball.c 项目: paud/d2x-xl
double ObjectVolume (tObject *objP)
{
	tPolyModel	*pm;
	int			i, j;
	double		size;

if (objP->renderType != RT_POLYOBJ)
	size = 4 * Pi * pow (f2fl (objP->size), 3) / 3;
else {
	size = 0;
	pm = gameData.models.polyModels + objP->rType.polyObjInfo.nModel;
	if ((i = objP->rType.polyObjInfo.nSubObjFlags)) {
		for (j = 0; i && (j < pm->nModels); i >>= 1, j++)
			if (i & 1)
				size += VectorVolume (pm->subModels.mins + j, pm->subModels.maxs + j);
		}
	else {
		for (j = 0; j < pm->nModels; j++)
			size += VectorVolume (pm->subModels.mins + j, pm->subModels.maxs + j);
		}
	}