2 void W_GiveWeapon (entity e, float wep, string name)
9 e.items = e.items | wep;
14 if (other.classname == "player")
16 sprint (other, "You got the ^2");
25 void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, float deathtype)
27 local vector hitloc, force, endpoint, dir;
29 //local entity explosion;
31 dir = normalize(end - start);
34 // go a little bit into the wall because we need to hit this wall later
37 // trace multiple times until we hit a wall, each obstacle will be made
38 // non-solid so we can hit the next, while doing this we spawn effects and
39 // note down which entities were hit so we can damage them later
42 if(self.antilag_debug)
43 traceline_antilag (self, start, end, FALSE, self, self.antilag_debug);
45 traceline_antilag (self, start, end, FALSE, self, self.ping * 0.001);
47 // if it is world we can't hurt it so stop now
48 if (trace_ent == world || trace_fraction == 1)
51 // make the entity non-solid so we can hit the next one
52 trace_ent.railgunhit = TRUE;
53 trace_ent.railgunhitloc = end;
54 trace_ent.railgunhitsolidbackup = trace_ent.solid;
56 // stop if this is a wall
57 if (trace_ent.solid == SOLID_BSP)
60 // make the entity non-solid
61 trace_ent.solid = SOLID_NOT;
64 endpoint = trace_endpos;
66 // find all the entities the railgun hit and restore their solid state
67 ent = findfloat(world, railgunhit, TRUE);
70 // restore their solid type
71 ent.solid = ent.railgunhitsolidbackup;
72 ent = findfloat(ent, railgunhit, TRUE);
75 // spawn a temporary explosion entity for RadiusDamage calls
76 //explosion = spawn();
78 // find all the entities the railgun hit and hurt them
79 ent = findfloat(world, railgunhit, TRUE);
82 // get the details we need to call the damage function
83 hitloc = ent.railgunhitloc;
84 ent.railgunhitloc = '0 0 0';
85 ent.railgunhitsolidbackup = SOLID_NOT;
86 ent.railgunhit = FALSE;
89 if (ent.takedamage || ent.classname == "case")
90 Damage (ent, self, self, bdamage, deathtype, hitloc, force);
92 // create a small explosion to throw gibs around (if applicable)
93 //setorigin (explosion, hitloc);
94 //RadiusDamage (explosion, self, 10, 0, 50, world, 300, deathtype);
96 // advance to the next entity
97 ent = findfloat(ent, railgunhit, TRUE);
100 // we're done with the explosion entity, remove it
103 trace_endpos = endpoint;
106 void fireBullet (vector start, vector dir, float spread, float damage, float force, float dtype, float tracer)
111 dir = dir + randomvec() * spread;
112 end = start + dir * MAX_SHOT_DISTANCE;
113 if(self.antilag_debug)
114 traceline_antilag (self, start, end, FALSE, self, self.antilag_debug);
116 traceline_antilag (self, start, end, FALSE, self, self.ping * 0.001);
122 e.movetype = MOVETYPE_FLY;
124 e.think = SUB_Remove;
125 e.nextthink = time + vlen(trace_endpos - start) / 6000;
126 e.velocity = dir * 6000;
127 e.angles = vectoangles(e.velocity);
128 setmodel (e, "models/tracer.mdl"); // precision set below
129 setsize (e, '0 0 0', '0 0 0');
130 setorigin (e, start);
131 e.effects = EF_LOWPRECISION;
132 e.flags = FL_PROJECTILE;
135 if ((trace_fraction != 1.0) && (pointcontents (trace_endpos) != CONTENT_SKY))
137 if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
139 if (dtype == IT_SHOTGUN)
140 pointparticles(particleeffectnum("shotgun_impact"), trace_endpos, trace_plane_normal * 1000, 1);
142 pointparticles(particleeffectnum("machinegun_impact"), trace_endpos, trace_plane_normal * 1000, 1);
144 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * force);