1 void Create_Effect_Entity(int eff_name, string eff_string, bool eff_trail)
4 effects_ent[eff_name - 1] = eff = spawn();
6 eff.classname = "effect_entity";
7 eff.eent_net_name = eff_name;
8 eff.eent_eff_name = eff_string;
9 eff.eent_eff_trail = eff_trail;
13 void Read_Effect(bool is_new)
15 #if EFFECTS_COUNT >= 255
16 int net_name = ReadShort();
18 int net_name = ReadByte();
21 entity eff = effects_ent[net_name - 1];
23 vector v, vel = '0 0 0';
25 bool eff_trail = eff.eent_eff_trail;
30 bool use_vel = ReadByte();
43 WarpZone_TrailParticles(world, particleeffectnum(eff.eent_eff_name), v, vel);
45 pointparticles(particleeffectnum(eff.eent_eff_name), v, vel, eff_cnt);
50 bool Net_Write_Effect(entity client, int sf)
52 WriteByte(MSG_ENTITY, ENT_CLIENT_EFFECT);
53 #if EFFECTS_COUNT >= 255
54 WriteShort(MSG_ENTITY, self.eent_net_name);
56 WriteByte(MSG_ENTITY, self.eent_net_name);
58 WriteCoord(MSG_ENTITY, self.eent_net_location_x);
59 WriteCoord(MSG_ENTITY, self.eent_net_location_y);
60 WriteCoord(MSG_ENTITY, self.eent_net_location_z);
62 // attempt to save a tiny bit more bandwidth by not sending velocity if it isn't set
63 if(self.eent_net_velocity)
65 WriteByte(MSG_ENTITY, true);
66 WriteCoord(MSG_ENTITY, self.eent_net_velocity_x);
67 WriteCoord(MSG_ENTITY, self.eent_net_velocity_y);
68 WriteCoord(MSG_ENTITY, self.eent_net_velocity_z);
70 else { WriteByte(MSG_ENTITY, false); }
72 if(!self.eent_eff_trail) { WriteByte(MSG_ENTITY, self.eent_net_count); }
76 // problem with this is, we might not have all the available effects for it
77 int Effect_NameToID(string eff_name)
80 for(i = EFFECT_FIRST; i < MAX_EFFECTS; ++i)
82 if((effects_ent[i - 1]).eent_eff_name == eff_name)
83 return (effects_ent[i - 1]).eent_net_name;
89 void Send_Effect(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt)
91 int eff_id = Effect_NameToID(eff_name);
95 // revert to engine handling?
96 pointparticles(particleeffectnum(eff_name), eff_loc, eff_vel, eff_cnt);
100 entity eff = effects_ent[eff_id - 1];
102 if(!eff.eent_eff_trail && !eff_cnt) { return; } // effect has no count!
103 entity net_eff = spawn();
105 net_eff.classname = "net_effect";
106 //net_eff.eent_broadcast = broadcast;
107 net_eff.eent_net_name = eff_id;
108 net_eff.eent_net_velocity = eff_vel;
109 net_eff.eent_net_location = eff_loc;
110 net_eff.eent_net_count = eff_cnt;
111 net_eff.eent_eff_trail = eff.eent_eff_trail;
113 net_eff.think = SUB_Remove;
114 net_eff.nextthink = time + 0.2; // don't need to keep this long
116 Net_LinkEntity(net_eff, false, 0, Net_Write_Effect);