Makefile: use `-I.`
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / vehicle / bumblebee_weapons.qc
1 #ifndef VEHICLE_BUMBLEBEE_WEAPONS_H
2 #define VEHICLE_BUMBLEBEE_WEAPONS_H
3
4 #include <common/weapons/all.qh>
5
6 #endif
7
8 #ifdef IMPLEMENTATION
9
10 REGISTER_NET_LINKED(ENT_CLIENT_BUMBLE_RAYGUN)
11
12 #ifdef SVQC
13
14 float autocvar_g_vehicle_bumblebee_cannon_cost;
15 float autocvar_g_vehicle_bumblebee_cannon_damage;
16 float autocvar_g_vehicle_bumblebee_cannon_radius;
17 float autocvar_g_vehicle_bumblebee_cannon_refire;
18 float autocvar_g_vehicle_bumblebee_cannon_speed;
19 float autocvar_g_vehicle_bumblebee_cannon_spread;
20 float autocvar_g_vehicle_bumblebee_cannon_force;
21
22 bool bumble_raygun_send(entity this, entity to, int sf);
23
24 void bumblebee_fire_cannon(entity _gun, string _tagname, entity _owner)
25 {
26     vector v = gettaginfo(_gun, gettagindex(_gun, _tagname));
27     vehicles_projectile(EFFECT_BIGPLASMA_MUZZLEFLASH.eent_eff_name, SND(VEH_BUMBLEBEE_FIRE),
28                         v, normalize(v_forward + randomvec() * autocvar_g_vehicle_bumblebee_cannon_spread) * autocvar_g_vehicle_bumblebee_cannon_speed,
29                         autocvar_g_vehicle_bumblebee_cannon_damage, autocvar_g_vehicle_bumblebee_cannon_radius, autocvar_g_vehicle_bumblebee_cannon_force,  0,
30                         DEATH_VH_BUMB_GUN.m_id, PROJECTILE_BUMBLE_GUN, 0, true, true, _owner);
31 }
32
33 bool bumble_raygun_send(entity this, entity to, float sf)
34 {
35     WriteHeader(MSG_ENTITY, ENT_CLIENT_BUMBLE_RAYGUN);
36
37     WriteByte(MSG_ENTITY, sf);
38     if(sf & BRG_SETUP)
39     {
40         WriteByte(MSG_ENTITY, etof(self.realowner));
41         WriteByte(MSG_ENTITY, self.realowner.team);
42         WriteByte(MSG_ENTITY, self.cnt);
43     }
44
45     if(sf & BRG_START)
46     {
47         WriteCoord(MSG_ENTITY, self.hook_start_x);
48         WriteCoord(MSG_ENTITY, self.hook_start_y);
49         WriteCoord(MSG_ENTITY, self.hook_start_z);
50     }
51
52     if(sf & BRG_END)
53     {
54         WriteCoord(MSG_ENTITY, self.hook_end_x);
55         WriteCoord(MSG_ENTITY, self.hook_end_y);
56         WriteCoord(MSG_ENTITY, self.hook_end_z);
57     }
58
59     return true;
60 }
61
62 #endif
63
64 #ifdef CSQC
65
66 void bumble_raygun_draw(entity this);
67
68 NET_HANDLE(ENT_CLIENT_BUMBLE_RAYGUN, bool isnew)
69 {
70     int sf = ReadByte();
71
72     if(sf & BRG_SETUP)
73     {
74         self.cnt  = ReadByte();
75         self.team = ReadByte();
76         self.cnt  = ReadByte();
77
78         if(self.cnt)
79             self.colormod = '1 0 0';
80         else
81             self.colormod = '0 1 0';
82
83         self.traileffect = EFFECT_BUMBLEBEE_HEAL_MUZZLEFLASH.m_id;
84         self.lip = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_IMPACT);
85
86         self.draw = bumble_raygun_draw;
87     }
88
89
90     if(sf & BRG_START)
91     {
92         self.origin_x = ReadCoord();
93         self.origin_y = ReadCoord();
94         self.origin_z = ReadCoord();
95         setorigin(self, self.origin);
96     }
97
98     if(sf & BRG_END)
99     {
100         self.move_origin_x = ReadCoord();
101         self.move_origin_y = ReadCoord();
102         self.move_origin_z = ReadCoord();
103     }
104     return true;
105 }
106
107 .float bumble_raygun_nextdraw;
108 void bumble_raygun_draw(entity this)
109 {
110     float _len;
111     vector _dir;
112     vector _vtmp1, _vtmp2;
113
114     _len = vlen(self.origin - self.move_origin);
115     _dir = normalize(self.move_origin - self.origin);
116
117     if(self.bumble_raygun_nextdraw < time)
118     {
119         boxparticles(particleeffectnum(Effects_from(self.traileffect)), self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
120         boxparticles(self.lip, self, self.move_origin, self.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
121         self.bumble_raygun_nextdraw = time + 0.1;
122     }
123
124     float i, df, sz, al;
125     for(i = -0.1; i < 0.2; i += 0.1)
126     {
127         df = DRAWFLAG_NORMAL; //((random() < 0.5) ? DRAWFLAG_ADDITIVE : DRAWFLAG_SCREEN);
128         sz = 5 + random() * 5;
129         al = 0.25 + random() * 0.5;
130         _vtmp1 = self.origin + _dir * _len * (0.25 + i);
131         _vtmp1 += (randomvec() * (_len * 0.2) * (frametime * 2));       //self.raygun_l1;
132         Draw_CylindricLine(self.origin, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
133
134         _vtmp2 = self.origin + _dir * _len * (0.5 + i);
135         _vtmp2 += (randomvec() * (_len * 0.2) * (frametime * 5));       //self.raygun_l2;
136         Draw_CylindricLine(_vtmp1, _vtmp2, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
137
138         _vtmp1 = self.origin + _dir * _len * (0.75 + i);
139         _vtmp1 += randomvec() * (_len * 0.2) * (frametime * 10);     //self.raygun_l3;
140         Draw_CylindricLine(_vtmp2, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
141
142         Draw_CylindricLine(_vtmp1, self.move_origin +  randomvec() * 32, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
143     }
144 }
145
146 #endif
147
148 #endif