home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-27 | 58.0 KB | 2,497 lines |
- /*
-
- Timed Bomb (tic toc) by W. Harris (willh@demonic.demon.co.uk) irc:Paragon_
- BFG by J. Ripley (pslam@pslam.demon.co.uk) irc:PsLaM
- Teamplay concepts J. Ripley
- Teamplay written by W. Harris
- Capture the Flag by W. Harris
- Teleport by W. Harris
- TripWire by W. Harris
-
- Multiskin by dunno. but not me.
-
- Quality Assurance
- Alek Hayes (alek@linefeed.com)
- Pete Ripley (pete@pslam.demon.co.uk) irc:Pete_
- Simon Jago (72046.263@compuserve.com)
- */
-
- void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
- void () player_run;
- void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
- void(vector org, vector vel, float damage) SpawnBlood;
- void() SuperDamageSound;
- void() W_PlaceFlag;
- void(float checkflag) DropFlag;
- void() Place_Mega;
- // called by worldspawn
- void() W_Precache =
- {
- precache_sound ("weapons/r_exp3.wav"); // new rocket explosion
- precache_sound ("weapons/rocket1i.wav"); // spike gun
- precache_sound ("weapons/sgun1.wav");
- precache_sound ("weapons/guncock.wav"); // player shotgun
- precache_sound ("weapons/ric1.wav"); // ricochet (used in c code)
- precache_sound ("weapons/ric2.wav"); // ricochet (used in c code)
- precache_sound ("weapons/ric3.wav"); // ricochet (used in c code)
- precache_sound ("weapons/spike2.wav"); // super spikes
- precache_sound ("weapons/tink1.wav"); // spikes tink (used in c code)
- precache_sound ("weapons/grenade.wav"); // grenade launcher
- precache_sound ("weapons/bounce.wav"); // grenade bounce
- precache_sound ("weapons/shotgn2.wav"); // super shotgun
- precache_sound ("enforcer/enfire.wav"); // bomb fire
- precache_sound ("enforcer/enfstop.wav"); // bfg on wall
- precache_sound ("doors/runetry.wav");
- precache_sound ("items/inv1.wav");
- precache_sound ("misc/basekey.wav");
- precache_sound ("misc/secret.wav"); // capture the flag
- precache_sound ("items/protect2.wav");
- precache_sound ("items/protect3.wav");
- precache_sound ("items/damage3.wav");
- };
-
- float() crandom =
- {
- return 2*(random() - 0.5);
- };
-
- /*
- ================
- W_FireAxe
- ================
- */
- void() W_FireAxe =
- {
- local vector source;
- local vector org;
-
- source = self.origin + '0 0 16';
- traceline (source, source + v_forward*64, FALSE, self);
- if (trace_fraction == 1.0)
- return;
-
- org = trace_endpos - v_forward*4;
-
- if (trace_ent.takedamage)
- {
- trace_ent.axhitme = 1;
- SpawnBlood (org, '0 0 0', 20);
- T_Damage (trace_ent, self, self, 20);
- }
- else
- { // hit wall
- sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_GUNSHOT);
- WriteCoord (MSG_BROADCAST, org_x);
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- }
- };
-
-
- //============================================================================
-
-
- vector() wall_velocity =
- {
- local vector vel;
-
- vel = normalize (self.velocity);
- vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
- vel = vel + 2*trace_plane_normal;
- vel = vel * 200;
-
- return vel;
- };
-
-
- /*
- ================
- SpawnMeatSpray
- ================
- */
- void(vector org, vector vel) SpawnMeatSpray =
- {
- local entity missile, mpuff;
- local vector org;
-
- missile = spawn ();
- missile.owner = self;
- missile.movetype = MOVETYPE_BOUNCE;
- missile.solid = SOLID_NOT;
-
- makevectors (self.angles);
-
- missile.velocity = vel;
- missile.velocity_z = missile.velocity_z + 250 + 50*random();
-
- missile.avelocity = '3000 1000 2000';
-
- // set missile duration
- missile.nextthink = time + 1;
- missile.think = SUB_Remove;
-
- setmodel (missile, "progs/zom_gib.mdl");
- setsize (missile, '0 0 0', '0 0 0');
- setorigin (missile, org);
- };
-
- /*
- ================
- SpawnBlood
- ================
- */
- void(vector org, vector vel, float damage) SpawnBlood =
- {
- particle (org, vel*0.1, 73, damage*2);
- };
-
- /*
- ================
- spawn_touchblood
- ================
- */
- void(float damage) spawn_touchblood =
- {
- local vector vel;
-
- vel = wall_velocity () * 0.2;
- SpawnBlood (self.origin + vel*0.01, vel, damage);
- };
-
-
- /*
- ================
- SpawnChunk
- ================
- */
- void(vector org, vector vel) SpawnChunk =
- {
- particle (org, vel*0.02, 0, 10);
- };
-
- /*
- ==============================================================================
-
- MULTI-DAMAGE
-
- Collects multiple small damages into a single damage
-
- ==============================================================================
- */
-
- entity multi_ent;
- float multi_damage;
-
- void() ClearMultiDamage =
- {
- multi_ent = world;
- multi_damage = 0;
- };
-
- void() ApplyMultiDamage =
- {
- if (!multi_ent)
- return;
- T_Damage (multi_ent, self, self, multi_damage);
- };
-
- void(entity hit, float damage) AddMultiDamage =
- {
- if (!hit)
- return;
-
- if (hit != multi_ent)
- {
- ApplyMultiDamage ();
- multi_damage = damage;
- multi_ent = hit;
- }
- else
- multi_damage = multi_damage + damage;
- };
-
- /*
-
- ==============================================================================
-
- BULLETS
-
- ==============================================================================
- */
-
- /*
- ================
- TraceAttack
- ================
- */
- void(float damage, vector dir) TraceAttack =
- {
- local vector vel, org;
-
- vel = normalize(dir + v_up*crandom() + v_right*crandom());
- vel = vel + 2*trace_plane_normal;
- vel = vel * 200;
-
- org = trace_endpos - dir*4;
-
- if (trace_ent.takedamage)
- {
- SpawnBlood (org, vel*0.2, damage);
- AddMultiDamage (trace_ent, damage);
- }
- else
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_GUNSHOT);
- WriteCoord (MSG_BROADCAST, org_x);
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- }
- };
-
- /*
- ================
- FireBullets
-
- Used by shotgun, super shotgun, and enemy soldier firing
- Go to the trouble of combining multiple pellets into a single damage call.
- ================
- */
- void(float shotcount, vector dir, vector spread) FireBullets =
- {
- local vector direction;
- local vector src;
-
- makevectors(self.v_angle);
-
- src = self.origin + v_forward*10;
- src_z = self.absmin_z + self.size_z * 0.7;
-
- ClearMultiDamage ();
- while (shotcount > 0)
- {
- direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
-
- traceline (src, src + direction*2048, FALSE, self);
- if (trace_fraction != 1.0)
- TraceAttack (4, direction);
-
- shotcount = shotcount - 1;
- }
- ApplyMultiDamage ();
- };
-
- /*
- ================
- W_FireShotgun
- ================
- */
- void() W_FireShotgun =
- {
- local vector dir;
-
- sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
-
- self.punchangle_x = -2;
-
- self.currentammo = self.ammo_shells = self.ammo_shells - 1;
- dir = aim (self, 100000);
-
- if (self.items2 & IT2_MEGAPOWER)
- {
- FireBullets (18, dir, '0.08 0.08 0');
- }
- else
- {
- FireBullets (6, dir, '0.04 0.04 0');
- }
- };
-
- /*
- ================
- W_FireSuperShotgun
- ================
- */
- void() W_FireSuperShotgun =
- {
- local vector dir;
-
- if (self.currentammo == 1)
- {
- W_FireShotgun ();
- return;
- }
-
- sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
-
- self.punchangle_x = -4;
-
- self.currentammo = self.ammo_shells = self.ammo_shells - 2;
- dir = aim (self, 100000);
-
- if (self.items2 & IT2_MEGAPOWER)
- {
- FireBullets (42, dir, '0.32 0.20 0');
- }
- else
- {
- FireBullets (14, dir, '0.14 0.08 0');
- }
- };
-
-
- /*
- ==============================================================================
-
- ROCKETS
-
- ==============================================================================
- */
-
- void() s_explode1 = [0, s_explode2] {};
- void() s_explode2 = [1, s_explode3] {};
- void() s_explode3 = [2, s_explode4] {};
- void() s_explode4 = [3, s_explode5] {};
- void() s_explode5 = [4, s_explode6] {};
- void() s_explode6 = [5, SUB_Remove] {};
-
- void() bfg_explodefunc;
-
- void() bfg_explode1 = [0, bfg_explode2] {};
- void() bfg_explode2 = [1, bfg_explode3] {self.effects = self.effects | EF_MUZZLEFLASH;};
- void() bfg_explode3 = [2, bfg_explode4] {};
- void() bfg_explode4 = [3, bfg_explodefunc] {};
- void() bfg_explode5 = [4, bfg_explode6] {};
- void() bfg_explode6 = [5, SUB_Remove] {};
-
-
- void() BecomeExplosion =
- {
- self.movetype = MOVETYPE_NONE;
- self.velocity = '0 0 0';
- self.touch = SUB_Null;
- setmodel (self, "progs/s_explod.spr");
- self.solid = SOLID_NOT;
- s_explode1 ();
- };
-
- void(vector Spawn_velocity) W_FireCluster;
- void() W_SpawnGrenade;
-
- void() T_MissileTouch =
- {
- local float damg;
-
- if (other == self.owner)
- return; // don't explode on owner
-
- if (pointcontents(self.origin) == CONTENT_SKY)
- {
- remove(self);
- return;
- }
-
- damg = 100 + random()*20;
-
- if (other.health)
- {
- if (other.classname == "monster_shambler")
- damg = damg * 0.5; // mostly immune
- T_Damage (other, self, self.owner, damg );
- }
-
- // don't do radius damage to the other, because all the damage
- // was done in the impact
- T_RadiusDamage (self, self.owner, 120, other);
-
- // sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
- self.origin = self.origin - 8*normalize(self.velocity);
-
- if (self.items2 & IT2_MEGAPOWER)
- {
- W_SpawnGrenade();
- W_SpawnGrenade();
- W_SpawnGrenade();
- W_SpawnGrenade();
- W_SpawnGrenade();
- }
-
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
-
- BecomeExplosion ();
-
- };
-
-
- /*
- ================
- W_FireRocket
- ================
- */
- void() W_FireRocket =
- {
- local entity missile, mpuff;
-
- self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
-
- sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
-
- self.punchangle_x = -2;
-
- missile = spawn ();
- missile.owner = self;
- missile.movetype = MOVETYPE_FLYMISSILE;
- missile.solid = SOLID_BBOX;
-
- // set missile speed
-
- makevectors (self.v_angle);
- missile.velocity = aim(self, 1000);
- missile.velocity = missile.velocity * 1000;
- missile.angles = vectoangles(missile.velocity);
-
- missile.touch = T_MissileTouch;
-
- // set missile duration
- if (self.items2 & IT2_MEGAPOWER)
- {
- missile.items2 = missile.items2 | IT2_MEGAPOWER;
- missile.health = 60;
- missile.nextthink = time + 0.1;
- missile.think = W_SpawnGrenade;
- }
- else
- {
- missile.nextthink = time + 5;
- missile.think = SUB_Remove;
- }
- setmodel (missile, "progs/missile.mdl");
- setsize (missile, '0 0 0', '0 0 0');
- setorigin (missile, self.origin + v_forward*8 + '0 0 16');
- };
-
- /*
- ===============================================================================
-
- LIGHTNING
-
- ===============================================================================
- */
-
- /*
- =================
- LightningDamage
- =================
- */
- void(vector p1, vector p2, entity from, float damage) LightningDamage =
- {
- local entity e1, e2;
- local vector f;
-
- local float damadd;
-
- f = p2 - p1;
- normalize (f);
- f_x = 0 - f_y;
- f_y = f_x;
- f_z = 0;
- f = f*16;
-
- e1 = e2 = world;
-
- traceline (p1, p2, FALSE, self);
- if (trace_ent.takedamage)
- {
- particle (trace_endpos, '0 0 300', 225, damage*4);
- if (self.classname == "player")
- {
- if (self.items2 & IT2_MEGAPOWER)
- {
- if (trace_ent.health >= damage) damadd = damage;
- else damadd = trace_ent.health;
- self.health = self.health + damadd;
- }
- }
- T_Damage (trace_ent, from, from, damage);
- if (self.classname == "player")
- {
- if (other.classname == "player")
- trace_ent.velocity_z = trace_ent.velocity_z + 400;
- }
- }
- e1 = trace_ent;
-
- traceline (p1 + f, p2 + f, FALSE, self);
- if (trace_ent != e1 && trace_ent.takedamage)
- {
- particle (trace_endpos, '0 0 300', 225, damage*4);
- T_Damage (trace_ent, from, from, damage);
- }
- e2 = trace_ent;
-
- traceline (p1 - f, p2 - f, FALSE, self);
- if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
- {
- particle (trace_endpos, '0 0 300', 225, damage*4);
- T_Damage (trace_ent, from, from, damage);
- }
- };
-
- void(vector start_pos, vector bolt_dir, float spawn_num) LightningBounce =
- {
- local entity tempent;
-
- local vector old_endpos;
-
- if (spawn_num < 1)
- return;
-
- tempent=spawn();
- tempent.origin = start_pos;
- setorigin(tempent,start_pos);
- setmodel(tempent,"progs/grenade.mdl");
- tempent.v_angle = bolt_dir;
- tempent.angles = vectoangles(tempent.v_angle);
-
- traceline (start_pos, start_pos + bolt_dir * 600, FALSE, self);
-
- old_endpos = trace_endpos + bolt_dir * 4;
-
- bolt_dir_x = bolt_dir_x * (((0 - 2) * fabs(trace_plane_normal_x)) + 1);
- bolt_dir_y = bolt_dir_y * (((0 - 2) * fabs(trace_plane_normal_y)) + 1);
- bolt_dir_z = bolt_dir_z * (((0 - 2) * fabs(trace_plane_normal_z)) + 1);
-
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
- WriteEntity (MSG_BROADCAST, tempent);
- WriteCoord (MSG_BROADCAST, start_pos_x);
- WriteCoord (MSG_BROADCAST, start_pos_y);
- WriteCoord (MSG_BROADCAST, start_pos_z);
- WriteCoord (MSG_BROADCAST, trace_endpos_x);
- WriteCoord (MSG_BROADCAST, trace_endpos_y);
- WriteCoord (MSG_BROADCAST, trace_endpos_z);
-
- LightningDamage (start_pos, trace_endpos, self, 30);
-
- bolt_dir_x = bolt_dir_x + 0.05 * crandom();
- bolt_dir_y = bolt_dir_y + 0.05 * crandom();
- bolt_dir_z = bolt_dir_z + 0.05 * crandom();
-
- LightningBounce(old_endpos, bolt_dir, spawn_num - 1);
-
- remove(tempent);
- };
-
- void() W_FireSuperLightning =
- {
- if (self.ammo_cells < 1)
- {
- self.weapon = W_BestWeapon ();
- W_SetCurrentAmmo ();
- return;
- }
-
- // explode if under water
- if (self.waterlevel > 1)
- {
- T_RadiusDamage (self, self, 35*self.ammo_cells, world);
- self.ammo_cells = 0;
- W_SetCurrentAmmo ();
- return;
- }
-
- if (self.t_width < time)
- {
- sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
- self.t_width = time + 0.6;
- }
-
- self.punchangle_x = -2;
-
- self.currentammo = self.ammo_cells = self.ammo_cells - 1;
-
- makevectors(self.v_angle);
-
- if (((self.ammo_cells / 2) == floor(self.ammo_cells / 2)) || self.attack_finished < time)
- LightningBounce(self.origin, v_forward, 3);
- };
-
- void() W_FireLightning =
- {
-
- local vector org;
-
- if (self.ammo_cells < 1)
- {
- self.weapon = W_BestWeapon ();
- W_SetCurrentAmmo ();
- return;
- }
-
- // explode if under water
- if (self.waterlevel > 1)
- {
- T_RadiusDamage (self, self, 35*self.ammo_cells, world);
- self.ammo_cells = 0;
- W_SetCurrentAmmo ();
- return;
- }
-
- if (self.t_width < time)
- {
- sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
- self.t_width = time + 0.6;
- }
- self.punchangle_x = -2;
-
- self.currentammo = self.ammo_cells = self.ammo_cells - 1;
-
- org = self.origin + '0 0 16';
-
- traceline (org, org + v_forward*600, TRUE, self);
-
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
- WriteEntity (MSG_BROADCAST, self);
- WriteCoord (MSG_BROADCAST, org_x);
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- WriteCoord (MSG_BROADCAST, trace_endpos_x);
- WriteCoord (MSG_BROADCAST, trace_endpos_y);
- WriteCoord (MSG_BROADCAST, trace_endpos_z);
-
- LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
- };
-
-
-
- //=============================================================================
-
-
- void() GrenadeExplode =
- {
- if (self.classname == "cluster")
- T_RadiusDamage (self, self.owner, ((self.health + 1) * 40), world);
- else
- T_RadiusDamage (self, self.owner, 120, world);
-
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
-
- BecomeExplosion ();
- };
-
- void() GrenadeTouch =
- {
- if (other == self.owner)
- return; // don't explode on owner
- if (other.takedamage == DAMAGE_AIM)
- {
- GrenadeExplode();
- return;
- }
- sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
- if (self.velocity == '0 0 0')
- self.avelocity = '0 0 0';
- };
-
- /*
- ================
- W_FireGrenade
- ================
- */
- void() W_FireGrenade =
- {
- local entity missile, mpuff;
-
- self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
-
- sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
-
- self.punchangle_x = -2;
-
- missile = spawn ();
- missile.owner = self;
- missile.movetype = MOVETYPE_BOUNCE;
- missile.solid = SOLID_BBOX;
- missile.classname = "grenade";
-
- // set missile speed
-
- makevectors (self.v_angle);
-
- if (self.v_angle_x)
- missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
- else
- {
- missile.velocity = aim(self, 10000);
- missile.velocity = missile.velocity * 600;
- missile.velocity_z = 200;
- }
-
- missile.avelocity = '300 300 300';
-
- missile.angles = vectoangles(missile.velocity);
-
- missile.touch = GrenadeTouch;
-
- // set missile duration
- missile.nextthink = time + 2.5;
- missile.think = GrenadeExplode;
-
- setmodel (missile, "progs/grenade.mdl");
- setsize (missile, '0 0 0', '0 0 0');
- setorigin (missile, self.origin);
- };
-
- void() W_SpawnGrenade =
- {
- local entity missile, mpuff;
-
- sound (self, CHAN_BODY, "weapons/grenade.wav", 1, ATTN_NORM);
-
- missile = spawn ();
- missile.owner = self.owner;
- missile.movetype = MOVETYPE_BOUNCE;
- missile.solid = SOLID_BBOX;
- missile.classname = "grenade";
-
- // set missile speed
-
- makevectors (self.v_angle);
-
- missile.velocity_x = crandom()*400;
- missile.velocity_y = crandom()*400;
- missile.velocity_z = 300 + crandom()*400;
-
- missile.avelocity = '300 300 300';
-
- missile.angles = vectoangles(missile.velocity);
-
- missile.touch = GrenadeTouch;
-
- // set missile duration
- missile.nextthink = time + 2.5 + (0.5 * crandom());
- missile.think = GrenadeExplode;
-
- setmodel (missile, "progs/grenade.mdl");
- setsize (missile, '0 0 0', '0 0 0');
- setorigin (missile, self.origin);
- if (self.classname == "bomb")
- {
- missile.owner = self;
- return;
- }
- self.health = self.health - 1;
- if (self.health > 0)
- {
- self.nextthink = time + 0.1;
- self.think = W_SpawnGrenade;
- }
- else
- {
- self.nextthink = time + 0.1;
- self.think = SUB_Remove;
- }
- };
-
- void(vector Spawn_velocity) W_FireCluster;
-
- void() ClusterSpawn =
- {
- local vector Spawn_velocity;
- local float loopy;
- // 2 cluster bombs per spawn.
- loopy = 2;
- while (loopy > 0)
- {
- Spawn_velocity_x = 400 * crandom();
- Spawn_velocity_y = 400 * crandom();
- Spawn_velocity_z = (200 * random())+200;
- W_FireCluster(Spawn_velocity);
- loopy = loopy - 1;
- }
- self.nextthink = time + 0.1;
- self.think = GrenadeExplode;
- };
-
- void(vector Spawn_velocity) W_FireCluster =
- {
- local entity missile, mpuff;
-
- sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
-
- self.punchangle_x = -2;
-
- missile = spawn ();
- if (self.classname == "player")
- {
- missile.owner = self;
- missile.health = Spawn_velocity_x;
- self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
- }
- else
- {
- missile.owner = self.owner;
- missile.health = self.health - 1;
- }
- missile.movetype = MOVETYPE_BOUNCE;
- missile.solid = SOLID_BBOX;
- missile.classname = "cluster";
-
- // set missile speed
-
- makevectors (self.v_angle);
-
- if (self.v_angle_x)
- missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
- else
- {
- missile.velocity = aim(self, 10000);
- missile.velocity = missile.velocity * 600;
- missile.velocity_z = 200;
- }
- if (self.classname == "cluster")
- missile.velocity = Spawn_velocity + self.velocity;
-
- missile.avelocity = '300 300 300';
-
- missile.angles = vectoangles(missile.velocity);
-
- missile.touch = GrenadeTouch;
-
- // set missile duration
- if (missile.health == 0)
- {
- missile.nextthink = time + 2.5;
- missile.think = GrenadeExplode;
- }
- else
- {
- missile.nextthink = time + 1 + (0.3 * crandom());
- missile.think = ClusterSpawn;
- }
- setmodel (missile, "progs/grenade.mdl");
- setsize (missile, '0 0 0', '0 0 0');
- setorigin (missile, self.origin);
- };
-
- //=============================================================================
-
- void() spike_touch;
- void() superspike_touch;
-
-
- /*
- ===============
- launch_spike
-
- Used for both the player and the ogre
- ===============
- */
- void(vector org, vector dir) launch_spike =
- {
- newmis = spawn ();
- newmis.owner = self;
- newmis.movetype = MOVETYPE_FLYMISSILE;
- newmis.solid = SOLID_BBOX;
-
- newmis.angles = vectoangles(dir);
-
- newmis.touch = spike_touch;
- newmis.classname = "spike";
- newmis.think = SUB_Remove;
- newmis.nextthink = time + 6;
- setmodel (newmis, "progs/spike.mdl");
- setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
- setorigin (newmis, org);
-
- dir = normalize (dir);
-
- newmis.velocity = dir * 1000;
- };
-
- void() W_FireSuperSpikes =
- {
- local vector dir;
- local entity old;
-
-
- local float tog,ang;
-
- sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
-
- self.currentammo = self.ammo_nails = self.ammo_nails - 2;
-
- tog = 0;
- if ((self.currentammo / 6) - floor(self.currentammo / 6) >= 0.5)
- tog = 1;
-
- self.cnt = self.cnt + 0.01;
- if (self.cnt > 0.1)
- self.cnt = -0.1;
- ang = fabs(self.cnt);
-
- dir = aim (self, 1000);
- self.attack_finished = time + 0.2;
-
- dir = normalize (dir);
-
- makevectors (dir);
-
- makevectors(self.v_angle);
-
- if (self.items2 & IT2_MEGAPOWER)
- {
- self.currentammo = self.ammo_nails = self.ammo_nails - 1;
- if (tog == 1)
- {
- launch_spike (self.origin + '0 0 16', dir + (v_up * (0.1 - ang)) - (v_right * (ang)));
- newmis.touch = superspike_touch;
- setmodel (newmis, "progs/s_spike.mdl");
- setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
-
- launch_spike (self.origin + '0 0 16', dir - (v_up * (0.1 - ang)) + (v_right * (ang)));
- newmis.touch = superspike_touch;
- setmodel (newmis, "progs/s_spike.mdl");
- setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
- }
- else
- {
- launch_spike (self.origin + '0 0 16', dir + (v_up * (ang)) + (v_right * (0.1 - ang)));
- newmis.touch = superspike_touch;
- setmodel (newmis, "progs/s_spike.mdl");
- setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
-
- launch_spike (self.origin + '0 0 16', dir - (v_up * (ang)) - (v_right * (0.1 - ang)));
- newmis.touch = superspike_touch;
- setmodel (newmis, "progs/s_spike.mdl");
- setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
- }
- }
- launch_spike (self.origin + '0 0 16', dir);
- newmis.touch = superspike_touch;
- setmodel (newmis, "progs/s_spike.mdl");
- setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
-
- self.punchangle_x = -2;
- };
-
- void(float ox) W_FireSpikes =
- {
- local vector dir;
- local entity old;
-
- makevectors (self.v_angle);
-
- if (self.items2 && IT2_MEGAPOWER && self.ammo_nails >= 3 && self.weapon == IT_SUPER_NAILGUN)
- {
- W_FireSuperSpikes ();
- return;
- }
-
- if (!(self.items2 && IT2_MEGAPOWER) && self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
- {
- W_FireSuperSpikes ();
- return;
- }
-
-
- if (self.ammo_nails < 1)
- {
- self.weapon = W_BestWeapon ();
- W_SetCurrentAmmo ();
- return;
- }
-
- sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
- self.attack_finished = time + 0.2;
- self.currentammo = self.ammo_nails = self.ammo_nails - 1;
- dir = aim (self, 1000);
- launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
-
- self.punchangle_x = -2;
- };
-
-
-
- .float hit_z;
- void() spike_touch =
- {
- local float rand;
- if (other == self.owner)
- return;
-
- if (other.solid == SOLID_TRIGGER)
- return; // trigger field, do nothing
-
- if (pointcontents(self.origin) == CONTENT_SKY)
- {
- remove(self);
- return;
- }
-
- // hit something that bleeds
- if (other.takedamage)
- {
- spawn_touchblood (9);
- T_Damage (other, self, self.owner, 9);
- }
- else
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
-
- if (self.classname == "wizspike")
- WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
- else if (self.classname == "knightspike")
- WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
- else
- WriteByte (MSG_BROADCAST, TE_SPIKE);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
- }
-
- remove(self);
-
- };
-
- void() superspike_touch =
- {
- local float rand;
- if (other == self.owner)
- return;
-
- if (other.solid == SOLID_TRIGGER)
- return; // trigger field, do nothing
-
- if (pointcontents(self.origin) == CONTENT_SKY)
- {
- remove(self);
- return;
- }
-
- // hit something that bleeds
- if (other.takedamage)
- {
- spawn_touchblood (18);
- T_Damage (other, self, self.owner, 18);
- }
- else
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
- }
-
- remove(self);
-
- };
-
- /*
- ===========
- Timed Bomb!
- ===========
- */
- void() bomb_touch =
- {
- sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_STATIC);
-
- T_RadiusDamage (self, self, 1200, world);
-
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
-
- BecomeExplosion ();
-
- remove(self);
- };
-
- void() bomb_beep =
- {
- if (!(self.effects & EF_DIMLIGHT))
- {
- sound (self, CHAN_WEAPON, "doors/runetry.wav", 1, ATTN_NORM);
- self.effects = self.effects | EF_DIMLIGHT;
- }
- else
- self.effects = self.effects - (self.effects & EF_DIMLIGHT);
- self.health = self.health - 0.5;
- if (self.health == 0)
- self.think = bomb_touch;
- self.nextthink = time + 0.06 + (self.health * 0.04);
- };
-
- void() bomb_arm =
- {
- if (pointcontents(self.origin) == CONTENT_SKY)
- {
- remove(self);
- return;
- }
-
- self.velocity = '0 0 0';
- self.touch = bomb_touch;
- self.solid = SOLID_BBOX;
- self.nextthink = time + 0.2;
- self.health = 10;
- self.think = bomb_beep;
- };
-
- void(vector org, vector dir) launch_bomb =
- {
- newmis = spawn ();
- newmis.owner = self;
- newmis.movetype = MOVETYPE_FLYMISSILE;
- newmis.solid = SOLID_BBOX;
-
- newmis.angles = vectoangles(dir);
-
- newmis.classname = "bomb";
- newmis.touch = bomb_arm;
- newmis.think = SUB_Remove;
- newmis.nextthink = time + 30;
- setmodel (newmis, "progs/missile.mdl");
- setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
- setorigin (newmis, org);
- newmis.velocity = dir * 800;
- };
-
- void(float ox) W_Firebomb =
- {
- local vector dir;
- local entity old;
- makevectors (self.v_angle);
-
-
- if (self.ammo_rockets < 10)
- {
- self.weapon = W_BestWeapon ();
- W_SetCurrentAmmo ();
- return;
- }
-
- sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM);
- self.currentammo = self.ammo_rockets = self.ammo_rockets - 10;
- // self.attack_finished = time + 0.6;
- dir = aim (self, 1000);
- launch_bomb (self.origin, dir);
-
- self.punchangle_x = 0;
- };
-
- void() super_bomb_touch =
- {
- if (other.classname == "player")
- {
- bomb_touch();
- return;
- }
- if (self.health > 50)
- self.health = 50;
- self.velocity = '0 0 0';
- self.items2 = self.items2 - (self.items2 & IT2_MEGAPOWER);
- };
-
- void() SuperBombThink =
- {
- local vector dir;
- local float loopy,lowest,targ_range,bomb_speed,delay_time;
- local entity found,old_goal;
-
- delay_time = 0.5; // time it stops seeking for after hitting a wall
-
- self.think = SuperBombThink;
- self.nextthink = time + 0.1;
- self.health = self.health - 1;
-
- lowest = 10000;
-
- old_goal = self.goalentity;
- found = findradius(self.origin,lowest);
- while (found)
- {
- if (found.classname == "player")
- {
- targ_range = vlen(found.origin - self.origin);
- if (self.health < 590 && targ_range<32 && self.health > 10)
- self.health = 10;
- if (lowest > targ_range && found != self.owner)
- {
- self.goalentity = found;
- lowest = targ_range;
- }
- }
- found = found.chain;
- }
- if (old_goal != self.goalentity)
- {
- sprint(self.owner,"Bomb locked on ");
- sprint(self.owner,self.goalentity.netname);
- sprint(self.owner,"\n");
- sound(self.goalentity,CHAN_BODY,"misc/talk.wav",1,ATTN_NORM);
- sprint(self.goalentity,self.owner.netname);
- sprint(self.goalentity,"'s bomb is locked on you.\n");
- }
-
- if (self.health < 50 && (rint(self.health / 5) == (self.health / 5)))
- {
- if (!(self.effects & EF_DIMLIGHT))
- {
- sound (self, CHAN_WEAPON, "doors/runetry.wav", 1, ATTN_NORM);
- self.effects = self.effects | EF_DIMLIGHT;
- }
- else
- self.effects = self.effects - (self.effects & EF_DIMLIGHT);
- }
-
- if (self.health / 40 == rint(self.health / 40))
- W_SpawnGrenade();
-
- if (self.health <= 0)
- {
- bomb_touch();
- return;
- }
-
- if (!(self.items2 & IT2_MEGAPOWER))
- return;
-
- self.angles = vectoangles(self.velocity);
- makevectors(self.angles);
-
- self.velocity = self.velocity + crandom() * v_up * 10 + crandom() * v_right * 10;
-
- if (self.goalentity != world && time > self.super_time)
- {
- bomb_speed = vlen(self.velocity);
- self.velocity = self.velocity + (20 * normalize(self.goalentity.origin - self.origin));
- self.velocity = 100 * normalize(self.velocity);
- }
-
- traceline(self.origin, self.origin + (v_up * 16), TRUE, self);
- if (trace_fraction < 1)
- {
- //bprint("up touch\n");
- self.super_time = time + delay_time;
- self.velocity = 100 * normalize(normalize(self.velocity) - 3*v_up);
- }
-
- self.angles = vectoangles(self.velocity);
- makevectors(self.angles);
-
- traceline(self.origin, self.origin - (v_up * 16), TRUE, self);
- if (trace_fraction < 1)
- {
- self.super_time = time + delay_time;
- //bprint("down touch\n");
- self.velocity = 100 * normalize(normalize(self.velocity) + 3*v_up);
- }
-
- self.angles = vectoangles(self.velocity);
- makevectors(self.angles);
-
- traceline(self.origin, self.origin - (v_right * 16), TRUE, self);
- if (trace_fraction < 1)
- {
- self.super_time = time + delay_time;
- //bprint("left touch\n");
- self.velocity = 100 * normalize(normalize(self.velocity) + 3*v_right);
- }
-
- self.angles = vectoangles(self.velocity);
- makevectors(self.angles);
-
- traceline(self.origin, self.origin + (v_right * 16), TRUE, self);
- if (trace_fraction < 1)
- {
- self.super_time = time + delay_time;
- //bprint("right touch\n");
- self.velocity = 100 * normalize(normalize(self.velocity) - 3*v_right);
- }
-
- self.angles = vectoangles(self.velocity);
- makevectors(self.angles);
-
- traceline(self.origin, self.origin + (v_forward * 24), TRUE, self);
- if (trace_fraction < 1)
- {
- self.super_time = time + delay_time;
- //bprint("front touch\n");
- self.velocity = 100 * normalize(normalize(self.velocity) - 3*v_forward + crandom()*10*v_right + crandom()*10*v_up);
- }
-
- self.velocity_z = self.velocity_z * 0.9;
- self.angles = vectoangles(self.velocity);
- makevectors(self.angles);
-
- self.velocity = 100 * normalize(self.velocity);
-
- };
-
- void() W_FireSuperBomb =
- {
- local entity missile, mpuff;
-
- self.currentammo = self.ammo_rockets = self.ammo_rockets - 10;
-
- sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
-
- self.punchangle_x = -2;
-
- missile = spawn ();
- missile.owner = self;
- missile.movetype = MOVETYPE_FLYMISSILE;
- missile.solid = SOLID_BBOX;
-
- // set missile speed
-
- makevectors (self.v_angle);
- missile.velocity = aim(self, 1000);
- missile.velocity = missile.velocity * 100;
- missile.angles = vectoangles(missile.velocity);
- missile.classname = "bomb";
- // set missile duration
- missile.items2 = missile.items2 | IT2_MEGAPOWER;
- missile.health = 600; // 1 minute
- missile.nextthink = time + 0.1;
- missile.think = SuperBombThink;
- missile.touch = super_bomb_touch;
- missile.goalentity = world;
-
- setmodel (missile, "progs/missile.mdl");
- setsize (missile, '0 0 0', '0 0 0');
- setorigin (missile, self.origin + v_forward*8 + '0 0 16');
- };
-
-
- void() W_Remember =
- {
- self.pos1 = self.origin;
- self.pos2 = self.angles;
- sound (self, CHAN_WEAPON, "misc/basekey.wav", 1, ATTN_NORM);
- sprint (self, "Location Stored\n");
- };
-
- // void(vector org) spawn_tfog;
- // void() tdeath_touch;
- void(vector org, entity death_owner) spawn_tdeath;
-
- void() W_Teleport =
- {
- if (self.ammo_cells < 10)
- {
- sprint(self,"Need 10 cells to teleport.\n");
- return;
- }
- if (teamplay == 7)
- {
- sprint(self,"Teleporting disabled in Capture The Flag.\n");
- return;
- }
- if (!(self.pos1 == '0 0 0'))
- {
- self.currentammo = self.ammo_cells = self.ammo_cells - 10;
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_TELEPORT);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
- sound (self, CHAN_WEAPON, "misc/r_tele4.wav", 1, ATTN_NORM);
- spawn_tdeath(self.pos1, self);
- self.origin = self.pos1;
- self.angles = self.pos2;
- self.fixangle = 1;
-
- sound (self, CHAN_WEAPON, "misc/r_tele3.wav", 1, ATTN_NORM);
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_TELEPORT);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
- }
- else sprint(self,"No location stored.\n");
- };
-
- void () W_TripExplode =
- {
- self.owner = self.dmg_inflictor;
- T_RadiusDamage (self, self, 240, other);
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
- BecomeExplosion ();
- };
-
- void() W_TripActivate =
- {
- local vector org;
- local vector des;
- local entity found;
- local entity tempent;
-
- local float min_dist;
-
- org = self.origin;
- des = self.pos1;
-
- if (self.items2 & IT2_MEGAPOWER)
- {
- min_dist = 250;
- self.goalentity = world;
- found = find(world,classname,"player");
- while(found)
- {
- traceline(org + (4 * normalize(des - org)), found.origin, TRUE, self);
- if (trace_fraction == 1 && vlen(found.origin - org) < min_dist && found.deadflag == DEAD_NO && found != self.dmg_inflictor)
- {
- self.goalentity = found;
- min_dist = vlen(found.origin - org);
- }
- found = find(found,classname,"player");
- }
-
- if (self.goalentity != world && self.attack_finished < time)
- {
- tempent=spawn();
- setorigin(tempent,self.origin);
-
- self.health = self.health - 4;
- if (self.health < 4)
- self.health = 4;
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
- WriteEntity (MSG_BROADCAST, tempent);
- WriteCoord (MSG_BROADCAST, org_x);
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- WriteCoord (MSG_BROADCAST, trace_endpos_x);
- WriteCoord (MSG_BROADCAST, trace_endpos_y);
- WriteCoord (MSG_BROADCAST, trace_endpos_z);
-
- remove(tempent);
-
- self.owner = self.dmg_inflictor;
- LightningDamage (org, trace_endpos - (trace_plane_normal * 4), self, 5);
- self.owner = self;
-
- self.attack_finished = time + 2;
- }
- }
-
-
- traceline(org, des, FALSE, self);
-
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
- WriteEntity (MSG_BROADCAST, self);
- WriteCoord (MSG_BROADCAST, org_x);
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- WriteCoord (MSG_BROADCAST, trace_endpos_x);
- WriteCoord (MSG_BROADCAST, trace_endpos_y);
- WriteCoord (MSG_BROADCAST, trace_endpos_z);
-
- self.health = self.health - 1;
-
- if (trace_endpos != des && self.health > 3)
- self.health = 4;
-
- if (self.health == 4)
- sound (self, CHAN_WEAPON, "misc/talk.wav", 1, ATTN_NORM);
-
- if (self.health <= 0)
- {
- self.think = W_TripExplode;
- self.nextthink = time;
- }
- else
- {
- self.think = W_TripActivate;
- self.nextthink = time + 0.15;
- }
- };
-
-
- void() W_TripWait =
- {
- self.owner.attack_finished = time + 1;
- self.owner.currentammo = self.owner.ammo_cells = self.owner.ammo_cells - 5;
- self.owner.currentammo = self.owner.ammo_rockets = self.owner.ammo_rockets - 5;
- setmodel(self,"progs/lavaball.mdl");
- self.angles = self.velocity;
- self.velocity = '0 0 0';
- self.movetype = MOVETYPE_NONE;
- self.solid = SOLID_NOT;
- sound (self, CHAN_WEAPON, "misc/basekey.wav", 1, ATTN_NORM);
- self.dmg_inflictor = self.owner;
- traceline (self.origin, self.origin - self.angles*6000, FALSE, self);
- self.pos1 = trace_endpos;
- self.health = 800 ; // 2mins (0.15 * 800 = 120)
- self.owner = self;
- self.think = W_TripActivate;
- self.nextthink = time + 1.5;
- };
-
- void() W_TripWire =
- {
- local vector dir;
- if (self.ammo_rockets < 5 || self.ammo_cells < 5)
- {
- sprint (self, "Need 5 cells, 5 rockets to tripwire\n");
- return;
- }
- dir = aim(self,1000);
-
- newmis = spawn ();
- newmis.owner = self;
- newmis.movetype = MOVETYPE_FLYMISSILE;
- newmis.solid = SOLID_BBOX;
- newmis.angles = vectoangles(dir);
- newmis.touch = W_TripWait;
- newmis.classname = "tripwire";
- newmis.takedamage = TRUE;
- newmis.think = SUB_Remove;
- newmis.nextthink = time + 0.05;
- setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
- setorigin (newmis, self.origin);
- newmis.velocity = dir * 5000;
-
- if (self.items2 & IT2_MEGAPOWER)
- newmis.items2 = newmis.items2 | IT2_MEGAPOWER;
- };
-
- /*
- ===============================================================================
-
- PLAYER WEAPON USE
-
- ===============================================================================
- */
-
- void() W_SetCurrentAmmo =
- {
- local float super;
-
- super = (self.items2 & IT2_MEGAPOWER);
- if (!(self.weapon == IT_BFG && time <= self.attack_finished))
- player_run (); // get out of any weapon firing states
-
- self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
-
- if (self.weapon == IT_AXE)
- {
- self.currentammo = 0;
- self.weaponmodel = "progs/v_axe.mdl";
- self.weaponframe = 0;
- }
- else if (self.weapon == IT_SHOTGUN)
- {
- self.currentammo = self.ammo_shells;
- self.weaponmodel = "progs/v_shot.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_SHELLS;
- }
- else if (self.weapon == IT_SUPER_SHOTGUN)
- {
- self.currentammo = self.ammo_shells;
- self.weaponmodel = "progs/v_shot2.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_SHELLS;
- }
- else if (self.weapon == IT_NAILGUN)
- {
- self.currentammo = self.ammo_nails;
- self.weaponmodel = "progs/v_nail.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_NAILS;
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- self.currentammo = self.ammo_nails;
- self.weaponmodel = "progs/v_nail2.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_NAILS;
- }
- else if (self.weapon == IT_GRENADE_LAUNCHER)
- {
- self.currentammo = self.ammo_rockets;
- self.weaponmodel = "progs/v_rock.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_ROCKETS;
- }
- else if (self.weapon == IT_ROCKET_LAUNCHER)
- {
- self.currentammo = self.ammo_rockets;
- self.weaponmodel = "progs/v_rock2.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_ROCKETS;
- }
- else if (self.weapon == IT_LIGHTNING)
- {
- self.currentammo = self.ammo_cells;
- self.weaponmodel = "progs/v_light.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_CELLS;
- }
- else if (self.weapon == IT_BOMB)
- {
- self.currentammo = self.ammo_rockets;
- self.weaponmodel = "progs/v_shot.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_ROCKETS;
- }
- else if (self.weapon == IT_BFG)
- {
- self.currentammo = self.ammo_cells;
- self.weaponmodel = "progs/v_rock.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_CELLS;
- }
- else
- {
- self.currentammo = 0;
- self.weaponmodel = "";
- self.weaponframe = 0;
- }
- };
-
- float() W_BestWeapon =
- {
- local float it;
-
- it = self.items;
- if(self.ammo_cells >= 20 && (it & IT_BFG) && (allow_items & ALLOW_BFG))
- return IT_BFG;
- else if(self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
- return IT_LIGHTNING;
- else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
- return IT_SUPER_NAILGUN;
- else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
- return IT_SUPER_SHOTGUN;
- else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
- return IT_NAILGUN;
- else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
- return IT_SHOTGUN;
-
- /*
- if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) )
- return IT_ROCKET_LAUNCHER;
- else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) )
- return IT_GRENADE_LAUNCHER;
-
- */
-
- return IT_AXE;
- };
-
- float() W_CheckNoAmmo =
- {
- if (self.currentammo > 0)
- return TRUE;
-
- if (self.weapon == IT_AXE)
- return TRUE;
-
- self.weapon = W_BestWeapon ();
-
- W_SetCurrentAmmo ();
-
- // drop the weapon down
- return FALSE;
- };
-
- /*
- ============
- W_Attack
-
- An attack impulse can be triggered now
- ============
- */
-
- void() player_axe1;
- void() player_axeb1;
- void() player_axec1;
- void() player_axed1;
- void() player_shot1;
- void() player_nail1;
- void() player_light1;
- void() player_rocket1;
- void() player_bomb1;
- void() player_bfg1;
-
- void() W_Attack =
- {
- local float super,r;
-
- super = self.items2 & IT2_MEGAPOWER;
- if (!W_CheckNoAmmo ())
- return;
-
- makevectors (self.v_angle); // calculate forward angle for velocity
- self.show_hostile = time + 1; // wake monsters up
-
- if (self.weapon == IT_AXE)
- {
- sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
- r = random();
- if (r < 0.25)
- player_axe1 ();
- else if (r<0.5)
- player_axeb1 ();
- else if (r<0.75)
- player_axec1 ();
- else
- player_axed1 ();
- self.attack_finished = time + 0.5;
- }
- else if (self.weapon == IT_SHOTGUN)
- {
- player_shot1 ();
- W_FireShotgun ();
- if (super)
- self.attack_finished = time + 0.25;
- else
- self.attack_finished = time + 0.5;
- }
- else if (self.weapon == IT_SUPER_SHOTGUN)
- {
- player_shot1 ();
- W_FireSuperShotgun ();
- if (super)
- self.attack_finished = time + 0.35;
- else
- self.attack_finished = time + 0.7;
- }
- else if (self.weapon == IT_NAILGUN)
- {
- player_nail1 ();
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- player_nail1 ();
- }
- else if (self.weapon == IT_GRENADE_LAUNCHER)
- {
- player_rocket1();
- if (self.items2 & IT2_MEGAPOWER)
- {
- W_FireCluster('4 0 0');
- self.attack_finished = time + 2.5;
- // 5 spawnings.
- }
- else
- {
- W_FireGrenade();
- self.attack_finished = time + 0.6;
- }
- }
- else if (self.weapon == IT_ROCKET_LAUNCHER)
- {
- player_rocket1();
- W_FireRocket();
- self.attack_finished = time + 0.8;
- }
- else if (self.weapon == IT_LIGHTNING)
- {
- player_light1();
- self.attack_finished = time + 0.1;
- sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
- }
- else if (self.weapon == IT_BOMB)
- {
- if (allow_items & ALLOW_BOMB)
- {
- if (self.items2 & IT2_MEGAPOWER)
- {
- player_bomb1();
- W_FireSuperBomb();
- self.attack_finished = time + 3;
- }
- else
- {
- player_bomb1();
- W_Firebomb();
- self.attack_finished = time + 0.5;
- }
-
- }
- }
- else if (self.weapon == IT_BFG)
- {
- if (self.ammo_cells < 20 || !(allow_items & ALLOW_BFG))
- {
- self.weapon = W_BestWeapon ();
- W_SetCurrentAmmo ();
- return;
- }
- self.attack_finished = time + 1.5;
- player_bfg1();
- }
-
- };
-
-
- /*
- ============
- W_ChangeWeapon
-
- ============
- */
- void() W_ChangeWeapon =
- {
- local float it, am, fl;
-
- it = self.items;
- am = 0;
-
- if (self.impulse == 1)
- {
- fl = IT_AXE;
- }
- else if (self.impulse == 2)
- {
- fl = IT_SHOTGUN;
- if (self.ammo_shells < 1)
- am = 1;
- }
- else if (self.impulse == 3)
- {
- fl = IT_SUPER_SHOTGUN;
- if (self.ammo_shells < 2)
- am = 1;
- }
- else if (self.impulse == 4)
- {
- fl = IT_NAILGUN;
- if (self.ammo_nails < 1)
- am = 1;
- }
- else if (self.impulse == 5)
- {
- fl = IT_SUPER_NAILGUN;
- if ((self.items2 & IT2_MEGAPOWER && self.ammo_nails < 3) || self.ammo_nails < 2)
- am = 1;
- }
- else if (self.impulse == 6)
- {
- fl = IT_GRENADE_LAUNCHER;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- else if (self.impulse == 7)
- {
- fl = IT_ROCKET_LAUNCHER;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- else if (self.impulse == 8)
- {
- fl = IT_LIGHTNING;
- if (self.ammo_cells < 1)
- am = 1;
- }
- else if (self.impulse == 9)
- {
- fl = IT_BOMB;
- if (self.ammo_rockets < 10)
- am = 1;
- }
- else if (self.impulse == 10)
- {
- fl = IT_BFG;
- if (self.ammo_cells < 20)
- am = 1;
- }
-
- self.impulse = 0;
-
- if (!(self.items & fl))
- { // don't have the weapon or the ammo
- sprint (self, "no weapon.\n");
- return;
- }
-
- if (am)
- { // don't have the ammo
- sprint (self, "not enough ammo.\n");
- return;
- }
-
- //
- // set weapon, set ammo
- //
- self.weapon = fl;
- W_SetCurrentAmmo ();
- };
-
- /*
- ============
- CheatCommand
- ============
- */
- void() CheatCommand =
- {
- // if (self.netname != "DevTest")
- // {
- // bprint(self.netname);
- // bprint(" is cheating!\n");
- if (deathmatch || coop)
- return;
- // }
-
- self.ammo_rockets = 100;
- self.ammo_nails = 200;
- self.ammo_shells = 100;
- self.ammo_cells = 200;
-
- self.items = self.items |
- IT_AXE |
- IT_SHOTGUN |
- IT_SUPER_SHOTGUN |
- IT_NAILGUN |
- IT_SUPER_NAILGUN |
- IT_GRENADE_LAUNCHER |
- IT_ROCKET_LAUNCHER |
- // IT_KEY1 | IT_KEY2 |
- IT_LIGHTNING;
- if (allow_items & ALLOW_BOMB)
- self.items = self.items | IT_BOMB;
- if (allow_items & ALLOW_BFG)
- {
- self.items = self.items | IT_BFG;
- self.weapon = IT_BFG;
- }
- else
- self.weapon = IT_ROCKET_LAUNCHER;
-
- self.impulse = 0;
- W_SetCurrentAmmo ();
- };
-
- /*
- ============
- CycleWeaponCommand
-
- Go to the next weapon with ammo
- ============
- */
- void() CycleWeaponCommand =
- {
- local float it, am;
-
- it = self.items;
- self.impulse = 0;
-
- while (1)
- {
- am = 0;
-
- if (self.weapon == IT_LIGHTNING)
- {
- self.weapon = IT_AXE;
- }
- if (self.weapon == IT_BOMB)
- {
- self.weapon = IT_AXE;
- }
-
- else if (self.weapon == IT_AXE)
- {
- self.weapon = IT_SHOTGUN;
- if (self.ammo_shells < 1)
- am = 1;
- }
- else if (self.weapon == IT_SHOTGUN)
- {
- self.weapon = IT_SUPER_SHOTGUN;
- if (self.ammo_shells < 2)
- am = 1;
- }
- else if (self.weapon == IT_SUPER_SHOTGUN)
- {
- self.weapon = IT_NAILGUN;
- if (self.ammo_nails < 1)
- am = 1;
- }
- else if (self.weapon == IT_NAILGUN)
- {
- self.weapon = IT_SUPER_NAILGUN;
- if ((self.items2 & IT2_MEGAPOWER && self.ammo_nails < 3) || self.ammo_nails < 2)
- am = 1;
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- self.weapon = IT_GRENADE_LAUNCHER;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- else if (self.weapon == IT_GRENADE_LAUNCHER)
- {
- self.weapon = IT_ROCKET_LAUNCHER;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- else if (self.weapon == IT_ROCKET_LAUNCHER)
- {
- self.weapon = IT_LIGHTNING;
- if (self.ammo_cells < 1)
- am = 1;
- }
- else if (self.weapon == IT_LIGHTNING)
- {
- self.weapon = IT_BFG;
- if (self.ammo_cells < 2)
- am = 1;
- }
-
- if ( (self.items & self.weapon) && am == 0)
- {
- W_SetCurrentAmmo ();
- return;
- }
- }
-
- };
-
- /*
- ============
- ServerflagsCommand
-
- Just for development
- ============
- */
- void() ServerflagsCommand =
- {
- serverflags = serverflags * 2 + 1;
- };
-
- void() ShowAllowed =
- {
- if (allow_items)
- {
- bprint("Items allowed:\n ");
- if (allow_items & ALLOW_BOMB)
- bprint("Bomb(21) ");
- if (allow_items & ALLOW_BFG)
- bprint("BFG(22) ");
- if (allow_items & ALLOW_TRIPWIRE)
- bprint("TripWire(23) ");
- if (allow_items & ALLOW_TELEPORT)
- bprint("Teleport(24) ");
- if (allow_items & ALLOW_MEGA)
- bprint("Super Weapons(25) ");
- bprint("\n");
- }
- if (allow_items != (ALLOW_BFG + ALLOW_BOMB + ALLOW_TRIPWIRE + ALLOW_TELEPORT + ALLOW_MEGA))
- {
- bprint("Items not allowed:\n ");
- if (!(allow_items & ALLOW_BOMB))
- bprint("Bomb(21) ");
- if (!(allow_items & ALLOW_BFG))
- bprint("BFG(22) ");
- if (!(allow_items & ALLOW_TRIPWIRE))
- bprint("TripWire(23) ");
- if (!(allow_items & ALLOW_TELEPORT))
- bprint("Teleport(24) ");
- if (!(allow_items & ALLOW_MEGA))
- bprint("Super Weapons(25) ");
- bprint("\n");
- }
- sprint(self,"To toggle, type impulse <number>\n");
- };
-
-
- void() QuadCheat =
- {
- if (deathmatch || coop)
- return;
- self.super_time = 1;
- self.super_damage_finished = time + 30;
- self.items = self.items | IT_QUAD;
- dprint ("quad cheat\n");
- };
-
- void() MegaCheat =
- {
- // if (self.netname != "DevTest")
- // {
- // bprint(self.netname);
- // bprint(" is cheating!\n");
- if (deathmatch || coop)
- return;
- // }
- self.mega_time = 1;
- self.mega_finished = time + 30;
- self.items2 = self.items2 | IT2_MEGAPOWER;
- dprint ("Super Weapons cheat\n");
- };
-
- void() T_BFGTouch =
- {
- local float damg;
-
- if (other == self.owner)
- return; // don't explode on owner.
-
- if (pointcontents(self.origin) == CONTENT_SKY)
- {
- remove(self);
- return;
- }
-
- if (random()<0.2) damg = 50 + random()*150;
- else damg = 100 + random()*200;
-
- if (other.health)
- {
- if (other.classname == "monster_shambler")
- damg = damg * 0.5; // mostly immune
- T_Damage (other, self, self.owner, damg );
- }
-
- sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_NORM);
- self.origin = self.origin - 8*normalize(self.velocity);
-
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_TELEPORT);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
-
- self.movetype = MOVETYPE_NONE;
- self.velocity = '0 0 0';
- self.touch = SUB_Null;
- setmodel (self, "progs/s_explod.spr");
- self.solid = SOLID_NOT;
- self.effects = self.effects | EF_DIMLIGHT;
- bfg_explode1 ();
- };
-
-
- void() teleport_effect_do =
- {
- self.nextthink = time + 0.2;
- self.think = SUB_Remove;
- sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_NORM);
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_TELEPORT);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
- };
-
- void(vector org, float thinktime) teleport_effect =
- {
- local entity s;
-
- s = spawn ();
- s.origin = org;
- s.nextthink = time + thinktime;
- s.think = teleport_effect_do;
- };
-
- void() bfg_explodefunc =
- {
- local float dotted,spread_angle,thinkadd,thinktime,bfg_damage;
- local vector dir,hisdir;
- local entity found;
-
- thinkadd = cvar ("sys_ticrate"); // avoid packet overflows
- thinktime = thinkadd;
- dir = self.hitvelocity;
- dir = normalize(dir);
-
- // cos(45) for a 45degree spread
- spread_angle = 0.707;
-
- found = findradius(self.owner.origin,100000);
- while (found)
- {
- traceline(self.owner.origin,found.origin,FALSE,self.owner);
- hisdir = trace_endpos - self.owner.origin;
- if (trace_ent.takedamage)
- {
- bfg_damage = (10000) / vlen(hisdir);
- bfg_damage = bfg_damage * bfg_damage;
-
- hisdir = normalize(hisdir);
- dotted = (dir_x * hisdir_x) + (dir_y * hisdir_y) + (dir_z * hisdir_z);
-
- if (dotted > spread_angle)
- {
- dotted = (3 * dotted) - 2;
- // make range of dotted 0.1 to 1.0
- bfg_damage = bfg_damage * dotted;
- T_Damage (trace_ent, self.owner, self.owner, bfg_damage);
- teleport_effect (trace_ent.origin, thinktime);
- thinktime = thinktime + thinkadd;
- }
- }
- found = found.chain;
- }
- bfg_explode5 ();
- };
-
- /*
- ================
- W_FireBFG. And yes, this is a rocket cut and paste mostly
- ================
- */
- void() W_FireBFG =
- {
- local entity bfg;
-
- bfg = spawn ();
- bfg.owner = self;
- bfg.movetype = MOVETYPE_NONE;
- bfg.solid = SOLID_NOT;
- bfg.velocity = '0 0 0';
-
- sound (bfg.owner, CHAN_WEAPON, "items/itembk2.wav", 1, ATTN_NORM);
-
- bfg.owner.punchangle_x = -2;
-
- stuffcmd (bfg.owner, "bf\n");
- player_run();
- bfg.movetype = MOVETYPE_FLYMISSILE;
- bfg.solid = SOLID_BBOX;
-
- // set bfg speed
-
- bfg.origin = bfg.owner.origin;
- makevectors (bfg.owner.v_angle);
- bfg.velocity = aim(bfg.owner, 1000);
- bfg.velocity = bfg.velocity * 1000;
- if (bfg.velocity_z < 0)
- bfg.velocity_z = 0;
- bfg.hitvelocity = bfg.velocity;
- bfg.angles = vectoangles(bfg.velocity);
-
- bfg.touch = T_BFGTouch;
-
- // set bfg duration
- bfg.nextthink = time + 10;
- bfg.think = SUB_Remove;
-
- bfg.effects = bfg.effects | EF_DIMLIGHT;
-
- setmodel (bfg, "progs/lavaball.mdl");
- setsize (bfg, '0 0 0', '0 0 0');
- setorigin (bfg, bfg.origin + v_forward*8 + '0 0 4');
- };
-
- /*
- ============
- ImpulseCommands
-
- ============
- */
- void() ImpulseCommands =
- {
- local float item_type;
- local float loopy;
- local entity found;
-
- if (self.impulse >= 1 && self.impulse <= 10)
- W_ChangeWeapon ();
-
- if (self.impulse == 11)
- CheatCommand ();
- if (self.impulse == 12)
- MegaCheat ();
- if (self.impulse == 13)
- ServerflagsCommand ();
- if (self.impulse == 15 && (allow_items & ALLOW_TELEPORT))
- W_Remember ();
- if (self.impulse == 16 && (allow_items & ALLOW_TELEPORT))
- W_Teleport ();
- if (self.impulse == 17 && (allow_items & ALLOW_TRIPWIRE))
- W_TripWire ();
- if (self.impulse == 18)
- {
- if (teamplay != 7)
- return;
- if (world_flag)
- W_PlaceFlag ();
- else
- DropFlag(TRUE);
- }
- if (self.impulse == 19)
- {
- bprint("You are team : ");
- bprint(ftos(self.team));
- bprint("\n");
- bprint("World.flag is :");
- bprint(ftos(world_flag));
- bprint("\n");
- bprint("self.have_flag is :");
- bprint(ftos(self.have_flag));
- bprint("\n");
- bprint("self.am_it is :");
- bprint(ftos(self.am_it));
- bprint("\n");
- bprint("numplayers = ");
- bprint(ftos(numplayers));
- bprint("\n");
- bprint("Mega_placed = ");
- bprint(ftos(mega_placed));
- bprint("\n");
- }
- if (self.impulse == 20)
- ShowAllowed();
- if (self.impulse > 20 && self.impulse < 26)
- {
- if (self.impulse == 25)
- {
- if (allow_items & ALLOW_MEGA)
- {
- found = find(world,classname,"item_artifact_mega_power");
- while(found)
- {
- remove(found);
- found = found.chain;
- }
- }
- else
- mega_placed = FALSE;
- }
- item_type = 1;
- loopy = self.impulse - 21;
- while (loopy)
- {
- item_type = item_type * 2;
- loopy = loopy - 1;
- }
- if (allow_items & item_type)
- allow_items = allow_items - (allow_items & item_type);
- else
- allow_items = allow_items | item_type;
- ShowAllowed();
- }
-
- if (self.impulse == 26)
- {
- bprint("Your position is:");
- bprint(vtos(self.origin));
- bprint("\n");
- }
-
- // *************************************************************************
- // ** **
- // ** M U L T I S K I N 1.1 (start) **
- // ** **
- // *************************************************************************
-
-
- if ((self.impulse == 200) || (self.impulse == 201))
- {
- if (self.impulse == 200)
- {
- self.skin = self.skin + 1;
- if (self.skin == 19) self.skin = 0;
- } else
- if (self.impulse == 201)
- {
- self.skin = self.skin - 1;
- if (self.skin == -1) self.skin = 18;
- }
- if (self.skin == 0) centerprint(self, "SKIN: Quake himself (1)"); else
- if (self.skin == 1) centerprint(self, "SKIN: Duke Nukem 3d (2)"); else
- if (self.skin == 2) centerprint(self, "SKIN: Mr. Toad (3)"); else
- if (self.skin == 3) centerprint(self, "SKIN: the Stormtrooper (4)"); else
- if (self.skin == 4) centerprint(self, "SKIN: Max (5)"); else
- if (self.skin == 5) centerprint(self, "SKIN: the Terminator (6)"); else
- if (self.skin == 6) centerprint(self, "SKIN: Judge Dredd (7)"); else
- if (self.skin == 7) centerprint(self, "SKIN: Camouflaged soldier (8)"); else
- if (self.skin == 8) centerprint(self, "SKIN: Captain Picard (9)"); else
- if (self.skin == 9) centerprint(self, "SKIN: the Wizzard (10)"); else
- if (self.skin == 10) centerprint(self,"SKIN: the Predator (11)"); else
- if (self.skin == 11) centerprint(self,"SKIN: Skeleton (12)"); else
- if (self.skin == 12) centerprint(self,"SKIN: Wan-Fu (13)"); else
- if (self.skin == 13) centerprint(self,"SKIN: Henry Rollins (14)"); else
- if (self.skin == 14) centerprint(self,"SKIN: He-Man (15)"); else
- if (self.skin == 15) centerprint(self,"SKIN: Boba (16)"); else
- if (self.skin == 16) centerprint(self,"SKIN: Superman (17)"); else
- if (self.skin == 17) centerprint(self,"SKIN: NYPD Cop (18)"); else
- if (self.skin == 18) centerprint(self,"SKIN: Red/Yellow women dude (19)");
- }
-
- // *************************************************************************
- // ** **
- // ** M U L T I S K I N 1.1 (end) **
- // ** **
- // *************************************************************************
-
- if (self.impulse == 255)
- QuadCheat ();
- self.impulse = 0;
- };
-
- /*
- ============
- W_WeaponFrame
-
- Called every frame so impulse events can be handled as well as possible
- ============
- */
- void() W_WeaponFrame =
- {
- if (time < self.attack_finished)
- return;
- ImpulseCommands ();
-
- // check for attack
- if (self.button0)
- {
- SuperDamageSound ();
- W_Attack ();
- }
- };
-
- /*
- ========
- SuperDamageSound
-
- Plays sound if needed
- ========
- */
- void() SuperDamageSound =
- {
- if (self.super_damage_finished > time)
- {
- if (self.super_sound < time)
- {
- self.super_sound = time + 1;
- sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
- }
- }
- if (self.mega_finished > time)
- {
- if (self.mega_sound < time)
- {
- sound (self, CHAN_BODY, "items/protect3.wav", 1, ATTN_NORM);
- self.mega_sound = time + 2;
- }
- }
- return;
- };
-
-
-