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 traceline_hitcorpse (self, start, end, FALSE, self);
44 // if it is world we can't hurt it so stop now
45 if (trace_ent == world || trace_fraction == 1)
48 // make the entity non-solid so we can hit the next one
49 trace_ent.railgunhit = TRUE;
50 trace_ent.railgunhitloc = end;
51 trace_ent.railgunhitsolidbackup = trace_ent.solid;
53 // stop if this is a wall
54 if (trace_ent.solid == SOLID_BSP)
57 // make the entity non-solid
58 trace_ent.solid = SOLID_NOT;
61 endpoint = trace_endpos;
63 // find all the entities the railgun hit and restore their solid state
64 ent = findfloat(world, railgunhit, TRUE);
67 // restore their solid type
68 ent.solid = ent.railgunhitsolidbackup;
69 ent = findfloat(ent, railgunhit, TRUE);
72 // spawn a temporary explosion entity for RadiusDamage calls
73 //explosion = spawn();
75 // find all the entities the railgun hit and hurt them
76 ent = findfloat(world, railgunhit, TRUE);
79 // get the details we need to call the damage function
80 hitloc = ent.railgunhitloc;
81 ent.railgunhitloc = '0 0 0';
82 ent.railgunhitsolidbackup = SOLID_NOT;
83 ent.railgunhit = FALSE;
86 if (ent.takedamage || ent.classname == "case")
87 Damage (ent, self, self, bdamage, deathtype, hitloc, force);
89 // create a small explosion to throw gibs around (if applicable)
90 //setorigin (explosion, hitloc);
91 //RadiusDamage (explosion, self, 10, 0, 50, world, 300, deathtype);
93 // advance to the next entity
94 ent = findfloat(ent, railgunhit, TRUE);
97 // we're done with the explosion entity, remove it
100 trace_endpos = endpoint;
103 void fireBullet (vector start, vector dir, float spread, float damage, float force, float dtype, float tracer)
108 // use traceline_hitcorpse to make sure it can hit gibs and corpses too
109 dir = dir + randomvec() * spread;
110 end = start + dir * MAX_SHOT_DISTANCE;
111 traceline_hitcorpse (self, start, end, FALSE, self);
117 e.movetype = MOVETYPE_FLY;
119 e.think = SUB_Remove;
120 e.nextthink = time + vlen(trace_endpos - start) / 6000;
121 e.velocity = dir * 6000;
122 e.angles = vectoangles(e.velocity);
123 setmodel (e, "models/tracer.mdl"); // precision set below
124 setsize (e, '0 0 0', '0 0 0');
125 setorigin (e, start);
126 e.effects = EF_LOWPRECISION;
127 e.flags = FL_PROJECTILE;
130 if ((trace_fraction != 1.0) && (pointcontents (trace_endpos) != CONTENT_SKY))
132 if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
134 if (dtype == IT_SHOTGUN)
135 pointparticles(particleeffectnum("shotgun_impact"), trace_endpos, trace_plane_normal * 1000, 1);
137 pointparticles(particleeffectnum("machinegun_impact"), trace_endpos, trace_plane_normal * 1000, 1);
139 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * force);