File: gun_efmsingle.cpp

package info (click to toggle)
rafkill 1.2.2-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,268 kB
  • ctags: 5,074
  • sloc: cpp: 13,508; makefile: 64; sh: 14
file content (56 lines) | stat: -rw-r--r-- 1,501 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "gunobj.h"
#include "weaponobj.h"
#include "gun_efmsingle.h"
#include "hulls/hull_weapon_s_s.h"
#include "trigtable.h"
#include "spaceobj.h"
#include <vector>

using namespace std;

EnemyFindSingleMachine::EnemyFindSingleMachine( int d, int al ):
WeaponObject( d, "Find Single Machine", 0, al, 0, 0 ),
tear( 5 ){}

void EnemyFindSingleMachine::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * objects ) {

	setShotCounter( 40 );

	if ( objects == NULL ) return;
	if ( tear > 0 ) {
		tear--;
		setShotCounter( 10 );
	} else tear = 5;
	if ( objects->empty() ) return;

	/* fixed:
	 * Find actual enemy, not just front
	 */
	SpaceObject obj(0,0,0,0,NULL, NULL, PLANE_AIR|PLANE_GROUND, getTeam() );

	/*
	vector< SpaceObject * > my_fight;
	for ( vector< SpaceObject *>::const_iterator it = objects->begin(); it != objects->end(); it++ ){
		SpaceObject * potential = *it;
		if ( potential->CanbeHit( &gay ) ){
			my_fight.push_back( potential );
		}
	}
	*/

	// if ( my_fight.empty() ) return;
	// const SpaceObject * use = my_fight[ Util::rnd(my_fight.size()) ];
	const SpaceObject * use = getCollidableObject( objects, &obj );

	if ( use != NULL ) {
		const double FIND_BULLET = -1.2 * 8;
		int sang = gang( x, y, use->getX(), use->getY()+7 );
		double sx = Tcos(sang)*FIND_BULLET;
		double sy = Tsine(sang)*FIND_BULLET;
		Ammo->push_back( new WeaponNode(x,y,sx,sy,new SS_WHull(), alignment ) );
	}

}

EnemyFindSingleMachine::~EnemyFindSingleMachine() {
}