8 #include <client/view.qh>
11 void orb_draw(entity this)
13 float dt = time - this.move_time;
14 this.move_time = time;
18 this.alpha = (this.ltime - time) / this.orb_lifetime;
19 this.scale = min((1 - this.alpha)*this.orb_lifetime*4,1)*this.orb_radius;
20 this.angles = this.angles + dt * this.avelocity;
23 float orb_drawtime; // global storage of last drawn orb frame, to counter overlapping orbs
24 void orb_draw2d(entity this)
26 if(time <= orb_drawtime)
29 if(boxesoverlap(view_origin - '1 1 1', view_origin + '1 1 1', this.absmin, this.absmax))
31 orb_drawtime = time; // prevent rendering more than one of these per frame!
32 float orb_alpha = 0.65 * (this.ltime - time) / this.orb_lifetime;
33 drawfill('0 0 0', vec2(vid_conwidth, vid_conheight), this.colormod, autocvar_hud_colorflash_alpha * orb_alpha, DRAWFLAG_ADDITIVE);
37 void orb_setup(entity e)
39 setmodel(e, MDL_NADE_ORB);
42 setorigin(e, e.origin);
44 float model_radius = e.maxs.x;
45 vector size = '1 1 1' * e.orb_radius / 2;
46 setsize(e,-size,size);
47 e.orb_radius = e.orb_radius/model_radius*0.6;
50 e.draw2d = orb_draw2d;
51 IL_PUSH(g_drawables, e);
52 IL_PUSH(g_drawables_2d, e);
53 SetResourceExplicit(e, RES_HEALTH, 255);
54 set_movetype(e, MOVETYPE_NONE);
56 e.drawmask = MASK_NORMAL;
58 e.avelocity = '7 0 11';
59 e.renderflags |= RF_ADDITIVE;
63 REGISTER_NET_LINKED(Nade_Orb)
66 NET_HANDLE(Nade_Orb, bool isNew)
71 this.origin = ReadVector();
72 setorigin(this, this.origin);
73 this.colormod = ReadVector();
74 this.orb_lifetime = ReadByte();
75 this.orb_radius = ReadShort();
76 this.ltime = time + ReadByte()/10.0;
77 // this.ltime = time + this.orb_lifetime;
85 bool orb_send(entity this, entity to, int sf)
87 int channel = MSG_ENTITY;
88 WriteHeader(channel, Nade_Orb);
89 WriteByte(channel, sf);
91 WriteVector(channel, this.origin);
93 WriteVector(channel, this.colormod);
95 WriteByte(channel, this.orb_lifetime);
96 //WriteByte(MSG_ENTITY, this.ltime - time + 1);
97 WriteShort(channel, this.orb_radius);
98 // round time delta to a 1/10th of a second
99 WriteByte(channel, (this.ltime - time)*10.0+0.5);