2 void W_GiveWeapon (entity e, float wep, string name)
9 e.weapons = e.weapons | W_WeaponBit(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 railgun_start = start;
35 dir = normalize(end - start);
38 // go a little bit into the wall because we need to hit this wall later
41 // trace multiple times until we hit a wall, each obstacle will be made
42 // non-solid so we can hit the next, while doing this we spawn effects and
43 // note down which entities were hit so we can damage them later
46 if(self.antilag_debug)
47 traceline_antilag (self, start, end, FALSE, self, self.antilag_debug);
49 traceline_antilag (self, start, end, FALSE, self, ANTILAG_LATENCY(self));
51 // if it is world we can't hurt it so stop now
52 if (trace_ent == world || trace_fraction == 1)
55 // make the entity non-solid so we can hit the next one
56 trace_ent.railgunhit = TRUE;
57 trace_ent.railgunhitloc = end;
58 trace_ent.railgunhitsolidbackup = trace_ent.solid;
60 // stop if this is a wall
61 if (trace_ent.solid == SOLID_BSP)
64 // make the entity non-solid
65 trace_ent.solid = SOLID_NOT;
68 endpoint = trace_endpos;
70 endq3surfaceflags = trace_dphitq3surfaceflags;
72 // find all the entities the railgun hit and restore their solid state
73 ent = findfloat(world, railgunhit, TRUE);
76 // restore their solid type
77 ent.solid = ent.railgunhitsolidbackup;
78 ent = findfloat(ent, railgunhit, TRUE);
81 // spawn a temporary explosion entity for RadiusDamage calls
82 //explosion = spawn();
84 // find all the entities the railgun hit and hurt them
85 ent = findfloat(world, railgunhit, TRUE);
88 // get the details we need to call the damage function
89 hitloc = ent.railgunhitloc;
90 ent.railgunhitloc = '0 0 0';
91 ent.railgunhitsolidbackup = SOLID_NOT;
92 ent.railgunhit = FALSE;
95 if (ent.takedamage || ent.classname == "case")
96 Damage (ent, self, self, bdamage, deathtype, hitloc, force);
98 // create a small explosion to throw gibs around (if applicable)
99 //setorigin (explosion, hitloc);
100 //RadiusDamage (explosion, self, 10, 0, 50, world, 300, deathtype);
102 // advance to the next entity
103 ent = findfloat(ent, railgunhit, TRUE);
106 // we're done with the explosion entity, remove it
109 trace_endpos = endpoint;
111 trace_dphitq3surfaceflags = endq3surfaceflags;
114 void fireBullet (vector start, vector dir, float spread, float damage, float force, float dtype, float tracer)
119 dir = dir + randomvec() * spread;
120 end = start + dir * MAX_SHOT_DISTANCE;
121 if(self.antilag_debug)
122 traceline_antilag (self, start, end, FALSE, self, self.antilag_debug);
124 traceline_antilag (self, start, end, FALSE, self, ANTILAG_LATENCY(self));
130 e.movetype = MOVETYPE_FLY;
132 e.think = SUB_Remove;
133 e.nextthink = time + vlen(trace_endpos - start) / 6000;
134 e.velocity = dir * 6000;
135 e.angles = vectoangles(e.velocity);
136 setmodel (e, "models/tracer.mdl"); // precision set below
137 setsize (e, '0 0 0', '0 0 0');
138 setorigin (e, start);
139 e.effects = EF_LOWPRECISION;
140 e.flags = FL_PROJECTILE;
143 if ((trace_fraction != 1.0) && (pointcontents (trace_endpos) != CONTENT_SKY))
145 if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
147 if (DEATH_ISWEAPON(dtype, WEP_SHOTGUN))
148 pointparticles(particleeffectnum("shotgun_impact"), trace_endpos, trace_plane_normal * 1000, 1);
150 pointparticles(particleeffectnum("machinegun_impact"), trace_endpos, trace_plane_normal * 1000, 1);
152 Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * force);
156 void W_PrepareExplosionByDamage(entity attacker, void() explode)
158 self.takedamage = DAMAGE_NO;
159 self.event_damage = SUB_Null;
160 self.owner = attacker;
162 // do not explode NOW but in the NEXT FRAME!
163 // because recursive calls to RadiusDamage are not allowed
164 self.nextthink = time;
165 self.think = explode;