]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/effects/all.qc
Merge branch 'master' into Mario/cts_respawn_clear
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / effects / all.qc
1 #include "all.qh"
2
3 REGISTER_NET_TEMP(net_effect)
4 #ifdef CSQC
5 NET_HANDLE(net_effect, bool isNew)
6 {
7         int net_name = (Effects_COUNT >= 255) ? ReadShort() : ReadByte();
8
9         entity eff = Effects_from(net_name);
10
11         vector vel = '0 0 0';
12         int eff_cnt = 1;
13         bool eff_trail = eff.eent_eff_trail;
14         vector v;
15         v_x = ReadCoord();
16         v_y = ReadCoord();
17         v_z = ReadCoord();
18
19         bool use_vel = ReadByte();
20         if(use_vel)
21         {
22                 vel_x = ReadCoord();
23                 vel_y = ReadCoord();
24                 vel_z = ReadCoord();
25         }
26
27         if(!eff_trail)
28                 eff_cnt = ReadByte();
29
30         if(eff_trail)
31                 WarpZone_TrailParticles(NULL, particleeffectnum(eff), v, vel);
32         else
33                 pointparticles(eff, v, vel, eff_cnt);
34         return true;
35 }
36 #endif
37
38 #ifdef SVQC
39 bool Net_Write_Effect(entity this, entity client, int sf)
40 {
41         int channel = MSG_ONE;
42         msg_entity = client;
43         WriteHeader(channel, net_effect);
44         (Effects_COUNT >= 255)
45         ? WriteShort(channel, this.m_id)
46         : WriteByte(channel, this.m_id);
47         WriteCoord(channel, this.eent_net_location_x);
48         WriteCoord(channel, this.eent_net_location_y);
49         WriteCoord(channel, this.eent_net_location_z);
50
51         // attempt to save a tiny bit more bandwidth by not sending velocity if it isn't set
52         if(this.eent_net_velocity)
53         {
54                 WriteByte(channel, true);
55                 WriteCoord(channel, this.eent_net_velocity_x);
56                 WriteCoord(channel, this.eent_net_velocity_y);
57                 WriteCoord(channel, this.eent_net_velocity_z);
58         }
59         else { WriteByte(channel, false); }
60
61         if(!this.eent_eff_trail) { WriteByte(channel, this.eent_net_count); }
62         return true;
63 }
64
65 void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
66 {
67         if(!eff) { return; }
68         if(!eff.eent_eff_trail && !eff_cnt) { return; } // effect has no count!
69         entity net_eff = new_pure(net_effect);
70         net_eff.owner = eff;
71         //net_eff.eent_broadcast = broadcast;
72         net_eff.m_id = eff.m_id;
73         net_eff.eent_net_velocity = eff_vel;
74         net_eff.eent_net_location = eff_loc;
75         net_eff.eent_net_count = eff_cnt;
76         net_eff.eent_eff_trail = eff.eent_eff_trail;
77
78         FOREACH_CLIENT(IS_REAL_CLIENT(it), Net_Write_Effect(net_eff, it, 0));
79         delete(net_eff);
80 }
81
82 void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt)
83 {
84         // problem with this is, we might not have all the available effects for it
85         FOREACH(Effects, it.eent_eff_name == eff_name, {
86                 Send_Effect(it, eff_loc, eff_vel, eff_cnt);
87                 return;
88         });
89         // revert to engine handling
90         __pointparticles(_particleeffectnum(eff_name), eff_loc, eff_vel, eff_cnt);
91 }
92 #endif
93
94 #ifdef EFFECTINFO_ENABLED
95         #include "effectinfo.qc"
96 #endif