File: gun_machine.cpp

package info (click to toggle)
rafkill 1.2.2-3.3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 13,268 kB
  • sloc: cpp: 13,508; makefile: 64; sh: 14
file content (90 lines) | stat: -rw-r--r-- 3,088 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "gunobj.h"
#include "gun_machine.h"
#include "weaponobj.h"
#include "hulls/hull_weapon_machine.h"
#include "trigtable.h"

// #define MACHINE_SPEED -21.0
const int MACHINE_SPEED = -21;

WeaponMachineGun::WeaponMachineGun( int z, int d, int _smp, int al ):
WeaponObject( d, "Machine Gun", 23500, al, z, -1 ),
dang( 0 ) {
	smp = _smp;
}


WeaponObject * WeaponMachineGun::copy() {
	return new WeaponMachineGun( strength, dir, smp, alignment );
}


void WeaponMachineGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) {
	if ( smp != -1 ){
		// Util::playSample( smp, 255, 128, 1000, false );
		Util::playSound( smp, 255 );
	}

	switch( strength ) {
		case 0  : {

			shot_counter = 1;

			Ammo->push_back( new WeaponNode(x-8,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) );
			Ammo->push_back( new WeaponNode(x+8,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) );

			break;

		}
		case 1  : {

			shot_counter = 2;

			Ammo->push_back( new WeaponNode(x-9,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) );
			Ammo->push_back( new WeaponNode(x+9,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) );
			Ammo->push_back( new WeaponNode(x-4,y-1,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) );
			Ammo->push_back( new WeaponNode(x+4,y-1,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) );
			Ammo->push_back( new WeaponNode(x,y-2,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) );

			break;
		}
		case 2  : {
			shot_counter = 2;
			Ammo->push_back( new WeaponNode(x-9,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) );
			Ammo->push_back( new WeaponNode(x+9,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) );
			Ammo->push_back( new WeaponNode(x-4,y-2,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) );
			Ammo->push_back( new WeaponNode(x+4,y-2,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) );
			break;
		}
		case 3  : {
			shot_counter = 0;

			Ammo->push_back( new WeaponNode(x+7,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) );
			Ammo->push_back( new WeaponNode(x-7,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) );
			//Ammo->push_back( new WeaponNode(x,y-2,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) );
			break;
		}
		case 4  : {
			dang = (dang+30)%360;
			shot_counter = 2;

			#define magx(x) ( (int)( (x)+Tcos(dang)*6 ) )
			#define magy(y) ( (int)( (y)+Tsine(dang) ) )

			Ammo->push_back( new WeaponNode(magx(x-8),y-2,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) );
			Ammo->push_back( new WeaponNode(magx(x-5),y,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) );
			Ammo->push_back( new WeaponNode(magx(x+5),y,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) );
			Ammo->push_back( new WeaponNode(magx(x+8),y-2,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) );
			break;

		}
		default : {

			shot_counter = 0;
			Ammo->push_back( new WeaponNode(x+7,y,0,MACHINE_SPEED, new Machine_WHull(strength), alignment ) );
			Ammo->push_back( new WeaponNode(x-7,y,0,MACHINE_SPEED, new Machine_WHull(strength), alignment ) );

		}
	}

}