Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- */
- void( vector pos ) placebullethole;
- 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;
- 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;
- };
- /*
- ================
- spawn_touchblood
- ================
- */
- void(float damage) spawn_touchblood =
- {
- local vector vel;
- vel = wall_velocity () * 0.2;
- SpawnBlood (self.origin + vel*0.01, vel, damage);
- };
- // 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 ("weapons/nailshrd.wav"); // infantry gun AKA nailbuster sound
- precache_sound ("weapons/mingn1.wav"); // gatling gun spin up
- precache_sound ("weapons/mingn2.wav"); // gatling gun firing loop
- precache_sound ("weapons/mingn3.wav"); // gatling gun spin down
- precache_sound ("weapons/mingn4.wav"); // gatling gun spin loop
- precache_sound ("weapons/expl.wav"); //new explosion sound, to allow custom explosion sounds
- precache_sound ("weapons/bfgprep.wav"); //bfg charging up
- precache_sound ("weapons/bfgfire1.wav"); //bfg firing
- precache_sound ("weapons/bfgcrank.wav"); //bfg recharging
- precache_sound ("weapons/bfgexp.wav"); //bfg explosion
- precache_sound ("weapons/bfgblast.wav"); //bfg blast
- precache_sound ("weapons/mtshot.wav");
- precache_model ("progs/g_infg.mdl"); //infantry gun AKA nailbuster world model
- precache_model ("progs/v_infg.mdl"); //infantry gun AKA nailbuster view model
- precache_model ("progs/v_gatlg.mdl");
- precache_model ("progs/g_bfg.mdl");
- precache_model ("progs/v_bfg.mdl");
- precache_model ("progs/s_bullet.spr");
- precache_model ("progs/bfgshot.spr");
- precache_model ("progs/bfgexpl.spr");
- precache_model ("progs/bfgblst.spr");
- };
- float() crandom =
- {
- return 2*(random() - 0.5);
- };
- /*
- ================
- HIPNOTIC WEAPONS
- ================
- */
- .vector old_velocity;
- .entity lastvictim;
- void() HIP_LaserTouch =
- {
- local vector org;
- local vector spot1,spot2;
- local vector oldvel;
- local float mag;
- local float r;
- self.owner = world;
- self.cnt = self.cnt + 1;
- if (pointcontents(self.origin) == CONTENT_SKY)
- {
- remove(self);
- return;
- }
- oldvel = normalize(self.old_velocity);
- spot1 = self.origin - (16*oldvel);
- spot2 = self.origin + (16*oldvel);
- traceline (spot1, spot2, FALSE, self); // see through other monsters
- self.origin = trace_endpos;
- org = self.origin;
- if (other.health)
- {
- if (self.lastvictim == other)
- {
- self.dmg = self.dmg / 2;
- }
- spawn_touchblood (self.dmg);
- T_Damage (other, self, self.lastvictim, self.dmg);
- }
- else if ((self.cnt == 3) || (random()<0.15))
- {
- 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);
- }
- else
- {
- // self.dmg = 0.66 * self.dmg;
- self.dmg = 0.9 * self.dmg;
- // self.speed = 0.95 * self.speed;
- self.velocity = oldvel+(2*trace_plane_normal);
- self.velocity = normalize(self.velocity);
- self.velocity = self.speed * self.velocity;
- self.old_velocity = self.velocity;
- if (self.flags & FL_ONGROUND)
- self.flags = self.flags - FL_ONGROUND;
- r = random();
- sound (self, CHAN_WEAPON, "hipweap/laserric.wav", 1, ATTN_STATIC);
- /*
- if (r<0.33)
- sound (self, CHAN_WEAPON, "weapons/ric1.wav", 1, ATTN_STATIC);
- else if (r<0.66)
- sound (self, CHAN_WEAPON, "weapons/ric2.wav", 1, ATTN_STATIC);
- else
- sound (self, CHAN_WEAPON, "weapons/ric3.wav", 1, ATTN_STATIC);
- */
- return;
- }
- sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC);
- remove(self);
- };
- void() HIP_LaserThink =
- {
- local float delta;
- if (time>self.attack_finished)
- {
- remove(self);
- return;
- }
- if (self.flags & FL_ONGROUND)
- self.flags = self.flags - FL_ONGROUND;
- self.velocity = self.old_velocity;
- self.angles = vectoangles(self.velocity);
- self.nextthink = time+0.1;
- };
- void(vector org, vector vec, float light) HIP_LaunchLaser =
- {
- // sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);
- sound (self ,CHAN_WEAPON, "hipweap/laserg.wav", 1, ATTN_NORM);
- vec = normalize(vec);
- newmis = spawn();
- newmis.owner = self;
- newmis.classname = "hiplaser";
- newmis.lastvictim = self;
- newmis.movetype = MOVETYPE_FLYMISSILE;
- newmis.solid = SOLID_BBOX;
- if (light)
- newmis.effects = EF_DIMLIGHT;
- setmodel (newmis, "progs/lasrspik.mdl");
- setsize (newmis, '0 0 0', '0 0 0');
- setorigin (newmis, org);
- newmis.speed = 1000;
- newmis.dmg = 18;
- newmis.velocity = vec * newmis.speed;
- newmis.old_velocity = newmis.velocity;
- newmis.angles = vectoangles(newmis.velocity);
- newmis.avelocity = '0 0 400';
- newmis.nextthink = time;
- newmis.attack_finished = time + 5;
- newmis.think = HIP_LaserThink;
- newmis.touch = HIP_LaserTouch;
- newmis.count = 0;
- };
- /*
- =================
- HIP_FireLaser
- =================
- */
- void(float stat) HIP_FireLaser =
- {
- local vector org;
- local vector dir;
- local vector out;
- local float ofs;
- local float aofs;
- if (!self.button0)
- {
- player_run ();
- return;
- }
- if (self.ammo_cells < 1)
- {
- self.weapon = W_BestWeapon ();
- W_SetCurrentAmmo ();
- return;
- }
- SuperDamageSound();
- self.effects = self.effects | EF_MUZZLEFLASH;
- makevectors (self.v_angle);
- ofs = 6;
- out = v_forward;
- out_z = 0;
- out = normalize(out);
- org = self.origin + ((12-ofs) * v_up) + (12*out);
- // org = self.origin + (1*v_forward);
- dir = aim (self, 1000);
- aofs = ofs * 0.707;
- if (stat == 0)
- {
- self.currentammo = self.ammo_cells = self.ammo_cells - 1;
- org = org + (aofs*v_right);
- org = org - (aofs*v_up);
- HIP_LaunchLaser(org, dir, 0);
- org = org - (2*aofs*v_right);
- HIP_LaunchLaser(org, dir, 0);
- }
- else if (stat == 1)
- {
- self.currentammo = self.ammo_cells = self.ammo_cells - 1;
- org = org + (ofs*v_up);
- if (random()<0.1)
- {
- HIP_LaunchLaser(org, dir, 1);
- newmis.dmg = 25;
- }
- else
- HIP_LaunchLaser(org, dir, 0);
- }
- self.punchangle_x = -1;
- };
- /*
- ================
- W_FireAxe
- ================
- */
- void() W_FireAxe =
- {
- local vector source;
- local vector org;
- makevectors (self.v_angle);
- 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, 50); //20
- sound (self, CHAN_AUTO, "weapons/mtshot.wav", 1, ATTN_NORM);
- }
- 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);
- }
- };
- //============================================================================
- /*
- ================
- 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);
- };
- /*
- ================
- 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;
- //JIM
- local float bullet;
- bullet = 0;
- 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)
- //JIM
- {
- TraceAttack (4, direction);
- if ( ( !bullet ) && ( trace_ent == world ) )
- {
- placebullethole( trace_endpos );
- bullet = 1;
- }
- }
- shotcount = shotcount - 1;
- }
- ApplyMultiDamage ();
- };
- /*
- ================
- FireNailShards
- Used by hitscan weapons using nail ammo.
- ================
- */
- void(float shotcount, vector dir, vector spread) FireNailShards =
- {
- local vector direction;
- local vector src;
- float i = 0;
- local float len, cunt;
- //JIM
- local float bullet;
- bullet = 0;
- 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 (9, direction); //9
- //JIM
- if ( ( !bullet ) && ( trace_ent == world ) )
- {
- placebullethole( trace_endpos );
- bullet = 1;
- }
- len = vlen(src - trace_endpos) / 4; // len = length, vlen = vector length. for example vlen(position1 - position2); will return the distance between position1 and position2
- cunt = 0; // cunt = alt "count"
- while (cunt < 4) {
- particle(src+direction*(cunt+0.5)*len, direction, 6, 1); //10
- cunt = cunt + 1;
- }
- shotcount = shotcount - 1;
- }
- ApplyMultiDamage (); //It is vital to let this in! Or else no damage is registered...
- //while(len > 0)
- //{
- //particle(src, trace_fraction, 8, 1);
- //len = len - 16; //do it spaced out by 16 units
- //}
- //while (i < distance)
- //{
- // particle(startpoint + i*direction, '0 0 0', color, count);
- // i = i + gaplength;
- //}
- };
- /*
- ================
- FireNailShardsInfantry
- Used by the Nail Infantry
- ================
- */
- void(float shotcount, vector dir, vector spread) FireNailShardsInfantry =
- {
- local vector direction;
- local vector src;
- float i = 0;
- local float len, cunt;
- local float bullet;
- 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 (3, direction); //9
- //JIM
- if ( ( !bullet ) && ( trace_ent == world ) )
- {
- placebullethole( trace_endpos );
- bullet = 1;
- }
- len = vlen(src - trace_endpos) / 4; // len = length, vlen = vector length. for example vlen(position1 - position2); will return the distance between position1 and position2
- cunt = 0; // cunt = alt "count"
- while (cunt < 4) {
- particle(src+direction*(cunt+0.5)*len, direction, 6, 1); //10
- cunt = cunt + 1;
- }
- shotcount = shotcount - 1;
- }
- ApplyMultiDamage ();
- };
- /*
- ================
- FireNailShardsGatling
- Used by the gatling gun, the difference is more damage.
- ================
- */
- void(float shotcount, vector dir, vector spread) FireNailShardsGatling =
- {
- local vector direction;
- local vector src;
- float i = 0;
- local float len, cunt;
- //JIM
- local float bullet;
- bullet = 0;
- 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 (10, direction); //9
- //JIM
- if ( ( !bullet ) && ( trace_ent == world ) )
- {
- placebullethole( trace_endpos );
- bullet = 1;
- }
- len = vlen(src - trace_endpos) / 4; // len = length, vlen = vector length. for example vlen(position1 - position2); will return the distance between position1 and position2
- cunt = 0; // cunt = alt "count"
- while (cunt < 4) {
- particle(src+direction*(cunt+0.5)*len, direction, 6, 1); //10
- cunt = cunt + 1;
- }
- shotcount = shotcount - 1;
- }
- ApplyMultiDamage ();
- //while(len > 0)
- //{
- //particle(src, trace_fraction, 8, 1);
- //len = len - 16; //do it spaced out by 16 units
- //}
- //while (i < distance)
- //{
- // particle(startpoint + i*direction, '0 0 0', color, count);
- // i = i + gaplength;
- //}
- };
- /*
- ================
- 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);
- 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);
- FireBullets (14, dir, '0.14 0.08 0');
- };
- /*
- ================
- W_FireInfantry
- ================
- */
- void() W_FireInfantry =
- {
- local vector dir;
- sound (self, CHAN_WEAPON, "weapons/nailshrd.wav", 1, ATTN_NORM);
- self.punchangle_x = -2;
- self.currentammo = self.ammo_nails = self.ammo_nails - 1;
- dir = aim (self, 100000);
- FireNailShards (1, dir, '0.02 0.02 0');
- };
- /*
- ================
- W_FireGatling
- ================
- */
- void() W_FireGatling =
- {
- local vector dir;
- self.currentammo = self.ammo_nails = self.ammo_nails - 1;
- dir = aim (self, 100000);
- FireNailShardsGatling (1, dir, '0.04 0.04 0');
- };
- /*
- ==============================================================================
- BFG
- ==============================================================================
- */
- //BFG explosion sprites
- void() bfgexpl1 = [0, bfgexpl2] {};
- void() bfgexpl2 = [1, bfgexpl3] {};
- void() bfgexpl3 = [2, bfgexpl4] {};
- void() bfgexpl4 = [3, bfgexpl5] {};
- void() bfgexpl5 = [4, SUB_Remove] {};
- //BFG blast sprites
- void() bfgblast1 = [4, bfgblast2] {};
- void() bfgblast2 = [0, bfgblast3] {};
- void() bfgblast3 = [1, bfgblast4] {};
- void() bfgblast4 = [2, bfgblast5] {};
- void() bfgblast5 = [3, SUB_Remove] {};
- void() bfg_ball_think =
- {
- //continuous lightning bolt targetting nearby ennemies from BFG orb
- local vector org;
- //local float cells,damage=0;
- local entity head;
- local float damage;
- local entity lightcont;
- org = self.origin;
- head = findradius(self.origin, 250); // finds all entitys within 250 (2.5 meters?)
- while (head)
- {
- if (head.takedamage)
- {
- if(head != self.owner) // if the entity (head) is you (self.owner as stated in BFG_Shot), skip
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
- WriteEntity (MSG_BROADCAST, head); // Start position for lightning
- WriteCoord (MSG_BROADCAST, org_x); // Your position
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- WriteCoord (MSG_BROADCAST, head.origin_x); // entity's position
- WriteCoord (MSG_BROADCAST, head.origin_y);
- WriteCoord (MSG_BROADCAST, head.origin_z);
- sound (head, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
- damage = 20; //40 + random()*20
- T_Damage (head, lightcont, lightcont.owner, damage);
- }
- }
- head = head.chain; // cycle to next head (entity)
- }
- };
- //BFG orb sprites
- void() bfgshot1 = [0, bfgshot2] {self.nextthink = time + 0.05;bfg_ball_think();};
- void() bfgshot2 = [1, bfgshot1] {self.nextthink = time + 0.05;bfg_ball_think();};
- void(vector org) BFG_Blast =
- {
- local entity newent;
- newent = spawn(); //create new entity to become the blast
- newent.origin = org; //set location to the ending of the lightning
- newent.movetype = MOVETYPE_NONE;
- newent.velocity = '0 0 0';
- newent.touch = SUB_Null;
- setmodel (newent, "progs/bfgblst.spr"); //self
- newent.solid = SOLID_NOT;
- //bfgblast1();
- newent.nextthink = time + 0.01;
- newent.think = bfgblast1;
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
- WriteCoord (MSG_BROADCAST, org_x); //self.origin, org_
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- WriteByte (MSG_BROADCAST, 246);
- WriteByte (MSG_BROADCAST, 1);
- sound (newent, CHAN_WEAPON, "weapons/bfgblast.wav", 1, ATTN_NORM);
- };
- void() BFG_Expl =
- {
- local vector org;
- local entity head;
- local float damage;
- local entity bfgexpl;
- self.movetype = MOVETYPE_NONE;
- self.velocity = '0 0 0';
- self.touch = SUB_Null;
- setmodel (self, "progs/bfgexpl.spr"); //self
- self.solid = SOLID_NOT;
- //bfgexpl1();
- self.nextthink = time + 0.01;
- self.think = bfgexpl1;
- //the bfg blast fires deadlier lightning bolts to nearby enemies, comes from BFG orb on impact
- org = self.origin;
- head = findradius(self.origin, 300);
- while (head)
- {
- if (head.takedamage)
- {
- if(head != self.owner) // if the entity (head) is you (self.owner as stated in BFG_Shot), skip
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
- WriteEntity (MSG_BROADCAST, head); // Start position for lightning
- WriteCoord (MSG_BROADCAST, org_x); // Your position
- WriteCoord (MSG_BROADCAST, org_y);
- WriteCoord (MSG_BROADCAST, org_z);
- WriteCoord (MSG_BROADCAST, head.origin_x); // entity's position
- WriteCoord (MSG_BROADCAST, head.origin_y);
- WriteCoord (MSG_BROADCAST, head.origin_z);
- damage = 150;
- T_Damage (head, self, self.owner, damage);
- BFG_Blast(head.origin);
- }
- }
- head = head.chain; // cycle to next head (entity)
- }
- };
- void() BFG_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)
- {
- if (other.health < 265)
- {
- spawn_touchblood (32);
- T_Damage (other, self, self.owner, 300); //most monsters would gib on impact, so it will keep going. If the body's still in one piece when dying, the orb should explode as they're solid.
- }
- else
- {
- //spawn_touchblood (16);
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
- WriteByte (MSG_BROADCAST, 246);
- WriteByte (MSG_BROADCAST, 1);
- sound (self, CHAN_WEAPON, "weapons/bfgexp.wav", 1, ATTN_NORM);
- T_Damage (other, self, self.owner, 300);
- BFG_Expl();
- remove(self);
- }
- }
- else
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
- WriteByte (MSG_BROADCAST, 246);
- WriteByte (MSG_BROADCAST, 1);
- sound (self, CHAN_WEAPON, "weapons/bfgexp.wav", 1, ATTN_NORM);
- BFG_Expl();
- remove(self);
- }
- };
- void(vector org, vector vec) BFGShot =
- {
- local vector vec;
- local entity bfgsphere;
- vec = normalize(vec);
- bfgsphere = spawn();
- bfgsphere.owner = self;
- bfgsphere.movetype = MOVETYPE_FLY;
- bfgsphere.solid = SOLID_BBOX;
- bfgsphere.effects = EF_DIMLIGHT;
- setmodel (bfgsphere, "progs/bfgshot.spr");
- setsize (bfgsphere, '0 0 0', '0 0 0');
- bfgsphere.think = bfgshot1;
- setorigin (bfgsphere, org);
- bfgsphere.velocity = vec * 800; //600
- bfgsphere.angles = vectoangles(bfgsphere.velocity);
- //bfgsphere.nextthink = time + 5;
- //bfgsphere.think = SUB_Remove;
- //bfgsphere.nextthink = time + 0.3; //how often lightning strikes
- //bfgsphere.think = bfg_ball_think; //keep repeating
- bfgsphere.nextthink = time + 0.1;
- bfgsphere.think = bfgshot1;
- //for nextthinks: the greater values ust be put at first
- bfgsphere.touch = BFG_Touch;
- };
- void() W_Bfg_Fire =
- {
- local vector org;
- self.effects = self.effects | EF_MUZZLEFLASH;
- makevectors (self.v_angle); //v_xxx refers to the player's facing direction
- org = self.origin + v_forward * 30 + '0 0 16'; //org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 16';
- sound (self, CHAN_WEAPON, "weapons/bfgfire1.wav", 1, ATTN_NORM);
- BFGShot(org, v_forward);
- self.currentammo = self.ammo_cells = self.ammo_cells - 30;
- };
- /*
- ==============================================================================
- 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() 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() 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; //Quake3 damage, original is "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/expl.wav", 1, ATTN_NORM);
- self.origin = self.origin - 8*normalize(self.velocity);
- 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;
- missile.classname = "missile";
- // set missile speed
- makevectors (self.v_angle);
- missile.velocity = aim(self, 900); //Quake3 speed, original is 1000
- missile.velocity = missile.velocity * 900; //Quake3 speed, original is 1000
- missile.angles = vectoangles(missile.velocity);
- missile.touch = T_MissileTouch;
- // set missile duration
- 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;
- 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 100', 225, damage*4);
- 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 100', 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 100', 225, damage*4);
- T_Damage (trace_ent, from, from, damage);
- }
- };
- void() W_FireLightning =
- {
- local vector org;
- local float cells;
- if (self.ammo_cells < 1)
- {
- self.weapon = W_BestWeapon ();
- W_SetCurrentAmmo ();
- return;
- }
- // explode if under water
- if (self.waterlevel > 1)
- {
- cells = self.ammo_cells;
- self.ammo_cells = 0;
- W_SetCurrentAmmo ();
- T_RadiusDamage (self, self, 35*cells, world);
- 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 =
- {
- T_RadiusDamage (self, self.owner, 120, world);
- sound (self, CHAN_WEAPON, "weapons/expl.wav", 1, ATTN_NORM);
- 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() spike_touch;
- void() superspike_touch;
- void() spike_butcher_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);
- newmis.velocity = dir * 1200; //1000
- };
- void(vector org, vector dir) launch_spike_butcher =
- {
- newmis = spawn ();
- newmis.owner = self;
- newmis.movetype = MOVETYPE_FLYMISSILE;
- newmis.solid = SOLID_BBOX;
- newmis.angles = vectoangles(dir);
- newmis.touch = spike_butcher_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);
- newmis.velocity = dir * 900; //1000
- };
- void() W_FireSuperSpikes =
- {
- local vector dir;
- local entity old;
- sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
- self.attack_finished = time + 0.2;
- self.currentammo = self.ammo_nails = self.ammo_nails - 2;
- dir = aim (self, 1000);
- 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.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);
- sound (self, CHAN_AUTO, "weapons/mtshot.wav", 1, ATTN_NORM);
- }
- 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);
- };
- void() spike_butcher_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, 5); //9
- sound (self, CHAN_AUTO, "weapons/mtshot.wav", 1, ATTN_NORM);
- }
- 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);
- };
- /*
- ===============================================================================
- PLAYER WEAPON USE
- ===============================================================================
- */
- void() W_SetCurrentAmmo =
- {
- 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_INFANTRY_GUN)
- {
- self.currentammo = self.ammo_nails;
- self.weaponmodel = "progs/v_infg.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_GATLING_GUN)
- {
- self.currentammo = self.ammo_nails;
- self.weaponmodel = "progs/v_gatlg.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_BFG9500)
- {
- self.currentammo = self.ammo_cells;
- self.weaponmodel = "progs/v_bfg.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 >= 30 && (it & IT_BFG9500) )
- return IT_BFG9500;
- if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
- return IT_LIGHTNING;
- if(self.ammo_nails >= 1 && (it & IT_GATLING_GUN) )
- return IT_GATLING_GUN;
- if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
- return IT_SUPER_NAILGUN;
- if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
- return IT_SUPER_SHOTGUN;
- if(self.ammo_nails >= 1 && (it & IT_INFANTRY_GUN) )
- return IT_INFANTRY_GUN;
- if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
- return IT_NAILGUN;
- if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
- return IT_SHOTGUN;
- 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_inf1;
- void() player_gatlup1;
- void() player_light1;
- void() player_rocket1;
- void() player_bfgprep1;
- void() W_Attack =
- {
- local float r;
- 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 ();
- self.attack_finished = time + 0.5;
- }
- else if (self.weapon == IT_SUPER_SHOTGUN)
- {
- player_shot1 ();
- W_FireSuperShotgun ();
- self.attack_finished = time + 0.7;
- }
- else if (self.weapon == IT_NAILGUN)
- {
- player_nail1 ();
- }
- else if (self.weapon == IT_INFANTRY_GUN)
- {
- player_inf1 ();
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- player_nail1 ();
- }
- else if (self.weapon == IT_GATLING_GUN)
- {
- player_gatlup1 ();
- }
- else if (self.weapon == IT_GRENADE_LAUNCHER)
- {
- player_rocket1();
- 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_BFG9500)
- {
- player_bfgprep1 ();
- }
- };
- /*
- ============
- W_ChangeWeapon
- ============
- */
- void() W_ChangeWeapon =
- {
- local float it, am, fl;
- local float oldimpulse;
- 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)
- {
- if (self.weapon == IT_NAILGUN)
- {
- fl = IT_INFANTRY_GUN;
- }
- else
- {
- fl = IT_NAILGUN;
- }
- if (self.ammo_nails < 1)
- am = 1;
- }
- //else if (self.impulse == 4)
- //{
- // if (self.weapon == IT_NAILGUN)
- // {
- // fl = IT_INFANTRY_GUN;
- // }
- //
- // if (self.weapon == IT_INFANTRY_GUN)
- // {
- // fl = IT_NAILGUN;
- // }
- //
- // if (self.weapon != IT_NAILGUN)
- // {
- // fl = IT_NAILGUN;
- // }
- //
- // if (self.weapon != IT_INFANTRY_GUN)
- // {
- // fl = IT_INFANTRY_GUN;
- // }
- //
- // if (self.ammo_nails < 1)
- // am = 1;
- //
- // }
- else if (self.impulse == 5)
- {
- if (self.weapon == IT_SUPER_NAILGUN)
- {
- fl = IT_GATLING_GUN;
- if (self.ammo_nails < 1)
- am = 1;
- }
- else
- {
- fl = IT_SUPER_NAILGUN;
- if (self.ammo_nails < 2)
- am = 1;
- }
- }
- //else if (self.impulse == 5)
- //{
- // if (self.weapon == IT_SUPER_NAILGUN)
- // {
- // fl = IT_GATLING_GUN;
- // }
- //
- // if (self.weapon == IT_GATLING_GUN)
- // {
- // fl = IT_SUPER_NAILGUN;
- // }
- //
- // if (self.weapon != IT_SUPER_NAILGUN)
- // {
- // fl = IT_SUPER_NAILGUN;
- // }
- //
- // if (self.weapon != IT_GATLING_GUN)
- // {
- // fl = IT_GATLING_GUN;
- // }
- //
- // if (self.ammo_nails < 1)
- // am = 1; // < 2
- // }
- 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)
- {
- if (self.weapon == IT_LIGHTNING)
- {
- fl = IT_BFG9500;
- if (self.ammo_cells < 30)
- am = 1;;
- }
- else
- {
- fl = IT_LIGHTNING;
- if (self.ammo_cells < 1)
- am = 1;
- }
- }
- //else if (self.impulse == 8)
- //{
- // if (self.weapon == IT_LIGHTNING)
- // {
- // fl = IT_BFG9500;
- // if (self.ammo_cells < 30)
- // am = 1;
- // }
- //
- // if (self.weapon == IT_BFG9500)
- // {
- // fl = IT_LIGHTNING;
- // if (self.ammo_cells < 1)
- // am = 1;
- // }
- //
- // if (self.weapon != IT_LIGHTNING)
- // {
- // fl = IT_LIGHTNING;
- // if (self.ammo_cells < 1)
- // am = 1;
- // }
- //
- // if (self.weapon != IT_BFG9500)
- // {
- // fl = IT_BFG9500;
- // if (self.ammo_cells < 30)
- // am = 1;
- // }
- }
- //else if (self.impulse == 9)
- //{
- //fl = IT_BFG9500;
- //if (self.ammo_cells < 30)
- //am = 1;
- //}
- //MED
- oldimpulse = self.impulse;
- self.impulse = 0;
- if (!(self.items & fl))
- {
- //MED
- if (fl == IT_NAILGUN)
- {
- fl = IT_INFANTRY_GUN;
- if (!(self.items & fl))
- {
- sprint (self, "no weapon.\n");
- sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
- return;
- }
- if (self.ammo_nails < 1)
- am = 1;
- else
- am = 0;
- }
- else
- {
- sprint (self, "no weapon.\n");
- sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
- return;
- }
- if (fl == IT_SUPER_NAILGUN)
- {
- fl = IT_GATLING_GUN;
- if (!(self.items & fl))
- {
- sprint (self, "no weapon.\n");
- sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
- return;
- }
- if (self.ammo_nails < 1)
- am = 1;
- else
- am = 0;
- }
- else
- {
- sprint (self, "no weapon.\n");
- sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
- return;
- }
- if (fl == IT_LIGHTNING)
- {
- fl = IT_BFG9500;
- if (self.ammo_cells < 30)
- am = 1;
- if (!(self.items & fl))
- {
- sprint (self, "no weapon.\n");
- sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
- return;
- }
- if (self.ammo_cells < 1)
- am = 1;
- else
- am = 0;
- }
- else
- {
- sprint (self, "no weapon.\n");
- return;
- }
- }
- if (!(self.items & fl))
- { // don't have the weapon or the ammo
- sprint (self, "no weapon.\n");
- sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
- return;
- }
- if (am)
- { // don't have the ammo
- sprint (self, "not enough ammo.\n");
- sound (self, CHAN_WEAPON, "weapons/noammo.wav", 1, ATTN_NORM);
- return;
- }
- //
- // set weapon, set ammo
- //
- self.weapon = fl;
- W_SetCurrentAmmo ();
- };
- /*
- ============
- CheatCommand
- ============
- */
- void() CheatCommand =
- {
- if (deathmatch || coop)
- return;
- self.ammo_rockets = 100;
- self.ammo_nails = 200;
- self.ammo_shells = 100;
- self.items = self.items |
- IT_AXE |
- IT_SHOTGUN |
- IT_SUPER_SHOTGUN |
- IT_NAILGUN |
- IT_INFANTRY_GUN |
- IT_SUPER_NAILGUN |
- IT_GATLING_GUN |
- IT_GRENADE_LAUNCHER |
- IT_ROCKET_LAUNCHER |
- IT_KEY1 | IT_KEY2;
- self.ammo_cells = 200;
- self.items = self.items | IT_LIGHTNING | IT_BFG9500;
- 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_BFG9500)
- {
- 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_INFANTRY_GUN;
- if (self.ammo_nails < 1)
- am = 1;
- }
- else if (self.weapon == IT_INFANTRY_GUN)
- {
- self.weapon = IT_SUPER_NAILGUN;
- if (self.ammo_nails < 2)
- am = 1;
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- self.weapon = IT_GATLING_GUN;
- if (self.ammo_nails < 1)
- am = 1;
- }
- else if (self.weapon == IT_GATLING_GUN)
- {
- 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_BFG9500;
- if (self.ammo_cells < 30)
- am = 1;
- }
- if ( (it & self.weapon) && am == 0)
- {
- W_SetCurrentAmmo ();
- return;
- }
- }
- };
- /*
- ============
- CycleWeaponReverseCommand
- Go to the prev weapon with ammo
- ============
- */
- void() CycleWeaponReverseCommand =
- {
- local float it, am;
- it = self.items;
- self.impulse = 0;
- while (1)
- {
- am = 0;
- if (self.weapon == IT_BFG9500)
- {
- self.weapon = IT_LIGHTNING;
- if (self.ammo_cells < 1)
- am = 1;
- }
- if (self.weapon == IT_LIGHTNING)
- {
- self.weapon = IT_ROCKET_LAUNCHER;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- else if (self.weapon == IT_ROCKET_LAUNCHER)
- {
- self.weapon = IT_GRENADE_LAUNCHER;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- else if (self.weapon == IT_GRENADE_LAUNCHER)
- {
- self.weapon = IT_GATLING_GUN;
- if (self.ammo_nails < 1)
- am = 1;
- }
- else if (self.weapon == IT_GATLING_GUN)
- {
- self.weapon = IT_SUPER_NAILGUN;
- if (self.ammo_nails < 2)
- am = 1;
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- self.weapon = IT_INFANTRY_GUN;
- if (self.ammo_nails < 1)
- am = 1;
- }
- else if (self.weapon == IT_INFANTRY_GUN)
- {
- self.weapon = IT_NAILGUN;
- if (self.ammo_nails < 1)
- am = 1;
- }
- else if (self.weapon == IT_NAILGUN)
- {
- self.weapon = IT_SUPER_SHOTGUN;
- if (self.ammo_shells < 2)
- am = 1;
- }
- else if (self.weapon == IT_SUPER_SHOTGUN)
- {
- self.weapon = IT_SHOTGUN;
- if (self.ammo_shells < 1)
- am = 1;
- }
- else if (self.weapon == IT_SHOTGUN)
- {
- self.weapon = IT_AXE;
- }
- else if (self.weapon == IT_AXE)
- {
- self.weapon = IT_BFG9500;
- if (self.ammo_cells < 30)
- am = 1;
- }
- if ( (it & self.weapon) && am == 0)
- {
- W_SetCurrentAmmo ();
- return;
- }
- }
- };
- /*
- ============
- ServerflagsCommand
- Just for development
- ============
- */
- void() ServerflagsCommand =
- {
- serverflags = serverflags * 2 + 1;
- };
- 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");
- };
- /*
- ============
- ImpulseCommands
- ============
- */
- void() ImpulseCommands =
- {
- if (self.impulse >= 1 && self.impulse <= 8)
- W_ChangeWeapon ();
- if (self.impulse == 9)
- CheatCommand ();
- if (self.impulse == 10)
- CycleWeaponCommand ();
- if (self.impulse == 11)
- ServerflagsCommand ();
- if (self.impulse == 12)
- CycleWeaponReverseCommand ();
- 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);
- }
- }
- return;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement