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;
28 local entity ent, endent;
29 local float endq3surfaceflags;
30 //local entity explosion;
32 dir = normalize(end - start);
35 // go a little bit into the wall because we need to hit this wall later
38 // trace multiple times until we hit a wall, each obstacle will be made
39 // non-solid so we can hit the next, while doing this we spawn effects and
40 // note down which entities were hit so we can damage them later
43 if(self.antilag_debug)
44 traceline_antilag (self, start, end, FALSE, self, self.antilag_debug);
46 traceline_antilag (self, start, end, FALSE, self, self.ping * 0.001);
48 // if it is world we can't hurt it so stop now
49 if (trace_ent == world || trace_fraction == 1)
52 // make the entity non-solid so we can hit the next one
53 trace_ent.railgunhit = TRUE;
54 trace_ent.railgunhitloc = end;
55 trace_ent.railgunhitsolidbackup = trace_ent.solid;
57 // stop if this is a wall
58 if (trace_ent.solid == SOLID_BSP)
61 // make the entity non-solid
62 trace_ent.solid = SOLID_NOT;
65 endpoint = trace_endpos;
67 endq3surfaceflags = trace_dphitq3surfaceflags;
69 // find all the entities the railgun hit and restore their solid state
70 ent = findfloat(world, railgunhit, TRUE);
73 // restore their solid type
74 ent.solid = ent.railgunhitsolidbackup;
75 ent = findfloat(ent, railgunhit, TRUE);
78 // spawn a temporary explosion entity for RadiusDamage calls
79 //explosion = spawn();
81 // find all the entities the railgun hit and hurt them
82 ent = findfloat(world, railgunhit, TRUE);
85 // get the details we need to call the damage function
86 hitloc = ent.railgunhitloc;
87 ent.railgunhitloc = '0 0 0';
88 ent.railgunhitsolidbackup = SOLID_NOT;
89 ent.railgunhit = FALSE;
92 if (ent.takedamage || ent.classname == "case")
93 Damage (ent, self, self, bdamage, deathtype, hitloc, force);
95 // create a small explosion to throw gibs around (if applicable)
96 //setorigin (explosion, hitloc);
97 //RadiusDamage (explosion, self, 10, 0, 50, world, 300, deathtype);
99 // advance to the next entity
100 ent = findfloat(ent, railgunhit, TRUE);
103 // we're done with the explosion entity, remove it
106 trace_endpos = endpoint;
108 trace_dphitq3surfaceflags = endq3surfaceflags;
111 void fireBullet (vector start, vector dir, float spread, float damage, float force, float dtype, float tracer)
116 dir = dir + randomvec() * spread;
117 end = start + dir * MAX_SHOT_DISTANCE;
118 if(self.antilag_debug)
119 traceline_antilag (self, start, end, FALSE, self, self.antilag_debug);
121 traceline_antilag (self, start, end, FALSE, self, self.ping * 0.001);
127 e.movetype = MOVETYPE_FLY;
129 e.think = SUB_Remove;
130 e.nextthink = time + vlen(trace_endpos - start) / 6000;
131 e.velocity = dir * 6000;
132 e.angles = vectoangles(e.velocity);
133 setmodel (e, "models/tracer.mdl"); // precision set below
134 setsize (e, '0 0 0', '0 0 0');
135 setorigin (e, start);
136 e.effects = EF_LOWPRECISION;
137 e.flags = FL_PROJECTILE;
140 if ((trace_fraction != 1.0) && (pointcontents (trace_endpos) != CONTENT_SKY))
142 if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
144 if (dtype == IT_SHOTGUN)
145 pointparticles(particleeffectnum("shotgun_impact"), trace_endpos, trace_plane_normal * 1000, 1);
147 pointparticles(particleeffectnum("machinegun_impact"), trace_endpos, trace_plane_normal * 1000, 1);
149 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * force);