]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/vehicles/cl_vehicles.qc
Merge branch 'master' into Mario/vehicles
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / cl_vehicles.qc
1 #define hud_bg "gfx/vehicles/frame.tga"
2 #define hud_sh "gfx/vehicles/vh-shield.tga"
3
4 #define hud_hp_bar "gfx/vehicles/bar_up_left.tga"
5 #define hud_hp_ico "gfx/vehicles/health.tga"
6 #define hud_sh_bar "gfx/vehicles/bar_dwn_left.tga"
7 #define hud_sh_ico "gfx/vehicles/shield.tga"
8
9 #define hud_ammo1_bar "gfx/vehicles/bar_up_right.tga"
10 #define hud_ammo1_ico "gfx/vehicles/bullets.tga"
11 #define hud_ammo2_bar "gfx/vehicles/bar_dwn_right.tga"
12 #define hud_ammo2_ico "gfx/vehicles/rocket.tga"
13 #define hud_energy "gfx/vehicles/energy.tga"
14
15 entity dropmark;
16 var float autocvar_cl_vehicles_hudscale = 0.5;
17 var float autocvar_cl_vehicles_hudalpha = 0.75;
18
19 const float MAX_AXH = 4;
20 entity AuxiliaryXhair[MAX_AXH];
21
22 .string axh_image;
23 .float  axh_fadetime;
24 .float  axh_drawflag;
25 .float  axh_scale;
26
27 float alarm1time;
28 float alarm2time;
29
30 void vehicle_alarm(entity e, float 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(float bIsNew)
56 {
57         float 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         float i;
86
87         float hud_id = ReadByte();
88
89         // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
90         if(hud_id == 0)
91         {
92                 sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
93                 sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
94                 return;
95         }
96
97         // Init auxiliary crosshairs
98         entity axh;
99         for(i = 0; i < MAX_AXH; ++i)
100         {
101                 axh = AuxiliaryXhair[i];
102                 if(axh != world && !wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
103                         remove(axh);
104
105                 axh                                     = spawn();
106                 axh.draw2d                      = func_null;
107                 axh.drawmask            = MASK_NORMAL;
108                 axh.axh_drawflag        = DRAWFLAG_NORMAL;
109                 axh.axh_fadetime        = 0.1;
110                 axh.axh_image           = "gfx/vehicles/axh-ring.tga";
111                 axh.axh_scale           = 1;
112                 axh.alpha                       = 1;
113                 AuxiliaryXhair[i]       = axh;
114         }
115
116         if(hud_id == HUD_BUMBLEBEE_GUN)
117         {
118                 // Plasma cannons
119                 AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
120                 AuxiliaryXhair[0].axh_scale   = 0.25;
121                 // Raygun
122                 AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-bracket.tga";
123                 AuxiliaryXhair[1].axh_scale   = 0.25;
124         }
125         else { VEH_ACTION(hud_id, VR_SETUP); }
126 }