Exemplo n.º 1
0
void actor_orbital(int a)
{
  if (actor[a].grace_period > 0)
   return;
// this could make boss enemies too easy

  int colours [4], ox, oy;

//  if (actor[a].upgraded_system [UPG_ORBITAL] >= 4)
//   actor[a].orbital_spin = 25;
//    else
     actor[a].orbital_spin = 18;

  actor[a].orbital_angle += actor[a].orbital_spin;
  if (actor[a].orbital_angle > ANGLE_FULL)
   actor[a].orbital_angle -= ANGLE_FULL;
  if (actor[a].orbital_angle < 0)
   actor[a].orbital_angle += ANGLE_FULL;

  int damage = 500 + actor[a].total_power * 35;
  int special1 = 1 + actor[a].total_power / 5;
  
  if (special1 > 7) special1 = 7;
  
    colours [0] = TRANS_YELLOW;
    colours [1] = TRANS_LGREEN;
    colours [2] = TRANS_LGREEN;
    colours [3] = TRANS_DGREEN;
//    colours [0] = TRANS_YELLOW;
//    colours [1] = TRANS_ORANGE;
//    colours [2] = TRANS_LRED;
//    colours [3] = TRANS_DRED;
//    colours [0] = COLOUR_YELLOW8;
//    colours [1] = COLOUR_YELLOW8;
//    colours [2] = COLOUR_YELLOW6;
//    colours [3] = COLOUR_YELLOW4;

  ox = actor[a].x + xpart(actor[a].orbital_angle, ORBITAL_DISTANCE);
  oy = actor[a].y + ypart(actor[a].orbital_angle, ORBITAL_DISTANCE);

  create_bullet(BULLET_NICE_ORBITAL, ox, oy,
   0, 0,
   a, damage, 2, 100, 0,
   0, 0, colours, 1,special1,0,0,0,0);

  ox = actor[a].x + xpart(actor[a].orbital_angle + ANGLE_HALF, ORBITAL_DISTANCE);
  oy = actor[a].y + ypart(actor[a].orbital_angle + ANGLE_HALF, ORBITAL_DISTANCE);

  create_bullet(BULLET_NICE_ORBITAL, ox, oy,
   0, 0,
   a, damage, 2, 100, 0,
   0, 0, colours, 1,special1,0,0,0,0);


}
Exemplo n.º 2
0
void SlideShip::update()
{
    Ship::update();

    if (timer == 0)
    {
	timer = randint(5, 25);
	int n = randint(0, 3);
	if      (n == 0) { set_pair(v, 0, -1 * s); }
	else if (n == 1) { set_pair(v, 0, s); }
	else if (n == 2) { set_pair(v, -1 * s, 0); }
	else if (n == 3) { set_pair(v, s, 0); }
    }
    else
	timer--;

    int k = 20;
    if (health < 40)
	k = 10;
    if (randint(0, k) == 0)
	create_bullet();
}
Exemplo n.º 3
0
void run_hostile_level()
{
  int hostile_attack, i, angle;
  int x, y, xs, ys;

  
//  colours_for_cloud [0] = TRANS_DRED;

 for (i = 0; i < arena.eyes_on_level; i ++)
 {
  angle = grand(ANGLE_FULL);
  xs = 2000 + grand(2000);
  simple_cloud_trans(arena.eye_colour3, arena.eye_x [i], arena.eye_y [i],
   xpart(angle, xs), ypart(angle, xs), 400);   
 }


//  if (counter % 8 != 0 || grand(3) != 0)
  if (counter % 8 != 0 || grand(2000) > arena.hostile)
   return;

  hostile_attack = grand(5) + arena.hostile / 100;

  if (hostile_attack > 5)
   hostile_attack = 5;

  int colours [4] = {COLOUR_BLUE3, COLOUR_BLUE5, COLOUR_BLUE7, COLOUR_WHITE};

//  play_wavf(WAV_);
//   enemy_soundf(e, NWAV_SZAP, 100 + grand(5));
// play_wav_pos(NWAV_BURSTZL, 600, 255, xs, ys);

//  do
//  {
   i = grand(arena.eyes_on_level);
   if (arena.eye_x [i] == 0)
    return;
//  } while (arena.eye_x [i] != 0); 
  
//  angle = grand(ANGLE_FULL);
  int target = -1;
  if (actor[0].in_play == 1 && actor[1].in_play == 1)
   target = grand(2);
    else
    {
     if (actor[0].in_play == 1)
      target = 0;
     if (actor[1].in_play == 1)
      target = 1;
    }

  if (target == -1)
   return;

  angle = radians_to_angle(atan2(actor[target].y - arena.eye_y [i], actor[target].x - arena.eye_x [i]));
 
  x = arena.eye_x [i] + xpart(angle, 5000);
  y = arena.eye_y [i] + ypart(angle, 5000);

  play_wav_pos(NWAV_SZAP, 50 + grand(10), 200, x, y);

  xs = xpart(angle, 15000);
  ys = ypart(angle, 15000);
  simple_cloud_trans(TRANS_WHITE, x, y, 0, 0, 400);

   create_bullet(BULLET_HOSTILE, x, y,
    xs, ys, OWNER_ENEMY,
    400, 2000, 40, 0,
    0, 0, colours, 3,0,0,0,0,0);

}
Exemplo n.º 4
0
void cRocketTurret::think() {
	int iMyIndex = -1;

	for (int i = 0; i < MAX_STRUCTURES; i++) {
		if (structure[i] == this) {
			iMyIndex = i;
			break;
		}
	}

	// this should not happen, but just in case
	if (iMyIndex < 0) {
		return;
	}

	if (player[getOwner()].bEnoughPower() == false) {
		return; // do not fire a thing now
	}

	// turning & shooting
	if (iTargetID > -1) {
		if (unit[iTargetID].isValid()) {
			// first make sure we face okay!
			int iCellX = iCellGiveX(getCell());
			int iCellY = iCellGiveY(getCell());

			int iTargetX = iCellGiveX(unit[iTargetID].iCell);
			int iTargetY = iCellGiveY(unit[iTargetID].iCell);

			int d = fDegrees(iCellX, iCellY, iTargetX, iTargetY);
			int f = face_angle(d); // get the angle

			// set facing
			iShouldHeadFacing = f;

			if (iShouldHeadFacing == iHeadFacing || (unit[iTargetID].iType == ORNITHOPTER)) {

				TIMER_fire++;

				int iDistance = 9999;
				int iSlowDown = 250;

				if (getType() == RTURRET)
					iSlowDown = 450;

				if (unit[iTargetID].isValid()) {
					// calculate distance
					iDistance = ABS_length(iCellX, iCellY, iTargetX, iTargetY);

					if (iDistance > structures[getType()].sight)
						iTargetID = -1;
				} else
					iTargetID = -1;

				if (iTargetID < 0)
					return;

				if (TIMER_fire > iSlowDown) {
					int iTargetCell = unit[iTargetID].iCell;

					int iBullet = BULLET_TURRET;

					if (getType() == RTURRET && iDistance > 3)
						iBullet = ROCKET_RTURRET;
					else {
						int iShootX = (iDrawX() + 16) + (mapCamera->getX() * 32);
						int iShootY = (iDrawY() + 16) + (mapCamera->getY() * 32);
						int bmp_head = convert_angle(iHeadFacing);

						PARTICLE_CREATE(iShootX, iShootY, OBJECT_TANKSHOOT, -1, bmp_head);

					}

					int iBull = create_bullet(iBullet, getCell(), iTargetCell, -1, iMyIndex);

					if (unit[iTargetID].iType == ORNITHOPTER) {
						// it is a homing missile!
						bullet[iBull].iHoming = iTargetID;
						bullet[iBull].TIMER_homing = 200;

					}

					TIMER_fire = 0;

				}

			} else {
				TIMER_turn++;

				int iSlowDown = 200;

				if (TIMER_turn > iSlowDown) {
					TIMER_turn = 0;

					int d = 1;

					int toleft = (iHeadFacing + 8) - iShouldHeadFacing;
					if (toleft > 7)
						toleft -= 8;

					int toright = abs(toleft - 8);

					if (toright == toleft)
						d = -1 + (rnd(2));
					if (toleft > toright)
						d = 1;
					if (toright > toleft)
						d = -1;

					iHeadFacing += d;

					if (iHeadFacing < 0)
						iHeadFacing = 7;

					if (iHeadFacing > 7)
						iHeadFacing = 0;
				} // turning

			}

		} else
			iTargetID = -1;
	}

	// think like base class
	cAbstractStructure::think();

}
Exemplo n.º 5
0
void run_hostile_level()
{
  int hostile_attack, i;

  if (counter % 8 != 0 || grand(3) != 0)
   return;

  hostile_attack = grand(5) + arena.hostile / 100;

  if (hostile_attack > 5)
   hostile_attack = 5;

  int x, y, xs, ys;

//  int colours [4] = {COLOUR_WHITE, COLOUR_BLUE6, COLOUR_BLUE4, COLOUR_BLUE2};
  int colours [4] = {COLOUR_BLUE3, COLOUR_BLUE5, COLOUR_BLUE7, COLOUR_WHITE};
//  int colours [4] = {COLOUR_WHITE, COLOUR_BLUE7, COLOUR_BLUE5, COLOUR_BLUE3};

  play_sound(WAV_HOSTILE);

  for (i = 0; i < hostile_attack; i ++)
  {

   if (grand(2) == 0)
   {
    x = 1000;
    xs = 10000;
    if (grand(2) == 0)
    {
     x = arena.max_x - 1000;
     xs = -10000;
    }
    y = grand(arena.max_y - 20000) + 10000;
    y /= GRID_WIDTH * GRAIN;
    y *= GRID_WIDTH * GRAIN;
    y -= 4000;
    ys = 0;
   }
    else
    {
     y = 2000;
     ys = 10000;
     if (grand(2) == 0)
     {
      y = arena.max_y - 2000;
      ys = -10000;
     }
     x = grand(arena.max_x - 20000) + 10000;
     x /= GRID_WIDTH * GRAIN;
     x *= GRID_WIDTH * GRAIN;
     x -= 4000;
     xs = 0;
    }

   create_bullet(BULLET_HOSTILE, x, y,
    xs, ys, OWNER_ENEMY,
    400, 2000, 400, 0,
    0, 0, colours, 3,0,0,0,0,0);

  }

}
Exemplo n.º 6
0
void shoot(int posx, int posy, int direct){
  object bullet = create_bullet(posx,posy,direct);
  proj = insert(bullet, proj);
}