2 * The point of these entities is to avoid the problems
\r
3 * with clientprediction.
\r
4 * If you add SendEntity to players, the engine will not
\r
5 * do any prediction anymore, and you'd have to write the whole
\r
6 * prediction code in CSQC, you want that? :P
\r
7 * Data can depend on gamemode. For now, it serves as GPS entities
\r
8 * in onslaught... YAY ;)
\r
11 // Beware: do not redefine those in other files
\r
12 // and NO, you cannot use ".version", which already exists (at least
\r
13 // it did when I added this) But you have to use .Version
\r
20 print("Initializing ClientSide information entities\n");
\r
23 float entcs_customize()
\r
27 if(o.deadflag != DEAD_NO)
\r
29 if(o.classname != "player")
\r
33 if(other.classname == "player")
\r
34 if(!teamplay || o.team != other.team)
\r
35 if not (radar_showennemies)
\r
40 float entcs_send(entity to, float sf)
\r
42 WriteByte(MSG_ENTITY, ENT_CLIENT_ENTCS);
\r
43 WriteByte(MSG_ENTITY, sf);
\r
45 WriteByte(MSG_ENTITY, num_for_edict(self.owner)-1);
\r
48 WriteShort(MSG_ENTITY, self.origin_x);
\r
49 WriteShort(MSG_ENTITY, self.origin_y);
\r
50 WriteShort(MSG_ENTITY, self.origin_z);
\r
53 WriteByte(MSG_ENTITY, self.angles_y * 256.0 / 360);
\r
55 WriteByte(MSG_ENTITY, self.health / 10); // FIXME use a better scale?
\r
57 WriteByte(MSG_ENTITY, self.armorvalue / 10); // FIXME use a better scale?
\r
59 WriteByte(MSG_ENTITY, self.stat_eaten);
\r
65 self.nextthink = time + 0.01;
\r
70 if(o.origin != self.origin)
\r
72 setorigin(self, o.origin);
\r
73 self.SendFlags |= 2;
\r
75 if(o.angles_y != self.angles_y)
\r
77 self.angles = o.angles;
\r
78 self.SendFlags |= 4;
\r
80 if(o.health != self.health)
\r
82 self.health = o.health;
\r
83 self.SendFlags |= 8;
\r
85 if(o.armorvalue != self.armorvalue)
\r
87 self.armorvalue = o.armorvalue;
\r
88 self.SendFlags |= 16;
\r
90 if(o.stat_eaten != self.stat_eaten)
\r
92 self.stat_eaten = o.stat_eaten;
\r
93 self.SendFlags |= 32;
\r
97 entity attach_entcs()
\r
102 ent.classname = "entcs_sender_v2";
\r
104 ent.think = entcs_think;
\r
105 ent.nextthink = time;
\r
107 Net_LinkEntity(ent, FALSE, 0, entcs_send);
\r
108 ent.customizeentityforclient = entcs_customize;
\r
115 void detach_entcs()
\r
117 remove(self.entcs);
\r
118 self.entcs = world;
\r