Remove some leftovers from merge
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / cl_vehicles.qc
1 const string hud_bg = "gfx/vehicles/frame.tga";
2 const string hud_sh = "gfx/vehicles/vh-shield.tga";
3
4 const string hud_hp_bar = "gfx/vehicles/bar_up_left.tga";
5 const string hud_hp_ico = "gfx/vehicles/health.tga";
6 const string hud_sh_bar = "gfx/vehicles/bar_dwn_left.tga";
7 const string hud_sh_ico = "gfx/vehicles/shield.tga";
8
9 const string hud_ammo1_bar = "gfx/vehicles/bar_up_right.tga";
10 const string hud_ammo1_ico = "gfx/vehicles/bullets.tga";
11 const string hud_ammo2_bar = "gfx/vehicles/bar_dwn_right.tga";
12 const string hud_ammo2_ico = "gfx/vehicles/rocket.tga";
13 const string hud_energy = "gfx/vehicles/energy.tga";
14
15 entity dropmark;
16 float autocvar_cl_vehicles_hudscale = 0.5;
17 float autocvar_cl_vehicles_hudalpha = 0.75;
18
19 const int MAX_AXH = 4;
20 entity AuxiliaryXhair[MAX_AXH];
21
22 .string axh_image;
23 .float  axh_fadetime;
24 .int    axh_drawflag;
25 .float  axh_scale;
26
27 float alarm1time;
28 float alarm2time;
29
30 void vehicle_alarm(entity e, int ch, string s0und)
31 {
32         if(!autocvar_cl_vehicles_alarm)
33                 return;
34
35         sound(e, ch, s0und, VOL_BASEVOICE, ATTEN_NONE);
36 }
37
38 void AuxiliaryXhair_Draw2D()
39 {
40         vector loc, psize;
41
42         psize = self.axh_scale * draw_getimagesize(self.axh_image);
43         loc = project_3d_to_2d(self.move_origin) - 0.5 * psize;
44         if(!(loc_z < 0 || loc_x < 0 || loc_y < 0 || loc_x > vid_conwidth || loc_y > vid_conheight))
45         {
46                 loc_z = 0;
47                 psize_z = 0;
48                 drawpic(loc, self.axh_image, psize, self.colormod, self.alpha, self.axh_drawflag);
49         }
50
51         if(time - self.cnt > self.axh_fadetime)
52                 self.draw2d = func_null;
53 }
54
55 void Net_AuXair2(bool bIsNew)
56 {
57         int axh_id      = bound(0, ReadByte(), MAX_AXH);
58         entity axh              = AuxiliaryXhair[axh_id];
59
60         if(axh == world || wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
61         {
62                 axh                                     = spawn();
63                 axh.draw2d                      = func_null;
64                 axh.drawmask            = MASK_NORMAL;
65                 axh.axh_drawflag        = DRAWFLAG_ADDITIVE;
66                 axh.axh_fadetime        = 0.1;
67                 axh.axh_image           = "gfx/vehicles/axh-ring.tga";
68                 axh.axh_scale           = 1;
69                 axh.alpha                       = 1;
70                 AuxiliaryXhair[axh_id] = axh;
71         }
72
73         axh.move_origin_x       = ReadCoord();
74         axh.move_origin_y       = ReadCoord();
75         axh.move_origin_z       = ReadCoord();
76         axh.colormod_x          = ReadByte() / 255;
77         axh.colormod_y          = ReadByte() / 255;
78         axh.colormod_z          = ReadByte() / 255;
79         axh.cnt                         = time;
80         axh.draw2d                      = AuxiliaryXhair_Draw2D;
81 }
82
83 void Net_VehicleSetup()
84 {
85         int i;
86         int hud_id = ReadByte();
87
88         // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
89         if(hud_id == 0)
90         {
91                 sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
92                 sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
93                 return;
94         }
95
96         // Init auxiliary crosshairs
97         entity axh;
98         for(i = 0; i < MAX_AXH; ++i)
99         {
100                 axh = AuxiliaryXhair[i];
101                 if(axh != world && !wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
102                         remove(axh);
103
104                 axh                                     = spawn();
105                 axh.draw2d                      = func_null;
106                 axh.drawmask            = MASK_NORMAL;
107                 axh.axh_drawflag        = DRAWFLAG_NORMAL;
108                 axh.axh_fadetime        = 0.1;
109                 axh.axh_image           = "gfx/vehicles/axh-ring.tga";
110                 axh.axh_scale           = 1;
111                 axh.alpha                       = 1;
112                 AuxiliaryXhair[i]       = axh;
113         }
114
115         if(hud_id == HUD_BUMBLEBEE_GUN)
116         {
117                 // Plasma cannons
118                 AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
119                 AuxiliaryXhair[0].axh_scale   = 0.25;
120                 // Raygun
121                 AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-bracket.tga";
122                 AuxiliaryXhair[1].axh_scale   = 0.25;
123         }
124         else { VEH_ACTION(hud_id, VR_SETUP); }
125 }