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