示例#1
0
int NaroolLurker::activate_weapon()
{
	STACKTRACE;
	double a, relativity = game->shot_relativity;
	if (target) {
		a = intercept_angle2(pos, vel * relativity, weaponVelocity,
			target->normal_pos(), target->get_vel());
	}
	else a = angle;
	add(new NaroolGas(0.0, 0.0,
		a , weaponVelocity, weaponDamage, weaponDuration, weaponRange, weaponArmour,
		poison, this, data->spriteWeapon, relativity));
	return(TRUE);
}
示例#2
0
void KorvianSniper::calculate()
{
  double angle2;

  
  if(beep == TRUE) {
	  if(target && target->exists() && !target->isInvisible()) {
		angle2 = angle - intercept_angle2(pos, vel * 1.0, weaponVelocity,
					target->normal_pos(), target->get_vel() );
		Vector2 v = 350*Vector2(unit_vector(angle+PI/2));
		double w = v.dot(target->get_vel())/distance(target);
		if(w < 0.0) w = -w;
		if(w > angle2 && angle2 > -w) {
			play_sound2(data->sampleSpecial[0]);
			beep = FALSE;
		}
	  }
	}

  Ship::calculate();
}
示例#3
0
void AstromorphBasilisk::calculate()
{
	STACKTRACE;

	// firing the weapon

	//	vel*=0.99;
	if (aimline && !fire_weapon && batt - weapon_drain >= 0 && weapon_recharge <= 0) {
		play_sound2(data->sampleWeapon[1]);

		batt -= weapon_drain;
		if (recharge_amount > 1)
			recharge_step = recharge_rate;
		weapon_recharge += weapon_rate;

		regrow_delay = regrowTime;

		double a;

		if (aimline->target != NULL) {
			SpaceObject* targ = aimline->target;

			a = intercept_angle2(pos, vel * game->shot_relativity, weaponVelocity*aimBonus,
				targ->normal_pos(), targ->get_vel());
		}
		else
			a = angle;

		add(new BasiliskGas(0.0, 0.0,
			a, (aimline->target != NULL) ? weaponVelocity*aimBonus : weaponVelocity,
			weaponDamage, weaponLife, weaponRange, iround(weaponArmour),
			poison, this, data->spriteWeapon, 1.0));

		aimline->target = NULL;
		aimline = NULL;
	}

	// slithering
	//if (!(turn_left || turn_right || !thrust))
	{
		//double frac = float(numSegs)/float(specialSegs);
		//double frac2 = numSegs/specialSegs;
		//double frac2 = magnitude(this->vel)/speed_max;
		double frac2 = 1.0;

		Vector2 normal;
		normal = Vector2(-vel.y, vel.x);
		normalize(normal);

		slitherFrame += frame_time * 1E-3;

		double a;
		//a = sin(PI * (frac2)*slitherFrame / 1.0 + (PI/2) ) *( (frac)*slitherAmount);

		// needs some work!
		a = (slitherAmount)*sin(slitherFrame * (frac2*slitherTime)/(PI/2) );

		vel += (accel_rate*frame_time) * a * normal;
		/*

		slitherFrame -= frame_time;

		slitherTick += frame_time * slitherAmount;

		frac2 = sin(slitherTick);

		slitherFrame *= frac;*/

		//if (slitherFrame < 0)
		//{
		//	slitherFrame = slitherTime;
		//	bOtherWay = !bOtherWay;
		//}
		//angle -= (bOtherWay) ? (PI2/64) : -(PI2/64);

		/*accelerate(this,
			//normalize(angle - ((bOtherWay) ? (PI/4) : -(PI/4)), PI2),
			normalize(angle -  (frac2*(PI/4))),
			slitherAccel*frac*frame_time, speed_max);*/
	}
	//	else
	{
		//slitherFrame = slitherTime/2;
		//bOtherWay = turn_right;
	}

	Ship::calculate();

	// ouchification tickdown

	if (hurty_time <= 0)
		vel *= 1 - slitherFriction * frame_time;

	if (hurty_time >= 0)
		hurty_time -= frame_time * 1E-3;
	if (hurty_time < 0)
		hurty_time = 0;

	// regrowth
	if (batt == batt_max && regrowTime > 0) {
		regrow_delay -= frame_time * 1E-3;
		if (regrow_delay <= 0)
			if (Head)
			if (Head->regrow(specialSegs)) {
				batt -= regrowDrain;
			regrow_delay = regrowTime;
		}
	}
}