1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332 |
- /* Copyright (C) 1996-2022 id Software LLC
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- See file, 'COPYING', for details.
- */
- /*
- */
- //JIM
- 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;
- //MED 10/18/96
- void(float damage) spawn_touchblood;
- /*
- ================
- HIPNOTIC WEAPONS
- ================
- */
- 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;
- };
- /*
- =================
- HIP_HammerDamage
- =================
- */
- void(vector p1, vector p2, entity from, float damage) HIP_HammerDamage =
- {
- 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);
- //JIM
- if (trace_ent.takedamage && !trace_ent.wetsuit_finished )
- {
- 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);
- //JIM
- if (trace_ent != e1 && trace_ent.takedamage &&
- !trace_ent.wetsuit_finished )
- {
- 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);
- //JIM
- if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage &&
- !trace_ent.wetsuit_finished )
- {
- particle (trace_endpos, '0 0 100', 225, damage*4);
- T_Damage (trace_ent, from, from, damage);
- }
- };
- /*
- void() HIP_DiversionLightningThink =
- {
- local vector org,end;
- if (time > self.delay)
- {
- remove(self);
- return;
- }
- makevectors(self.v_angle);
- org = self.origin;
- end = org + v_forward*200;
- // end = end + (((200*random()) - 100) * v_up);
- end = end + (((400*random()) - 200) * v_right);
- traceline (org, end, 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);
- self.nextthink = time + 0.1;
- };
- */
- //void(entity prev, entity owner, float dst) HIP_SpawnMjolnirLightning;
- void() HIP_LightningThink =
- {
- local vector org;
- local vector dst;
- local entity head;
- local entity selected;
- local float cur_dist;
- local float head_dist;
- local vector vec;
- local float dot;
- local float oldstate;
- local float dam;
- if (time > self.delay)
- {
- if (self.enemy != world)
- self.enemy.struck_by_mjolnir = 0;
- remove(self);
- return;
- }
- oldstate = self.state;
- if (self.state==0)
- {
- // look in our immediate vicinity
- self.enemy = world;
- selected = world;
- cur_dist = self.distance;
- head = findradius(self.owner.origin, self.distance);
- while(head)
- {
- if(!(head.flags & FL_NOTARGET) && ((head.flags & FL_MONSTER) || (head.flags & FL_CLIENT)))
- {
- // if (visible(head) && (head!=self.owner.owner) && (head.health>0))
- if ((visible(head)) && (head!=self.owner.owner) && (head.health>0))
- {
- head_dist = vlen(head.origin - self.lastvictim.origin);
- if ((head_dist<cur_dist) && (head.struck_by_mjolnir==0))
- {
- selected = head;
- cur_dist = head_dist;
- }
- }
- }
- head = head.chain;
- }
- if (selected != world)
- {
- self.state = 1;
- self.enemy = selected;
- self.enemy.struck_by_mjolnir = 1;
- }
- else
- {
- local vector org,end;
- makevectors(self.v_angle);
- org = self.owner.origin;
- end = org + v_forward*200;
- end = end + (((400*random()) - 200) * v_right);
- traceline (org, end, 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);
- self.nextthink = time + 0.1;
- // self.think = HIP_DiversionLightningThink;
- // self.nextthink = time;
- // self.delay = time + 0.30;
- // self.origin = self.owner.origin;
- // self.think();
- return;
- }
- }
- org = self.lastvictim.origin;
- dst = self.enemy.absmin + 0.25*(self.enemy.absmax-self.enemy.absmin);
- dst = dst + (random()*0.5*(self.enemy.absmax-self.enemy.absmin));
- traceline (org, dst, TRUE, self.owner.owner);
- if (trace_fraction != 1.0 || self.enemy.health<=0)
- {
- self.enemy.struck_by_mjolnir = 0;
- self.state = 0;
- self.nextthink = time + 0.1;
- return;
- }
- 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);
- vec = normalize(self.enemy.origin - self.owner.origin);
- dot = vec * self.owner.movedir;
- head = self;
- self = self.owner.owner;
- if (oldstate==0)
- dam = 80;
- else
- dam = 30;
- if (dot>0.3)
- HIP_HammerDamage (org, trace_endpos, self, dam);
- else
- HIP_HammerDamage (org, trace_endpos, self, dam*0.5);
- self = head;
- self.nextthink = time + 0.2;
- };
- void(entity prev, entity own, float dst) HIP_SpawnMjolnirLightning =
- {
- local entity light;
- // spawn actual lightning
- light = spawn();
- light.delay = time + 0.8;
- light.state = 0;
- light.lastvictim = prev;
- light.distance = dst;
- light.owner = own;
- light.v_angle = self.angles;
- light.v_angle_x = 0;
- light.v_angle_z = 0;
- light.origin = own.origin;
- light.think = HIP_LightningThink;
- light.nextthink = time;
- };
- void() HIP_SpawnMjolnirBase =
- {
- local entity light;
- // spawn lightning base
- light = spawn();
- // light.origin = self.origin - '0 0 24' + (32*v_forward);
- light.origin = trace_endpos;
- light.flags = 0;
- light.owner = self;
- light.struck_by_mjolnir = 1;
- light.think = SUB_Remove;
- light.nextthink = time + 1;
- sound (light, CHAN_AUTO, "hipweap/mjolslap.wav", 1, ATTN_NORM);
- sound (light, CHAN_WEAPON, "hipweap/mjolhit.wav", 1, ATTN_NORM);
- makevectors(self.v_angle);
- light.movedir = v_forward;
- HIP_SpawnMjolnirLightning( light, light, 350 );
- HIP_SpawnMjolnirLightning( light, light, 350 );
- HIP_SpawnMjolnirLightning( light, light, 350 );
- HIP_SpawnMjolnirLightning( light, light, 350 );
- };
- void() HIP_FireMjolnirLightning =
- {
- local vector org;
- local float cells;
- // explode if under water
- if (self.waterlevel > 1)
- {
- cells = self.ammo_cells;
- self.ammo_cells = 0;
- discharged = 1;
- T_RadiusDamage (self, self, 35*cells, world);
- discharged = 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 = 12;
- self.currentammo = self.ammo_cells = self.ammo_cells - 15;
- HIP_SpawnMjolnirBase();
- };
- void() HIP_FireMjolnir =
- {
- local vector org;
- local float cells;
- local float damage;
- local vector source;
- local vector ang;
- self.attack_finished = time + 0.4;
- source = self.origin + '0 0 16';
- // ang = self.angles;
- // ang_x = 0;
- // ang_y = 0;
- makevectors(self.v_angle);
- traceline (source, source + v_forward*32, FALSE, self);
- if (trace_fraction == 1.0 && (self.ammo_cells >= 15))
- {
- source = source + v_forward*32;
- traceline (source , source - v_up*50, FALSE, self);
- // dprint("fraction = ");
- // dprint(ftos(trace_fraction));
- // dprint("\n");
- if (trace_fraction > 0.3 && trace_fraction< 1.0)
- {
- HIP_FireMjolnirLightning();
- self.attack_finished = time + 1.5;
- return;
- }
- }
- org = trace_endpos - v_forward*4;
- if (trace_ent.takedamage)
- {
- damage = 50;
- if (trace_ent.classname == "monster_zombie")
- damage = 70;
- trace_ent.axhitme = 1;
- SpawnBlood (org, v_forward, damage);
- T_Damage (trace_ent, self, self, damage);
- }
- else
- { // hit wall
- if (trace_fraction != 1.0)
- {
- // sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
- sound (self, CHAN_WEAPON, "hipweap/mjoltink.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);
- }
- else
- {
- sound (self, CHAN_WEAPON, "knight/sword1.wav", 1, ATTN_NORM);
- }
- }
- self.attack_finished = time + 0.4;
- };
- // 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
- //MED
- precache_sound ("enforcer/enfstop.wav"); // laser cannon
- //MED 11/06/96
- precache_sound ("knight/sword1.wav"); // laser cannon
- precache_sound ("hipweap/laserg.wav"); // laser cannon
- precache_sound ("hipweap/laserric.wav"); // laser cannon ricochet
- precache_sound ("hipweap/proxwarn.wav"); // proximity bomb
- precache_sound ("hipweap/proxbomb.wav"); // proximity bomb
- //MED 11/19/96
- precache_sound ("hipweap/mjolhit.wav"); // mjolnir
- precache_sound ("hipweap/mjolslap.wav"); // mjolnir
- precache_sound ("hipweap/mjoltink.wav"); // mjolnir
- };
- float() crandom =
- {
- return 2*(random() - 0.5);
- };
- /*
- ================
- 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, 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;
- //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 ();
- };
- /*
- ================
- 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');
- };
- /*
- ==============================================================================
- 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 + 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);
- 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, 1000);
- missile.velocity = missile.velocity * 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');
- //MED 11/09/96
- newmis = missile;
- };
- /*
- ===============================================================================
- 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);
- //JIM
- if (trace_ent.takedamage && !trace_ent.wetsuit_finished )
- {
- 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);
- //JIM
- if (trace_ent != e1 && trace_ent.takedamage &&
- !trace_ent.wetsuit_finished )
- {
- 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);
- //JIM
- if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage &&
- !trace_ent.wetsuit_finished )
- {
- 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;
- //MED 01/05/97 added discharge flag
- discharged = 1;
- T_RadiusDamage (self, self, 35*cells, world);
- discharged = 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 =
- {
- 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() ProximityExplode =
- {
- T_RadiusDamage (self, self.owner, 95, 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 ();
- };
- //MED 10/31/96
- float NumProximityGrenades;
- /*
- ================
- ProximityGrenadeExplode
- ================
- */
- void() ProximityGrenadeExplode =
- {
- self.takedamage = DAMAGE_NO;
- NumProximityGrenades = NumProximityGrenades - 1;
- self.deathtype = "exploding";
- self.nextthink = time + 0.1;
- self.owner = self.lastvictim;
- self.think = ProximityExplode;
- };
- /*
- ================
- ProximityGrenadeTouch
- ================
- */
- void() ProximityGrenadeTouch =
- {
- if (other == self)
- return;
- if (other.classname == self.classname)
- return;
- self.movetype = MOVETYPE_TOSS;
- if (self.state == 1)
- return;
- if (vlen(other.velocity) > 0)
- {
- ProximityGrenadeExplode();
- self.think();
- return;
- }
- if (other.takedamage == DAMAGE_AIM)
- {
- ProximityGrenadeExplode();
- self.think();
- return;
- }
- sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
- self.movetype = MOVETYPE_NONE;
- setsize (self, '-8 -8 -8', '8 8 8');
- self.state = 1;
- self.spawnmaster = other;
- };
- /*
- ================
- ProximityBomb
- ================
- */
- void() ProximityBomb =
- {
- local entity head;
- local float blowup;
- if ((time > self.delay) || (NumProximityGrenades > 15) || (vlen(self.spawnmaster.velocity)>0) )
- {
- ProximityGrenadeExplode();
- self.think();
- return;
- }
- self.owner = world;
- self.takedamage = DAMAGE_YES;
- head = findradius(self.origin, 140);
- blowup = 0;
- while (head)
- {
- if ((head != self) && (head.health > 0) && (head.flags & (FL_CLIENT|FL_MONSTER)) && (head.classname!=self.classname))
- blowup = 1;
- if ((head.classname == self.classname) && (head.state==0))
- blowup = 1;
- traceline(self.origin,head.origin,TRUE,self);
- if (trace_fraction != 1.0)
- blowup = 0;
- if (blowup==1)
- {
- sound (self, CHAN_WEAPON, "hipweap/proxwarn.wav", 1, ATTN_NORM);
- ProximityGrenadeExplode();
- self.nextthink = time + 0.5;
- return;
- }
- head = head.chain;
- }
- self.nextthink = time + 0.25;
- };
- /*
- ================
- W_FireProximityGrenade
- ================
- */
- void() W_FireProximityGrenade =
- {
- local entity missile, mpuff;
- NumProximityGrenades = NumProximityGrenades + 1;
- self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
- sound (self, CHAN_WEAPON, "hipweap/proxbomb.wav", 1, ATTN_NORM);
- self.punchangle_x = -2;
- missile = spawn ();
- missile.owner = self;
- missile.lastvictim = self;
- missile.movetype = MOVETYPE_TOSS;
- missile.solid = SOLID_BBOX;
- missile.classname = "proximity_grenade";
- missile.takedamage = DAMAGE_NO;
- missile.health = 5;
- missile.state = 0;
- // 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 = '100 600 100';
- missile.angles = vectoangles(missile.velocity);
- missile.touch = ProximityGrenadeTouch;
- // set missile duration
- missile.nextthink = time + 2;
- missile.delay = time + 15 + (10*random());
- missile.think = ProximityBomb;
- missile.th_die = ProximityGrenadeExplode;
- setmodel (missile, "progs/proxbomb.mdl");
- setorigin (missile, self.origin);
- setsize (missile, '-1 -1 -1', '1 1 1');
- };
- //=============================================================================
- 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);
- newmis.velocity = dir * 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);
- }
- 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);
- };
- /*
- ===============================================================================
- PLAYER WEAPON USE
- ===============================================================================
- */
- //MED 10/18/96 added HIPWEAPONS
- 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_SUPER_NAILGUN)
- {
- self.currentammo = self.ammo_nails;
- self.weaponmodel = "progs/v_nail2.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_NAILS;
- }
- //MED
- else if (self.weapon == IT_LASER_CANNON)
- {
- self.currentammo = self.ammo_cells;
- self.weaponmodel = "progs/v_laserg.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_CELLS;
- }
- 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;
- }
- //MED
- else if (self.weapon == IT_MJOLNIR)
- {
- self.currentammo = self.ammo_cells;
- self.weaponmodel = "progs/v_hammer.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_CELLS;
- }
- //MED
- else if (self.weapon == IT_PROXIMITY_GUN)
- {
- self.currentammo = self.ammo_rockets;
- self.weaponmodel = "progs/v_prox.mdl";
- self.weaponframe = 0;
- self.items = self.items | IT_ROCKETS;
- }
- else
- {
- self.currentammo = 0;
- self.weaponmodel = "";
- self.weaponframe = 0;
- }
- };
- float() W_BestWeapon =
- {
- local float it;
- it = self.items;
- if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
- return IT_LIGHTNING;
- //MED
- else if(self.ammo_cells >= 1 && (it & IT_LASER_CANNON) )
- return IT_LASER_CANNON;
- 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;
- //MED
- else if( it & IT_MJOLNIR )
- return IT_MJOLNIR;
- /*
- 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(entity playerEnt, float old, float new) W_WantsToChangeWeapon =
- {
- float playerFlags = CheckPlayerEXFlags(playerEnt);
- if((playerFlags & PEF_CHANGENEVER) != 0)
- {
- return 0;
- }
-
- if(((playerFlags & PEF_CHANGEONLYNEW) != 0) && old == new)
- {
- return 0;
- }
- return 1;
- };
- float() W_CheckNoAmmo =
- {
- if (self.currentammo > 0)
- return TRUE;
- if (self.weapon == IT_AXE)
- return TRUE;
- //MED
- if (self.weapon == IT_MJOLNIR)
- {
- 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;
- //MED
- void() player_laser1;
- void() player_hammer1;
- void() player_mjolnir1;
- 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_SUPER_NAILGUN)
- {
- player_nail1 ();
- }
- 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);
- }
- //MED
- else if (self.weapon == IT_LASER_CANNON)
- {
- player_laser1();
- }
- //MED
- else if (self.weapon == IT_MJOLNIR)
- {
- if (self.ammo_cells < 30)
- player_hammer1();
- else
- player_mjolnir1();
- self.attack_finished = time + 0.8;
- }
- //MED
- else if (self.weapon == IT_PROXIMITY_GUN)
- {
- player_rocket1();
- W_FireProximityGrenade();
- self.attack_finished = time + 0.6;
- }
- };
- /*
- ============
- W_ChangeWeapon
- ============
- */
- //MED 10/18/96 added hipweapons
- void() W_ChangeWeapon =
- {
- local float it, am, fl;
- local float oldimpulse;
- it = self.items;
- am = 0;
- //MED
- 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;
- }
- //MED
- else if (self.impulse == 5)
- {
- fl = IT_SUPER_NAILGUN;
- if (self.ammo_nails < 2)
- am = 1;
- }
- //MED
- else if (self.impulse == 6)
- {
- if (self.weapon == IT_GRENADE_LAUNCHER)
- {
- fl = IT_PROXIMITY_GUN;
- }
- else
- {
- 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;
- }
- //MED
- else if (self.impulse == 8)
- {
- fl = IT_LIGHTNING;
- if (self.ammo_cells < 1)
- am = 1;
- }
- else if (self.impulse == 225)
- {
- fl = IT_LASER_CANNON;
- if (self.ammo_cells < 1)
- am = 1;
- }
- else if (self.impulse == 226)
- {
- fl = IT_MJOLNIR;
- }
- else if (self.impulse == 227)
- {
- fl = IT_PROXIMITY_GUN;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- else if (self.impulse == 228)
- {
- fl = IT_GRENADE_LAUNCHER;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- //MED
- oldimpulse = self.impulse;
- self.impulse = 0;
- if (!(self.items & fl))
- {
- //MED
- if (fl == IT_GRENADE_LAUNCHER)
- {
- fl = IT_PROXIMITY_GUN;
- if (!(self.items & fl))
- {
- sprint (self, "$qc_no_weapon");
- return;
- }
- if (self.ammo_rockets < 1)
- am = 1;
- else
- am = 0;
- }
- else
- {
- sprint (self, "$qc_no_weapon");
- return;
- }
- }
- if (am)
- { // don't have the ammo
- sprint (self, "$qc_not_enough_ammo");
- return;
- }
- //
- // set weapon, set ammo
- //
- self.weapon = fl;
- W_SetCurrentAmmo ();
- };
- /*
- ============
- CheatCommand
- ============
- */
- void() CheatCommand =
- {
- if ( ( deathmatch || coop ) && cheats_allowed == 0 ) { // mal: allow impulse 9 IF cheats allowed
- 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_SUPER_NAILGUN |
- IT_GRENADE_LAUNCHER |
- IT_ROCKET_LAUNCHER |
- IT_KEY1 | IT_KEY2;
- self.ammo_cells = 200;
- self.items = self.items | IT_LIGHTNING;
- //MED
- self.items = self.items | IT_LASER_CANNON;
- self.items = self.items | IT_MJOLNIR;
- self.items = self.items | IT_PROXIMITY_GUN;
- 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;
- //MED
- if (self.weapon == IT_MJOLNIR)
- {
- 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.ammo_nails < 2)
- am = 1;
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- self.weapon = IT_GRENADE_LAUNCHER;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- //MED
- else if (self.weapon == IT_GRENADE_LAUNCHER)
- {
- self.weapon = IT_PROXIMITY_GUN;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- //MED
- else if (self.weapon == IT_PROXIMITY_GUN)
- {
- 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_LASER_CANNON;
- if (self.ammo_cells < 1)
- am = 1;
- }
- else if (self.weapon == IT_LASER_CANNON)
- {
- self.weapon = IT_MJOLNIR;
- }
- if ( (self.items & 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;
- //MED
- if (self.weapon == IT_MJOLNIR)
- {
- self.weapon = IT_LASER_CANNON;
- if (self.ammo_cells < 1)
- am = 1;
- }
- //MED
- else if (self.weapon == IT_LASER_CANNON)
- {
- self.weapon = IT_LIGHTNING;
- if (self.ammo_cells < 1)
- am = 1;
- }
- else 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_PROXIMITY_GUN;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- else if (self.weapon == IT_PROXIMITY_GUN)
- {
- self.weapon = IT_GRENADE_LAUNCHER;
- if (self.ammo_rockets < 1)
- am = 1;
- }
- else if (self.weapon == IT_GRENADE_LAUNCHER)
- {
- self.weapon = IT_SUPER_NAILGUN;
- if (self.ammo_nails < 2)
- am = 1;
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- 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_MJOLNIR;
- }
- 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;
- bprint ("$qc_quad_cheat");
- };
- //MED
- void() WetsuitCheat =
- {
- if (deathmatch || coop)
- return;
- self.items2 = self.items2 | HIP_IT_WETSUIT;
- self.wetsuit_time = 1;
- self.wetsuit_finished = time + 30;
- bprint( "$qc_wetsuit_cheat" );
- };
- //MED
- void() EmpathyShieldsCheat =
- {
- if (deathmatch || coop)
- return;
- self.items2 = self.items2 | HIP_IT_EMPATHY_SHIELDS;
- self.empathy_time = 1;
- self.empathy_finished = time + 30;
- bprint( "$qc_empathy_cheat" );
- };
- void() DumpEntities =
- {
- local entity head;
- local float i;
- i = 1;
- head = nextent(world);
- while (head!=world)
- {
- dprint(ftos(i));
- dprint(" ");
- dprint(head.classname);
- dprint("\n");
- head = nextent(head);
- i = i + 1;
- }
- };
- void() DumpLiveEntities =
- {
- local entity head;
- local float i;
- i = 1;
- head = nextent(world);
- while (head!=world)
- {
- if (head.health > 0)
- {
- dprint(ftos(i));
- dprint(" ");
- dprint(head.classname);
- dprint(" ");
- dprint(vtos(head.origin));
- dprint("\n");
- dprint("--------------------\n");
- }
- head = nextent(head);
- i = i + 1;
- }
- };
- void() Genocide =
- {
- local entity head;
- if (deathmatch || coop)
- return;
- bprint("$qc_genocide_cheat");
- head = nextent(world);
- while (head!=world)
- {
- if ((head.health > 0) && (head.flags & FL_MONSTER))
- {
- T_Damage(head,world,world,head.health+10);
- }
- head = nextent(head);
- }
- };
- float dump_coord;
- void () ToggleDump =
- {
- dump_coord = 1 - dump_coord;
- if (dump_coord == 1)
- bprint("$qc_dump_player_loc");
- };
- void () DumpCoordinates =
- {
- local entity pl;
- pl = checkclient();
- if (pl)
- {
- bprint("Player: ");
- bprint(vtos(pl.origin));
- bprint("\n");
- }
- };
- /*
- ============
- ImpulseCommands
- ============
- */
- void() ImpulseCommands =
- {
- if (self.impulse >= 1 && self.impulse <= 8)
- W_ChangeWeapon ();
- if (self.impulse >= 225 && self.impulse <= 228)
- W_ChangeWeapon ();
- if (self.impulse == 9)
- CheatCommand ();
- if (self.impulse == 10)
- CycleWeaponCommand ();
- if (self.impulse == 11)
- ServerflagsCommand ();
- if (self.impulse == 12)
- CycleWeaponReverseCommand ();
- //JIM
- if ( self.impulse == 200 )
- WetsuitCheat();
- //MED
- if ( self.impulse == 201 )
- EmpathyShieldsCheat();
- if ( self.impulse == 205 )
- Genocide();
- if ( self.impulse == 206 )
- ToggleDump();
- if ( self.impulse == 202 )
- DumpEntities();
- if ( self.impulse == 203 )
- DumpLiveEntities();
- if (self.impulse == 255)
- QuadCheat ();
- if (dump_coord == 1)
- DumpCoordinates();
- 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;
- };
|