Exemplo n.º 1
0
action trigger_visible ()
{
	VECTOR vecTemp;
	while(1)
	{
		vec_set(vecTemp, my.x);
		if (vec_to_screen(vecTemp, camera) != NULL) {
			switch(my.skill1)
			{
			case 0:
				snd_play(snd_narrator_start, 100, 0);
				break;
			case 1:
				snd_play(snd_narrator_sky, 100, 0);
				break;
			case 2:
				snd_play(snd_narrator_enemy, 100, 0);
				break;
			case 3:
				snd_play(snd_narrator_lottifant, 100, 0);
				break;
			}
			break;
		}
		wait(1);
	}
}
Exemplo n.º 2
0
int msg_mines (int n, int msg, int z) {		// space mines
	int sh, x, y;
	switch (msg) {
		case msg_update:
			objs[n].count = (objs[n].count + 1)&3; return (1);
		case msg_draw:
			sh = 0xf00 + 18 + objs[n].count/2;
			drawshape (&gamevp, sh, objs[n].x, objs[n].y); break;
		case msg_touch:
			switch (objs[z].kind) {
				case obj_player:
					if (class_cnt(class_shield)==0) {
						p_hit (2); snd_play (1,5);
						x = objs[n].x - 11; y = objs[n].y - 9;
						addobj (obj_explode3, x, y, 0, 0);
						explosion (objs[n].x, objs[n].y, 5);
						text ("You hit an enemy space mine!",0);
						killobj (n);
						}; break;
				case obj_shield:
					addobj (obj_explode2, objs[n].x, objs[n].y, 0, 0);
					explosion (objs[n].x, objs[n].y, 5);
					text ("Your shield was destroyed by a space mine",0);
					killobj (n); killobj (z); snd_play (1,5);
				};
		}; return (0);
	};
Exemplo n.º 3
0
void supernova_process()
{
	int sn_stage;

	// if the supernova is running
	sn_stage = supernova_active();
	if(sn_stage) {
		Supernova_time -= flFrametime;

		// sound stuff
		if((Supernova_time <= SUPERNOVA_SOUND_1_TIME) && !Supernova_sound_1_played) {
			Supernova_sound_1_played = 1;
			snd_play(&Snds[SND_SUPERNOVA_1], 0.0f, 1.0f, SND_PRIORITY_MUST_PLAY);
		}
		if((Supernova_time <= SUPERNOVA_SOUND_2_TIME) && !Supernova_sound_2_played) {
			Supernova_sound_2_played = 1;
			snd_play(&Snds[SND_SUPERNOVA_2], 0.0f, 1.0f, SND_PRIORITY_MUST_PLAY);
		}

		// if we've crossed from stage 1 to stage 2 kill all particles and stick a bunch on the player ship
		if((sn_stage == 1) && (supernova_active() == 2)) {
			// first kill all active particles so we have a bunch of free ones
			particle_kill_all();
		}

		// if we're in stage 2, emit particles
		if((sn_stage >= 2) && (sn_stage != 5)) {
			supernova_do_particles();
		}

		// if we've got negative. the supernova is done
		if(Supernova_time < 0.0f) {
			Supernova_finished = 1;
			Supernova_fade_to_white += flFrametime;

			// start the dead popup
			if(Supernova_fade_to_white >= SUPERNOVA_FADE_TO_WHITE_TIME) {
				if(!Supernova_popup) {
					// main freespace 2 campaign? if so - end it now
					//
					// don't actually check for a specific campaign here since others may want to end this way but we
					// should test positive here if in campaign mode and sexp_end_campaign() got called - taylor
					if (Campaign_ending_via_supernova && (Game_mode & GM_CAMPAIGN_MODE) /*&& !stricmp(Campaign.filename, "freespace2")*/) {
						gameseq_post_event(GS_EVENT_END_CAMPAIGN);
					} else {
						popupdead_start();
					}
					Supernova_popup = 1;
				}
				Supernova_finished = 2;
			}
		}
	}
}
Exemplo n.º 4
0
void ebHandsBgFly ()
{
	if (isEbWarghostAlive())
	{
		var handRadius = 500;
		
		snd_play(g_sndSparkle, 100, 0);

		ENTITY* hands [2];
		hands[0] = ent_create("warhand.mdl", vector(-handRadius, 500, 400), ebHandFlyL);
		hands[1] = ent_create("warhand.mdl", vector(handRadius, 500, 400), ebHandFlyR);	
	
		var t = maxv(g_facTimeEbHandsFlyMin, g_facTimeEbHandsFly * (5 + random(5))) * 16;
		
		snd_play(g_sndHandFlyBoth, 100, 0);
		
		while (t > 0)
		{
			t -= time_step;
			wait(1);
		}
		
		g_facTimeEbHandsFly *= g_facTimeEbHandsFlyDec;
		
		ebSndAttack();
		
		int i;
		var m = (1 + random(2)) * 16;
		for (i = 0; i < 2; i++)
		{
			(hands[i])->skill1 = 1;
			(hands[i])->skill2 = m;
		}
		
		while (m > 0)
		{
			m -= time_step;
			wait(1);
		}
		
		snd_play(g_sndSparkle, 100, 0);
		
		wait(-0.5);
		
		VECTOR v;
		vec_set(&v, player->x);
		v.z += 400;
		
		ent_create("warhand.mdl", &v, ebHandWatchSelect);
	}
	
	ptr_remove(my);
}
Exemplo n.º 5
0
int msg_shield (int n, int msg, int z) {
	int sh;
	switch (msg) {
		case msg_update:
			if (objs[n].count2 >= 240)
				objs[n].count = (objs[n].count + 1)&3;
			move_obj (n, objs[0].x-2, objs[0].y-2);
			if (++objs[n].count2==340) killobj (n); return (1);
		case msg_draw:
			sh = 0x804 + objs[n].count/2;
			drawshape (&gamevp, sh, objs[n].x, objs[n].y); break;
		case msg_touch:
			switch (objs[z].kind) {
				case obj_enemy1:
				case obj_enemy2:
				case obj_enemy3:
				case obj_enemy4:
				case obj_enemy5:
				case obj_enemy6:
				case obj_enemy7:
				case obj_enemy8:
				case obj_enemy9:
				case obj_enemya:
				case obj_enemyb:
				case obj_enemyc:
				case obj_enemyd:
				case obj_enemye:
				case obj_enemyf:
				case obj_enemyg:
				case obj_enemyh:
				case obj_enemyi:
				case obj_enemyj:
				case obj_enemyk:
					snd_play (1,7);
					if (objs[z].count3 < 1) {
						killobj (z);
						}
					else {
						objs[z].xd = -objs[z].xd;
						objs[z].yd = -objs[z].yd;
						}; break;
				case obj_bullet2:
				case obj_spinner:
				case obj_laser:
					snd_play (1,7);
					explosion (objs[z].x, objs[z].y, 5);
					killobj (z);
				};
		}; return (0);
	};
Exemplo n.º 6
0
action ebStartSpeech ()
{
	set(my, INVISIBLE | PASSABLE);
	
	// wait
	var t = 3 * 16;
	while (t > 0)
	{
		t -= time_step;
		wait(1);
	}
	
	if (g_ebSpeech)
	{
		g_ebSpeech = false;
		var h = snd_play(g_sndWarghostBattleSpeechStart, 100, 0);
		
		while (snd_playing(h))
			wait(1);
	}
	
	// switch warghost to model without hands
	if (g_entEbWarghost != NULL)
		ent_morph(g_entEbWarghost, "warghostChop.mdl");
		
	ent_create(NULL, nullvector, ebHandsBgFly);
	ptr_remove(my);
}
// Maybe play a directive success sound... need to poll since the sound is delayed from when
// the directive is actually satisfied.
void mission_maybe_play_directive_success_sound()
{
	if ( timestamp_elapsed(Mission_directive_sound_timestamp) ) {
		Mission_directive_sound_timestamp=0;
		snd_play( &Snds[SND_DIRECTIVE_COMPLETE] );
	}
}
Exemplo n.º 8
0
void playTaunt(int index)
{
   if (g_num_taunts[index] > 0)
         {
      int sndIndex = 0;

      if (g_num_taunts[index] > 1) {
         sndIndex = (int) random(g_num_taunts[index]);
      }

      if (g_tauntHandles[index] != 0) {
         snd_stop(g_tauntHandles[index]);
         g_tauntHandles[index] = 0;
      }

      SOUND** sndArr = g_taunts[index];
      if (sndArr != null) {

         SOUND* snd = sndArr[sndIndex];
         if (snd != null) {
            g_tauntHandles[index] = snd_play(snd, g_tauntVolume, 0);
         }
      }
   }
}
Exemplo n.º 9
0
/*--------------------------------------------------------------------------------*
| <<< パンチ >>>
*---------------------------------------------------------------------------------*/
void	cPlayer::Punch(void)
{
	for(int i = 0; i < PLAYER_PUNCH_MAX; i++)
	{//一回目 左
												//二回目 右
		//--- パンチを出す処理 -----------------------------------------
		//
		int	aiKey[] = {KEY_LCTRL, KEY_RCTRL};

		// ↓キー入力があり、			↓パンチしてなく、			↓防御してない時にパンチが打てる
		if(pad.bKeyClick[aiKey[i]] && m_afPunchTime[i] == 0 && m_fGuardTime == 0)
		{
			m_afPunchTime[i] = PUNCH_TIME;		// パンチ時間に値を入れたら開始
			snd_play(SND_PUNCH);
		}

		//--- パンチを戻す処理 ------------------------------------------
		VALUE_TO_TARGET(m_afPunchTime[i], 0, PUNCH_SPEED);
		//--- ダメージ計算 ----------------------------------------------
		if(m_afPunchTime[i] > 0)				// パンチのアニメーションを進める。PUNCH_TIME が 0 になるまで。
		{										// 20は速度(大きくすると速くなる)
			CalcEnemyDamage(i);					// ここでダメージ計算
		}
	}
}
Exemplo n.º 10
0
void gamesnd_play_iface(int n)
{
	if (Snds_iface_handle[n] >= 0)
		snd_stop(Snds_iface_handle[n]);

	Snds_iface_handle[n] = snd_play(&Snds_iface[n]);
}
Exemplo n.º 11
0
void raceintro_trigger(ENTITY* ent, SOUND* snd, void *callback)
{
	var i;
	ent.flags2 |= SHOW;
	
	ent->pan = -100;

	snd_play(snd, 100, 0);

	ent->material = mtl_unlit;
	ent->ambient = 200;

	var i = 0;
	for(i = 0; i < g_raceintro_ticks; i += time_step) {

	   vec_set(ent.x, vector(0.5 * screen_size.x, 0.5 * screen_size.y, g_raceintro_offset + i*g_raceintro_speed));
		rel_for_screen(ent.x, camera);

		ent->pan += 2 *time_step;

		ent.u = 10*total_ticks;
		ent.v = 10*total_ticks;

		wait(1);
	}
	
	ent.flags2 &= ~SHOW;
	
	if(callback != NULL) {
		void tmp();
		tmp = callback;
		tmp();
	}
}
Exemplo n.º 12
0
void doChopped (ENTITY* entHand, int lr, int fingerId)
{
	ENTITY* entFinger = ent_create(entHand->type, entHand->x, flyawaychoppedhand);
	
	entFinger->skill20 = lr;
	
	vec_set(entFinger->scale_x, entHand->scale_x);
	
	entFinger->frame = entHand->frame;
	entFinger->next_frame = entHand->next_frame;
	
	if (lr == 1)
		entFinger->material = g_mtlHandL;
	else
		entFinger->material = g_mtlHandR;
		
	entFinger->skill1 = fingerId;
	
	BOOL* arr = NULL;
	
	if (lr == 1) // left
		arr = g_handChopL;
	else // right
		arr = g_handChopR;
		
	int i;
	for (i = 0; i <= 5; i++)
		entFinger->vmask |= 1 << i;
	
	entFinger->vmask &= ~(1 << (4 - fingerId));
	
	snd_play(g_sndFingerChop, 100, 0);
}
Exemplo n.º 13
0
Arquivo: ui.c Projeto: evegard/tdt4258
void ui_state_title(void)
{
    int x = 0, y = 0, dx = 1, dy = 1, w = 20, h = 20, i = 0;

    snd_play("sounds/intro-valkyrie.raw");

    while (1) {
        image_draw(0, 0, img_bg);
        image_draw(x, y, img_soldier);
        screen_show_buffer();

        if (y + h == SCREEN_HEIGHT && dy == 1) dy = -1;
        if (y == 0 && dy == -1) dy = 1;
        if (x + w == SCREEN_WIDTH && dx == 1) dx = -1;
        if (x == 0 && dx == -1) dx = 1;
        x += dx; y += dy;

        led_setup = (i++ / 10) % 2 ? 0xaa : 0x55;
        led_update();

        if ((btn_ignore = btn_read()) > 0) {
            ui_state = UI_GAME_SOLDIER;
            game_init();
            return;
        }
    }
}
Exemplo n.º 14
0
/*-----------------------------------------------------------------------------*
| <<< メニュー使用時のタイトル >>>
|	入力	iTex	= 表示するテクスチャー番号
|			iSound	= 左クリック時の効果音
|			bSw		= true : フェードアウト開始
|	戻り値	true	= モードが変わった
*-------------------------------------------------------------------------------*/
bool	TitleMenu(int	iTex,	int	iSound,	bool bSw)
{
	bool	bRet	= false;

	//--- 640×480 ドットの絵を表示 --------------------
	d3_tex_set(iTex);
	d3_2d_box_fill_tex_draw(&VEC2(0, 0), &VEC2(__SCR_W, __SCR_H), D3_COL((int)fCount, 255, 255, 255));

	//--- キー入力チェック --------------------------------------
	if(bSw)						// ここ、Title関数と違う
	{
		iFade = 1;
		snd_play(iSound);
	}
	//--- フィード ------------------------------------
	switch(iFade)
	{
	case -1:		//イン
		fCount += FADE_SPEED_;
		if(fCount >= 255.0f){ fCount = 255.0f; iFade = 0;}
		break;
	case 1:			//アウト
		fCount -= FADE_SPEED_;
		if(fCount <= 0.0f)
		{
			fCount = 0.0f;
			iFade  = -1;
			
				bRet	= true;
		}
		break;
	}
	return bRet;
}
Exemplo n.º 15
0
// ------------------------------------------------------------------
// hud_shield_equalize()
//
// Equalize the four shield quadrants for an object
//
void hud_shield_equalize(object* objp, player* pl)
{
	float strength;
	int idx;
	int all_equal;

	Assert(objp != NULL);
	if (objp == NULL)
		return;

	Assert(pl != NULL);
	if (pl == NULL)
		return;

	Assert(objp->type == OBJ_SHIP);
	if (objp->type != OBJ_SHIP)
		return;

	// Goober5000 - quick out if we have no shields
	if (objp->flags & OF_NO_SHIELDS)
		return;

	// are all quadrants equal?
	all_equal = 1;
	for (idx = 0; idx < MAX_SHIELD_SECTIONS - 1; idx++)
	{
		if (objp->shield_quadrant[idx] != objp->shield_quadrant[idx + 1])
		{
			all_equal = 0;
			break;
		}
	}

	if (all_equal)
		return;

	strength = shield_get_strength(objp);
	if (strength == 0.0f)
		return;

	// maybe impose a 2% penalty - server side and single player only
	if (!MULTIPLAYER_CLIENT && (pl->shield_penalty_stamp < 0) || timestamp_elapsed_safe(pl->shield_penalty_stamp,
		1000))
	{
		strength *= 0.98f;

		// reset the penalty timestamp
		pl->shield_penalty_stamp = timestamp(1000);
	}

	shield_set_strength(objp, strength);

	// beep
	if (objp == Player_obj)
	{
		snd_play(&Snds[SND_SHIELD_XFER_OK]);
	}
}
Exemplo n.º 16
0
// ------------------------------------------------------------------
// hud_augment_shield_quadrant()
//
// Transfer shield energy to a shield quadrant from the three other
//	quadrants.  Works by trying to transfer a fixed amount of shield
//	energy from the other three quadrants, taking the same percentage
// from each quadrant.
//
//	input:	objp			=>		object to perform shield transfer on
//				direction	=>		which quadrant to augment:
//										0 - right
//										1 - top
//										2 - bottom
//										3 - left
//
void hud_augment_shield_quadrant(object *objp, int direction)
{
	Assert(objp->type == OBJ_SHIP);

	ship *shipp = &Ships[objp->instance];
	ship_info *sip = &Ship_info[shipp->ship_info_index];
	float	xfer_amount, energy_avail, percent_to_take, delta;
	float	max_quadrant_val;
	int	i;

	if (sip->flags[Ship::Info_Flags::Model_point_shields]) {
		direction = sip->shield_point_augment_ctrls[direction];

		// The re-mapped direction can be -1 if this direction cannot be augmented
		if (direction < 0)
			return;
	}

	Assert(direction >= 0 && direction < objp->n_quadrants);
	
	xfer_amount = shipp->ship_max_shield_strength * SHIELD_TRANSFER_PERCENT;
	max_quadrant_val = get_max_shield_quad(objp);

	if ( (objp->shield_quadrant[direction] + xfer_amount) > max_quadrant_val )
		xfer_amount = max_quadrant_val - objp->shield_quadrant[direction];

	Assert(xfer_amount >= 0);
	if ( xfer_amount == 0 ) {
		// TODO: provide a feedback sound
		return;
	}
	else {
		snd_play( &Snds[SND_SHIELD_XFER_OK] );
	}

	energy_avail = 0.0f;
	for ( i = 0; i < objp->n_quadrants; i++ ) {
		if ( i == direction )
			continue;
		energy_avail += objp->shield_quadrant[i];
	}

	percent_to_take = xfer_amount/energy_avail;
	if ( percent_to_take > 1.0f )
		percent_to_take = 1.0f;

	for ( i = 0; i < objp->n_quadrants; i++ ) {
		if ( i == direction )
			continue;
		delta = percent_to_take * objp->shield_quadrant[i];
		objp->shield_quadrant[i] -= delta;
		Assert(objp->shield_quadrant[i] >= 0 );
		objp->shield_quadrant[direction] += delta;
		if ( objp->shield_quadrant[direction] > max_quadrant_val )
			objp->shield_quadrant[direction] = max_quadrant_val;
	}
}
Exemplo n.º 17
0
// try to add a ship to the escort list, if slot available
void hud_add_ship_to_escort(int objnum, int supress_feedback)
{
	escort_info complete_escorts[MAX_COMPLETE_ESCORT_LIST];
	int num_complete_escorts, idx, found;

	// get complete escort list
	hud_create_complete_escort_list(complete_escorts, &num_complete_escorts);

	// check if ship is already on complete escort list
	found = 0;
	for (idx=0; idx<num_complete_escorts; idx++) {
		if (complete_escorts[idx].obj_signature == Objects[objnum].signature) {
			found = 1;
			break;
		}
	}

	// add new ship into complete list
	if ( !found ) {
		complete_escorts[num_complete_escorts].objnum = objnum;
		complete_escorts[num_complete_escorts].obj_signature = Objects[objnum].signature;
		complete_escorts[num_complete_escorts].priority = Ships[Objects[objnum].instance].escort_priority;

		// remove him from escort list
		Ships[Objects[objnum].instance].flags |= SF_ESCORT;

		num_complete_escorts++;
	}

	// sort escort list by priority
	insertion_sort(complete_escorts, num_complete_escorts, sizeof(escort_info), escort_compare_func);

	// merge list
	merge_escort_lists(complete_escorts, num_complete_escorts);

	// maybe do feedback
	if ( (Num_escort_ships == Max_escort_ships) && !supress_feedback) {
		found = 0;
		// search thru list for objnum
		for (idx=0; idx<Num_escort_ships; idx++) {
			if (Escort_ships[idx].objnum == objnum) {
				found = 1;
				break;
			}
		}

		if (!found) {
			HUD_sourced_printf(HUD_SOURCE_HIDDEN, XSTR( "Escort list is full with %d ships", 288), Num_escort_ships);
			snd_play( &Snds[SND_TARGET_FAIL]);
		}
	}

	hud_gauge_popup_start(HUD_ESCORT_VIEW);
}
Exemplo n.º 18
0
// ----------------------------------------------------------------------------
// afterburners_stop() will be called when a ship disengages the afterburners.
//
// parameters:   *objp				=> pointer to the object starting afterburners
//						key_released	=>	OPTIONAL parameter (default value 0)
//												This is only used for the player object, to
//												manage starting/stopping
//
void afterburners_stop(object* objp, int key_released)
{
	Assert(objp != NULL);
	Assert(objp->instance >= 0 && objp->instance < MAX_SHIPS);

	ship_info* sip;
	ship* shipp;

	shipp = &Ships[objp->instance];

	Assert(shipp->ship_info_index >= 0 && shipp->ship_info_index < Num_ship_classes);
	sip = &Ship_info[shipp->ship_info_index];

	if ((objp->flags & OF_PLAYER_SHIP) && key_released)
	{
		objp->phys_info.flags &= ~PF_AFTERBURNER_WAIT;
	}

	if (!(sip->flags & SIF_AFTERBURNER))
	{
		nprintf(("Warning", "Ship type %s does not have afterburner capability\n", sip->name));
		return;
	}

	if (!(objp->phys_info.flags & PF_AFTERBURNER_ON))
	{
		return;
	}

	objp->phys_info.flags &= ~PF_AFTERBURNER_ON;
	float percent_left;
	percent_left = shipp->afterburner_fuel / sip->afterburner_fuel_capacity;

	//Do anim
	model_anim_start_type(shipp, TRIGGER_TYPE_AFTERBURNER, ANIMATION_SUBTYPE_ALL, -1);

	if (objp == Player_obj)
	{

		if (!key_released)
		{
			snd_play(&Snds[SND_ABURN_FAIL]);
		}

		if (Player_afterburner_loop_id > -1)
		{
			Player_disengage_timer = timestamp(DISENGAGE_TIME);
		}

		joy_ff_afterburn_off();
	}
}
Exemplo n.º 19
0
void chicken()												// This function defines the chicken's behaviour
{
	my.animPercentage = integer(random(100));		// set the frame the animation is started on to a random value so the chickens are not in synch
	
	while(1)													// start the chicken's looping function. The following commands will be executed every tick in the game.
	{
	
		// cycle through the animation
	
		my.animPercentage += 2 * time_step;			// animPercentage determines how far through the animation we are (think of it as frame number)	
//																// It is increased here by a small amount that is multiplied by the speed the game runs at.
//																//	This ensures that the animation will run at the same speed for all players no matter how fast their computer is.

		if (my.animPercentage > 100) 					// when animPercentage reaches 100 we have played all the way through the animation. If this is the case
		{														// we need to reset some variables and choose a new animation to play:
			
			my.animPercentage -= 100;					// reset animPercentage
			my.eggLaid = 0;								// reset the eggLaid variable (this is a marker that prevents the chicken from laying more than 1 egg per animation)
				
//																// choose which animation to play next:
			my.animCycle = integer(random(3));		// generate a random number and assign it to the variable animCycle
			
			if (my.animCycle == 2)						// if animCycle is 2 the chicken will lay an egg, and 
			{
				snd_play(chickenSound, 100, 0);		// we need to start the egg laying sound now.
			}
		}
		
		switch (my.animCycle)														// this is where the animation actually gets played:
		{
			case 0:																		// if animCycle is 0 play the breathe animation
				ent_animate(me,"breathe",my.animPercentage,ANM_CYCLE);
				break;
				
			case 1:																		// if animCycle is 1 play the breathe and blink animation
				ent_animate(me,"blink",my.animPercentage,ANM_CYCLE);
				break;
				
			case 2:																		// if animCycle is 2:
				if ((my.animPercentage > 70) && (my.eggLaid == 0))			// are we more than 70% through the animation and we haven't made an egg?
				{
					
					ent_create ("egg.mdl", vector (my.x - 30, my.y, my.z - 50), egg);		// create an egg entity slightly behind and below the chicken
					my.eggLaid = 1;																		// set the eggLaid variable to 1 so we don't do this every tick from now on	
				}
				ent_animate(me,"layEgg",my.animPercentage,ANM_CYCLE);		// play the layEgg animation
				break;
		}
		
		wait(1);												// wait for the other entities to get updated so we don't crash the game.
	}
}
Exemplo n.º 20
0
void transfer_energy_weapon_common(object *objp, float from_field, float to_field, float *from_delta, float *to_delta, float max, float scale)
{
	float	delta;

	delta = from_field * ENERGY_DIVERT_DELTA * scale;

	if (to_field + *to_delta + delta > max)
		delta = max - to_field - *to_delta;

	if ( delta > 0 ) {
		if ( objp == Player_obj )
			snd_play( &Snds[SND_ENERGY_TRANS], 0.0f );

		if (delta > from_field)
			delta = from_field;

		*to_delta += delta;
		*from_delta -= delta;
	} else
		if ( objp == Player_obj )
			snd_play( &Snds[SND_ENERGY_TRANS_FAIL], 0.0f );
}
// called once per frame to update the reticle gauges.  Makes calls to
// ship_dumbfire_threat() and ship_lock_threat() and updates Threat_flags.
void hud_update_reticle( player *pp )
{
	int rval;
	ship *shipp;

	// multiplayer clients won't call this routine
	if ( MULTIPLAYER_CLIENT || MULTI_OBSERVER(Net_players[MY_NET_PLAYER_NUM]))
		return;

	shipp = &Ships[Objects[pp->objnum].instance];

	if ( ship_dumbfire_threat(shipp) ) {
		pp->threat_flags |= THREAT_DUMBFIRE;
		pp->update_dumbfire_time = timestamp(THREAT_UPDATE_DUMBFIRE_TIME);
	}

	if ( timestamp_elapsed(pp->update_dumbfire_time) ) {
		pp->update_dumbfire_time = timestamp(THREAT_UPDATE_DUMBFIRE_TIME);
		pp->threat_flags &= ~THREAT_DUMBFIRE;
	}

	if ( timestamp_elapsed(pp->update_lock_time) ) {
		pp->threat_flags &= ~(THREAT_LOCK | THREAT_ATTEMPT_LOCK);
		pp->update_lock_time = timestamp(THREAT_UPDATE_LOCK_TIME);
		rval = ship_lock_threat(shipp);
		if ( rval == 1 ) {
			pp->threat_flags |= THREAT_ATTEMPT_LOCK;
		} else if ( rval == 2 ) {
			pp->threat_flags |= THREAT_LOCK;
		}
	}

	if(Player->threat_flags & THREAT_LOCK ) {
		// a less hacked up version of the missile launch warning
		hud_start_text_flash(XSTR("Launch", 1507), THREAT_LOCK_FLASH, fl2i(THREAT_LOCK_FLASH/2.0f));
	}

	if ( Player->threat_flags & (THREAT_ATTEMPT_LOCK) ) {
		if ( timestamp_elapsed(Threat_lock_timer) ) {
			Threat_lock_timer = timestamp(THREAT_LOCK_FLASH);
			
			Threat_lock_frame++;
			if ( Threat_lock_frame > 2 ) {
				Threat_lock_frame = 1;
			}
			if ( (Threat_lock_frame == 2) && (Player->threat_flags & THREAT_ATTEMPT_LOCK ) ) {
				snd_play( &Snds[ship_get_sound(Player_obj, SND_THREAT_FLASH)]);
			}
		}
	} 
}
Exemplo n.º 22
0
		// Stone rain
		action ebHandStone () {
			set(me, PASSABLE);
			var randomFallSpeed = random(20);
			while(my.z > -100) {
				my.z -=(20+randomFallSpeed) * time_step;
				my.pan +=randomFallSpeed * time_step;
				my.tilt +=randomFallSpeed * time_step;
				my.roll +=randomFallSpeed * time_step;
				
				// Give player 2 seconds to recover from last hit
				if (g_playerJustBeenHit == 0) {
					
					// Stone hits player?
					if (vec_dist(player.x, my.x) < 30) {
						
						// Play sounds
						if (!snd_playing(vPlayerSndHandle))
							vPlayerSndHandle = snd_play(g_sndHitByStone, 100, 0);
						snd_play(g_sndStoneImpact, 100, 0);	
							
						player.PL_HEALTH -=1;
						ent_remove(me);
						
						g_playerJustBeenHit = 2;
						
						// Wait 2 seconds
						while(g_playerJustBeenHit > 0) {
							g_playerJustBeenHit -=1;
							wait(-1);
						}
						return;
					}
				}
				
				wait(1);
			}
			ent_remove(me);
		}
Exemplo n.º 23
0
// ------------------------------------------------------------------
// hud_augment_shield_quadrant()
//
// Transfer shield energy to a shield quadrant from the three other
//	quadrants.  Works by trying to transfer a fixed amount of shield
//	energy from the other three quadrants, taking the same percentage
// from each quadrant.
//
//	input:	objp			=>		object to perform shield transfer on
//				direction	=>		which quadrant to augment:
//										0 - right
//										1 - top
//										2 - bottom
//										3 - left
//
void hud_augment_shield_quadrant(object* objp, int direction)
{
	float xfer_amount, energy_avail, percent_to_take, delta;
	float max_quadrant_val;
	int i;

	Assert(direction >= 0 && direction < MAX_SHIELD_SECTIONS);
	Assert(objp->type == OBJ_SHIP);

	xfer_amount = Ships[objp->instance].ship_max_shield_strength * SHIELD_TRANSFER_PERCENT;
	max_quadrant_val = get_max_shield_quad(objp);

	if ((objp->shield_quadrant[direction] + xfer_amount) > max_quadrant_val)
		xfer_amount = max_quadrant_val - objp->shield_quadrant[direction];

	Assert(xfer_amount >= 0);
	if (xfer_amount == 0)
	{
		// TODO: provide a feedback sound
		return;
	}
	else
	{
		snd_play(&Snds[SND_SHIELD_XFER_OK]);
	}

	energy_avail = 0.0f;
	for (i = 0; i < MAX_SHIELD_SECTIONS; i++)
	{
		if (i == direction)
			continue;
		energy_avail += objp->shield_quadrant[i];
	}

	percent_to_take = xfer_amount / energy_avail;
	if (percent_to_take > 1.0f)
		percent_to_take = 1.0f;

	for (i = 0; i < MAX_SHIELD_SECTIONS; i++)
	{
		if (i == direction)
			continue;
		delta = percent_to_take * objp->shield_quadrant[i];
		objp->shield_quadrant[i] -= delta;
		Assert(objp->shield_quadrant[i] >= 0);
		objp->shield_quadrant[direction] += delta;
		if (objp->shield_quadrant[direction] > max_quadrant_val)
			objp->shield_quadrant[direction] = max_quadrant_val;
	}
}
Exemplo n.º 24
0
// display ingame,inmission message text
void multi_msg_display_mission_text(const char *msg, int player_index)
{
	// play a cue voice sound and text to speech if not from this player
	if(Net_players[player_index].player_id != MY_NET_PLAYER_NUM) {
		snd_play(&Snds[MULTI_MSG_TEXT_SOUND]);
		fsspeech_play(FSSPEECH_FROM_MULTI, msg);
	}

	if(MULTI_STANDALONE(Net_players[player_index])){
		HUD_sourced_printf(HUD_SOURCE_NETPLAYER,"%s %s",XSTR("<SERVER>", 698), msg);			
	} else {
		HUD_sourced_printf(HUD_SOURCE_NETPLAYER,"%s: %s", Net_players[player_index].m_player->callsign, msg);			
	}
}
Exemplo n.º 25
0
// ------------------------------------------------------------------
// hud_shield_equalize()
//
// Equalize the four shield quadrants for an object
//
void hud_shield_equalize(object *objp, player *pl)
{
	float	strength;
	int idx;
	int all_equal = 1;

	Assert(objp != NULL);
	if(objp == NULL){
		return;
	}
	Assert(pl != NULL);
	if(pl == NULL){
		return;
	}
	Assert(objp->type == OBJ_SHIP);
	if(objp->type != OBJ_SHIP){
		return;
	}

	// are all quadrants equal?
	for(idx=0; idx<MAX_SHIELD_SECTIONS-1; idx++){
		if(objp->shields[idx] != objp->shields[idx+1]){
			all_equal = 0;
			break;
		}
	}

	// not all equal
	if(!all_equal){
		strength = get_shield_strength(objp);
		if ( strength != 0 ) {
			// maybe impose a 2% penalty - server side and single player only
			if(!MULTIPLAYER_CLIENT &&  (pl->shield_penalty_stamp < 0) || timestamp_elapsed_safe(pl->shield_penalty_stamp, 1000) ){
				strength *= 0.98f;

				// reset the penalty timestamp
				pl->shield_penalty_stamp = timestamp(1000);
			}
			
			set_shield_strength(objp, strength);					
		}
	}

	// beep
	if ( objp == Player_obj ){
		snd_play( &Snds[SND_SHIELD_XFER_OK] );
	}
}
Exemplo n.º 26
0
/**
 * Called when a ship disengages the afterburners.
 *
 * @param *objp			pointer to the object starting afterburners
 * @param key_released	OPTIONAL parameter (default value 0) This is only used for the player object, to manage starting/stopping
 */
void afterburners_stop(object *objp, int key_released)
{
	Assert( objp != NULL );
	Assert( objp->instance >= 0 && objp->instance < MAX_SHIPS );
	
	ship_info *sip;
	ship *shipp;

	shipp = &Ships[objp->instance];

	Assert( shipp->ship_info_index >= 0 && shipp->ship_info_index < static_cast<int>(Ship_info.size()) );
	sip = &Ship_info[shipp->ship_info_index];

	if ( (objp->flags[Object::Object_Flags::Player_ship]) && key_released ) {
		objp->phys_info.flags &= ~PF_AFTERBURNER_WAIT;
	}

	if ( !(sip->flags[Ship::Info_Flags::Afterburner]) )	{
		nprintf(("Warning","Ship type %s does not have afterburner capability\n", sip->name));
		return;
	}

	if ( !(objp->phys_info.flags & PF_AFTERBURNER_ON) ) {
		return;
	}

	Script_system.SetHookObjects(1, "Ship", objp);
	Script_system.RunCondition(CHA_AFTERBURNEND, 0, NULL, objp);
	Script_system.RemHookVars(1, "Ship");

	objp->phys_info.flags &= ~PF_AFTERBURNER_ON;

	//Do anim
	model_anim_start_type(shipp, TRIGGER_TYPE_AFTERBURNER, ANIMATION_SUBTYPE_ALL, -1);

	if ( objp == Player_obj ) {

		if ( !key_released ) {
			snd_play( gamesnd_get_game_sound(ship_get_sound(objp, GameSounds::ABURN_FAIL)) );
		}

		if ( Player_afterburner_loop_id > -1 )	{
			Player_disengage_timer = timestamp(DISENGAGE_TIME);
		}

		joy_ff_afterburn_off();
	}
}
Exemplo n.º 27
0
void cmeasure_maybe_alert_success(object *objp)
{
	//Is this a countermeasure, and does it have a parent
	if ( objp->type != OBJ_WEAPON || objp->parent < 0) {
		return;
	}

	Assert(Weapon_info[Weapons[objp->instance].weapon_info_index].wi_flags[Weapon::Info_Flags::Cmeasure]);

	if ( objp->parent == OBJ_INDEX(Player_obj) ) {
		hud_start_text_flash(XSTR("Evaded", 1430), 800);
		snd_play(gamesnd_get_game_sound(ship_get_sound(Player_obj, SND_MISSILE_EVADED_POPUP)));
	} else if ( Objects[objp->parent].flags[Object::Object_Flags::Player_ship] ) {
		send_countermeasure_success_packet( objp->parent );
	}
}
Exemplo n.º 28
0
void startDay()
{
	if(!player)
	{
		return;
	}
	
	dayOrNight = DAY;
	snd_play(sndDayStart, soundVolume, 0);
	on_space = NULL;
	on_mouse_left = NULL;
	ent_remove(player);
	mouse_mode = 0;
	ent_create("player.mdl", vector(-147, -44, 0), actPlayerMove);
	stopMusicGame();
	playMusicGameDay();
	show_dayhint();
}
Exemplo n.º 29
0
void startNight()
{
	if(!player)
	{
		return;
	}
	
	dayOrNight = NIGHT;
	snd_play(sndNightStart, soundVolume, 0);
	mouse_mode = 1;
	ent_remove(player);
	ent_create("player.mdl", vector(entHut.x, entHut.y, entHut.z + 200), actPlayerShoot);
	on_space = throwSnowball;
	on_mouse_left = throwSnowball;
	stopMusicGame();
	playMusicGameNight();
	show_nighthint();
}
Exemplo n.º 30
0
// target the next ship in the escort list
void hud_escort_target_next()
{
	int objnum;

	if ( Num_escort_ships == 0 ) {
		snd_play( &Snds[SND_TARGET_FAIL], 0.0f );
		return;
	}

	Last_target_index++;
	if ( Last_target_index >= Num_escort_ships ) {
		Last_target_index = 0;
	}

	objnum = Escort_ships[Last_target_index].objnum;
	set_target_objnum( Player_ai,  objnum);
	hud_restore_subsystem_target(&Ships[Objects[objnum].instance]);
}