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();
44 WarpZone_TrailParticles(world, particleeffectnum(eff.eent_eff_name), v, vel);
46 pointparticles(particleeffectnum(eff.eent_eff_name), v, vel, eff_cnt);
52 bool Net_Write_Effect(entity client, int sf)
54 WriteByte(MSG_ENTITY, ENT_CLIENT_EFFECT);
55 #if EFFECTS_COUNT >= 255
56 WriteShort(MSG_ENTITY, self.eent_net_name);
58 WriteByte(MSG_ENTITY, self.eent_net_name);
60 WriteCoord(MSG_ENTITY, self.eent_net_location_x);
61 WriteCoord(MSG_ENTITY, self.eent_net_location_y);
62 WriteCoord(MSG_ENTITY, self.eent_net_location_z);
64 // attempt to save a tiny bit more bandwidth by not sending velocity if it isn't set
65 if(self.eent_net_velocity)
67 WriteByte(MSG_ENTITY, true);
68 WriteCoord(MSG_ENTITY, self.eent_net_velocity_x);
69 WriteCoord(MSG_ENTITY, self.eent_net_velocity_y);
70 WriteCoord(MSG_ENTITY, self.eent_net_velocity_z);
72 else { WriteByte(MSG_ENTITY, false); }
74 if(!self.eent_eff_trail) { WriteByte(MSG_ENTITY, self.eent_net_count); }
78 // problem with this is, we might not have all the available effects for it
79 int Effect_NameToID(string eff_name)
82 for(i = EFFECT_FIRST; i < MAX_EFFECTS; ++i)
84 if((effects_ent[i - 1]).eent_eff_name == eff_name)
85 return (effects_ent[i - 1]).eent_net_name;
91 void Send_Effect(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt)
93 int eff_id = Effect_NameToID(eff_name);
97 // revert to engine handling?
98 pointparticles(particleeffectnum(eff_name), eff_loc, eff_vel, eff_cnt);
102 entity eff = effects_ent[eff_id - 1];
104 if(!eff.eent_eff_trail && !eff_cnt) { return; } // effect has no count!
105 entity net_eff = spawn();
107 net_eff.classname = "net_effect";
108 //net_eff.eent_broadcast = broadcast;
109 net_eff.eent_net_name = eff_id;
110 net_eff.eent_net_velocity = eff_vel;
111 net_eff.eent_net_location = eff_loc;
112 net_eff.eent_net_count = eff_cnt;
113 net_eff.eent_eff_trail = eff.eent_eff_trail;
115 net_eff.think = SUB_Remove;
116 net_eff.nextthink = time + 0.2; // don't need to keep this long
118 Net_LinkEntity(net_eff, false, 0, Net_Write_Effect);