diff --git a/nqw/ai.qc b/nqw/ai.qc index 2eff546..f51b30f 100644 --- a/nqw/ai.qc +++ b/nqw/ai.qc @@ -5,7 +5,6 @@ void() knight_bow6; void() knight_bow1; void(entity etemp, entity stemp, entity stemp, float dmg) T_Damage; /* - .enemy Will be world if not currently angry at anyone. @@ -30,17 +29,12 @@ time > .pausetime. walkmove(angle, speed) primitive is all or nothing */ - -// // globals -// float current_yaw; -// // when a monster becomes angry at a player, that monster will be used // as the sight target the next frame so that monsters near that one // will wake up even if they wouldn't have noticed the player -// entity sight_entity; float sight_entity_time; @@ -55,7 +49,6 @@ float(float v) anglemod = /* ============================================================================== - MOVETARGET CODE The angle of the movetarget effects standing and bowing direction, but has no effect on movement, which allways heads to the next target. @@ -68,16 +61,13 @@ the next spot to move to. If not present, stop here for good. pausetime The number of seconds to spend standing or bowing for path_stand or path_bow - ============================================================================== */ - - void() movetarget_f = { if (!self.targetname) objerror ("monster_movetarget: no targetname"); - + self.solid = SOLID_TRIGGER; self.touch = t_movetarget; setsize (self, '-8 -8 -8', '8 8 8'); @@ -92,7 +82,6 @@ void() path_corner = movetarget_f (); }; - /* ============= t_movetarget @@ -103,11 +92,11 @@ moving towards it, change the next destination and continue. */ void() t_movetarget = { -local entity temp; + local entity temp; if (other.movetarget != self) return; - + if (other.enemy) return; // fighting, not following a path @@ -118,19 +107,16 @@ local entity temp; if (self.classname == "monster_ogre") sound (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE);// play chainsaw drag sound -//dprint ("t_movetarget\n"); +// dprint ("t_movetarget\n"); self.goalentity = self.movetarget = find (world, targetname, other.target); self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin); - if (!self.movetarget) - { + if (!self.movetarget) { self.pausetime = time + 999999; self.th_stand (); return; } }; - - //============================================================================ /* @@ -146,11 +132,12 @@ returns the range catagorization of an entity reletive to self */ float(entity targ) range = { -local vector spot1, spot2; -local float r; + local vector spot1, spot2; + local float r; + spot1 = self.origin + self.view_ofs; spot2 = targ.origin + targ.view_ofs; - + r = vlen (spot1 - spot2); if (r < 120) return RANGE_MELEE; @@ -171,11 +158,11 @@ returns 1 if the entity is visible to self, even if not infront () float (entity targ) visible = { local vector spot1, spot2; - + spot1 = self.origin + self.view_ofs; spot2 = targ.origin + targ.view_ofs; traceline (spot1, spot2, TRUE, self); // see through other monsters - + if (trace_inopen && trace_inwater) return FALSE; // sight line crossed contents @@ -184,7 +171,6 @@ float (entity targ) visible = return FALSE; }; - /* ============= infront @@ -196,19 +182,16 @@ float(entity targ) infront = { local vector vec; local float dot; - + makevectors (self.angles); vec = normalize (targ.origin - self.origin); dot = vec * v_forward; - - if ( dot > 0.3) - { + + if (dot > 0.3) return TRUE; - } return FALSE; }; - //============================================================================ /* @@ -221,50 +204,41 @@ Called every 0.1 sec by monsters ============ */ /* - void() ChangeYaw = { local float ideal, move; -//current_yaw = self.ideal_yaw; -// mod down the current angle - current_yaw = anglemod( self.angles_y ); +// current_yaw = self.ideal_yaw; + // mod down the current angle + current_yaw = anglemod (self.angles_y); ideal = self.ideal_yaw; - + if (current_yaw == ideal) return; - + move = ideal - current_yaw; - if (ideal > current_yaw) - { + if (ideal > current_yaw) { if (move > 180) move = move - 360; - } - else - { + } else { if (move < -180) move = move + 360; } - if (move > 0) - { + if (move > 0) { if (move > self.yaw_speed) move = self.yaw_speed; - } - else - { - if (move < 0-self.yaw_speed ) - move = 0-self.yaw_speed; + } else { + if (move < 0 - self.yaw_speed) + move = 0 - self.yaw_speed; } current_yaw = anglemod (current_yaw + move); self.angles_y = current_yaw; }; - */ - //============================================================================ void() HuntTarget = @@ -278,54 +252,64 @@ void() HuntTarget = void() SightSound = { -local float rsnd; + local float rsnd; - if (self.classname == "monster_ogre") + switch (self.classname) { + case "monster_ogre": sound (self, CHAN_VOICE, "ogre/ogwake.wav", 1, ATTN_NORM); - else if (self.classname == "monster_knight") + break; + case "monster_knight": sound (self, CHAN_VOICE, "knight/ksight.wav", 1, ATTN_NORM); - else if (self.classname == "monster_shambler") + break; + case "monster_shambler": sound (self, CHAN_VOICE, "shambler/ssight.wav", 1, ATTN_NORM); - else if (self.classname == "monster_demon1") + break; + case "monster_demon1": sound (self, CHAN_VOICE, "demon/sight2.wav", 1, ATTN_NORM); - else if (self.classname == "monster_wizard") + break; + case "monster_wizard": sound (self, CHAN_VOICE, "wizard/wsight.wav", 1, ATTN_NORM); - else if (self.classname == "monster_zombie") + break; + case "monster_zombie": sound (self, CHAN_VOICE, "zombie/z_idle.wav", 1, ATTN_NORM); - else if (self.classname == "monster_dog") + break; + case "monster_dog": sound (self, CHAN_VOICE, "dog/dsight.wav", 1, ATTN_NORM); - else if (self.classname == "monster_hell_knight") + break; + case "monster_hell_knight": sound (self, CHAN_VOICE, "hknight/sight1.wav", 1, ATTN_NORM); - else if (self.classname == "monster_tarbaby") + break; + case "monster_tarbaby": sound (self, CHAN_VOICE, "blob/sight1.wav", 1, ATTN_NORM); - else if (self.classname == "monster_vomit") - sound (self, CHAN_VOICE, "vomitus/v_sight1.wav", 1, ATTN_NORM); - else if (self.classname == "monster_enforcer") - { - rsnd = rint(random() * 3); - if (rsnd == 1) + break; + case "monster_enforcer": + rsnd = random (); + if (rsnd < 0.25) sound (self, CHAN_VOICE, "enforcer/sight1.wav", 1, ATTN_NORM); - else if (rsnd == 2) + else if (rsnd < 0.5) sound (self, CHAN_VOICE, "enforcer/sight2.wav", 1, ATTN_NORM); - else if (rsnd == 0) + else if (rsnd < 0.75) sound (self, CHAN_VOICE, "enforcer/sight3.wav", 1, ATTN_NORM); else sound (self, CHAN_VOICE, "enforcer/sight4.wav", 1, ATTN_NORM); - } - else if (self.classname == "monster_army") + break; + case "monster_army": sound (self, CHAN_VOICE, "soldier/sight1.wav", 1, ATTN_NORM); - else if (self.classname == "monster_shalrath") + break; + case "monster_shalrath": sound (self, CHAN_VOICE, "shalrath/sight.wav", 1, ATTN_NORM); + break; + } }; void() FoundTarget = { - if (self.enemy.classname == "player") - { // let other monsters see this monster for a while + if (self.enemy.classname == "player") { + // let other monsters see this monster for a while sight_entity = self; sight_entity_time = time; } - + self.show_hostile = time + 1; // wake up other monsters SightSound (); @@ -360,14 +344,11 @@ float() FindTarget = // spawnflags & 3 is a big hack, because zombie crucified used the first // spawn flag prior to the ambush flag, and I forgot about it, so the second // spawn flag works as well - if (sight_entity_time >= time - 0.1 && !(self.spawnflags & 3) ) - { + if (sight_entity_time >= time - 0.1 && !(self.spawnflags & 3)) { client = sight_entity; if (client.enemy == self.enemy) return FALSE; - } - else - { + } else { client = checkclient (); if (!client) return FALSE; // current check entity isn't in PVS @@ -384,41 +365,33 @@ float() FindTarget = r = range (client); if (r == RANGE_FAR) return FALSE; - + if (!visible (client)) return FALSE; - if (r == RANGE_NEAR) - { + if (r == RANGE_NEAR) { if (client.show_hostile < time && !infront (client)) return FALSE; - } - else if (r == RANGE_MID) - { + } else if (r == RANGE_MID) { if ( /* client.show_hostile < time || */ !infront (client)) return FALSE; } - -// -// got one -// + + // got one self.enemy = client; - if (self.enemy.classname != "player") - { + if (self.enemy.classname != "player") { self.enemy = self.enemy.enemy; - if (self.enemy.classname != "player") - { + if (self.enemy.classname != "player") { self.enemy = world; return FALSE; } } - + FoundTarget (); return TRUE; }; - //============================================================================= void(float dist) ai_forward = @@ -431,7 +404,6 @@ void(float dist) ai_back = walkmove ( (self.angles_y+180), dist); }; - /* ============= ai_pain @@ -444,10 +416,10 @@ void(float dist) ai_pain = ai_back (dist); /* local float away; - + away = anglemod (vectoyaw (self.origin - self.enemy.origin) - + 180*(random()- 0.5) ); - + + 180 * (random () - 0.5) ); + walkmove (away, dist); */ }; @@ -474,12 +446,7 @@ The monster is walking it's beat void(float dist) ai_walk = { movedist = dist; - - if (self.classname == "monster_dragon") - { - movetogoal (dist); - return; - } + // check for noticing a player if (FindTarget ()) return; @@ -487,7 +454,6 @@ void(float dist) ai_walk = movetogoal (dist); }; - /* ============= ai_stand @@ -499,15 +465,12 @@ void() ai_stand = { if (FindTarget ()) return; - - if (time > self.pausetime) - { + + if (time > self.pausetime) { self.th_walk (); return; } - -// change angle slightly - + // change angle slightly }; /* @@ -521,17 +484,12 @@ void() ai_turn = { if (FindTarget ()) return; - + ChangeYaw (); }; //============================================================================= -/* -============= -ChooseTurn -============= -*/ void(vector dest3) ChooseTurn = { local vector dir, newdir; @@ -542,13 +500,10 @@ void(vector dest3) ChooseTurn = newdir_y = 0 - trace_plane_normal_x; newdir_z = 0; - if (dir * newdir > 0) - { + if (dir * newdir > 0) { dir_x = 0 - trace_plane_normal_y; dir_y = trace_plane_normal_x; - } - else - { + } else { dir_x = trace_plane_normal_y; dir_y = 0 - trace_plane_normal_x; } @@ -557,17 +512,11 @@ void(vector dest3) ChooseTurn = self.ideal_yaw = vectoyaw(dir); }; -/* -============ -FacingIdeal - -============ -*/ float() FacingIdeal = { local float delta; - delta = anglemod(self.angles_y - self.ideal_yaw); + delta = anglemod (self.angles_y - self.ideal_yaw); if (delta > 45 && delta < 315) return FALSE; return TRUE; @@ -583,21 +532,31 @@ float() CheckAnyAttack = { if (!enemy_vis) return 0; - if (self.classname == "monster_army") - return SoldierCheckAttack (); - if (self.classname == "monster_ogre") - return OgreCheckAttack (); - if (self.classname == "monster_shambler") - return ShamCheckAttack (); - if (self.classname == "monster_demon1") - return DemonCheckAttack (); - if (self.classname == "monster_dog") - return DogCheckAttack (); - if (self.classname == "monster_wizard") - return WizardCheckAttack (); - return CheckAttack (); -}; + switch (self.classname) { + case "monster_army": + return SoldierCheckAttack (); + break; + case "monster_ogre": + return OgreCheckAttack (); + break; + case "monster_shambler": + return ShamCheckAttack (); + break; + case "monster_demon1": + return DemonCheckAttack (); + break; + case "monster_dog": + return DogCheckAttack (); + break; + case "monster_wizard": + return WizardCheckAttack (); + break; + default: + return CheckAttack (); + break; + } +}; /* ============= @@ -611,14 +570,12 @@ void() ai_run_melee = self.ideal_yaw = enemy_yaw; ChangeYaw (); - if (FacingIdeal()) - { + if (FacingIdeal ()) { self.th_melee (); self.attack_state = AS_STRAIGHT; } }; - /* ============= ai_run_missile @@ -630,14 +587,12 @@ void() ai_run_missile = { self.ideal_yaw = enemy_yaw; ChangeYaw (); - if (FacingIdeal()) - { + if (FacingIdeal ()) { self.th_missile (); self.attack_state = AS_STRAIGHT; } }; - /* ============= ai_run_slide @@ -648,23 +603,22 @@ Strafe sideways, but stay at aproximately the same range void() ai_run_slide = { local float ofs; - + self.ideal_yaw = enemy_yaw; ChangeYaw (); if (self.lefty) ofs = 90; else ofs = -90; - + if (walkmove (self.ideal_yaw + ofs, movedist)) return; - + self.lefty = 1 - self.lefty; - + walkmove (self.ideal_yaw - ofs, movedist); }; - /* ============= ai_run @@ -675,18 +629,14 @@ The monster has an enemy it is trying to kill void(float dist) ai_run = { movedist = dist; -// see if the enemy is dead - if (self.enemy.health <= 0) - { + // see if the enemy is dead + if (self.enemy.health <= 0) { self.enemy = world; - // FIXME: look all around for other targets - if (self.oldenemy.health > 0) - { + // FIXME: look all around for other targets + if (self.oldenemy.health > 0) { self.enemy = self.oldenemy; HuntTarget (); - } - else - { + } else { if (self.movetarget) self.th_walk (); else @@ -697,45 +647,40 @@ void(float dist) ai_run = self.show_hostile = time + 1; // wake up other monsters -// check knowledge of enemy + // check knowledge of enemy enemy_vis = visible(self.enemy); if (enemy_vis) self.search_time = time + 5; -// look for other coop players - if (coop && self.search_time < time) - { + // look for other coop players + if (coop && self.search_time < time) { if (FindTarget ()) return; } - enemy_infront = infront(self.enemy); - enemy_range = range(self.enemy); - enemy_yaw = vectoyaw(self.enemy.origin - self.origin); + enemy_infront = infront (self.enemy); + enemy_range = range (self.enemy); + enemy_yaw = vectoyaw (self.enemy.origin - self.origin); - if (self.attack_state == AS_MISSILE) - { -//dprint ("ai_run_missile\n"); + if (self.attack_state == AS_MISSILE) { +// dprint ("ai_run_missile\n"); ai_run_missile (); return; } - if (self.attack_state == AS_MELEE) - { -//dprint ("ai_run_melee\n"); + if (self.attack_state == AS_MELEE) { +// dprint ("ai_run_melee\n"); ai_run_melee (); return; } if (CheckAnyAttack ()) return; // beginning an attack - - if (self.attack_state == AS_SLIDING) - { + + if (self.attack_state == AS_SLIDING) { ai_run_slide (); return; } - -// head straight in + + // head straight in movetogoal (dist); // done in C code... }; - diff --git a/nqw/boss.qc b/nqw/boss.qc index 949de52..b57900d 100644 --- a/nqw/boss.qc +++ b/nqw/boss.qc @@ -39,10 +39,8 @@ void(vector p) boss_missile; void() boss_face = { - -// go for another player if multi player - if (self.enemy.health <= 0 || random() < 0.02) - { + // go for another player if multi player + if (self.enemy.health <= 0 || random () < 0.02) { self.enemy = find(self.enemy, classname, "player"); if (!self.enemy) self.enemy = find(self.enemy, classname, "player"); @@ -74,7 +72,7 @@ void() boss_rise17 =[ $rise17, boss_missile1 ] {}; void() boss_idle1 =[ $walk1, boss_idle2 ] { -// look for other players + // look for other players }; void() boss_idle2 =[ $walk2, boss_idle3 ] {boss_face();}; void() boss_idle3 =[ $walk3, boss_idle4 ] {boss_face();}; @@ -177,16 +175,13 @@ void() boss_death8 = [$death8, boss_death9] {}; void() boss_death9 = [$death9, boss_death10] { sound (self, CHAN_BODY, "boss1/out1.wav", 1, ATTN_NORM); - WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); - WriteByte (MSG_BROADCAST, TE_LAVASPLASH); - WriteCoord (MSG_BROADCAST, self.origin_x); - WriteCoord (MSG_BROADCAST, self.origin_y); - WriteCoord (MSG_BROADCAST, self.origin_z); + WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_LAVASPLASH); + WriteCoordV (MSG_BROADCAST, self.origin); }; void() boss_death10 = [$death9, boss_death10] { - killed_monsters = killed_monsters + 1; + killed_monsters++; WriteByte (MSG_ALL, SVC_KILLEDMONSTER); // FIXME: reliable broadcast SUB_UseTargets (); remove (self); @@ -198,21 +193,18 @@ void(vector p) boss_missile = local vector org, vec, d; local float t; - offang = vectoangles (self.enemy.origin - self.origin); + offang = vectoangles (self.enemy.origin - self.origin); makevectors (offang); - org = self.origin + p_x*v_forward + p_y*v_right + p_z*'0 0 1'; - -// lead the player on hard mode - if (skill > 1) - { - t = vlen(self.enemy.origin - org) / 300; + org = self.origin + p_x * v_forward + p_y * v_right + p_z * '0 0 1'; + + // lead the player on hard mode + if (skill > 1) { + t = vlen (self.enemy.origin - org) / 300; vec = self.enemy.velocity; vec_z = 0; - d = self.enemy.origin + t * vec; - } - else - { + d = self.enemy.origin + t * vec; + } else { d = self.enemy.origin; } @@ -221,12 +213,12 @@ void(vector p) boss_missile = launch_spike (org, vec); setmodel (newmis, "progs/lavaball.mdl"); newmis.avelocity = '200 100 300'; - setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); - newmis.velocity = vec*300; + setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); + newmis.velocity = vec * 300; newmis.touch = T_MissileTouch; // rocket explosion sound (self, CHAN_WEAPON, "boss1/throw.wav", 1, ATTN_NORM); -// check for dead enemy + // check for dead enemy if (self.enemy.health <= 0) boss_idle1 (); }; @@ -237,10 +229,10 @@ void() boss_awake = self.solid = SOLID_SLIDEBOX; self.movetype = MOVETYPE_STEP; self.takedamage = DAMAGE_NO; - + setmodel (self, "progs/boss.mdl"); setsize (self, '-128 -128 -24', '128 128 256'); - + if (skill == 0) self.health = 1; else @@ -248,24 +240,19 @@ void() boss_awake = self.enemy = activator; - WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); - WriteByte (MSG_BROADCAST, TE_LAVASPLASH); - WriteCoord (MSG_BROADCAST, self.origin_x); - WriteCoord (MSG_BROADCAST, self.origin_y); - WriteCoord (MSG_BROADCAST, self.origin_z); + WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_LAVASPLASH); + WriteCoordV (MSG_BROADCAST, self.origin); self.yaw_speed = 20; boss_rise1 (); }; - /*QUAKED monster_boss (1 0 0) (-128 -128 -24) (128 128 256) */ void() monster_boss = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } precache_model ("progs/boss.mdl"); @@ -292,37 +279,31 @@ float lightning_end; void() lightning_fire = { local vector p1, p2; - - if (time >= lightning_end) - { // done here, put the terminals back up + + if (time >= lightning_end) { // done here, put the terminals back up self = le1; door_go_down (); self = le2; door_go_down (); return; } - + p1 = (le1.mins + le1.maxs) * 0.5; p1_z = le1.absmin_z - 16; - + p2 = (le2.mins + le2.maxs) * 0.5; p2_z = le2.absmin_z - 16; - + // compensate for length of bolt - p2 = p2 - normalize(p2-p1)*100; + p2 -= normalize (p2 - p1) * 100; self.nextthink = time + 0.1; self.think = lightning_fire; - WriteByte (MSG_ALL, SVC_TEMPENTITY); - WriteByte (MSG_ALL, TE_LIGHTNING3); + WriteBytes (MSG_ALL, SVC_TEMPENTITY, TE_LIGHTNING3); WriteEntity (MSG_ALL, world); - WriteCoord (MSG_ALL, p1_x); - WriteCoord (MSG_ALL, p1_y); - WriteCoord (MSG_ALL, p1_z); - WriteCoord (MSG_ALL, p2_x); - WriteCoord (MSG_ALL, p2_y); - WriteCoord (MSG_ALL, p2_z); + WriteCoordV (MSG_ALL, p1); + WriteCoordV (MSG_ALL, p2); }; void() lightning_use = @@ -330,38 +311,34 @@ void() lightning_use = if (lightning_end >= time + 1) return; - le1 = find( world, target, "lightning"); - le2 = find( le1, target, "lightning"); - if (!le1 || !le2) - { + le1 = find (world, target, "lightning"); + le2 = find (le1, target, "lightning"); + if (!le1 || !le2) { dprint ("missing lightning targets\n"); return; } - - if ( - (le1.state != STATE_TOP && le1.state != STATE_BOTTOM) - || (le2.state != STATE_TOP && le2.state != STATE_BOTTOM) - || (le1.state != le2.state) ) - { + + if ((le1.state != STATE_TOP && le1.state != STATE_BOTTOM) + || (le2.state != STATE_TOP && le2.state != STATE_BOTTOM) + || (le1.state != le2.state)) { // dprint ("not aligned\n"); return; } -// don't let the electrodes go back up until the bolt is done + // don't let the electrodes go back up until the bolt is done le1.nextthink = -1; le2.nextthink = -1; lightning_end = time + 1; sound (self, CHAN_VOICE, "misc/power.wav", 1, ATTN_NORM); - lightning_fire (); + lightning_fire (); -// advance the boss pain if down + // advance the boss pain if down self = find (world, classname, "monster_boss"); if (!self) return; self.enemy = activator; - if (le1.state == STATE_TOP && self.health > 0) - { + if (le1.state == STATE_TOP && self.health > 0) { sound (self, CHAN_VOICE, "boss1/pain.wav", 1, ATTN_NORM); self.health = self.health - 1; if (self.health >= 2) @@ -370,10 +347,9 @@ void() lightning_use = boss_shockb1(); else if (self.health == 0) boss_shockc1(); - } + } }; - /*QUAKED event_lightning (0 1 1) (-16 -16 -16) (16 16 16) Just for boss level. */ @@ -381,5 +357,3 @@ void() event_lightning = { self.use = lightning_use; }; - - diff --git a/nqw/buttons.qc b/nqw/buttons.qc index 1df47c9..ac63a54 100644 --- a/nqw/buttons.qc +++ b/nqw/buttons.qc @@ -9,7 +9,7 @@ void() button_wait = self.nextthink = self.ltime + self.wait; self.think = button_return; activator = self.enemy; - SUB_UseTargets(); + SUB_UseTargets (); self.frame = 1; // use alternate textures }; @@ -27,12 +27,11 @@ void() button_return = self.takedamage = DAMAGE_YES; // can be shot again }; - void() button_blocked = -{ // do nothing, just don't ome all the way back out +{ + // do nothing, just don't come all the way back out }; - void() button_fire = { if (self.state == STATE_UP || self.state == STATE_TOP) @@ -44,7 +43,6 @@ void() button_fire = SUB_CalcMove (self.pos2, self.speed, button_wait); }; - void() button_use = { self.enemy = activator; @@ -67,7 +65,6 @@ void() button_killed = button_fire (); }; - /*QUAKED func_button (0 .5 .8) ? When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again. @@ -85,27 +82,25 @@ When a button is touched, it moves some distance in the direction of it's angle, */ void() func_button = { - if (self.sounds == 0) - { + switch (self.sounds) { + case 0: precache_sound ("buttons/airbut1.wav"); self.noise = "buttons/airbut1.wav"; - } - if (self.sounds == 1) - { + break; + case 1: precache_sound ("buttons/switch21.wav"); self.noise = "buttons/switch21.wav"; - } - if (self.sounds == 2) - { + break; + case 2: precache_sound ("buttons/switch02.wav"); self.noise = "buttons/switch02.wav"; - } - if (self.sounds == 3) - { + break; + case 3: precache_sound ("buttons/switch04.wav"); self.noise = "buttons/switch04.wav"; + break; } - + SetMovedir (); self.movetype = MOVETYPE_PUSH; @@ -115,13 +110,11 @@ void() func_button = self.blocked = button_blocked; self.use = button_use; - if (self.health) - { + if (self.health) { self.max_health = self.health; self.th_die = button_killed; self.takedamage = DAMAGE_YES; - } - else + } else self.touch = button_touch; if (!self.speed) @@ -134,6 +127,6 @@ void() func_button = self.state = STATE_BOTTOM; self.pos1 = self.origin; - self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip); + self.pos2 = self.pos1 + self.movedir * (fabs (self.movedir * self.size) + - self.lip); }; - diff --git a/nqw/client.qc b/nqw/client.qc index 89a2223..12a0fba 100644 --- a/nqw/client.qc +++ b/nqw/client.qc @@ -1,4 +1,3 @@ - // prototypes void () W_WeaponFrame; void() W_SetCurrentAmmo; @@ -9,18 +8,12 @@ void (vector org, entity death_owner) spawn_tdeath; float modelindex_eyes, modelindex_player; -/* -============================================================================= +// LEVEL CHANGING / INTERMISSION ============================================== - LEVEL CHANGING / INTERMISSION +string nextmap; -============================================================================= -*/ - -string nextmap; - -float intermission_running; -float intermission_exittime; +float intermission_running; +float intermission_exittime; /*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16) This is the camera point for the intermission. @@ -31,21 +24,19 @@ void() info_intermission = self.angles = self.mangle; // so C can get at it }; - - void() SetChangeParms = { - if (self.health <= 0) - { + if (self.health <= 0) { SetNewParms (); return; } - -// remove items - self.items = self.items - (self.items & - (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) ); - -// cap super health + + // remove items + self.items = self.items - + (self.items & (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | + IT_INVULNERABILITY | IT_SUIT | IT_QUAD)); + + // cap super health if (self.health > 100) self.health = 100; if (self.health < 50) @@ -79,12 +70,11 @@ void() SetNewParms = void() DecodeLevelParms = { - if (serverflags) - { + if (serverflags) { if (world.model == "maps/start.bsp") - SetNewParms (); // take away all stuff on starting new episode + SetNewParms (); // take away all stuff on starting new episode } - + self.items = parm1; self.health = parm2; self.armorvalue = parm3; @@ -105,16 +95,14 @@ Returns the entity to view from */ entity() FindIntermission = { - local entity spot; - local float cyc; + local entity spot; + local float cyc; -// look for info_intermission first + // look for info_intermission first spot = find (world, classname, "info_intermission"); - if (spot) - { // pick a random one - cyc = random() * 4; - while (cyc > 1) - { + if (spot) { // pick a random one + cyc = 4 * random (); + while (cyc > 1) { spot = find (spot, classname, "info_intermission"); if (!spot) spot = find (spot, classname, "info_intermission"); @@ -123,24 +111,23 @@ entity() FindIntermission = return spot; } -// then look for the start position + // then look for the start position spot = find (world, classname, "info_player_start"); if (spot) return spot; - + objerror ("FindIntermission: no spot"); }; - void() GotoNextMap = { local string newmap; -//ZOID: 12-13-96, samelevel is overloaded, only 1 works for same level + //ZOID: 12-13-96, samelevel is overloaded, only 1 works for same level if (!deathmatch) changelevel (nextmap); - else if (cvar("samelevel") == 1) // if samelevel is set, stay on same level + else if (cvar("samelevel") == 1) // if samelevel is set, stay on same level changelevel (mapname); else { // configurable map lists, see if the current map exists as a @@ -155,87 +142,53 @@ void() GotoNextMap = void() ExitIntermission = { -// skip any text in deathmatch - if (deathmatch) - { + // skip any text in deathmatch + if (deathmatch) { GotoNextMap (); return; } - + intermission_exittime = time + 1; intermission_running = intermission_running + 1; -// -// run some text if at the end of an episode -// - if (intermission_running == 2) - { - if (world.model == "maps/e1m7.bsp") - { - WriteByte (MSG_ALL, SVC_CDTRACK); - WriteByte (MSG_ALL, 2); -// WriteByte (MSG_ALL, 3); - if (!cvar("registered")) - { - WriteByte (MSG_ALL, SVC_FINALE); + // run some text if at the end of an episode + if (intermission_running == 2) { + if (world.model == "maps/e1m7.bsp") { + WriteBytes (MSG_ALL, SVC_CDTRACK, 2.0, SVC_FINALE); + if (!cvar("registered")) { WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task in the other three\nhaunted lands of Quake. Or are you? If\nyou don't register Quake, you'll never\nknow what awaits you in the Realm of\nBlack Magic, the Netherworld, and the\nElder World!"); - } - else - { - WriteByte (MSG_ALL, SVC_FINALE); + } else { WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task. A Rune of magic\npower lies at the end of each haunted\nland of Quake. Go forth, seek the\ntotality of the four Runes!"); } return; - } - else if (world.model == "maps/e2m6.bsp") - { - WriteByte (MSG_ALL, SVC_CDTRACK); - WriteByte (MSG_ALL, 2); -// WriteByte (MSG_ALL, 3); - - WriteByte (MSG_ALL, SVC_FINALE); + } else if (world.model == "maps/e2m6.bsp") { + WriteBytes (MSG_ALL, SVC_CDTRACK, 2.0, SVC_FINALE); WriteString (MSG_ALL, "The Rune of Black Magic throbs evilly in\nyour hand and whispers dark thoughts\ninto your brain. You learn the inmost\nlore of the Hell-Mother; Shub-Niggurath!\nYou now know that she is behind all the\nterrible plotting which has led to so\nmuch death and horror. But she is not\ninviolate! Armed with this Rune, you\nrealize that once all four Runes are\ncombined, the gate to Shub-Niggurath's\nPit will open, and you can face the\nWitch-Goddess herself in her frightful\notherworld cathedral."); return; - } - else if (world.model == "maps/e3m6.bsp") - { - WriteByte (MSG_ALL, SVC_CDTRACK); - WriteByte (MSG_ALL, 2); -// WriteByte (MSG_ALL, 3); - - WriteByte (MSG_ALL, SVC_FINALE); + } else if (world.model == "maps/e3m6.bsp") { + WriteBytes (MSG_ALL, SVC_CDTRACK, 2.0, SVC_FINALE); WriteString (MSG_ALL, "The charred viscera of diabolic horrors\nbubble viscously as you seize the Rune\nof Hell Magic. Its heat scorches your\nhand, and its terrible secrets blight\nyour mind. Gathering the shreds of your\ncourage, you shake the devil's shackles\nfrom your soul, and become ever more\nhard and determined to destroy the\nhideous creatures whose mere existence\nthreatens the souls and psyches of all\nthe population of Earth."); return; - } - else if (world.model == "maps/e4m7.bsp") - { - WriteByte (MSG_ALL, SVC_CDTRACK); - WriteByte (MSG_ALL, 2); -// WriteByte (MSG_ALL, 3); - - WriteByte (MSG_ALL, SVC_FINALE); + } else if (world.model == "maps/e4m7.bsp") { + WriteBytes (MSG_ALL, SVC_CDTRACK, 2.0, SVC_FINALE); WriteString (MSG_ALL, "Despite the awful might of the Elder\nWorld, you have achieved the Rune of\nElder Magic, capstone of all types of\narcane wisdom. Beyond good and evil,\nbeyond life and death, the Rune\npulsates, heavy with import. Patient and\npotent, the Elder Being Shub-Niggurath\nweaves her dire plans to clear off all\nlife from the Earth, and bring her own\nfoul offspring to our world! For all the\ndwellers in these nightmare dimensions\nare her descendants! Once all Runes of\nmagic power are united, the energy\nbehind them will blast open the Gateway\nto Shub-Niggurath, and you can travel\nthere to foil the Hell-Mother's plots\nin person."); return; } - GotoNextMap(); } - if (intermission_running == 3) - { - if (!cvar("registered")) - { // shareware episode has been completed, go to sell screen + if (intermission_running == 3) { + if (!cvar("registered")) { + // shareware episode has been completed, go to sell screen WriteByte (MSG_ALL, SVC_SELLSCREEN); return; } - if ( (serverflags&15) == 15) - { + if ((serverflags & 15) == 15) { WriteByte (MSG_ALL, SVC_FINALE); WriteString (MSG_ALL, "Now, you have all four Runes. You sense\ntremendous invisible forces moving to\nunseal ancient barriers. Shub-Niggurath\nhad hoped to use the Runes Herself to\nclear off the Earth, but now instead,\nyou will use them to enter her home and\nconfront her as an avatar of avenging\nEarth-life. If you defeat her, you will\nbe remembered forever as the savior of\nthe planet. If she conquers, it will be\nas if you had never been born."); return; } - } GotoNextMap(); @@ -256,7 +209,6 @@ void() IntermissionThink = if (!self.button0 && !self.button1 && !self.button2) return; -// GotoNextMap (); ExitIntermission (); }; @@ -273,27 +225,19 @@ void() execute_changelevel = local entity pos; intermission_running = 1; - -// enforce a wait time before allowing changelevel + + // enforce a wait time before allowing changelevel intermission_exittime = time + 5; pos = FindIntermission (); -// play intermission music - WriteByte (MSG_ALL, SVC_CDTRACK); - WriteByte (MSG_ALL, 3); - - WriteByte (MSG_ALL, SVC_INTERMISSION); - WriteCoord (MSG_ALL, pos.origin_x); - WriteCoord (MSG_ALL, pos.origin_y); - WriteCoord (MSG_ALL, pos.origin_z); - WriteAngle (MSG_ALL, pos.mangle_x); - WriteAngle (MSG_ALL, pos.mangle_y); - WriteAngle (MSG_ALL, pos.mangle_z); + // play intermission music + WriteBytes (MSG_ALL, SVC_CDTRACK, 3.0, SVC_INTERMISSION); + WriteCoordV (MSG_ALL, pos.origin); + WriteAngleV (MSG_ALL, pos.mangle); other = find (world, classname, "player"); - while (other != world) - { + while (other != world) { other.takedamage = DAMAGE_NO; other.solid = SOLID_NOT; other.movetype = MOVETYPE_NONE; @@ -303,8 +247,7 @@ void() execute_changelevel = // sends all the entities seen from intermission spot! setorigin (other, pos.origin); other = find (other, classname, "player"); - } - + } }; @@ -316,32 +259,30 @@ void() changelevel_touch = // if "noexit" is set, blow up the player trying to leave //ZOID, 12-13-96, noexit isn't supported in QW. Overload samelevel // if ((cvar("noexit") == 1) || ((cvar("noexit") == 2) && (mapname != "start"))) - if ((cvar("samelevel") == 2) || ((cvar("samelevel") == 3) && (mapname != "start"))) - { + if ((cvar("samelevel") == 2) || ((cvar("samelevel") == 3) + && (mapname != "start"))) { T_Damage (other, self, self, 50000); return; } - if (coop || deathmatch) - { + if (coop || deathmatch) { bprint (PRINT_HIGH, other.netname); - bprint (PRINT_HIGH," exited the level\n"); + bprint (PRINT_HIGH, " exited the level\n"); } nextmap = self.map; SUB_UseTargets (); - if ( (self.spawnflags & 1) && (deathmatch == 0) ) - { // NO_INTERMISSION - GotoNextMap(); + if ((self.spawnflags & 1) && (deathmatch == 0)) { // NO_INTERMISSION + GotoNextMap (); return; } self.touch = SUB_Null; -// we can't move people right now, because touch functions are called -// in the middle of C movement code, so set a think time to do it + // we can't move people right now, because touch functions are called + // in the middle of C movement code, so set a think time to do it self.think = execute_changelevel; self.nextthink = time + 0.1; }; @@ -358,40 +299,28 @@ void() trigger_changelevel = self.touch = changelevel_touch; }; - -/* -============================================================================= - - PLAYER GAME EDGE FUNCTIONS - -============================================================================= -*/ +// PLAYER GAME EDGE FUNCTIONS ================================================= void() set_suicide_frame; // called by ClientKill and DeadThink void() respawn = { - if (coop) - { + if (coop) { // make a copy of the dead body for appearances sake - CopyToBodyQue (self); + CopyToBodyQueue (self); // get the spawn parms as they were at level start setspawnparms (self); // respawn PutClientInServer (); - } - else if (deathmatch) - { + } else if (deathmatch) { // make a copy of the dead body for appearances sake - CopyToBodyQue (self); + CopyToBodyQueue (self); // set default spawn parms SetNewParms (); // respawn PutClientInServer (); - } - else - { // restart the entire server + } else { // restart the entire server // localcmd ("restart\n"); localcmd ("map "); localcmd (mapname); @@ -399,7 +328,6 @@ void() respawn = } }; - /* ============ ClientKill @@ -432,42 +360,35 @@ Returns the entity to spawn at */ entity() SelectSpawnPoint = { - local entity spot, thing; - local float numspots, totalspots; - local float pcount; - local entity spots; + local entity spot, spots, thing; + local float numspots, totalspots, pcount; numspots = 0; totalspots = 0; -// testinfo_player_start is only found in regioned levels + // testinfo_player_start is only found in regioned levels spot = find (world, classname, "testplayerstart"); if (spot) return spot; - if (coop) - { + if (coop) { lastspawn = find(lastspawn, classname, "info_player_coop"); if (lastspawn == world) lastspawn = find (lastspawn, classname, "info_player_start"); if (lastspawn != world) return lastspawn; - } - else if (deathmatch) - { - // choose a info_player_deathmatch point + } else if (deathmatch) { + // choose a info_player_deathmatch point - // ok, find all spots that don't have players nearby + // ok, find all spots that don't have players nearby spots = world; spot = find (world, classname, "info_player_deathmatch"); - while (spot) - { + while (spot) { totalspots = totalspots + 1; thing=findradius(spot.origin, 84); pcount=0; - while (thing) - { + while (thing) { if (thing.classname == "player") pcount=pcount + 1; thing=thing.chain; @@ -479,13 +400,13 @@ entity() SelectSpawnPoint = } // Get the next spot in the chain - spot = find (spot, classname, "info_player_deathmatch"); + spot = find (spot, classname, "info_player_deathmatch"); } totalspots=totalspots - 1; if (!numspots) { // ack, they are all full, just pick one at random - // bprint (PRINT_HIGH, "Ackk! All spots are full. Selecting random spawn spot\n"); - totalspots = rint((random() * totalspots)); +// bprint (PRINT_HIGH, "Ackk! All spots are full. Selecting random spawn spot\n"); + totalspots = rint ((totalspots * random ())); spot = find (world, classname, "info_player_deathmatch"); while (totalspots > 0) { totalspots = totalspots - 1; @@ -493,14 +414,12 @@ entity() SelectSpawnPoint = } return spot; } - - // We now have the number of spots available on the map in numspots + + // We now have the number of spots available on the map in numspots // Generate a random number between 1 and numspots - numspots = numspots - 1; - - numspots = rint((random() * numspots ) ); + numspots = rint ((numspots * random ())); spot = spots; while (numspots > 0) { @@ -510,8 +429,7 @@ entity() SelectSpawnPoint = return spot; } - if (serverflags) - { // return with a rune to start + if (serverflags) { // return with a rune to start spot = find (world, classname, "info_player_start2"); if (spot) return spot; @@ -523,56 +441,42 @@ entity() SelectSpawnPoint = return spot; }; + void() DecodeLevelParms; void() PlayerDie; -/* -=========== -ValidateUser - - -============ -*/ float(entity e) ValidateUser = { /* - local string s; - local string userclan; - local float rank, rankmin, rankmax; + local string userclan, s; + local float rank, rankmin, rankmax; -// -// if the server has set "clan1" and "clan2", then it -// is a clan match that will allow only those two clans in -// - s = serverinfo("clan1"); - if (s) - { - userclan = masterinfo(e,"clan"); + // if the server has set "clan1" and "clan2", then it + // is a clan match that will allow only those two clans in + s = serverinfo ("clan1"); + if (s) { + userclan = masterinfo (e, "clan"); if (s == userclan) return true; - s = serverinfo("clan2"); + s = serverinfo ("clan2"); if (s == userclan) return true; return false; } -// -// if the server has set "rankmin" and/or "rankmax" then -// the users rank must be between those two values -// + // if the server has set "rankmin" and/or "rankmax" then + // the users rank must be between those two values s = masterinfo (e, "rank"); rank = stof (s); - s = serverinfo("rankmin"); - if (s) - { + s = serverinfo ("rankmin"); + if (s) { rankmin = stof (s); if (rank < rankmin) return false; } - s = serverinfo("rankmax"); - if (s) - { + s = serverinfo ("rankmax"); + if (s) { rankmax = stof (s); if (rankmax < rank) return false; @@ -582,7 +486,6 @@ float(entity e) ValidateUser = */ }; - /* =========== PutClientInServer @@ -592,7 +495,7 @@ called each time a player enters a new level */ void() PutClientInServer = { - local entity spot; + local entity spot; self.classname = "player"; self.health = 100; @@ -620,7 +523,7 @@ void() PutClientInServer = self.th_die = PlayerDie; self.deadflag = DEAD_NO; -// paustime is set by teleporters to keep the player from moving a while + // paustime is set by teleporters to keep the player from moving a while self.pausetime = 0; spot = SelectSpawnPoint (); @@ -629,7 +532,7 @@ void() PutClientInServer = self.angles = spot.angles; self.fixangle = TRUE; // turn this way immediately -// oh, this is a hack! + // oh, this is a hack! setmodel (self, "progs/eyes.mdl"); modelindex_eyes = self.modelindex; @@ -640,29 +543,24 @@ void() PutClientInServer = self.view_ofs = '0 0 22'; -// Mod - Xian (May.20.97) -// Bug where player would have velocity from their last kill - + // Mod - Xian (May.20.97) + // Bug where player would have velocity from their last kill self.velocity = '0 0 0'; player_stand1 (); makevectors(self.angles); - spawn_tfog (self.origin + v_forward*20); + spawn_tfog (self.origin + v_forward * 20); spawn_tdeath (self.origin, self); // Set Rocket Jump Modifiers if (stof(infokey(world, "rj")) != 0) - { rj = stof(infokey(world, "rj")); - } - if (deathmatch == 4) - { + if (deathmatch == 4) { self.ammo_shells = 0; - if (stof(infokey(world, "axe")) == 0) - { + if (stof(infokey(world, "axe")) == 0) { self.ammo_nails = 255; self.ammo_shells = 255; self.ammo_rockets = 255; @@ -671,10 +569,11 @@ void() PutClientInServer = self.items = self.items | IT_SUPER_NAILGUN; self.items = self.items | IT_SUPER_SHOTGUN; self.items = self.items | IT_ROCKET_LAUNCHER; -// self.items = self.items | IT_GRENADE_LAUNCHER; +// self.items = self.items | IT_GRENADE_LAUNCHER; self.items = self.items | IT_LIGHTNING; } - self.items = self.items - (self.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR3; + self.items = self.items + - (self.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR3; self.armorvalue = 200; self.armortype = 0.8; self.health = 250; @@ -683,8 +582,7 @@ void() PutClientInServer = self.invincible_finished = time + 3; } - if (deathmatch == 5) - { + if (deathmatch == 5) { self.ammo_nails = 80; self.ammo_shells = 30; self.ammo_rockets = 10; @@ -695,7 +593,8 @@ void() PutClientInServer = self.items = self.items | IT_ROCKET_LAUNCHER; self.items = self.items | IT_GRENADE_LAUNCHER; self.items = self.items | IT_LIGHTNING; - self.items = self.items - (self.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR3; + self.items = self.items + - (self.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR3; self.armorvalue = 200; self.armortype = 0.8; self.health = 200; @@ -703,19 +602,9 @@ void() PutClientInServer = self.invincible_time = 1; self.invincible_finished = time + 3; } - - }; - -/* -============================================================================= - - QUAKED FUNCTIONS - -============================================================================= -*/ - +// QUAKED FUNCTIONS =========================================================== /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24) The normal starting point for a level. @@ -724,7 +613,6 @@ void() info_player_start = { }; - /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24) Only used on start map for the return point from an episode. */ @@ -746,17 +634,9 @@ void() info_player_coop = { }; -/* -=============================================================================== +// RULES ====================================================================== -RULES - -=============================================================================== -*/ - -/* -go to the next level for deathmatch -*/ +// go to the next level for deathmatch void() NextLevel = { local entity o; @@ -764,42 +644,30 @@ void() NextLevel = if (nextmap != "") return; // already done - if (mapname == "start") - { - if (!cvar("registered")) - { + if (mapname == "start") { + if (!cvar("registered")) { mapname = "e1m1"; - } - else if (!(serverflags & 1)) - { + } else if (!(serverflags & 1)) { mapname = "e1m1"; serverflags = serverflags | 1; - } - else if (!(serverflags & 2)) - { + } else if (!(serverflags & 2)) { mapname = "e2m1"; serverflags = serverflags | 2; - } - else if (!(serverflags & 4)) - { + } else if (!(serverflags & 4)) { mapname = "e3m1"; serverflags = serverflags | 4; - } - else if (!(serverflags & 8)) - { + } else if (!(serverflags & 8)) { mapname = "e4m1"; serverflags = serverflags - 7; } - + o = spawn(); o.map = mapname; - } - else - { + } else { // find a trigger changelevel o = find(world, classname, "trigger_changelevel"); - if (!o || mapname == "start") - { // go back to same map if no trigger_changelevel + if (!o || mapname == "start") { + // go back to same map if no trigger_changelevel o = spawn(); o.map = mapname; } @@ -807,8 +675,7 @@ void() NextLevel = nextmap = o.map; - if (o.nextthink < time) - { + if (o.nextthink < time) { o.think = execute_changelevel; o.nextthink = time + 0.1; } @@ -822,40 +689,40 @@ Exit deathmatch games upon conditions ============ */ void() CheckRules = -{ - if (deathmatch && timelimit && time >= timelimit) - NextLevel (); - - if (deathmatch && fraglimit && self.frags >= fraglimit) - NextLevel (); +{ + if (deathmatch) { + if (timelimit && time >= timelimit) + NextLevel (); + + if (fraglimit && self.frags >= fraglimit) + NextLevel (); + } }; //============================================================================ void() PlayerDeathThink = { - local float forward; + local float forward; - if ((self.flags & FL_ONGROUND)) - { + if ((self.flags & FL_ONGROUND)) { forward = vlen (self.velocity); forward = forward - 20; if (forward <= 0) self.velocity = '0 0 0'; else - self.velocity = forward * normalize(self.velocity); + self.velocity = forward * normalize (self.velocity); } -// wait for all buttons released - if (self.deadflag == DEAD_DEAD) - { + // wait for all buttons released + if (self.deadflag == DEAD_DEAD) { if (self.button2 || self.button1 || self.button0) return; self.deadflag = DEAD_RESPAWNABLE; return; } -// wait for any button down + // wait for any button down if (!self.button2 && !self.button1 && !self.button0) return; @@ -865,19 +732,16 @@ void() PlayerDeathThink = respawn(); }; - void() PlayerJump = { if (self.flags & FL_WATERJUMP) return; - if (self.waterlevel >= 2) - { -// play swiming sound - if (self.swim_flag < time) - { + if (self.waterlevel >= 2) { + // play swiming sound + if (self.swim_flag < time) { self.swim_flag = time + 1; - if (random() < 0.5) + if (random () < 0.5) sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM); else sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM); @@ -888,47 +752,34 @@ void() PlayerJump = if (!(self.flags & FL_ONGROUND)) return; - - if ( !(self.flags & FL_JUMPRELEASED) ) + if (!(self.flags & FL_JUMPRELEASED)) return; // don't pogo stick self.flags = self.flags - (self.flags & FL_JUMPRELEASED); self.button2 = 0; -// player jumping sound + // player jumping sound sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM); }; - -/* -=========== -WaterMove - -============ -*/ .float dmgtime; - void() WaterMove = { -//dprint (ftos(self.waterlevel)); +// dprint (ftos (self.waterlevel)); if (self.movetype == MOVETYPE_NOCLIP) return; if (self.health < 0) return; - if (self.waterlevel != 3) - { + if (self.waterlevel != 3) { if (self.air_finished < time) sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM); else if (self.air_finished < time + 9) sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM); self.air_finished = time + 12; self.dmg = 2; - } - else if (self.air_finished < time) - { // drown! - if (self.pain_finished < time) - { + } else if (self.air_finished < time) { // drown! + if (self.pain_finished < time) { self.dmg = self.dmg + 2; if (self.dmg > 15) self.dmg = 10; @@ -937,10 +788,8 @@ void() WaterMove = } } - if (!self.waterlevel) - { - if (self.flags & FL_INWATER) - { + if (!self.waterlevel) { + if (self.flags & FL_INWATER) { // play leave water sound sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM); self.flags = self.flags - FL_INWATER; @@ -948,10 +797,8 @@ void() WaterMove = return; } - if (self.watertype == CONTENT_LAVA) - { // do damage - if (self.dmgtime < time) - { + if (self.watertype == CONTENT_LAVA) { // do damage + if (self.dmgtime < time) { if (self.radsuit_finished > time) self.dmgtime = time + 1; else @@ -959,28 +806,26 @@ void() WaterMove = T_Damage (self, world, world, 10*self.waterlevel); } - } - else if (self.watertype == CONTENT_SLIME) - { // do damage - if (self.dmgtime < time && self.radsuit_finished < time) - { + } else if (self.watertype == CONTENT_SLIME) { // do damage + if (self.dmgtime < time && self.radsuit_finished < time) { self.dmgtime = time + 1; T_Damage (self, world, world, 4*self.waterlevel); } } - - if ( !(self.flags & FL_INWATER) ) - { -// player enter water sound - - if (self.watertype == CONTENT_LAVA) + if (!(self.flags & FL_INWATER)) { + // player enter water sound + switch (self.watertype) { + case CONTENT_LAVA: sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM); - if (self.watertype == CONTENT_WATER) + break; + case CONTENT_WATER: sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM); - if (self.watertype == CONTENT_SLIME) + break; + case CONTENT_SLIME: sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM); - + break; + } self.flags = self.flags + FL_INWATER; self.dmgtime = 0; } @@ -990,22 +835,20 @@ void() CheckWaterJump = { local vector start, end; -// check for a jump-out-of-water + // check for a jump-out-of-water makevectors (self.angles); start = self.origin; start_z = start_z + 8; v_forward_z = 0; normalize(v_forward); - end = start + v_forward*24; + end = start + v_forward * 24; traceline (start, end, TRUE, self); - if (trace_fraction < 1) - { // solid at waist + if (trace_fraction < 1) { // solid at waist start_z = start_z + self.maxs_z - 8; - end = start + v_forward*24; + end = start + v_forward * 24; self.movedir = trace_plane_normal * -50; traceline (start, end, TRUE, self); - if (trace_fraction == 1) - { // open at eye level + if (trace_fraction == 1) { // open at eye level self.flags = self.flags | FL_WATERJUMP; self.velocity_z = 225; self.flags = self.flags - (self.flags & FL_JUMPRELEASED); @@ -1024,10 +867,9 @@ Called every frame before physics are run */ void() PlayerPreThink = { - if (intermission_running) - { - IntermissionThink (); // otherwise a button could be missed between - return; // the think tics + if (intermission_running) { + IntermissionThink (); // otherwise a button could be missed between + return; // the think tics } if (self.view_ofs == '0 0 0') @@ -1035,7 +877,7 @@ void() PlayerPreThink = makevectors (self.v_angle); // is this still used - self.deathtype = ""; + self.deathtype = ""; CheckRules (); WaterMove (); @@ -1043,9 +885,7 @@ void() PlayerPreThink = if (self.waterlevel == 2) CheckWaterJump (); */ - - if (self.deadflag >= DEAD_DEAD) - { + if (self.deadflag >= DEAD_DEAD) { PlayerDeathThink (); return; } @@ -1054,18 +894,16 @@ void() PlayerPreThink = return; // dying, so do nothing if (self.button2) - { PlayerJump (); - } else self.flags = self.flags | FL_JUMPRELEASED; -// teleporters can force a non-moving pause time + // teleporters can force a non-moving pause time if (time < self.pausetime) self.velocity = '0 0 0'; - if(time > self.attack_finished && self.currentammo == 0 && self.weapon != IT_AXE) - { + if (time > self.attack_finished && self.currentammo == 0 + && self.weapon != IT_AXE) { self.weapon = W_BestWeapon (); W_SetCurrentAmmo (); } @@ -1078,102 +916,79 @@ CheckPowerups Check for turning off powerups ================ */ -void() CheckPowerups = +void() CheckPowerups = // FIXME: this whole thing is a mess. { if (self.health <= 0) return; -// invisibility - if (self.invisible_finished) - { -// sound and screen flash when items starts to run out - if (self.invisible_sound < time) - { + // invisibility + if (self.invisible_finished) { + // sound and screen flash when items starts to run out + if (self.invisible_sound < time) { sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE); - self.invisible_sound = time + ((random() * 3) + 1); + self.invisible_sound = time + 3 * random () + 1; } - - if (self.invisible_finished < time + 3) - { - if (self.invisible_time == 1) - { + if (self.invisible_finished < time + 3) { + if (self.invisible_time == 1) { sprint (self, PRINT_HIGH, "Ring of Shadows magic is fading\n"); stuffcmd (self, "bf\n"); sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM); self.invisible_time = time + 1; } - if (self.invisible_time < time) - { + if (self.invisible_time < time) { self.invisible_time = time + 1; stuffcmd (self, "bf\n"); } } - if (self.invisible_finished < time) - { // just stopped + if (self.invisible_finished < time) { // just stopped self.items = self.items - IT_INVISIBILITY; self.invisible_finished = 0; self.invisible_time = 0; } - // use the eyes + // use the eyes self.frame = 0; self.modelindex = modelindex_eyes; - } - else + } else self.modelindex = modelindex_player; // don't use eyes -// invincibility - if (self.invincible_finished) - { -// sound and screen flash when items starts to run out - if (self.invincible_finished < time + 3) - { - if (self.invincible_time == 1) - { + // invincibility + if (self.invincible_finished) { + // sound and screen flash when items starts to run out + if (self.invincible_finished < time + 3) { + if (self.invincible_time == 1) { sprint (self, PRINT_HIGH, "Protection is almost burned out\n"); stuffcmd (self, "bf\n"); sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM); self.invincible_time = time + 1; } - if (self.invincible_time < time) - { + if (self.invincible_time < time) { self.invincible_time = time + 1; stuffcmd (self, "bf\n"); } } - if (self.invincible_finished < time) - { // just stopped + if (self.invincible_finished < time) { // just stopped self.items = self.items - IT_INVULNERABILITY; self.invincible_time = 0; self.invincible_finished = 0; } - if (self.invincible_finished > time) - { - self.effects = self.effects | EF_DIMLIGHT; - self.effects = self.effects | EF_RED; - } - else - { - self.effects = self.effects - (self.effects & EF_DIMLIGHT); - self.effects = self.effects - (self.effects & EF_RED); + if (self.invincible_finished > time) { + self.effects |= EF_DIMLIGHT | EF_RED; + } else { + self.effects &= ~(EF_DIMLIGHT | EF_RED); } } -// super damage - if (self.super_damage_finished) - { - -// sound and screen flash when items starts to run out - - if (self.super_damage_finished < time + 3) - { - if (self.super_time == 1) - { + // super damage + if (self.super_damage_finished) { + // sound and screen flash when items starts to run out + if (self.super_damage_finished < time + 3) { + if (self.super_time == 1) { if (deathmatch == 4) sprint (self, PRINT_HIGH, "OctaPower is wearing off\n"); else @@ -1181,20 +996,17 @@ void() CheckPowerups = stuffcmd (self, "bf\n"); sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM); self.super_time = time + 1; - } + } - if (self.super_time < time) - { + if (self.super_time < time) { self.super_time = time + 1; stuffcmd (self, "bf\n"); } } - if (self.super_damage_finished < time) - { // just stopped + if (self.super_damage_finished < time) { // just stopped self.items = self.items - IT_QUAD; - if (deathmatch == 4) - { + if (deathmatch == 4) { self.ammo_cells = 255; self.armorvalue = 1; self.armortype = 0.8; @@ -1202,53 +1014,40 @@ void() CheckPowerups = } self.super_damage_finished = 0; self.super_time = 0; - } - if (self.super_damage_finished > time) - { - self.effects = self.effects | EF_DIMLIGHT; - self.effects = self.effects | EF_BLUE; - } - else - { - self.effects = self.effects - (self.effects & EF_DIMLIGHT); - self.effects = self.effects - (self.effects & EF_BLUE); + } if (self.super_damage_finished > time) { + self.effects |= EF_DIMLIGHT | EF_BLUE; + } else { + self.effects &= ~(EF_DIMLIGHT | EF_BLUE); } } -// suit - if (self.radsuit_finished) - { + // suit + if (self.radsuit_finished) { self.air_finished = time + 12; // don't drown -// sound and screen flash when items starts to run out - if (self.radsuit_finished < time + 3) - { - if (self.rad_time == 1) - { + // sound and screen flash when items starts to run out + if (self.radsuit_finished < time + 3) { + if (self.rad_time == 1) { sprint (self, PRINT_HIGH, "Air supply in Biosuit expiring\n"); stuffcmd (self, "bf\n"); sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM); self.rad_time = time + 1; } - if (self.rad_time < time) - { + if (self.rad_time < time) { self.rad_time = time + 1; stuffcmd (self, "bf\n"); } } - if (self.radsuit_finished < time) - { // just stopped + if (self.radsuit_finished < time) { // just stopped self.items = self.items - IT_SUIT; self.rad_time = 0; self.radsuit_finished = 0; } - } - + } }; - /* ================ PlayerPostThink @@ -1264,18 +1063,15 @@ void() PlayerPostThink = if (self.deadflag) return; -// check to see if player landed and play landing sound - if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) ) - { + // check to see if player landed and play landing sound + if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) ) { if (self.watertype == CONTENT_WATER) sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM); - else if (self.jump_flag < -650) - { + else if (self.jump_flag < -650) { self.deathtype = "falling"; T_Damage (self, world, world, 5); sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM); - } - else + } else sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM); } @@ -1284,10 +1080,8 @@ void() PlayerPostThink = CheckPowerups (); W_WeaponFrame (); - }; - /* =========== ClientConnect @@ -1297,18 +1091,16 @@ called when a player connects to a server */ void() ClientConnect = { - if (deathmatch || coop) // Tonik - { + if (deathmatch || coop) { // Tonik bprint (PRINT_HIGH, self.netname); bprint (PRINT_HIGH, " entered the game\n"); } - -// a client connecting during an intermission can cause problems + + // a client connecting during an intermission can cause problems if (intermission_running) GotoNextMap (); }; - /* =========== ClientDisconnect @@ -1318,25 +1110,19 @@ called when a player disconnects from a server */ void() ClientDisconnect = { - local entity e; - local string tmp; + local entity e; + local string tmp; - if (!deathmatch) - { + if (!deathmatch) { e = find(world, classname, "player"); - if (e == self) - { - if (!find(e, classname, "player")) - { + if (e == self) { + if (!find(e, classname, "player")) { // No one is left on the server - if (coop) - { + if (coop) { localcmd ("map "); localcmd (mapname); localcmd ("\n"); - } - else // single player - { + } else { // single player serverflags = 0; localcmd("map start\n"); } @@ -1347,10 +1133,10 @@ void() ClientDisconnect = // let everyone else know bprint (PRINT_HIGH, self.netname); - bprint (PRINT_HIGH, " left the game with "); - tmp = ftos(self.frags); - bprint (PRINT_HIGH, tmp); - bprint (PRINT_HIGH, " frags\n"); + bprint (PRINT_HIGH, " left the game with "); + tmp = ftos (self.frags); + bprint (PRINT_HIGH, tmp); + bprint (PRINT_HIGH, " frags\n"); sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE); set_suicide_frame (); }; @@ -1362,25 +1148,19 @@ ClientObituary called when a player dies ============ */ - void(entity targ, entity attacker) ClientObituary = { - local float rnum; - local string deathstring, deathstring2; - local string attackerteam, targteam; + local float rnum; + local string deathstring, deathstring2, attackerteam, targteam; - rnum = random(); + rnum = random (); //ZOID 12-13-96: self.team doesn't work in QW. Use keys - attackerteam = infokey(attacker, "team"); - targteam = infokey(targ, "team"); + attackerteam = infokey (attacker, "team"); + targteam = infokey (targ, "team"); - if (targ.classname == "player") - { - - if (deathmatch > 3) - { - if (targ.deathtype == "selfwater") - { + if (targ.classname == "player") { + if (deathmatch > 3) { + if (targ.deathtype == "selfwater") { bprint (PRINT_MEDIUM, targ.netname); bprint (PRINT_MEDIUM," electrocutes himself.\n "); targ.frags = targ.frags - 1; @@ -1388,100 +1168,77 @@ void(entity targ, entity attacker) ClientObituary = } } - if (attacker.classname == "teledeath") - { - bprint (PRINT_MEDIUM,targ.netname); - bprint (PRINT_MEDIUM," was telefragged by "); - bprint (PRINT_MEDIUM,attacker.owner.netname); - bprint (PRINT_MEDIUM,"\n"); + switch (attacker.classname) { + case "teledeath": + bprint (PRINT_MEDIUM, targ.netname); + bprint (PRINT_MEDIUM, " was telefragged by "); + bprint (PRINT_MEDIUM, attacker.owner.netname); + bprint (PRINT_MEDIUM, "\n"); logfrag (attacker.owner, targ); - attacker.owner.frags = attacker.owner.frags + 1; return; - } - - if (attacker.classname == "teledeath2") - { - bprint (PRINT_MEDIUM,"Satan's power deflects "); - bprint (PRINT_MEDIUM,targ.netname); - bprint (PRINT_MEDIUM,"'s telefrag\n"); - + case "teledeath2": + bprint (PRINT_MEDIUM, "Satan's power deflects "); + bprint (PRINT_MEDIUM, targ.netname); + bprint (PRINT_MEDIUM, "'s telefrag\n"); targ.frags = targ.frags - 1; logfrag (targ, targ); return; - } - - // double 666 telefrag (can happen often in deathmatch 4) - if (attacker.classname == "teledeath3") - { - bprint (PRINT_MEDIUM,targ.netname); - bprint (PRINT_MEDIUM," was telefragged by "); - bprint (PRINT_MEDIUM,attacker.owner.netname); + case "teledeath3": + // double 666 telefrag (can happen often in deathmatch 4) + bprint (PRINT_MEDIUM, targ.netname); + bprint (PRINT_MEDIUM, " was telefragged by "); + bprint (PRINT_MEDIUM, attacker.owner.netname); bprint (PRINT_MEDIUM, "'s Satan's power\n"); targ.frags = targ.frags - 1; logfrag (targ, targ); return; - } - - - if (targ.deathtype == "squish") - { - if (teamplay && targteam == attackerteam && attackerteam != "" && targ != attacker) - { + case "squish": + if (teamplay && targteam == attackerteam && attackerteam != "" + && targ != attacker) { logfrag (attacker, attacker); attacker.frags = attacker.frags - 1; - bprint (PRINT_MEDIUM,attacker.netname); - bprint (PRINT_MEDIUM," squished a teammate\n"); - return; - } - else if (attacker.classname == "player" && attacker != targ) - { bprint (PRINT_MEDIUM, attacker.netname); - bprint (PRINT_MEDIUM," squishes "); - bprint (PRINT_MEDIUM,targ.netname); - bprint (PRINT_MEDIUM,"\n"); + bprint (PRINT_MEDIUM, " squished a teammate\n"); + return; + } else if (attacker.classname == "player" && attacker != targ) { + bprint (PRINT_MEDIUM, attacker.netname); + bprint (PRINT_MEDIUM, " squishes "); + bprint (PRINT_MEDIUM, targ.netname); + bprint (PRINT_MEDIUM, "\n"); logfrag (attacker, targ); attacker.frags = attacker.frags + 1; return; - } - else - { + } else { logfrag (targ, targ); targ.frags = targ.frags - 1; // killed self - bprint (PRINT_MEDIUM,targ.netname); - bprint (PRINT_MEDIUM," was squished\n"); + bprint (PRINT_MEDIUM, targ.netname); + bprint (PRINT_MEDIUM, " was squished\n"); return; } - } - - if (attacker.classname == "player") - { - if (targ == attacker) - { + break; + case "player": + if (targ == attacker) { // killed self logfrag (attacker, attacker); attacker.frags = attacker.frags - 1; bprint (PRINT_MEDIUM,targ.netname); if (targ.deathtype == "grenade") - bprint (PRINT_MEDIUM," tries to put the pin back in\n"); + bprint (PRINT_MEDIUM, " tries to put the pin back in\n"); else if (targ.deathtype == "rocket") - bprint (PRINT_MEDIUM," becomes bored with life\n"); - else if (targ.weapon == 64 && targ.waterlevel > 1) - { + bprint (PRINT_MEDIUM, " becomes bored with life\n"); + else if (targ.weapon == 64 && targ.waterlevel > 1) { if (targ.watertype == CONTENT_SLIME) - bprint (PRINT_MEDIUM," discharges into the slime\n"); + bprint (PRINT_MEDIUM, " discharges into the slime\n"); else if (targ.watertype == CONTENT_LAVA) - bprint (PRINT_MEDIUM," discharges into the lava\n"); + bprint (PRINT_MEDIUM, " discharges into the lava\n"); else - bprint (PRINT_MEDIUM," discharges into the water.\n"); - } - else - bprint (PRINT_MEDIUM," becomes bored with life\n"); + bprint (PRINT_MEDIUM, " discharges into the water.\n"); + } else + bprint (PRINT_MEDIUM, " becomes bored with life\n"); return; - } - else if ( (teamplay == 2) && (targteam == attackerteam) && - (attackerteam != "") ) - { + } else if ((teamplay == 2) && (targteam == attackerteam) && + (attackerteam != "")) { if (rnum < 0.25) deathstring = " mows down a teammate\n"; else if (rnum < 0.50) @@ -1496,45 +1253,36 @@ void(entity targ, entity attacker) ClientObituary = //ZOID 12-13-96: killing a teammate logs as suicide logfrag (attacker, attacker); return; - } - else - { + } else { + attacker.frags++; logfrag (attacker, targ); - attacker.frags = attacker.frags + 1; - rnum = attacker.weapon; - deathstring = deathstring2 = "'s quad rocket\n"; - if (targ.deathtype == "nail") - { + switch (targ.deathtype) { + case "nail": deathstring = " was nailed by "; deathstring2 = "\n"; - } - else if (targ.deathtype == "supernail") - { + break; + case "supernail": deathstring = " was punctured by "; deathstring2 = "\n"; - } - else if (targ.deathtype == "grenade") - { + break; + case "grenade": deathstring = " eats "; deathstring2 = "'s pineapple\n"; - if (targ.health < -40) - { + if (targ.health < -40) { deathstring = " was gibbed by "; deathstring2 = "'s grenade\n"; } - } - else if (targ.deathtype == "rocket") - { - if (attacker.super_damage_finished > 0 && targ.health < -40) - { - rnum = random(); - if (rnum < 0.3) + break; + case "rocket": + if (attacker.super_damage_finished > 0 && targ.health + < -40) { + rnum = random (); + if (rnum < 0.3) { deathstring = " was brutalized by "; - else if (rnum < 0.6) + } else if (rnum < 0.6) { deathstring = " was smeared by "; - else - { + } else { bprint (PRINT_MEDIUM, attacker.netname); bprint (PRINT_MEDIUM, " rips "); bprint (PRINT_MEDIUM, targ.netname); @@ -1542,157 +1290,162 @@ void(entity targ, entity attacker) ClientObituary = return; } deathstring2 = "'s quad rocket\n"; - } - else - { - deathstring = " rides "; - deathstring2 = "'s rocket\n"; + } else { if (targ.health < -40) - { deathstring = " was gibbed by "; - deathstring2 = "'s rocket\n" ; - } + else + deathstring = " rides "; + deathstring2 = "'s rocket\n"; } + break; + default: + break; } - else if (rnum == IT_AXE) - { + switch (attacker.weapon) { + case IT_AXE: deathstring = " was ax-murdered by "; deathstring2 = "\n"; - } - else if (rnum == IT_SHOTGUN) - { + break; + case IT_SHOTGUN: deathstring = " chewed on "; deathstring2 = "'s boomstick\n"; - } - else if (rnum == IT_SUPER_SHOTGUN) - { + break; + case IT_SUPER_SHOTGUN: deathstring = " ate 2 loads of "; deathstring2 = "'s buckshot\n"; - } - else if (rnum == IT_LIGHTNING) - { + break; + case IT_LIGHTNING: deathstring = " accepts "; if (attacker.waterlevel > 1) deathstring2 = "'s discharge\n"; else deathstring2 = "'s shaft\n"; + break; + default: + break; } - bprint (PRINT_MEDIUM,targ.netname); - bprint (PRINT_MEDIUM,deathstring); - bprint (PRINT_MEDIUM,attacker.netname); - bprint (PRINT_MEDIUM,deathstring2); + bprint (PRINT_MEDIUM, targ.netname); + bprint (PRINT_MEDIUM, deathstring); + bprint (PRINT_MEDIUM, attacker.netname); + bprint (PRINT_MEDIUM, deathstring2); } return; - } - else - { + case "explo.box": + targ.frags--; // killed self logfrag (targ, targ); - targ.frags = targ.frags - 1; // killed self - bprint (PRINT_MEDIUM,targ.netname); + bprint (PRINT_MEDIUM, targ.netname); + bprint (PRINT_MEDIUM," blew up\n"); + return; + case "fireball": + targ.frags--; // killed self + logfrag (targ, targ); + bprint (PRINT_MEDIUM, targ.netname); + bprint (PRINT_MEDIUM," ate a lavaball\n"); + return; + case "trigger_changelevel": + targ.frags--; // killed self + logfrag (targ, targ); + bprint (PRINT_MEDIUM, targ.netname); + bprint (PRINT_MEDIUM," tried to leave\n"); + return; + default: + targ.frags--; // killed self + logfrag (targ, targ); + bprint (PRINT_MEDIUM, targ.netname); - // killed by a montser? - if (attacker.flags & FL_MONSTER) - { - if (attacker.classname == "monster_army") + // killed by a monster? + if (attacker.flags & FL_MONSTER) { + switch (attacker.classname) { + case "monster_army": bprint (PRINT_HIGH, " was shot by a Grunt\n"); - if (attacker.classname == "monster_demon1") + return; + case "monster_demon1": bprint (PRINT_HIGH, " was eviscerated by a Fiend\n"); - if (attacker.classname == "monster_dog") + return; + case "monster_dog": bprint (PRINT_HIGH, " was mauled by a Rottweiler\n"); - if (attacker.classname == "monster_dragon") - bprint (PRINT_HIGH, " was fried by a Dragon\n"); - if (attacker.classname == "monster_enforcer") + return; + case "monster_enforcer": bprint (PRINT_HIGH, " was blasted by an Enforcer\n"); - if (attacker.classname == "monster_fish") + return; + case "monster_fish": bprint (PRINT_HIGH, " was fed to the Rotfish\n"); - if (attacker.classname == "monster_hell_knight") + return; + case "monster_hell_knight": bprint (PRINT_HIGH, " was slain by a Death Knight\n"); - if (attacker.classname == "monster_knight") + return; + case "monster_knight": bprint (PRINT_HIGH, " was slashed by a Knight\n"); - if (attacker.classname == "monster_ogre") + return; + case "monster_ogre": bprint (PRINT_HIGH, " was destroyed by an Ogre\n"); - if (attacker.classname == "monster_oldone") + return; + case "monster_oldone": bprint (PRINT_HIGH, " became one with Shub-Niggurath\n"); - if (attacker.classname == "monster_shalrath") + return; + case "monster_shalrath": bprint (PRINT_HIGH, " was exploded by a Vore\n"); - if (attacker.classname == "monster_shambler") + return; + case "monster_shambler": bprint (PRINT_HIGH, " was smashed by a Shambler\n"); - if (attacker.classname == "monster_tarbaby") + return; + case "monster_tarbaby": bprint (PRINT_HIGH, " was slimed by a Spawn\n"); - if (attacker.classname == "monster_vomit") - bprint (PRINT_HIGH, " was vomited on by a Vomitus\n"); - if (attacker.classname == "monster_wizard") + return; + case "monster_wizard": bprint (PRINT_HIGH, " was scragged by a Scrag\n"); - if (attacker.classname == "monster_zombie") + return; + case "monster_zombie": bprint (PRINT_HIGH, " joins the Zombies\n"); - - return; + return; + default: + break; + } } - rnum = targ.watertype; - - if (rnum == -3) - { - if (random() < 0.5) - bprint (PRINT_MEDIUM," sleeps with the fishes\n"); + switch (targ.watertype) { + case -3: + if (random () < 0.5) + bprint (PRINT_MEDIUM, " sleeps with the fishes\n"); else - bprint (PRINT_MEDIUM," sucks it down\n"); + bprint (PRINT_MEDIUM, " sucks it down\n"); return; - } - else if (rnum == -4) - { - if (random() < 0.5) - bprint (PRINT_MEDIUM," gulped a load of slime\n"); + case -4: + if (random () < 0.5) + bprint (PRINT_MEDIUM, " gulped a load of slime\n"); else - bprint (PRINT_MEDIUM," can't exist on slime alone\n"); + bprint (PRINT_MEDIUM, " can't exist on slime alone\n"); return; - } - else if (rnum == -5) - { - if (targ.health < -15) - { - bprint (PRINT_MEDIUM," burst into flames\n"); + case -5: + if (targ.health < -15) { + bprint (PRINT_MEDIUM, " burst into flames\n"); return; } - if (random() < 0.5) - bprint (PRINT_MEDIUM," turned into hot slag\n"); + if (random () < 0.5) + bprint (PRINT_MEDIUM, " turned into hot slag\n"); else - bprint (PRINT_MEDIUM," visits the Volcano God\n"); + bprint (PRINT_MEDIUM, " visits the Volcano God\n"); return; + default: + break; } - if (attacker.classname == "explo_box") - { - bprint (PRINT_MEDIUM," blew up\n"); + switch (targ.deathtype) { + case "falling": + bprint (PRINT_MEDIUM, " fell to his death\n"); return; - } - if (targ.deathtype == "falling") - { - bprint (PRINT_MEDIUM," fell to his death\n"); + case "nail": + case "supernail": + bprint (PRINT_MEDIUM, " was spiked\n"); return; - } - if (targ.deathtype == "nail" || targ.deathtype == "supernail") - { - bprint (PRINT_MEDIUM," was spiked\n"); - return; - } - if (targ.deathtype == "laser") - { - bprint (PRINT_MEDIUM," was zapped\n"); - return; - } - if (attacker.classname == "fireball") - { - bprint (PRINT_MEDIUM," ate a lavaball\n"); - return; - } - if (attacker.classname == "trigger_changelevel") - { - bprint (PRINT_MEDIUM," tried to leave\n"); + case "laser": + bprint (PRINT_MEDIUM, " was zapped\n"); return; + default: + break; } - bprint (PRINT_MEDIUM," died\n"); + bprint (PRINT_MEDIUM, " died\n"); } } }; diff --git a/nqw/combat.qc b/nqw/combat.qc index c6f9bcf..072fd0e 100644 --- a/nqw/combat.qc +++ b/nqw/combat.qc @@ -1,4 +1,3 @@ - void() T_MissileTouch; void() info_player_start; void(entity targ, entity attacker) ClientObituary; @@ -19,9 +18,9 @@ explosions and melee attacks. float(entity targ, entity inflictor) CanDamage = { // bmodels need special checking because their origin is 0,0,0 - if (targ.movetype == MOVETYPE_PUSH) - { - traceline(inflictor.origin, 0.5 * (targ.absmin + targ.absmax), TRUE, self); + if (targ.movetype == MOVETYPE_PUSH) { + traceline (inflictor.origin, 0.5 * (targ.absmin + targ.absmax), TRUE, + self); if (trace_fraction == 1) return TRUE; if (trace_ent == targ) @@ -29,26 +28,25 @@ float(entity targ, entity inflictor) CanDamage = return FALSE; } - traceline(inflictor.origin, targ.origin, TRUE, self); + traceline (inflictor.origin, targ.origin, TRUE, self); if (trace_fraction == 1) return TRUE; - traceline(inflictor.origin, targ.origin + '15 15 0', TRUE, self); + traceline (inflictor.origin, targ.origin + '15 15 0', TRUE, self); if (trace_fraction == 1) return TRUE; - traceline(inflictor.origin, targ.origin + '-15 -15 0', TRUE, self); + traceline (inflictor.origin, targ.origin + '-15 -15 0', TRUE, self); if (trace_fraction == 1) return TRUE; - traceline(inflictor.origin, targ.origin + '-15 15 0', TRUE, self); + traceline (inflictor.origin, targ.origin + '-15 15 0', TRUE, self); if (trace_fraction == 1) return TRUE; - traceline(inflictor.origin, targ.origin + '15 -15 0', TRUE, self); + traceline (inflictor.origin, targ.origin + '15 -15 0', TRUE, self); if (trace_fraction == 1) return TRUE; return FALSE; }; - /* ============ Killed @@ -64,8 +62,8 @@ void(entity targ, entity attacker) Killed = if (self.health < -99) self.health = -99; // don't let sbar look bad if a player - if (self.movetype == MOVETYPE_PUSH || self.movetype == MOVETYPE_NONE) - { // doors, triggers, etc + if (self.movetype == MOVETYPE_PUSH || self.movetype == MOVETYPE_NONE) { + // doors, triggers, etc self.th_die (); self = oself; return; @@ -73,9 +71,8 @@ void(entity targ, entity attacker) Killed = self.enemy = attacker; -// bump the monster counter - if (self.flags & FL_MONSTER) - { + // bump the monster counter + if (self.flags & FL_MONSTER) { killed_monsters = killed_monsters + 1; WriteByte (MSG_ALL, SVC_KILLEDMONSTER); } @@ -92,7 +89,6 @@ void(entity targ, entity attacker) Killed = self = oself; }; - /* ============ T_Damage @@ -109,15 +105,13 @@ void(entity targ, entity inflictor, entity attacker, float damage) T_Damage= local float take; local string attackerteam, targteam; - if (!targ.takedamage) return; -// used by buttons and triggers to set activator for target firing + // used by buttons and triggers to set activator for target firing damage_attacker = attacker; - -// check for quad damage powerup on the attacker + // check for quad damage powerup on the attacker if (attacker.super_damage_finished > time && inflictor.classname != "door") if (deathmatch == 4) damage = damage * 8; @@ -127,8 +121,7 @@ void(entity targ, entity inflictor, entity attacker, float damage) T_Damage= // save damage based on the target's armor level save = ceil(targ.armortype*damage); - if (save >= targ.armorvalue) - { + if (save >= targ.armorvalue) { save = targ.armorvalue; targ.armortype = 0; // lost all armor targ.items = targ.items - (targ.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)); @@ -137,11 +130,10 @@ void(entity targ, entity inflictor, entity attacker, float damage) T_Damage= targ.armorvalue = targ.armorvalue - save; take = ceil(damage-save); -// add to the damage total for clients, which will be sent as a single -// message at the end of the frame -// FIXME: remove after combining shotgun blasts? - if (targ.flags & FL_CLIENT) - { + // add to the damage total for clients, which will be sent as a single + // message at the end of the frame + // FIXME: remove after combining shotgun blasts? + if (targ.flags & FL_CLIENT) { targ.dmg_take = targ.dmg_take + take; targ.dmg_save = targ.dmg_save + save; targ.dmg_inflictor = inflictor; @@ -149,10 +141,8 @@ void(entity targ, entity inflictor, entity attacker, float damage) T_Damage= damage_inflictor = inflictor; - -// figure momentum add - if ( (inflictor != world) && (targ.movetype == MOVETYPE_WALK) ) - { + // figure momentum add + if ( (inflictor != world) && (targ.movetype == MOVETYPE_WALK) ) { dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5; dir = normalize(dir); // Set kickback for smaller weapons @@ -161,33 +151,28 @@ void(entity targ, entity inflictor, entity attacker, float damage) T_Damage= // if ( (damage < 60) & ((attacker.classname == "player") & (targ.classname == "player")) & ( attacker.netname != targ.netname)) // targ.velocity = targ.velocity + dir * damage * 11; // else - // Otherwise, these rules apply to rockets and grenades + // Otherwise, these rules apply to rockets and grenades // for blast velocity - targ.velocity = targ.velocity + dir * damage * 8; - + targ.velocity = targ.velocity + dir * damage * 8; + // Rocket Jump modifiers if ( (rj > 1) & ((attacker.classname == "player") & (targ.classname == "player")) & ( attacker.netname == targ.netname)) targ.velocity = targ.velocity + dir * damage * rj; - } - - -// check for godmode or invincibility + // check for godmode or invincibility if (targ.flags & FL_GODMODE) return; - if (targ.invincible_finished >= time) - { - if (self.invincible_sound < time) - { + if (targ.invincible_finished >= time) { + if (self.invincible_sound < time) { sound (targ, CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM); self.invincible_sound = time + 2; } return; } -// team play damage avoidance -//ZOID 12-13-96: self.team doesn't work in QW. Use keys + // team play damage avoidance + //ZOID 12-13-96: self.team doesn't work in QW. Use keys attackerteam = infokey(attacker, "team"); targteam = infokey(targ, "team"); @@ -200,28 +185,24 @@ void(entity targ, entity inflictor, entity attacker, float damage) T_Damage= (attacker.classname == "player") && (attackerteam != "") && (targ != attacker)&& inflictor.classname !="door") return; - -// do the damage + + // do the damage targ.health = targ.health - take; - if (targ.health <= 0) - { + if (targ.health <= 0) { Killed (targ, attacker); return; } -// react to the damage + // react to the damage oldself = self; self = targ; - if ( (self.flags & FL_MONSTER) && attacker != world) - { + if ( (self.flags & FL_MONSTER) && attacker != world) { // get mad unless of the same class (except for soldiers) - if (self != attacker && attacker != self.enemy) - { - if ( (self.classname != attacker.classname) - || (self.classname == "monster_army" ) ) - { + if (self != attacker && attacker != self.enemy) { + if ((self.classname != attacker.classname) + || (self.classname == "monster_army")) { if (self.enemy.classname == "player") self.oldenemy = self.enemy; self.enemy = attacker; @@ -230,8 +211,7 @@ void(entity targ, entity inflictor, entity attacker, float damage) T_Damage= } } - if (self.th_pain) - { + if (self.th_pain) { self.th_pain (attacker, take); // nightmare mode monsters don't go into pain frames often if (skill == 3) @@ -254,17 +234,14 @@ void(entity inflictor, entity attacker, float damage, entity ignore, string dtyp head = findradius(inflictor.origin, damage+40); - while (head) - { - //bprint (PRINT_HIGH, head.classname); - //bprint (PRINT_HIGH, " | "); - //bprint (PRINT_HIGH, head.netname); - //bprint (PRINT_HIGH, "\n"); + while (head) { +// bprint (PRINT_HIGH, head.classname); +// bprint (PRINT_HIGH, " | "); +// bprint (PRINT_HIGH, head.netname); +// bprint (PRINT_HIGH, "\n"); - if (head != ignore) - { - if (head.takedamage) - { + if (head != ignore) { + if (head.takedamage) { org = head.origin + (head.mins + head.maxs)*0.5; points = 0.5*vlen (inflictor.origin - org); if (points < 0) @@ -273,10 +250,8 @@ void(entity inflictor, entity attacker, float damage, entity ignore, string dtyp if (head == attacker) points = points * 0.5; - if (points > 0) - { - if (CanDamage (head, inflictor)) - { + if (points > 0) { + if (CanDamage (head, inflictor)) { head.deathtype = dtype; // shambler takes half damage from all explosions if (head.classname == "monster_shambler") @@ -284,7 +259,6 @@ void(entity inflictor, entity attacker, float damage, entity ignore, string dtyp else T_Damage (head, inflictor, attacker, points); } - } } } @@ -304,20 +278,16 @@ void(entity attacker, float damage) T_BeamDamage = head = findradius(attacker.origin, damage+40); - while (head) - { - if (head.takedamage) - { - points = 0.5*vlen (attacker.origin - head.origin); + while (head) { + if (head.takedamage) { + points = 0.5 * vlen (attacker.origin - head.origin); if (points < 0) points = 0; points = damage - points; if (head == attacker) points = points * 0.5; - if (points > 0) - { - if (CanDamage (head, attacker)) - { + if (points > 0) { + if (CanDamage (head, attacker)) { if (head.classname == "monster_shambler") T_Damage (head, attacker, attacker, points*0.5); else @@ -328,4 +298,3 @@ void(entity attacker, float damage) T_BeamDamage = head = head.chain; } }; - diff --git a/nqw/defs.qc b/nqw/defs.qc index 5a46426..c3107e6 100644 --- a/nqw/defs.qc +++ b/nqw/defs.qc @@ -1,4 +1,3 @@ - /* ============================================================================== @@ -7,21 +6,19 @@ ============================================================================== */ -// // system globals -// -entity self; -entity other; -entity world; -float time; -float frametime; +entity self; +entity other; +entity world; +float time; +float frametime; -entity newmis; // if this is set, the entity that just +entity newmis; // if this is set, the entity that just // run created a new missile that should // be simulated immediately -float force_retouch; // force all entities to touch triggers +float force_retouch; // force all entities to touch triggers // next frame. this is needed because // non-moving things don't normally scan // for triggers, and when a trigger is @@ -29,416 +26,374 @@ float force_retouch; // force all entities to touch triggers // needs to catch everything. // decremented each frame, so set to 2 // to guarantee everything is touched -string mapname; +string mapname; -float serverflags; // propagated from level to level, used to +float serverflags; // propagated from level to level, used to // keep track of completed episodes -float total_secrets; -float total_monsters; +float total_secrets; +float total_monsters; -float found_secrets; // number of secrets found -float killed_monsters; // number of monsters killed +float found_secrets; // number of secrets found +float killed_monsters; // number of monsters killed // spawnparms are used to encode information about clients across server // level changes -float parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16; +float parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16; // // global variables set by built in functions -// -vector v_forward, v_up, v_right; // set by makevectors() +// +vector v_forward, v_up, v_right; // set by makevectors() // set by traceline / tracebox -float trace_allsolid; -float trace_startsolid; -float trace_fraction; -vector trace_endpos; -vector trace_plane_normal; -float trace_plane_dist; -entity trace_ent; -float trace_inopen; -float trace_inwater; +float trace_allsolid; +float trace_startsolid; +float trace_fraction; +vector trace_endpos; +vector trace_plane_normal; +float trace_plane_dist; +entity trace_ent; +float trace_inopen; +float trace_inwater; -entity msg_entity; // destination of single entity writes +entity msg_entity; // destination of single entity writes -// // required prog functions -// -void() main; // only for testing +void() StartFrame; -void() StartFrame; +void() PlayerPreThink; +void() PlayerPostThink; -void() PlayerPreThink; -void() PlayerPostThink; +void() ClientKill; +void() ClientConnect; +void() PutClientInServer; // call after setting the parm1... parms +void() ClientDisconnect; -void() ClientKill; -void() ClientConnect; -void() PutClientInServer; // call after setting the parm1... parms -void() ClientDisconnect; - -void() SetNewParms; // called when a client first connects to - // a server. sets parms so they can be - // saved off for restarts - -void() SetChangeParms; // call to set parms for self so they can +void() SetNewParms; // called when a client first connects to a + // server. sets parms so they can be saved off for restarts +void() SetChangeParms; // call to set parms for self so they can // be saved for a level transition - //================================================ -void end_sys_globals; // flag for structure dumping +void end_sys_globals; // flag for structure dumping //================================================ -/* -============================================================================== +// SOURCE FOR ENTVARS_T C STRUCTURE =========================================== - SOURCE FOR ENTVARS_T C STRUCTURE -============================================================================== -*/ - -// // system fields (*** = do not set in prog code, maintained by C code) -// -.float modelindex; // *** model index in the precached list -.vector absmin, absmax; // *** origin + mins / maxs +.float modelindex; // *** model index in the precached list +.vector absmin, absmax; // *** origin + mins / maxs -.float ltime; // local time for entity -.float lastruntime; // *** to allow entities to run out of sequence +.float ltime; // local time for entity +.float lastruntime; // *** to allow entities to run out of sequence -.float movetype; -.float solid; +.float movetype; +.float solid; -.vector origin; // *** -.vector oldorigin; // *** -.vector velocity; -.vector angles; -.vector avelocity; +.vector origin; +.vector oldorigin; +.vector velocity; +.vector angles; +.vector avelocity; -.string classname; // spawn function -.string model; -.float frame; -.float skin; -.float effects; +.string classname; // spawn function +.string model; +.float frame; +.float skin; +.float effects; -.vector mins, maxs; // bounding box extents reletive to origin -.vector size; // maxs - mins - -.void() touch; -.void() use; -.void() think; -.void() blocked; // for doors or plats, called when can't push other - -.float nextthink; -.entity groundentity; +.vector mins, maxs; // bounding box extents reletive to origin +.vector size; // maxs - mins +.void() touch; +.void() use; +.void() think; +.void() blocked; // for doors or plats, called when can't push other +.float nextthink; +.entity groundentity; // stats -.float health; -.float frags; -.float weapon; // one of the IT_SHOTGUN, etc flags -.string weaponmodel; -.float weaponframe; -.float currentammo; -.float ammo_shells, ammo_nails, ammo_rockets, ammo_cells; +.float health; +.float frags; +.float weapon; // one of the IT_SHOTGUN, etc flags +.string weaponmodel; +.float weaponframe; +.float currentammo; +.float ammo_shells, ammo_nails, ammo_rockets, ammo_cells; -.float items; // bit flags +.float items; // bit flags -.float takedamage; -.entity chain; -.float deadflag; +.float takedamage; +.entity chain; +.float deadflag; -.vector view_ofs; // add to origin to get eye point +.vector view_ofs; // add to origin to get eye point +.float button0; // fire +.float button1; // use +.float button2; // jump -.float button0; // fire -.float button1; // use -.float button2; // jump +.float impulse; // weapon changes -.float impulse; // weapon changes +.float fixangle; +.vector v_angle; // view / targeting angle for players -.float fixangle; -.vector v_angle; // view / targeting angle for players +.string netname; -.string netname; +.entity enemy; -.entity enemy; +.float flags; -.float flags; +.float colormap; +.float team; -.float colormap; -.float team; +.float max_health; // players maximum health is stored here -.float max_health; // players maximum health is stored here +.float teleport_time; // don't back up -.float teleport_time; // don't back up +.float armortype; // save this fraction of incoming damage +.float armorvalue; -.float armortype; // save this fraction of incoming damage -.float armorvalue; +.float waterlevel; // 0 = not in, 1 = feet, 2 = wast, 3 = eyes +.float watertype; // a contents value -.float waterlevel; // 0 = not in, 1 = feet, 2 = wast, 3 = eyes -.float watertype; // a contents value +.float ideal_yaw; +.float yaw_speed; -.float ideal_yaw; -.float yaw_speed; +.entity aiment; -.entity aiment; +.entity goalentity; // a movetarget or an enemy -.entity goalentity; // a movetarget or an enemy +.float spawnflags; -.float spawnflags; - -.string target; -.string targetname; +.string target; +.string targetname; // damage is accumulated through a frame. and sent as one single // message, so the super shotgun doesn't generate huge messages -.float dmg_take; -.float dmg_save; -.entity dmg_inflictor; +.float dmg_take; +.float dmg_save; +.entity dmg_inflictor; -.entity owner; // who launched a missile -.vector movedir; // mostly for doors, but also used for waterjump +.entity owner; // who launched a missile +.vector movedir; // mostly for doors, but also used for waterjump -.string message; // trigger messages +.string message; // trigger messages -.float sounds; // either a cd track number or sound number +.float sounds; // either a cd track number or sound number -.string noise, noise1, noise2, noise3; // contains names of wavs to play +.string noise, noise1, noise2, noise3; // contains wav names to play //================================================ -void end_sys_fields; // flag for structure dumping +void end_sys_fields; // flag for structure dumping //================================================ -/* -============================================================================== +// VARS NOT REFERENCED BY C CODE ============================================== - VARS NOT REFERENCED BY C CODE - -============================================================================== -*/ - - -// // constants -// - -float FALSE = 0; -float TRUE = 1; +float FALSE = 0; +float TRUE = 1; // edict.flags -float FL_FLY = 1; -float FL_SWIM = 2; -float FL_CLIENT = 8; // set for all client edicts -float FL_INWATER = 16; // for enter / leave water splash -float FL_MONSTER = 32; -float FL_GODMODE = 64; // player cheat -float FL_NOTARGET = 128; // player cheat -float FL_ITEM = 256; // extra wide size for bonus items -float FL_ONGROUND = 512; // standing on something -float FL_PARTIALGROUND = 1024; // not all corners are valid -float FL_WATERJUMP = 2048; // player jumping out of water -float FL_JUMPRELEASED = 4096; // for jump debouncing +float FL_FLY = 1; +float FL_SWIM = 2; +float FL_CLIENT = 8; // set for all client edicts +float FL_INWATER = 16; // enter/leave water splash +float FL_MONSTER = 32; +float FL_GODMODE = 64; // player cheat +float FL_NOTARGET = 128; // player cheat +float FL_ITEM = 256; // extra wide size for bonus items +float FL_ONGROUND = 512; // standing on something +float FL_PARTIALGROUND = 1024; // not all corners are valid +float FL_WATERJUMP = 2048; // player jumping out of water +float FL_JUMPRELEASED = 4096; // for jump debouncing // edict.movetype values -float MOVETYPE_NONE = 0; // never moves -//float MOVETYPE_ANGLENOCLIP = 1; -//float MOVETYPE_ANGLECLIP = 2; -float MOVETYPE_WALK = 3; // players only -float MOVETYPE_STEP = 4; // discrete, not real time unless fall -float MOVETYPE_FLY = 5; -float MOVETYPE_TOSS = 6; // gravity -float MOVETYPE_PUSH = 7; // no clip to world, push and crush -float MOVETYPE_NOCLIP = 8; -float MOVETYPE_FLYMISSILE = 9; // fly with extra size against monsters -float MOVETYPE_BOUNCE = 10; -float MOVETYPE_BOUNCEMISSILE = 11; // bounce with extra size +float MOVETYPE_NONE = 0; // never moves +//float MOVETYPE_ANGLENOCLIP = 1; +//float MOVETYPE_ANGLECLIP = 2; +float MOVETYPE_WALK = 3; // players only +float MOVETYPE_STEP = 4; // discrete, not real time unless fall +float MOVETYPE_FLY = 5; +float MOVETYPE_TOSS = 6; // gravity +float MOVETYPE_PUSH = 7; // no clip to world, push and crush +float MOVETYPE_NOCLIP = 8; +float MOVETYPE_FLYMISSILE = 9; // fly with extra size against monsters +float MOVETYPE_BOUNCE = 10; +float MOVETYPE_BOUNCEMISSILE = 11; // bounce with extra size // edict.solid values -float SOLID_NOT = 0; // no interaction with other objects +float SOLID_NOT = 0; // no interaction with other objects float SOLID_TRIGGER = 1; // touch on edge, but not blocking -float SOLID_BBOX = 2; // touch on edge, block +float SOLID_BBOX = 2; // touch on edge, block float SOLID_SLIDEBOX = 3; // touch on edge, but not an onground -float SOLID_BSP = 4; // bsp clip, touch on edge, block +float SOLID_BSP = 4; // bsp clip, touch on edge, block // range values -float RANGE_MELEE = 0; -float RANGE_NEAR = 1; -float RANGE_MID = 2; -float RANGE_FAR = 3; +float RANGE_MELEE = 0; +float RANGE_NEAR = 1; +float RANGE_MID = 2; +float RANGE_FAR = 3; // deadflag values - -float DEAD_NO = 0; -float DEAD_DYING = 1; -float DEAD_DEAD = 2; +float DEAD_NO = 0; +float DEAD_DYING = 1; +float DEAD_DEAD = 2; float DEAD_RESPAWNABLE = 3; // takedamage values - -float DAMAGE_NO = 0; -float DAMAGE_YES = 1; -float DAMAGE_AIM = 2; +float DAMAGE_NO = 0; +float DAMAGE_YES = 1; +float DAMAGE_AIM = 2; // items -float IT_AXE = 4096; -float IT_SHOTGUN = 1; +float IT_AXE = 4096; +float IT_SHOTGUN = 1; float IT_SUPER_SHOTGUN = 2; -float IT_NAILGUN = 4; +float IT_NAILGUN = 4; float IT_SUPER_NAILGUN = 8; float IT_GRENADE_LAUNCHER = 16; float IT_ROCKET_LAUNCHER = 32; float IT_LIGHTNING = 64; float IT_EXTRA_WEAPON = 128; -float IT_SHELLS = 256; -float IT_NAILS = 512; -float IT_ROCKETS = 1024; -float IT_CELLS = 2048; +float IT_SHELLS = 256; +float IT_NAILS = 512; +float IT_ROCKETS = 1024; +float IT_CELLS = 2048; -float IT_ARMOR1 = 8192; -float IT_ARMOR2 = 16384; -float IT_ARMOR3 = 32768; +float IT_ARMOR1 = 8192; +float IT_ARMOR2 = 16384; +float IT_ARMOR3 = 32768; float IT_SUPERHEALTH = 65536; -float IT_KEY1 = 131072; -float IT_KEY2 = 262144; +float IT_KEY1 = 131072; +float IT_KEY2 = 262144; float IT_INVISIBILITY = 524288; float IT_INVULNERABILITY = 1048576; -float IT_SUIT = 2097152; -float IT_QUAD = 4194304; +float IT_SUIT = 2097152; +float IT_QUAD = 4194304; // point content values - float CONTENT_EMPTY = -1; float CONTENT_SOLID = -2; float CONTENT_WATER = -3; float CONTENT_SLIME = -4; float CONTENT_LAVA = -5; -float CONTENT_SKY = -6; +float CONTENT_SKY = -6; -float STATE_TOP = 0; -float STATE_BOTTOM = 1; -float STATE_UP = 2; -float STATE_DOWN = 3; +float STATE_TOP = 0; +float STATE_BOTTOM = 1; +float STATE_UP = 2; +float STATE_DOWN = 3; -vector VEC_ORIGIN = '0 0 0'; -vector VEC_HULL_MIN = '-16 -16 -24'; -vector VEC_HULL_MAX = '16 16 32'; +vector VEC_ORIGIN = '0 0 0'; +vector VEC_HULL_MIN = '-16 -16 -24'; +vector VEC_HULL_MAX = '16 16 32'; vector VEC_HULL2_MIN = '-32 -32 -24'; vector VEC_HULL2_MAX = '32 32 64'; // protocol bytes -float SVC_TEMPENTITY = 23; -float SVC_KILLEDMONSTER = 27; -float SVC_FOUNDSECRET = 28; -float SVC_INTERMISSION = 30; -float SVC_FINALE = 31; -float SVC_CDTRACK = 32; -float SVC_SELLSCREEN = 33; -float SVC_SMALLKICK = 34; -float SVC_BIGKICK = 35; -float SVC_MUZZLEFLASH = 39; +float SVC_TEMPENTITY = 23; +float SVC_KILLEDMONSTER = 27; +float SVC_FOUNDSECRET = 28; +float SVC_INTERMISSION = 30; +float SVC_FINALE = 31; +float SVC_CDTRACK = 32; +float SVC_SELLSCREEN = 33; +float SVC_SMALLKICK = 34; +float SVC_BIGKICK = 35; +float SVC_MUZZLEFLASH = 39; - -float TE_SPIKE = 0; -float TE_SUPERSPIKE = 1; -float TE_GUNSHOT = 2; -float TE_EXPLOSION = 3; -float TE_TAREXPLOSION = 4; -float TE_LIGHTNING1 = 5; -float TE_LIGHTNING2 = 6; -float TE_WIZSPIKE = 7; -float TE_KNIGHTSPIKE = 8; -float TE_LIGHTNING3 = 9; -float TE_LAVASPLASH = 10; -float TE_TELEPORT = 11; -float TE_BLOOD = 12; -float TE_LIGHTNINGBLOOD = 13; +float TE_SPIKE = 0; +float TE_SUPERSPIKE = 1; +float TE_GUNSHOT = 2; +float TE_EXPLOSION = 3; +float TE_TAREXPLOSION = 4; +float TE_LIGHTNING1 = 5; +float TE_LIGHTNING2 = 6; +float TE_WIZSPIKE = 7; +float TE_KNIGHTSPIKE = 8; +float TE_LIGHTNING3 = 9; +float TE_LAVASPLASH = 10; +float TE_TELEPORT = 11; +float TE_BLOOD = 12; +float TE_LIGHTNINGBLOOD = 13; // sound channels // channel 0 never willingly overrides // other channels (1-7) allways override a playing sound on that channel -float CHAN_AUTO = 0; -float CHAN_WEAPON = 1; -float CHAN_VOICE = 2; -float CHAN_ITEM = 3; -float CHAN_BODY = 4; -float CHAN_NO_PHS_ADD = 8; // ie: CHAN_BODY+CHAN_NO_PHS_ADD +float CHAN_AUTO = 0; +float CHAN_WEAPON = 1; +float CHAN_VOICE = 2; +float CHAN_ITEM = 3; +float CHAN_BODY = 4; +float CHAN_NO_PHS_ADD = 8; // ie: CHAN_BODY+CHAN_NO_PHS_ADD -float ATTN_NONE = 0; -float ATTN_NORM = 1; -float ATTN_IDLE = 2; -float ATTN_STATIC = 3; +float ATTN_NONE = 0; +float ATTN_NORM = 1; +float ATTN_IDLE = 2; +float ATTN_STATIC = 3; // update types - -float UPDATE_GENERAL = 0; -float UPDATE_STATIC = 1; -float UPDATE_BINARY = 2; -float UPDATE_TEMP = 3; +float UPDATE_GENERAL = 0; +float UPDATE_STATIC = 1; +float UPDATE_BINARY = 2; +float UPDATE_TEMP = 3; // entity effects -//float EF_BRIGHTFIELD = 1; -//float EF_MUZZLEFLASH = 2; -float EF_BRIGHTLIGHT = 4; -float EF_DIMLIGHT = 8; -float EF_FLAG1 = 16; -float EF_FLAG2 = 32; +float EF_BRIGHTLIGHT = 4; +float EF_DIMLIGHT = 8; +float EF_FLAG1 = 16; +float EF_FLAG2 = 32; // GLQuakeWorld Stuff -float EF_BLUE = 64; // Blue Globe effect for Quad -float EF_RED = 128; // Red Globe effect for Pentagram +float EF_BLUE = 64; // Blue Globe effect for Quad +float EF_RED = 128; // Red Globe effect for Pentagram // messages -float MSG_BROADCAST = 0; // unreliable to all -float MSG_ONE = 1; // reliable to one (msg_entity) -float MSG_ALL = 2; // reliable to all -float MSG_INIT = 3; // write to the init string -float MSG_MULTICAST = 4; // for multicast() call +float MSG_BROADCAST = 0; // unreliable to all +float MSG_ONE = 1; // reliable to one (msg_entity) +float MSG_ALL = 2; // reliable to all +float MSG_INIT = 3; // write to the init string +float MSG_MULTICAST = 4; // for multicast() call // message levels -float PRINT_LOW = 0; // pickup messages -float PRINT_MEDIUM = 1; // death messages -float PRINT_HIGH = 2; // critical messages -float PRINT_CHAT = 3; // also goes to chat console +float PRINT_LOW = 0; // pickup messages +float PRINT_MEDIUM = 1; // death messages +float PRINT_HIGH = 2; // critical messages +float PRINT_CHAT = 3; // also goes to chat console // multicast sets -float MULTICAST_ALL = 0; // every client -float MULTICAST_PHS = 1; // within hearing -float MULTICAST_PVS = 2; // within sight -float MULTICAST_ALL_R = 3; // every client, reliable -float MULTICAST_PHS_R = 4; // within hearing, reliable -float MULTICAST_PVS_R = 5; // within sight, reliable +float MULTICAST_ALL = 0; // every client +float MULTICAST_PHS = 1; // within hearing +float MULTICAST_PVS = 2; // within sight +float MULTICAST_ALL_R = 3; // every client, reliable +float MULTICAST_PHS_R = 4; // within hearing, reliable +float MULTICAST_PVS_R = 5; // within sight, reliable +// globals ==================================================================== +float movedist; +string string_null; // null string, nothing should be held here +float empty_float; -//================================================ +entity activator; // the entity that activated a trigger or brush -// -// globals -// -float movedist; - -string string_null; // null string, nothing should be held here -float empty_float; - -entity activator; // the entity that activated a trigger or brush - -entity damage_attacker; // set by T_Damage -entity damage_inflictor; -float framecount; +entity damage_attacker; // set by T_Damage +entity damage_inflictor; +float framecount; float coop; float skill; -// // cvars checked each frame -// float teamplay; float timelimit; float fraglimit; @@ -447,36 +402,29 @@ float rj; //================================================ -// // world fields (FIXME: make globals) -// -.string wad; -.string map; -.float worldtype; // 0=medieval 1=metal 2=base +.string wad; +.string map; +.float worldtype; // 0=medieval 1=metal 2=base //================================================ -.string killtarget; +.string killtarget; -// // quakeed fields -// -.float light_lev; // not used by game, but parsed by light util -.float style; +.float light_lev; // not used by game, but parsed by light util +.float style; - -// // monster ai -// -.void() th_stand; -.void() th_walk; -.void() th_run; -.void() th_missile; -.void() th_melee; -.void(entity attacker, float damage) th_pain; +.void() th_stand; +.void() th_walk; +.void() th_run; +.void() th_missile; +.void() th_melee; +.void(entity attacker, float damage) th_pain; .void() th_die; -.entity oldenemy; // mad at this player before taking damage +.entity oldenemy; // mad at this player before taking damage .float speed; @@ -490,9 +438,7 @@ float AS_SLIDING = 2; float AS_MELEE = 3; float AS_MISSILE = 4; -// // player only fields -// .float voided; .float walkframe; @@ -500,8 +446,6 @@ float AS_MISSILE = 4; .float maxspeed; // Used to set Maxspeed on a player .float gravity; // Gravity Multiplier (0 to 1.0) - - .float attack_finished; .float pain_finished; @@ -518,18 +462,16 @@ float AS_MISSILE = 4; .float axhitme; -.float show_hostile; // set to time+0.2 whenever a client fires a - // weapon or takes damage. Used to alert - // monsters that otherwise would let the player go -.float jump_flag; // player jump flag -.float swim_flag; // player swimming sound flag -.float air_finished; // when time > air_finished, start drowning -.float bubble_count; // keeps track of the number of bubbles -.string deathtype; // keeps track of how the player died +.float show_hostile; // set to time+0.2 whenever a client fires a + // weapon or takes damage. Used to alert + // monsters that otherwise ignore the player +.float jump_flag; // player jump flag +.float swim_flag; // player swimming sound flag +.float air_finished; // when time > air_finished, start drowning +.float bubble_count; // keeps track of the number of bubbles +.string deathtype; // keeps track of how the player died -// // object stuff -// .string mdl; .vector mangle; // angle at start @@ -537,86 +479,58 @@ float AS_MISSILE = 4; .float t_length, t_width; - -// // doors, etc -// .vector dest, dest1, dest2; .float wait; // time from firing to restarting .float delay; // time from activation to firing .entity trigger_field; // door's trigger entity .string noise4; -// // monsters -// .float pausetime; .entity movetarget; - -// // doors -// .float aflag; .float dmg; // damage done by door when hit -// // misc -// .float cnt; // misc flag -// // subs -// .void() think1; .vector finaldest, finalangle; -// // triggers -// .float count; // for counting triggers - -// // plats / doors / buttons -// .float lip; .float state; .vector pos1, pos2; // top and bottom positions .float height; -// // sounds -// .float waitmin, waitmax; .float distance; .float volume; +// builtin functions ========================================================== - - -//=========================================================================== - - -// -// builtin functions -// - -void(vector ang) makevectors = #1; // sets v_forward, etc globals -void(entity e, vector o) setorigin = #2; -void(entity e, string m) setmodel = #3; // set movetype and solid first -void(entity e, vector min, vector max) setsize = #4; -// #5 was removed -void() Break = #6; -float() random = #7; // returns 0 - 1 +void(vector ang) makevectors = #1; // sets v_forward, etc globals +void(entity e, vector o) setorigin = #2; +void(entity e, string m) setmodel = #3; // set movetype and solid first +void(entity e, vector min, vector max) setsize = #4; +void() Break = #6; +float() random = #7; // returns 0 - 1 void(entity e, float chan, string samp, float vol, float atten) sound = #8; -vector(vector v) normalize = #9; -void(string e) error = #10; -void(string e) objerror = #11; -float(vector v) vlen = #12; -float(vector v) vectoyaw = #13; -entity() spawn = #14; -void(entity e) remove = #15; +vector(vector v) normalize = #9; +void(string e) error = #10; +void(string e) objerror = #11; +float(vector v) vlen = #12; +float(vector v) vectoyaw = #13; +entity() spawn = #14; +void(entity e) remove = #15; // sets trace_* globals // nomonsters can be: @@ -624,91 +538,76 @@ void(entity e) remove = #15; // forent->owner == test, or test->owner == forent // a forent of world is ignored void(vector v1, vector v2, float nomonsters, entity forent) traceline = #16; - -entity() checkclient = #17; // returns a client to look for +entity() checkclient = #17; // returns a client to look for entity(entity start, .string fld, string match) find = #18; -string(string s) precache_sound = #19; -string(string s) precache_model = #20; -void(entity client, string s)stuffcmd = #21; +string(string s) precache_sound = #19; +string(string s) precache_model = #20; +void(entity client, string s)stuffcmd = #21; entity(vector org, float rad) findradius = #22; -void(float level, string s) bprint = #23; +void(float level, string s) bprint = #23; void(entity client, float level, string s) sprint = #24; -void(string s) dprint = #25; -string(float f) ftos = #26; -string(vector v) vtos = #27; -void() coredump = #28; // prints all edicts -void() traceon = #29; // turns statment trace on -void() traceoff = #30; -void(entity e) eprint = #31; // prints an entire edict +void(string s) dprint = #25; +string(float f) ftos = #26; +string(vector v) vtos = #27; +void() coredump = #28; // prints all edicts +void() traceon = #29; // turns statment trace on +void() traceoff = #30; +void(entity e) eprint = #31; // prints an entire edict float(float yaw, float dist) walkmove = #32; // returns TRUE or FALSE -// #33 was removed -float() droptofloor= #34; // TRUE if landed on floor +float() droptofloor = #34; // TRUE if landed on floor void(float style, string value) lightstyle = #35; -float(float v) rint = #36; // round to nearest int -float(float v) floor = #37; // largest integer <= v -float(float v) ceil = #38; // smallest integer >= v -// #39 was removed -float(entity e) checkbottom = #40; // true if self is on ground -float(vector v) pointcontents = #41; // returns a CONTENT_* -// #42 was removed -float(float f) fabs = #43; -vector(entity e, float speed) aim = #44; // returns the shooting vector -float(string s) cvar = #45; // return cvar.value -void(string s) localcmd = #46; // put string into local que -entity(entity e) nextent = #47; // for looping through all ents -// #48 was removed -void() ChangeYaw = #49; // turn towards self.ideal_yaw - // at self.yaw_speed -// #50 was removed -vector(vector v) vectoangles = #51; +float(float v) rint = #36; // round to nearest int +float(float v) floor = #37; // largest integer <= v +float(float v) ceil = #38; // smallest integer >= v +float(entity e) checkbottom = #40; // true if self is on ground +float(vector v) pointcontents = #41; // returns a CONTENT_* +float(float f) fabs = #43; +vector(entity e, float speed) aim = #44; // returns the shooting vector +float(string s) cvar = #45; // return cvar.value +void(string s) localcmd = #46; // put string into local que +entity(entity e) nextent = #47; // for looping through all ents +void() ChangeYaw = #49; // turn towards self.ideal_yaw + // at self.yaw_speed +vector(vector v) vectoangles = #51; -// // direct client message generation -// -void(float to, float f) WriteByte = #52; -void(float to, float f) WriteChar = #53; -void(float to, float f) WriteShort = #54; -void(float to, float f) WriteLong = #55; -void(float to, float f) WriteCoord = #56; -void(float to, float f) WriteAngle = #57; -void(float to, string s) WriteString = #58; -void(float to, entity s) WriteEntity = #59; +void(float to, float f) WriteByte = #52; +void(float to, float f) WriteChar = #53; +void(float to, float f) WriteShort = #54; +void(float to, float f) WriteLong = #55; +void(float to, string s) WriteString = #58; +void(float to, entity s) WriteEntity = #59; +void(float to, ...) WriteBytes = #0; +void(float to, vector v) WriteCoordV = #0; +void(float to, vector v) WriteAngleV = #0; -// several removed - -void(float step) movetogoal = #67; - -string(string s) precache_file = #68; // no effect except for -copy +void(float step) movetogoal = #67; +string(string s) precache_file = #68; // no effect except for -copy void(entity e) makestatic = #69; void(string s) changelevel = #70; -//#71 was removed +void(string var, string val) cvar_set = #72; // sets cvar.value -void(string var, string val) cvar_set = #72; // sets cvar.value - -void(entity client, string s) centerprint = #73; // sprint, but in middle +void(entity client, string s) centerprint = #73; // sprint, but in middle void(vector pos, string samp, float vol, float atten) ambientsound = #74; -string(string s) precache_model2 = #75; // registered version only -string(string s) precache_sound2 = #76; // registered version only -string(string s) precache_file2 = #77; // registered version only +string(string s) precache_model2 = #75; // registered version only +string(string s) precache_sound2 = #76; // registered version only +string(string s) precache_file2 = #77; // registered version only -void(entity e) setspawnparms = #78; // set parm1... to the - // values at level start - // for coop respawn -void(entity killer, entity killee) logfrag = #79; // add to stats +// set parm1... to the values at level start for coop respawn +void(entity e) setspawnparms = #78; +void(entity killer, entity killee) logfrag = #79; // add to stats -string(entity e, string key) infokey = #80; // get a key value (world = serverinfo) -float(string s) stof = #81; // convert string to float -void(vector where, float set) multicast = #82; // sends the temp message to a set - // of clients, possibly in PVS or PHS +// get a key value (world = serverinfo) +string(entity e, string key) infokey = #80; +float(string s) stof = #81; // convert string to float +// sends the temp message to a set of clients, possibly in PVS or PHS +void(vector where, float set) multicast = #82; -//============================================================================ +// subs.qc ==================================================================== -// -// subs.qc -// void(vector tdest, float tspeed, void() func) SUB_CalcMove; void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt; void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove; @@ -718,14 +617,10 @@ void() SUB_Null; void() SUB_UseTargets; void() SUB_Remove; -// -// combat.qc -// +// combat.qc ================================================================== + void(entity targ, entity inflictor, entity attacker, float damage) T_Damage; - -float (entity e, float healamount, float ignore) T_Heal; // health function +float(entity e, float healamount, float ignore) T_Heal; // health function float(entity targ, entity inflictor) CanDamage; - - diff --git a/nqw/demon.qc b/nqw/demon.qc index 6abcdc4..fee6866 100644 --- a/nqw/demon.qc +++ b/nqw/demon.qc @@ -48,9 +48,9 @@ void() demon1_stand12 =[ $stand12, demon1_stand13 ] {ai_stand();}; void() demon1_stand13 =[ $stand13, demon1_stand1 ] {ai_stand();}; void() demon1_walk1 =[ $walk1, demon1_walk2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "demon/idle1.wav", 1, ATTN_IDLE); -ai_walk(8); + if (random () < 0.2) + sound (self, CHAN_VOICE, "demon/idle1.wav", 1, ATTN_IDLE); + ai_walk (8); }; void() demon1_walk2 =[ $walk2, demon1_walk3 ] {ai_walk(6);}; void() demon1_walk3 =[ $walk3, demon1_walk4 ] {ai_walk(6);}; @@ -61,9 +61,9 @@ void() demon1_walk7 =[ $walk7, demon1_walk8 ] {ai_walk(10);}; void() demon1_walk8 =[ $walk8, demon1_walk1 ] {ai_walk(10);}; void() demon1_run1 =[ $run1, demon1_run2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "demon/idle1.wav", 1, ATTN_IDLE); -ai_run(20);}; + if (random () < 0.2) + sound (self, CHAN_VOICE, "demon/idle1.wav", 1, ATTN_IDLE); + ai_run (20);}; void() demon1_run2 =[ $run2, demon1_run3 ] {ai_run(15);}; void() demon1_run3 =[ $run3, demon1_run4 ] {ai_run(36);}; void() demon1_run4 =[ $run4, demon1_run5 ] {ai_run(20);}; @@ -97,7 +97,6 @@ self.nextthink = time + 3; void() demon1_jump11 =[ $leap11, demon1_jump12 ] {}; void() demon1_jump12 =[ $leap12, demon1_run1 ] {}; - void() demon1_atta1 =[ $attacka1, demon1_atta2 ] {ai_charge(4);}; void() demon1_atta2 =[ $attacka2, demon1_atta3 ] {ai_charge(0);}; void() demon1_atta3 =[ $attacka3, demon1_atta4 ] {ai_charge(0);}; @@ -132,7 +131,7 @@ void(entity attacker, float damage) demon1_pain = self.pain_finished = time + 1; sound (self, CHAN_VOICE, "demon/dpain1.wav", 1, ATTN_NORM); - if (random()*200 > damage) + if (random () * 200 > damage) return; // didn't flinch demon1_pain1 (); @@ -152,9 +151,8 @@ void() demon1_die9 =[ $death9, demon1_die9 ] {}; void() demon_die = { -// check for gib - if (self.health < -80) - { + // check for gib + if (self.health < -80) { sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); ThrowHead ("progs/h_demon.mdl", self.health); ThrowGib ("progs/gib1.mdl", self.health); @@ -179,8 +177,7 @@ void() Demon_MeleeAttack = */ void() monster_demon1 = { - if (deathmatch) - { + if (deathmatch) { remove(self); return; } @@ -210,17 +207,10 @@ void() monster_demon1 = self.th_missile = demon1_jump1; // jump attack self.th_pain = demon1_pain; - walkmonster_start(); + walkmonster_start (); }; - -/* -============================================================================== - -DEMON - -============================================================================== -*/ +// DEMON ====================================================================== /* ============== @@ -231,8 +221,7 @@ Returns TRUE if a melee attack would hit right now */ float() CheckDemonMelee = { - if (enemy_range == RANGE_MELEE) - { // FIXME: check canreach + if (enemy_range == RANGE_MELEE) { // FIXME: check canreach self.attack_state = AS_MELEE; return TRUE; } @@ -247,28 +236,27 @@ CheckDemonJump */ float() CheckDemonJump = { - local vector dist; - local float d; + local vector dist; + local float d; if (self.origin_z + self.mins_z > self.enemy.origin_z + self.enemy.mins_z - + 0.75 * self.enemy.size_z) + + 0.75 * self.enemy.size_z) return FALSE; if (self.origin_z + self.maxs_z < self.enemy.origin_z + self.enemy.mins_z - + 0.25 * self.enemy.size_z) + + 0.25 * self.enemy.size_z) return FALSE; dist = self.enemy.origin - self.origin; dist_z = 0; - d = vlen(dist); + d = vlen (dist); if (d < 100) return FALSE; - if (d > 200) - { - if (random() < 0.9) + if (d > 200) { + if (random () < 0.9) return FALSE; } @@ -277,15 +265,13 @@ float() CheckDemonJump = float() DemonCheckAttack = { -// if close enough for slashing, go for it - if (CheckDemonMelee ()) - { + // if close enough for slashing, go for it + if (CheckDemonMelee ()) { self.attack_state = AS_MELEE; return TRUE; } - if (CheckDemonJump ()) - { + if (CheckDemonJump ()) { self.attack_state = AS_MISSILE; sound (self, CHAN_VOICE, "demon/djump.wav", 1, ATTN_NORM); return TRUE; @@ -299,7 +285,7 @@ float() DemonCheckAttack = void(float side) Demon_Melee = { - local float ldmg; + local float ldmg; local vector delta; ai_face (); @@ -307,47 +293,42 @@ void(float side) Demon_Melee = delta = self.enemy.origin - self.origin; - if (vlen(delta) > 100) + if (vlen (delta) > 100) return; if (!CanDamage (self.enemy, self)) return; sound (self, CHAN_WEAPON, "demon/dhit2.wav", 1, ATTN_NORM); - ldmg = 10 + 5*random(); + ldmg = 10 + 5 * random (); T_Damage (self.enemy, self, self, ldmg); makevectors (self.angles); SpawnMeatSpray (self.origin + v_forward*16, side * v_right); }; - void() Demon_JumpTouch = { - local float ldmg; + local float ldmg; if (self.health <= 0) return; - if (other.takedamage) - { - if ( vlen(self.velocity) > 400 ) - { - ldmg = 40 + 10*random(); + if (other.takedamage) { + if (vlen (self.velocity) > 400) { + ldmg = 40 + 10 * random (); T_Damage (other, self, self, ldmg); } } - if (!checkbottom(self)) - { - if (self.flags & FL_ONGROUND) - { // jump randomly to not get hung up -//dprint ("popjump\n"); - self.touch = SUB_Null; - self.think = demon1_jump1; - self.nextthink = time + 0.1; + if (!checkbottom (self)) { + if (self.flags & FL_ONGROUND) { // jump randomly to not get hung up +// dprint ("popjump\n"); + self.touch = SUB_Null; + self.think = demon1_jump1; + self.nextthink = time + 0.1; -// self.velocity_x = (random() - 0.5) * 600; -// self.velocity_y = (random() - 0.5) * 600; +// self.velocity_x = (random () - 0.5) * 600; +// self.velocity_y = (random () - 0.5) * 600; // self.velocity_z = 200; // self.flags = self.flags - FL_ONGROUND; } @@ -358,4 +339,3 @@ void() Demon_JumpTouch = self.think = demon1_jump11; self.nextthink = time + 0.1; }; - diff --git a/nqw/dog.qc b/nqw/dog.qc index b28bebe..7764405 100644 --- a/nqw/dog.qc +++ b/nqw/dog.qc @@ -42,8 +42,8 @@ dog_bite */ void() dog_bite = { -local vector delta; -local float ldmg; + local vector delta; + local float ldmg; if (!self.enemy) return; @@ -58,7 +58,7 @@ local float ldmg; if (vlen(delta) > 100) return; - ldmg = (random() + random() + random()) * 8; + ldmg = (random () + random () + random ()) * 8; T_Damage (self.enemy, self, self, ldmg); }; @@ -69,26 +69,22 @@ void() Dog_JumpTouch = if (self.health <= 0) return; - if (other.takedamage) - { - if ( vlen(self.velocity) > 300 ) - { - ldmg = 10 + 10*random(); + if (other.takedamage) { + if (vlen (self.velocity) > 300) { + ldmg = 10 + 10 * random (); T_Damage (other, self, self, ldmg); } } - if (!checkbottom(self)) - { - if (self.flags & FL_ONGROUND) - { // jump randomly to not get hung up -//dprint ("popjump\n"); - self.touch = SUB_Null; - self.think = dog_leap1; - self.nextthink = time + 0.1; + if (!checkbottom (self)) { + if (self.flags & FL_ONGROUND) { // jump randomly to not get hung up +// dprint ("popjump\n"); + self.touch = SUB_Null; + self.think = dog_leap1; + self.nextthink = time + 0.1; -// self.velocity_x = (random() - 0.5) * 600; -// self.velocity_y = (random() - 0.5) * 600; +// self.velocity_x = (random () - 0.5) * 600; +// self.velocity_y = (random () - 0.5) * 600; // self.velocity_z = 200; // self.flags = self.flags - FL_ONGROUND; } @@ -112,9 +108,9 @@ void() dog_stand8 =[ $stand8, dog_stand9 ] {ai_stand();}; void() dog_stand9 =[ $stand9, dog_stand1 ] {ai_stand();}; void() dog_walk1 =[ $walk1 , dog_walk2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "dog/idle.wav", 1, ATTN_IDLE); -ai_walk(8);}; + if (random () < 0.2) + sound (self, CHAN_VOICE, "dog/idle.wav", 1, ATTN_IDLE); + ai_walk (8);}; void() dog_walk2 =[ $walk2 , dog_walk3 ] {ai_walk(8);}; void() dog_walk3 =[ $walk3 , dog_walk4 ] {ai_walk(8);}; void() dog_walk4 =[ $walk4 , dog_walk5 ] {ai_walk(8);}; @@ -124,9 +120,9 @@ void() dog_walk7 =[ $walk7 , dog_walk8 ] {ai_walk(8);}; void() dog_walk8 =[ $walk8 , dog_walk1 ] {ai_walk(8);}; void() dog_run1 =[ $run1 , dog_run2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "dog/idle.wav", 1, ATTN_IDLE); -ai_run(16);}; + if (random () < 0.2) + sound (self, CHAN_VOICE, "dog/idle.wav", 1, ATTN_IDLE); + ai_run (16);}; void() dog_run2 =[ $run2 , dog_run3 ] {ai_run(32);}; void() dog_run3 =[ $run3 , dog_run4 ] {ai_run(32);}; void() dog_run4 =[ $run4 , dog_run5 ] {ai_run(20);}; @@ -199,7 +195,7 @@ void(entity attacker, float damage) dog_pain = { sound (self, CHAN_VOICE, "dog/dpain1.wav", 1, ATTN_NORM); - if (random() > 0.5) + if (random () > 0.5) dog_pain1 (); else dog_painb1 (); @@ -225,12 +221,10 @@ void() dog_dieb7 =[ $deathb7, dog_dieb8 ] {}; void() dog_dieb8 =[ $deathb8, dog_dieb9 ] {}; void() dog_dieb9 =[ $deathb9, dog_dieb9 ] {}; - void() dog_die = { -// check for gib - if (self.health < -35) - { + // check for gib + if (self.health < -35) { sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); ThrowGib ("progs/gib3.mdl", self.health); ThrowGib ("progs/gib3.mdl", self.health); @@ -239,11 +233,11 @@ void() dog_die = return; } -// regular death + // regular death sound (self, CHAN_VOICE, "dog/ddeath.wav", 1, ATTN_NORM); self.solid = SOLID_NOT; - if (random() > 0.5) + if (random () > 0.5) dog_die1 (); else dog_dieb1 (); @@ -260,8 +254,7 @@ Returns TRUE if a melee attack would hit right now */ float() CheckDogMelee = { - if (enemy_range == RANGE_MELEE) - { // FIXME: check canreach + if (enemy_range == RANGE_MELEE) { // FIXME: check canreach self.attack_state = AS_MELEE; return TRUE; } @@ -280,17 +273,17 @@ float() CheckDogJump = local float d; if (self.origin_z + self.mins_z > self.enemy.origin_z + self.enemy.mins_z - + 0.75 * self.enemy.size_z) + + 0.75 * self.enemy.size_z) return FALSE; if (self.origin_z + self.maxs_z < self.enemy.origin_z + self.enemy.mins_z - + 0.25 * self.enemy.size_z) + + 0.25 * self.enemy.size_z) return FALSE; dist = self.enemy.origin - self.origin; dist_z = 0; - d = vlen(dist); + d = vlen (dist); if (d < 80) return FALSE; @@ -304,14 +297,12 @@ float() CheckDogJump = float() DogCheckAttack = { // if close enough for slashing, go for it - if (CheckDogMelee ()) - { + if (CheckDogMelee ()) { self.attack_state = AS_MELEE; return TRUE; } - if (CheckDogJump ()) - { + if (CheckDogJump ()) { self.attack_state = AS_MISSILE; return TRUE; } @@ -319,7 +310,6 @@ float() DogCheckAttack = return FALSE; }; - //=========================================================================== /*QUAKED monster_dog (1 0 0) (-32 -32 -24) (32 32 40) Ambush @@ -327,11 +317,11 @@ float() DogCheckAttack = */ void() monster_dog = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } + precache_model ("progs/h_dog.mdl"); precache_model ("progs/dog.mdl"); @@ -357,5 +347,5 @@ void() monster_dog = self.th_melee = dog_atta1; self.th_missile = dog_leap1; - walkmonster_start(); + walkmonster_start (); }; diff --git a/nqw/doors.qc b/nqw/doors.qc index 4a57950..d0f1ef9 100644 --- a/nqw/doors.qc +++ b/nqw/doors.qc @@ -1,4 +1,3 @@ - float DOOR_START_OPEN = 1; float DOOR_DONT_LINK = 4; float DOOR_GOLD_KEY = 8; @@ -6,7 +5,6 @@ float DOOR_SILVER_KEY = 16; float DOOR_TOGGLE = 32; /* - Doors are similar to buttons, but can spawn a fat trigger field around them to open without a touch, and they link together to form simultanious double/quad doors. @@ -15,7 +13,6 @@ Door.owner is the master door. If there is only one door, it points to itself. If multiple doors, all will point to a single one. Door.enemy chains from the master door through all doors linked in the chain. - */ /* @@ -36,8 +33,7 @@ void() door_blocked = // if a door has a negative wait, it would never come back if blocked, // so let it just squash the object to death real fast - if (self.wait >= 0) - { + if (self.wait >= 0) { if (self.state == STATE_DOWN) door_go_up (); else @@ -65,8 +61,7 @@ void() door_hit_bottom = void() door_go_down = { sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM); - if (self.max_health) - { + if (self.max_health) { self.takedamage = DAMAGE_YES; self.health = self.max_health; } @@ -80,8 +75,7 @@ void() door_go_up = if (self.state == STATE_UP) return; // allready going up - if (self.state == STATE_TOP) - { // reset top wait time + if (self.state == STATE_TOP) { // reset top wait time self.nextthink = self.ltime + self.wait; return; } @@ -93,7 +87,6 @@ void() door_go_up = SUB_UseTargets(); }; - /* ============================================================================= @@ -110,34 +103,29 @@ void() door_fire = if (self.owner != self) objerror ("door_fire: self.owner != self"); -// play use key sound - + // play use key sound if (self.items) sound (self, CHAN_VOICE, self.noise4, 1, ATTN_NORM); self.message = string_null; // no more message oself = self; - if (self.spawnflags & DOOR_TOGGLE) - { - if (self.state == STATE_UP || self.state == STATE_TOP) - { + if (self.spawnflags & DOOR_TOGGLE) { + if (self.state == STATE_UP || self.state == STATE_TOP) { starte = self; - do - { + do { door_go_down (); self = self.enemy; - } while ( (self != starte) && (self != world) ); + } while ((self != starte) && (self != world)); self = oself; return; } } - -// trigger all paired doors + + // trigger all paired doors starte = self; - do - { + do { self.goalentity = activator; // Who fired us door_go_up (); self = self.enemy; @@ -189,7 +177,6 @@ void() door_killed = self = oself; }; - /* ================ door_touch @@ -206,51 +193,36 @@ void() door_touch = self.owner.attack_finished = time + 2; - if (self.owner.message != "") - { + if (self.owner.message != "") { centerprint (other, self.owner.message); sound (other, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NORM); } - -// key door stuff + + // key door stuff if (!self.items) return; -// FIXME: blink key on player's status bar - if ( (self.items & other.items) != self.items ) - { - if (self.owner.items == IT_KEY1) - { - if (world.worldtype == 2) - { + // FIXME: blink key on player's status bar + if ((self.items & other.items) != self.items) { + if (self.owner.items == IT_KEY1) { + if (world.worldtype == 2) { centerprint (other, "You need the silver keycard"); sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); - } - else if (world.worldtype == 1) - { + } else if (world.worldtype == 1) { centerprint (other, "You need the silver runekey"); sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); - } - else if (world.worldtype == 0) - { + } else if (world.worldtype == 0) { centerprint (other, "You need the silver key"); sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); } - } - else - { - if (world.worldtype == 2) - { + } else { + if (world.worldtype == 2) { centerprint (other, "You need the gold keycard"); sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); - } - else if (world.worldtype == 1) - { + } else if (world.worldtype == 1) { centerprint (other, "You need the gold runekey"); sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); - } - else if (world.worldtype == 0) - { + } else if (world.worldtype == 0) { centerprint (other, "You need the gold key"); sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); } @@ -273,7 +245,6 @@ SPAWNING FUNCTIONS ============================================================================= */ - entity(vector fmins, vector fmaxs) spawn_field = { local entity trigger; @@ -309,12 +280,9 @@ float (entity e1, entity e2) EntitiesTouching = return TRUE; }; - /* ============= LinkDoors - - ============= */ void() LinkDoors = @@ -324,8 +292,7 @@ void() LinkDoors = if (self.enemy) return; // already linked by another door - if (self.spawnflags & 4) - { + if (self.spawnflags & 4) { self.owner = self.enemy = self; return; // don't want to link this door } @@ -336,8 +303,7 @@ void() LinkDoors = starte = self; t = self; - do - { + do { self.owner = starte; // master door if (self.health) @@ -348,12 +314,11 @@ void() LinkDoors = starte.message = self.message; t = find (t, classname, self.classname); - if (!t) - { + if (!t) { self.enemy = starte; // make the chain a loop - // shootable, fired, or key doors just needed the owner/enemy links, - // they don't spawn a field + // shootable, fired, or key doors just needed the owner/enemy + // links, they don't spawn a field self = self.owner; @@ -369,8 +334,7 @@ void() LinkDoors = return; } - if (EntitiesTouching(self,t)) - { + if (EntitiesTouching (self, t)) { if (t.enemy) objerror ("cross connected doors"); @@ -390,11 +354,9 @@ void() LinkDoors = if (t.maxs_z > cmaxs_z) cmaxs_z = t.maxs_z; } - } while (1 ); - + } while (1); }; - /*QUAKED func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK GOLD_KEY SILVER_KEY TOGGLE if two doors touch, they are assumed to be connected and operate as a unit. @@ -421,71 +383,53 @@ Key doors are allways wait -1. */ void() func_door = - { - if (world.worldtype == 0) - { + if (world.worldtype == 0) { precache_sound ("doors/medtry.wav"); precache_sound ("doors/meduse.wav"); self.noise3 = "doors/medtry.wav"; self.noise4 = "doors/meduse.wav"; - } - else if (world.worldtype == 1) - { + } else if (world.worldtype == 1) { precache_sound ("doors/runetry.wav"); precache_sound ("doors/runeuse.wav"); self.noise3 = "doors/runetry.wav"; self.noise4 = "doors/runeuse.wav"; - } - else if (world.worldtype == 2) - { + } else if (world.worldtype == 2) { precache_sound ("doors/basetry.wav"); precache_sound ("doors/baseuse.wav"); self.noise3 = "doors/basetry.wav"; self.noise4 = "doors/baseuse.wav"; - } - else - { + } else { dprint ("no worldtype set!\n"); } - if (self.sounds == 0) - { + if (self.sounds == 0) { precache_sound ("misc/null.wav"); precache_sound ("misc/null.wav"); self.noise1 = "misc/null.wav"; self.noise2 = "misc/null.wav"; - } - if (self.sounds == 1) - { + } if (self.sounds == 1) { precache_sound ("doors/drclos4.wav"); precache_sound ("doors/doormv1.wav"); self.noise1 = "doors/drclos4.wav"; self.noise2 = "doors/doormv1.wav"; - } - if (self.sounds == 2) - { + } if (self.sounds == 2) { precache_sound ("doors/hydro1.wav"); precache_sound ("doors/hydro2.wav"); self.noise2 = "doors/hydro1.wav"; self.noise1 = "doors/hydro2.wav"; - } - if (self.sounds == 3) - { + } if (self.sounds == 3) { precache_sound ("doors/stndr1.wav"); precache_sound ("doors/stndr2.wav"); self.noise2 = "doors/stndr1.wav"; self.noise1 = "doors/stndr2.wav"; - } - if (self.sounds == 4) - { + } if (self.sounds == 4) { precache_sound ("doors/ddoor1.wav"); precache_sound ("doors/ddoor2.wav"); self.noise1 = "doors/ddoor2.wav"; self.noise2 = "doors/ddoor1.wav"; } - SetMovedir (); self.max_health = self.health; @@ -515,10 +459,9 @@ void() func_door = self.pos1 = self.origin; self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip); -// DOOR_START_OPEN is to allow an entity to be lighted in the closed position -// but spawn in the open position - if (self.spawnflags & DOOR_START_OPEN) - { + // DOOR_START_OPEN is to allow an entity to be lighted in the closed + // position but spawn in the open position + if (self.spawnflags & DOOR_START_OPEN) { setorigin (self, self.pos2); self.pos2 = self.pos1; self.pos1 = self.origin; @@ -526,8 +469,7 @@ void() func_door = self.state = STATE_BOTTOM; - if (self.health) - { + if (self.health) { self.takedamage = DAMAGE_YES; self.th_die = door_killed; } @@ -537,8 +479,8 @@ void() func_door = self.touch = door_touch; -// LinkDoors can't be done until all of the doors have been spawned, so -// the sizes can be detected properly. + // LinkDoors can't be done until all of the doors have been spawned, so + // the sizes can be detected properly. self.think = LinkDoors; self.nextthink = self.ltime + 0.1; }; @@ -580,23 +522,20 @@ void () fd_secret_use = SUB_UseTargets(); // fire all targets / killtargets - if (!(self.spawnflags & SECRET_NO_SHOOT)) - { + if (!(self.spawnflags & SECRET_NO_SHOOT)) { //XXX needed? self.th_pain = SUB_Null; self.takedamage = DAMAGE_NO; } self.velocity = '0 0 0'; // Make a sound, wait a little... - sound(self, CHAN_VOICE, self.noise1, 1, ATTN_NORM); self.nextthink = self.ltime + 0.1; temp = 1 - (self.spawnflags & SECRET_1ST_LEFT); // 1 or -1 makevectors(self.mangle); - if (!self.t_width) - { + if (!self.t_width) { if (self.spawnflags & SECRET_1ST_DOWN) self. t_width = fabs(v_up * self.size); else @@ -640,8 +579,7 @@ void () fd_secret_move2 = void () fd_secret_move3 = { sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); - if (!(self.spawnflags & SECRET_OPEN_ONCE)) - { + if (!(self.spawnflags & SECRET_OPEN_ONCE)) { self.nextthink = self.ltime + self.wait; self.think = fd_secret_move4; } @@ -670,8 +608,7 @@ void () fd_secret_move6 = void () fd_secret_done = { - if (!self.targetname || self.spawnflags&SECRET_YES_SHOOT) - { + if (!self.targetname || self.spawnflags&SECRET_YES_SHOOT) { self.health = 10000; self.takedamage = DAMAGE_YES; self.th_pain = fd_secret_pain; @@ -705,8 +642,7 @@ void() secret_touch = self.attack_finished = time + 2; - if (self.message) - { + if (self.message) { centerprint (other, self.message); sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM); } @@ -734,8 +670,7 @@ void () func_door_secret = { if (self.sounds == 0) self.sounds = 3; - if (self.sounds == 1) - { + if (self.sounds == 1) { precache_sound ("doors/latch2.wav"); precache_sound ("doors/winch2.wav"); precache_sound ("doors/drclos4.wav"); @@ -743,16 +678,14 @@ void () func_door_secret = self.noise2 = "doors/winch2.wav"; self.noise3 = "doors/drclos4.wav"; } - if (self.sounds == 2) - { + if (self.sounds == 2) { precache_sound ("doors/airdoor1.wav"); precache_sound ("doors/airdoor2.wav"); self.noise2 = "doors/airdoor1.wav"; self.noise1 = "doors/airdoor2.wav"; self.noise3 = "doors/airdoor2.wav"; } - if (self.sounds == 3) - { + if (self.sounds == 3) { precache_sound ("doors/basesec1.wav"); precache_sound ("doors/basesec2.wav"); self.noise2 = "doors/basesec1.wav"; @@ -762,7 +695,7 @@ void () func_door_secret = if (!self.dmg) self.dmg = 2; - + // Magic formula... self.mangle = self.angles; self.angles = '0 0 0'; @@ -771,13 +704,12 @@ void () func_door_secret = self.classname = "door"; setmodel (self, self.model); setorigin (self, self.origin); - + self.touch = secret_touch; self.blocked = secret_blocked; self.speed = 50; self.use = fd_secret_use; - if ( !self.targetname || self.spawnflags&SECRET_YES_SHOOT) - { + if (!self.targetname || self.spawnflags & SECRET_YES_SHOOT) { self.health = 10000; self.takedamage = DAMAGE_YES; self.th_pain = fd_secret_pain; diff --git a/nqw/enforcer.qc b/nqw/enforcer.qc index 9e107f1..8301465 100644 --- a/nqw/enforcer.qc +++ b/nqw/enforcer.qc @@ -42,9 +42,9 @@ void() enforcer_fire = { local vector org; - muzzleflash(); + muzzleflash (); makevectors (self.angles); - + org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 16'; LaunchLaser(org, self.enemy.origin - self.origin); @@ -61,9 +61,10 @@ void() enf_stand6 =[ $stand6, enf_stand7 ] {ai_stand();}; void() enf_stand7 =[ $stand7, enf_stand1 ] {ai_stand();}; void() enf_walk1 =[ $walk1 , enf_walk2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE); -ai_walk(2);}; + if (random () < 0.2) + sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE); + ai_walk (2); +}; void() enf_walk2 =[ $walk2 , enf_walk3 ] {ai_walk(4);}; void() enf_walk3 =[ $walk3 , enf_walk4 ] {ai_walk(4);}; void() enf_walk4 =[ $walk4 , enf_walk5 ] {ai_walk(3);}; @@ -81,9 +82,10 @@ void() enf_walk15 =[ $walk15, enf_walk16 ] {ai_walk(4);}; void() enf_walk16 =[ $walk16, enf_walk1 ] {ai_walk(2);}; void() enf_run1 =[ $run1 , enf_run2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE); -ai_run(18);}; + if (random () < 0.2) + sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE); + ai_run (18); +}; void() enf_run2 =[ $run2 , enf_run3 ] {ai_run(14);}; void() enf_run3 =[ $run3 , enf_run4 ] {ai_run(7);}; void() enf_run4 =[ $run4 , enf_run5 ] {ai_run(12);}; @@ -105,8 +107,9 @@ void() enf_atk10 =[ $attack6, enf_atk11 ] {enforcer_fire();}; void() enf_atk11 =[ $attack7, enf_atk12 ] {ai_face();}; void() enf_atk12 =[ $attack8, enf_atk13 ] {ai_face();}; void() enf_atk13 =[ $attack9, enf_atk14 ] {ai_face();}; -void() enf_atk14 =[ $attack10, enf_run1 ] {ai_face(); -SUB_CheckRefire (enf_atk1); +void() enf_atk14 =[ $attack10, enf_run1 ] { + ai_face(); + SUB_CheckRefire (enf_atk1); }; void() enf_paina1 =[ $paina1, enf_paina2 ] {}; @@ -153,33 +156,25 @@ void(entity attacker, float damage) enf_pain = { local float r; - r = random (); if (self.pain_finished > time) return; - + r = random (); if (r < 0.5) sound (self, CHAN_VOICE, "enforcer/pain1.wav", 1, ATTN_NORM); else sound (self, CHAN_VOICE, "enforcer/pain2.wav", 1, ATTN_NORM); - if (r < 0.2) - { + if (r < 0.2) { self.pain_finished = time + 1; enf_paina1 (); - } - else if (r < 0.4) - { + } else if (r < 0.4) { self.pain_finished = time + 1; enf_painb1 (); - } - else if (r < 0.7) - { + } else if (r < 0.7) { self.pain_finished = time + 1; enf_painc1 (); - } - else - { + } else { self.pain_finished = time + 2; enf_paind1 (); } @@ -187,13 +182,13 @@ void(entity attacker, float damage) enf_pain = //============================================================================ - - - void() enf_die1 =[ $death1, enf_die2 ] {}; void() enf_die2 =[ $death2, enf_die3 ] {}; -void() enf_die3 =[ $death3, enf_die4 ] -{self.solid = SOLID_NOT;self.ammo_cells = 5;DropBackpack();}; +void() enf_die3 =[ $death3, enf_die4 ] { + self.solid = SOLID_NOT; + self.ammo_cells = 5; + DropBackpack(); +}; void() enf_die4 =[ $death4, enf_die5 ] {ai_forward(14);}; void() enf_die5 =[ $death5, enf_die6 ] {ai_forward(2);}; void() enf_die6 =[ $death6, enf_die7 ] {}; @@ -206,12 +201,13 @@ void() enf_die12 =[ $death12, enf_die13 ] {ai_forward(5);}; void() enf_die13 =[ $death13, enf_die14 ] {}; void() enf_die14 =[ $death14, enf_die14 ] {}; -void() enf_fdie1 =[ $fdeath1, enf_fdie2 ] { - -}; +void() enf_fdie1 =[ $fdeath1, enf_fdie2 ] {}; void() enf_fdie2 =[ $fdeath2, enf_fdie3 ] {}; -void() enf_fdie3 =[ $fdeath3, enf_fdie4 ] -{self.solid = SOLID_NOT;self.ammo_cells = 5;DropBackpack();}; +void() enf_fdie3 =[ $fdeath3, enf_fdie4 ] { + self.solid = SOLID_NOT; + self.ammo_cells = 5; + DropBackpack(); +}; void() enf_fdie4 =[ $fdeath4, enf_fdie5 ] {}; void() enf_fdie5 =[ $fdeath5, enf_fdie6 ] {}; void() enf_fdie6 =[ $fdeath6, enf_fdie7 ] {}; @@ -221,12 +217,10 @@ void() enf_fdie9 =[ $fdeath9, enf_fdie10 ] {}; void() enf_fdie10 =[ $fdeath10, enf_fdie11 ] {}; void() enf_fdie11 =[ $fdeath11, enf_fdie11 ] {}; - void() enf_die = { -// check for gib - if (self.health < -35) - { + // check for gib + if (self.health < -35) { sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); ThrowHead ("progs/h_mega.mdl", self.health); ThrowGib ("progs/gib1.mdl", self.health); @@ -235,25 +229,23 @@ void() enf_die = return; } -// regular death + // regular death sound (self, CHAN_VOICE, "enforcer/death1.wav", 1, ATTN_NORM); - if (random() > 0.5) + if (random () > 0.5) enf_die1 (); else enf_fdie1 (); }; - /*QUAKED monster_enforcer (1 0 0) (-16 -16 -24) (16 16 40) Ambush - */ void() monster_enforcer = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } + precache_model2 ("progs/enforcer.mdl"); precache_model2 ("progs/h_mega.mdl"); precache_model2 ("progs/laser.mdl"); @@ -284,5 +276,5 @@ void() monster_enforcer = self.th_die = enf_die; self.th_missile = enf_atk1; - walkmonster_start(); + walkmonster_start (); }; diff --git a/nqw/fight.qc b/nqw/fight.qc index 65966cd..573382f 100644 --- a/nqw/fight.qc +++ b/nqw/fight.qc @@ -1,11 +1,8 @@ - /* - A monster is in fight mode if it thinks it can effectively attack its enemy. When it decides it can't attack, it goes into hunt mode. - */ float(float v) anglemod; @@ -26,19 +23,18 @@ void(vector dest) ChooseTurn; void() ai_face; - float enemy_vis, enemy_infront, enemy_range; float enemy_yaw; - void() knight_attack = { local float len; + + // decide if now is a good swing time + len = vlen (self.enemy.origin + self.enemy.view_ofs + - (self.origin + self.view_ofs)); -// decide if now is a good swing time - len = vlen(self.enemy.origin+self.enemy.view_ofs - (self.origin+self.view_ofs)); - - if (len<80) + if (len < 80) knight_atk1 (); else knight_runatk1 (); @@ -61,8 +57,8 @@ float() CheckAttack = local float chance; targ = self.enemy; - -// see if any entities are in the way of the shot + + // see if any entities are in the way of the shot spot1 = self.origin + self.view_ofs; spot2 = targ.origin + targ.view_ofs; @@ -74,10 +70,8 @@ float() CheckAttack = if (trace_inopen && trace_inwater) return FALSE; // sight line crossed contents - if (enemy_range == RANGE_MELEE) - { // melee attack - if (self.th_melee) - { + if (enemy_range == RANGE_MELEE) { // melee attack + if (self.th_melee) { if (self.classname == "monster_knight") knight_attack (); else @@ -85,8 +79,8 @@ float() CheckAttack = return TRUE; } } - -// missile attack + + // missile attack if (!self.th_missile) return FALSE; @@ -95,40 +89,31 @@ float() CheckAttack = if (enemy_range == RANGE_FAR) return FALSE; - - if (enemy_range == RANGE_MELEE) - { + if (enemy_range == RANGE_MELEE) { chance = 0.9; self.attack_finished = 0; - } - else if (enemy_range == RANGE_NEAR) - { + } else if (enemy_range == RANGE_NEAR) { if (self.th_melee) chance = 0.2; else chance = 0.4; - } - else if (enemy_range == RANGE_MID) - { + } else if (enemy_range == RANGE_MID) { if (self.th_melee) chance = 0.05; else chance = 0.1; - } - else + } else chance = 0; - if (random () < chance) - { + if (random () < chance) { self.th_missile (); - SUB_AttackFinished (2*random()); + SUB_AttackFinished (2 * random ()); return TRUE; } return FALSE; }; - /* ============= ai_face @@ -163,9 +148,8 @@ void() ai_charge_side = { local vector dtemp; local float heading; - -// aim to the left of the enemy for a flyby + // aim to the left of the enemy for a flyby self.ideal_yaw = vectoyaw(self.enemy.origin - self.origin); ChangeYaw (); @@ -176,7 +160,6 @@ void() ai_charge_side = walkmove(heading, 20); }; - /* ============= ai_melee @@ -193,10 +176,10 @@ void() ai_melee = delta = self.enemy.origin - self.origin; - if (vlen(delta) > 60) + if (vlen (delta) > 60) return; - ldmg = (random() + random() + random()) * 3; + ldmg = (random () + random () + random ()) * 3; T_Damage (self.enemy, self, self, ldmg); }; @@ -217,7 +200,7 @@ void() ai_melee_side = return; if (!CanDamage (self.enemy, self)) return; - ldmg = (random() + random() + random()) * 3; + ldmg = (random () + random () + random ()) * 3; T_Damage (self.enemy, self, self, ldmg); }; @@ -239,8 +222,8 @@ float() SoldierCheckAttack = local float chance; targ = self.enemy; - -// see if any entities are in the way of the shot + + // see if any entities are in the way of the shot spot1 = self.origin + self.view_ofs; spot2 = targ.origin + targ.view_ofs; @@ -251,15 +234,13 @@ float() SoldierCheckAttack = if (trace_ent != targ) return FALSE; // don't have a clear shot - - -// missile attack + + // missile attack if (time < self.attack_finished) return FALSE; - + if (enemy_range == RANGE_FAR) return FALSE; - if (enemy_range == RANGE_MELEE) chance = 0.9; else if (enemy_range == RANGE_NEAR) @@ -269,11 +250,10 @@ float() SoldierCheckAttack = else chance = 0; - if (random () < chance) - { + if (random () < chance) { self.th_missile (); - SUB_AttackFinished (1 + random()); - if (random() < 0.3) + SUB_AttackFinished (1 + random ()); + if (random () < 0.3) self.lefty = !self.lefty; return TRUE; @@ -296,10 +276,8 @@ float() ShamCheckAttack = local vector spot1, spot2; local entity targ; - if (enemy_range == RANGE_MELEE) - { - if (CanDamage (self.enemy, self)) - { + if (enemy_range == RANGE_MELEE) { + if (CanDamage (self.enemy, self)) { self.attack_state = AS_MELEE; return TRUE; } @@ -312,8 +290,8 @@ float() ShamCheckAttack = return FALSE; targ = self.enemy; - -// see if any entities are in the way of the shot + + // see if any entities are in the way of the shot spot1 = self.origin + self.view_ofs; spot2 = targ.origin + targ.view_ofs; @@ -325,17 +303,16 @@ float() ShamCheckAttack = if (trace_inopen && trace_inwater) return FALSE; // sight line crossed contents - if (trace_ent != targ) - { + if (trace_ent != targ) { return FALSE; // don't have a clear shot } - -// missile attack + + // missile attack if (enemy_range == RANGE_FAR) return FALSE; self.attack_state = AS_MISSILE; - SUB_AttackFinished (2 + 2*random()); + SUB_AttackFinished (2 + 2 * random ()); return TRUE; }; @@ -355,10 +332,8 @@ float() OgreCheckAttack = local entity targ; local float chance; - if (enemy_range == RANGE_MELEE) - { - if (CanDamage (self.enemy, self)) - { + if (enemy_range == RANGE_MELEE) { + if (CanDamage (self.enemy, self)) { self.attack_state = AS_MELEE; return TRUE; } @@ -371,8 +346,8 @@ float() OgreCheckAttack = return FALSE; targ = self.enemy; - -// see if any entities are in the way of the shot + + // see if any entities are in the way of the shot spot1 = self.origin + self.view_ofs; spot2 = targ.origin + targ.view_ofs; @@ -382,11 +357,9 @@ float() OgreCheckAttack = return FALSE; // sight line crossed contents if (trace_ent != targ) - { return FALSE; // don't have a clear shot - } - -// missile attack + + // missile attack if (time < self.attack_finished) return FALSE; @@ -401,7 +374,6 @@ float() OgreCheckAttack = chance = 0; self.attack_state = AS_MISSILE; - SUB_AttackFinished (1 + 2*random()); + SUB_AttackFinished (1 + 2 * random ()); return TRUE; }; - diff --git a/nqw/fish.qc b/nqw/fish.qc index ce6e26e..9489226 100644 --- a/nqw/fish.qc +++ b/nqw/fish.qc @@ -59,7 +59,7 @@ void() f_walk17 =[ $swim17, f_walk18 ] {ai_walk(8);}; void() f_walk18 =[ $swim18, f_walk1 ] {ai_walk(8);}; void() f_run1 =[ $swim1, f_run2 ] {ai_run(12); - if (random() < 0.5) + if (random () < 0.5) sound (self, CHAN_VOICE, "fish/idle.wav", 1, ATTN_NORM); }; void() f_run2 =[ $swim3, f_run3 ] {ai_run(12);}; @@ -78,14 +78,14 @@ void() fish_melee = if (!self.enemy) return; // removed before stroke - + delta = self.enemy.origin - self.origin; - if (vlen(delta) > 60) + if (vlen (delta) > 60) return; - + sound (self, CHAN_VOICE, "fish/bite.wav", 1, ATTN_NORM); - ldmg = (random() + random()) * 3; + ldmg = (random () + random ()) * 3; T_Damage (self.enemy, self, self, ldmg); }; @@ -109,7 +109,7 @@ void() f_attack17 =[ $attack17, f_attack18] {ai_charge(10);}; void() f_attack18 =[ $attack18, f_run1 ] {ai_charge(10);}; void() f_death1 =[ $death1, f_death2 ] { -sound (self, CHAN_VOICE, "fish/death.wav", 1, ATTN_NORM); + sound (self, CHAN_VOICE, "fish/death.wav", 1, ATTN_NORM); }; void() f_death2 =[ $death2, f_death3 ] {}; void() f_death3 =[ $death3, f_death4 ] {}; @@ -144,22 +144,19 @@ void() f_pain9 =[ $pain9, f_run1 ] {ai_pain(6);}; void(entity attacker, float damage) fish_pain = { - -// fish allways do pain frames + // fish allways do pain frames f_pain1 (); }; - - /*QUAKED monster_fish (1 0 0) (-16 -16 -24) (16 16 24) Ambush */ void() monster_fish = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } + precache_model2 ("progs/fish.mdl"); precache_sound2 ("fish/death.wav"); @@ -183,4 +180,3 @@ void() monster_fish = swimmonster_start (); }; - diff --git a/nqw/flag.qc b/nqw/flag.qc index 44daa00..adb816e 100644 --- a/nqw/flag.qc +++ b/nqw/flag.qc @@ -5,4 +5,4 @@ void() deathball_touch; void() item_deathball = { self.touch = deathball_touch; -}; \ No newline at end of file +}; diff --git a/nqw/hknight.qc b/nqw/hknight.qc index 0e239e0..6cb864c 100644 --- a/nqw/hknight.qc +++ b/nqw/hknight.qc @@ -68,45 +68,43 @@ void(float offset) hknight_shot = org = self.origin + self.mins + self.size*0.5 + v_forward * 20; -// set missile speed + // set missile speed vec = normalize (v_forward); - vec_z = 0 - vec_z + (random() - 0.5)*0.1; + vec_z = 0 - vec_z + (random () - 0.5) * 0.1; launch_spike (org, vec); newmis.classname = "knightspike"; setmodel (newmis, "progs/k_spike.mdl"); setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); - newmis.velocity = vec*300; + newmis.velocity = vec * 300; sound (self, CHAN_WEAPON, "hknight/attack1.wav", 1, ATTN_NORM); }; void() CheckForCharge = { -// check for mad charge -if (!enemy_vis) - return; -if (time < self.attack_finished) - return; -if ( fabs(self.origin_z - self.enemy.origin_z) > 20) - return; // too much height change -if ( vlen (self.origin - self.enemy.origin) < 80) - return; // use regular attack + // check for mad charge + if (!enemy_vis) + return; + if (time < self.attack_finished) + return; + if (fabs (self.origin_z - self.enemy.origin_z) > 20) + return; // too much height change + if (vlen (self.origin - self.enemy.origin) < 80) + return; // use regular attack -// charge + // charge SUB_AttackFinished (2); hknight_char_a1 (); - }; void() CheckContinueCharge = { - if (time > self.attack_finished) - { + if (time > self.attack_finished) { SUB_AttackFinished (3); hknight_run1 (); return; // done charging } - if (random() > 0.5) + if (random () > 0.5) sound (self, CHAN_WEAPON, "knight/sword2.wav", 1, ATTN_NORM); else sound (self, CHAN_WEAPON, "knight/sword1.wav", 1, ATTN_NORM); @@ -127,8 +125,9 @@ void() hknight_stand9 =[ $stand9, hknight_stand1 ] {ai_stand();}; //=========================================================================== void() hknight_walk1 =[ $walk1, hknight_walk2 ] { -hk_idle_sound(); -ai_walk(2);}; + hk_idle_sound (); + ai_walk (2); +}; void() hknight_walk2 =[ $walk2, hknight_walk3 ] {ai_walk(5);}; void() hknight_walk3 =[ $walk3, hknight_walk4 ] {ai_walk(5);}; void() hknight_walk4 =[ $walk4, hknight_walk5 ] {ai_walk(4);}; @@ -152,8 +151,10 @@ void() hknight_walk20 =[ $walk20, hknight_walk1 ] {ai_walk(2);}; //=========================================================================== void() hknight_run1 =[ $run1, hknight_run2 ] { -hk_idle_sound(); -ai_run (20); CheckForCharge (); }; + hk_idle_sound (); + ai_run (20); + CheckForCharge (); +}; void() hknight_run2 =[ $run2, hknight_run3 ] {ai_run(25);}; void() hknight_run3 =[ $run3, hknight_run4 ] {ai_run(18);}; void() hknight_run4 =[ $run4, hknight_run5 ] {ai_run(16);}; @@ -164,7 +165,9 @@ void() hknight_run8 =[ $run8, hknight_run1 ] {ai_run(13);}; //============================================================================ -void() hknight_pain1 =[ $pain1, hknight_pain2 ] {sound (self, CHAN_VOICE, "hknight/pain1.wav", 1, ATTN_NORM);}; +void() hknight_pain1 =[ $pain1, hknight_pain2 ] { + sound (self, CHAN_VOICE, "hknight/pain1.wav", 1, ATTN_NORM); +}; void() hknight_pain2 =[ $pain2, hknight_pain3 ] {}; void() hknight_pain3 =[ $pain3, hknight_pain4 ] {}; void() hknight_pain4 =[ $pain4, hknight_pain5 ] {}; @@ -174,8 +177,10 @@ void() hknight_pain5 =[ $pain5, hknight_run1 ] {}; void() hknight_die1 =[ $death1, hknight_die2 ] {ai_forward(10);}; void() hknight_die2 =[ $death2, hknight_die3 ] {ai_forward(8);}; -void() hknight_die3 =[ $death3, hknight_die4 ] -{self.solid = SOLID_NOT; ai_forward(7);}; +void() hknight_die3 =[ $death3, hknight_die4 ] { + self.solid = SOLID_NOT; + ai_forward(7); +}; void() hknight_die4 =[ $death4, hknight_die5 ] {}; void() hknight_die5 =[ $death5, hknight_die6 ] {}; void() hknight_die6 =[ $death6, hknight_die7 ] {}; @@ -188,8 +193,7 @@ void() hknight_die12 =[ $death12, hknight_die12 ] {}; void() hknight_dieb1 =[ $deathb1, hknight_dieb2 ] {}; void() hknight_dieb2 =[ $deathb2, hknight_dieb3 ] {}; -void() hknight_dieb3 =[ $deathb3, hknight_dieb4 ] -{self.solid = SOLID_NOT;}; +void() hknight_dieb3 =[ $deathb3, hknight_dieb4 ] {self.solid = SOLID_NOT;}; void() hknight_dieb4 =[ $deathb4, hknight_dieb5 ] {}; void() hknight_dieb5 =[ $deathb5, hknight_dieb6 ] {}; void() hknight_dieb6 =[ $deathb6, hknight_dieb7 ] {}; @@ -199,9 +203,8 @@ void() hknight_dieb9 =[ $deathb9, hknight_dieb9 ] {}; void() hknight_die = { -// check for gib - if (self.health < -40) - { + // check for gib + if (self.health < -40) { sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); ThrowHead ("progs/h_hellkn.mdl", self.health); ThrowGib ("progs/gib1.mdl", self.health); @@ -210,9 +213,9 @@ void() hknight_die = return; } -// regular death + // regular death sound (self, CHAN_VOICE, "hknight/death1.wav", 1, ATTN_NORM); - if (random() > 0.5) + if (random () > 0.5) hknight_die1 (); else hknight_dieb1 (); @@ -273,7 +276,7 @@ void() hknight_char_a2 =[ $char_a2, hknight_char_a3 ] {ai_charge(25);}; void() hknight_char_a3 =[ $char_a3, hknight_char_a4 ] {ai_charge(18);}; void() hknight_char_a4 =[ $char_a4, hknight_char_a5 ] {ai_charge(16);}; void() hknight_char_a5 =[ $char_a5, hknight_char_a6 ] {ai_charge(14);}; -void() hknight_char_a6 =[ $char_a6, hknight_char_a7 ] {ai_charge(20); ai_melee();}; +void() hknight_char_a6 =[ $char_a6, hknight_char_a7 ] {ai_charge (20);ai_melee();}; void() hknight_char_a7 =[ $char_a7, hknight_char_a8 ] {ai_charge(21); ai_melee();}; void() hknight_char_a8 =[ $char_a8, hknight_char_a9 ] {ai_charge(13); ai_melee();}; void() hknight_char_a9 =[ $char_a9, hknight_char_a10 ] {ai_charge(20); ai_melee();}; @@ -287,8 +290,11 @@ void() hknight_char_a16=[ $char_a16, hknight_run1 ] {ai_charge(13);}; //=========================================================================== -void() hknight_char_b1 =[ $char_b1, hknight_char_b2 ] -{CheckContinueCharge (); ai_charge(23); ai_melee();}; +void() hknight_char_b1 =[ $char_b1, hknight_char_b2 ] { + CheckContinueCharge (); + ai_charge (23); + ai_melee (); +}; void() hknight_char_b2 =[ $char_b2, hknight_char_b3 ] {ai_charge(17); ai_melee();}; void() hknight_char_b3 =[ $char_b3, hknight_char_b4 ] {ai_charge(12); ai_melee();}; void() hknight_char_b4 =[ $char_b4, hknight_char_b5 ] {ai_charge(22); ai_melee();}; @@ -351,7 +357,7 @@ void() hknight_watk22 =[ $w_attack22, hknight_run1 ] {ai_charge(3);}; void() hk_idle_sound = { - if (random() < 0.2) + if (random () < 0.2) sound (self, CHAN_VOICE, "hknight/idle.wav", 1, ATTN_NORM); }; @@ -362,14 +368,14 @@ void(entity attacker, float damage) hknight_pain = sound (self, CHAN_VOICE, "hknight/pain1.wav", 1, ATTN_NORM); - if (time - self.pain_finished > 5) - { // allways go into pain frame if it has been a while + if (time - self.pain_finished > 5) { + // allways go into pain frame if it has been a while hknight_pain1 (); self.pain_finished = time + 1; return; } - if ((random()*30 > damage) ) + if ((random () *30 > damage)) return; // didn't flinch self.pain_finished = time + 1; @@ -387,8 +393,7 @@ void() hknight_melee = hknight_slice1 (); else if (hknight_type == 2) hknight_smash1 (); - else if (hknight_type == 3) - { + else if (hknight_type == 3) { hknight_watk1 (); hknight_type = 0; } @@ -398,15 +403,14 @@ void() hknight_melee = */ void() monster_hell_knight = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } + precache_model2 ("progs/hknight.mdl"); precache_model2 ("progs/k_spike.mdl"); precache_model2 ("progs/h_hellkn.mdl"); - precache_sound2 ("hknight/attack1.wav"); precache_sound2 ("hknight/death1.wav"); diff --git a/nqw/items.qc b/nqw/items.qc index bd0ef10..2a273b8 100644 --- a/nqw/items.qc +++ b/nqw/items.qc @@ -2,7 +2,6 @@ void() W_SetCurrentAmmo; /* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD BE .8 .3 .4 IN COLOR */ - void() SUB_regen = { self.model = self.mdl; // restore original model @@ -11,8 +10,6 @@ void() SUB_regen = setorigin (self, self.origin); }; - - /*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8) prints a warning message when spawned */ @@ -28,7 +25,7 @@ void() q_touch; void() q_touch = { -local string s; + local string s; if (other.classname != "player") return; @@ -42,18 +39,17 @@ local string s; self.solid = SOLID_NOT; other.items = other.items | IT_QUAD; self.model = string_null; - if (deathmatch == 4) - { - other.armortype = 0; - other.armorvalue = 0 * 0.01; - other.ammo_cells = 0; - } + if (deathmatch == 4) { + other.armortype = 0; + other.armorvalue = 0; + other.ammo_cells = 0; + } -// do the apropriate action + // do the apropriate action other.super_time = 1; other.super_damage_finished = self.cnt; - s=ftos(rint(other.super_damage_finished - time)); + s = ftos (rint (other.super_damage_finished - time)); bprint (PRINT_LOW, other.netname); if (deathmatch == 4) @@ -64,20 +60,19 @@ local string s; bprint (PRINT_LOW, " seconds remaining!\n"); activator = other; - SUB_UseTargets(); // fire all targets / killtargets + SUB_UseTargets(); // fire all targets / killtargets }; - void(float timeleft) DropQuad = { - local entity item; + local entity item; item = spawn(); item.origin = self.origin; + item.velocity_x = -100 + (200 * random ()); + item.velocity_y = -100 + (200 * random ()); item.velocity_z = 300; - item.velocity_x = -100 + (random() * 200); - item.velocity_y = -100 + (random() * 200); item.flags = FL_ITEM; item.solid = SOLID_TRIGGER; @@ -91,12 +86,11 @@ void(float timeleft) DropQuad = item.think = SUB_Remove; }; - void() r_touch; void() r_touch = { -local string s; + local string s; if (other.classname != "player") return; @@ -111,31 +105,29 @@ local string s; other.items = other.items | IT_INVISIBILITY; self.model = string_null; -// do the apropriate action + // do the apropriate action other.invisible_time = 1; other.invisible_finished = self.cnt; - s=ftos(rint(other.invisible_finished - time)); + s = ftos (rint (other.invisible_finished - time)); bprint (PRINT_LOW, other.netname); bprint (PRINT_LOW, " recovered a Ring with "); bprint (PRINT_LOW, s); bprint (PRINT_LOW, " seconds remaining!\n"); - activator = other; - SUB_UseTargets(); // fire all targets / killtargets + SUB_UseTargets (); // fire all targets / killtargets }; - void(float timeleft) DropRing = { - local entity item; + local entity item; item = spawn(); item.origin = self.origin; + item.velocity_x = -100 + (random () * 200); + item.velocity_y = -100 + (random () * 200); item.velocity_z = 300; - item.velocity_x = -100 + (random() * 200); - item.velocity_y = -100 + (random() * 200); item.flags = FL_ITEM; item.solid = SOLID_TRIGGER; @@ -167,12 +159,11 @@ void() PlaceItem = self.velocity = '0 0 0'; self.origin_z = self.origin_z + 6; oldz = self.origin_z; - if (!droptofloor()) - { + if (!droptofloor ()) { dprint ("Bonus item fell out of level at "); - dprint (vtos(self.origin)); + dprint (vtos (self.origin)); dprint ("\n"); - remove(self); + remove (self); return; } }; @@ -190,17 +181,10 @@ void() StartItem = self.think = PlaceItem; }; -/* -========================================================================= +// HEALTH BOX ================================================================= -HEALTH BOX - -========================================================================= -*/ -// // T_Heal: add health to an entity, limiting health to max_health // "ignore" will ignore max_health limit -// float (entity e, float healamount, float ignore) T_Heal = { if (e.health <= 0) @@ -225,7 +209,6 @@ megahealth will add 100 health, then rot you down to your maximum health limit, one point per second. */ - float H_ROTTEN = 1; float H_MEGA = 2; .float healamount, healtype; @@ -236,28 +219,21 @@ void() item_health = { self.touch = health_touch; - if (self.spawnflags & H_ROTTEN) - { + if (self.spawnflags & H_ROTTEN) { precache_model("maps/b_bh10.bsp"); - precache_sound("items/r_item1.wav"); setmodel(self, "maps/b_bh10.bsp"); self.noise = "items/r_item1.wav"; self.healamount = 15; self.healtype = 0; - } - else - if (self.spawnflags & H_MEGA) - { + } else if (self.spawnflags & H_MEGA) { precache_model("maps/b_bh100.bsp"); precache_sound("items/r_item2.wav"); setmodel(self, "maps/b_bh100.bsp"); self.noise = "items/r_item2.wav"; self.healamount = 100; self.healtype = 2; - } - else - { + } else { precache_model("maps/b_bh25.bsp"); precache_sound("items/health1.wav"); setmodel(self, "maps/b_bh25.bsp"); @@ -272,7 +248,7 @@ void() item_health = void() health_touch = { - local string s; + local string s; if (deathmatch == 4) if (other.invincible_time > 0) @@ -281,35 +257,31 @@ void() health_touch = if (other.classname != "player") return; - if (self.healtype == 2) // Megahealth? Ignore max_health... - { + if (self.healtype == 2) { // Megahealth? Ignore max_health... if (other.health >= 250) return; if (!T_Heal(other, self.healamount, 1)) return; - } - else - { + } else { if (!T_Heal(other, self.healamount, 0)) return; } - sprint(other, PRINT_LOW, "You receive "); - s = ftos(self.healamount); - sprint(other, PRINT_LOW, s); - sprint(other, PRINT_LOW, " health\n"); - -// health touch sound + sprint (other, PRINT_LOW, "You receive "); + s = ftos (self.healamount); + sprint (other, PRINT_LOW, s); + sprint (other, PRINT_LOW, " health\n"); + + // health touch sound sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM); stuffcmd (other, "bf\n"); - + self.model = string_null; self.solid = SOLID_NOT; // Megahealth = rot down the player's super health - if (self.healtype == 2) - { + if (self.healtype == 2) { other.items = other.items | IT_SUPERHEALTH; if (deathmatch != 4) { @@ -317,55 +289,42 @@ void() health_touch = self.think = item_megahealth_rot; } self.owner = other; - } - else - { - if (deathmatch && deathmatch != 2) // deathmatch 2 is the silly old rules - { + } else { + if (deathmatch && deathmatch != 2) { // deathmatch 2 is the silly old rules self.nextthink = time + 20; self.think = SUB_regen; } } activator = other; - SUB_UseTargets(); // fire all targets / killtargets -}; + SUB_UseTargets (); // fire all targets / killtargets +}; void() item_megahealth_rot = { other = self.owner; - if (other.health > other.max_health) - { + if (other.health > other.max_health) { other.health = other.health - 1; self.nextthink = time + 1; return; } -// it is possible for a player to die and respawn between rots, so don't -// just blindly subtract the flag off + // it is possible for a player to die and respawn between rots, so don't + // just blindly subtract the flag off other.items = other.items - (other.items & IT_SUPERHEALTH); - if (deathmatch && deathmatch != 2) // deathmatch 2 is silly old rules - { + if (deathmatch && deathmatch != 2) { // deathmatch 2 is silly old rules self.nextthink = time + 20; self.think = SUB_regen; } }; -/* -=============================================================================== - -ARMOR - -=============================================================================== -*/ - -void() armor_touch; +// ARMOR ====================================================================== void() armor_touch = { - local float type = 0, value = 0, bit = 0; + local float type = 0, value = 0, bit = 0; if (other.health <= 0) return; @@ -376,52 +335,48 @@ void() armor_touch = if (other.invincible_time > 0) return; - if (self.classname == "item_armor1") - { + switch (self.classname) { + case "item_armor1": type = 0.3; value = 100; bit = IT_ARMOR1; - } - if (self.classname == "item_armor2") - { + break; + case "item_armor2": type = 0.6; value = 150; bit = IT_ARMOR2; - } - if (self.classname == "item_armorInv") - { + break; + case "item_armorInv": type = 0.8; value = 200; bit = IT_ARMOR3; + break; } - if (other.armortype*other.armorvalue >= type*value) + if (other.armortype * other.armorvalue >= type * value) return; other.armortype = type; other.armorvalue = value; - other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit; - + other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | + IT_ARMOR3)) + bit; self.solid = SOLID_NOT; self.model = string_null; - if (deathmatch && deathmatch != 2) - { + if (deathmatch && deathmatch != 2) { self.nextthink = time + 20; self.think = SUB_regen; } - sprint(other, PRINT_LOW, "You got armor\n"); -// armor touch sound - sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM); + sprint (other, PRINT_LOW, "You got armor\n"); + // armor touch sound + sound (other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM); stuffcmd (other, "bf\n"); activator = other; - SUB_UseTargets(); // fire all targets / killtargets + SUB_UseTargets (); // fire all targets / killtargets }; - /*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32) */ - void() item_armor1 = { self.touch = armor_touch; @@ -434,7 +389,6 @@ void() item_armor1 = /*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32) */ - void() item_armor2 = { self.touch = armor_touch; @@ -447,7 +401,6 @@ void() item_armor2 = /*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32) */ - void() item_armorInv = { self.touch = armor_touch; @@ -458,13 +411,7 @@ void() item_armorInv = StartItem (); }; -/* -=============================================================================== - -WEAPONS - -=============================================================================== -*/ +// WEAPONS ==================================================================== void() bound_other_ammo = { @@ -478,39 +425,46 @@ void() bound_other_ammo = other.ammo_cells = 100; }; - float(float w) RankForWeapon = { - if (w == IT_LIGHTNING) + switch (w) { + case IT_LIGHTNING: return 1; - if (w == IT_ROCKET_LAUNCHER) + case IT_ROCKET_LAUNCHER: return 2; - if (w == IT_SUPER_NAILGUN) + case IT_SUPER_NAILGUN: return 3; - if (w == IT_GRENADE_LAUNCHER) + case IT_GRENADE_LAUNCHER: return 4; - if (w == IT_SUPER_SHOTGUN) + case IT_SUPER_SHOTGUN: return 5; - if (w == IT_NAILGUN) + case IT_NAILGUN: return 6; - return 7; + default: + return 7; + } }; float (float w) WeaponCode = { - if (w == IT_SUPER_SHOTGUN) + switch (w) { + case IT_SHOTGUN: + return 2; + case IT_SUPER_SHOTGUN: return 3; - if (w == IT_NAILGUN) + case IT_NAILGUN: return 4; - if (w == IT_SUPER_NAILGUN) + case IT_SUPER_NAILGUN: return 5; - if (w == IT_GRENADE_LAUNCHER) + case IT_GRENADE_LAUNCHER: return 6; - if (w == IT_ROCKET_LAUNCHER) + case IT_ROCKET_LAUNCHER: return 7; - if (w == IT_LIGHTNING) + case IT_LIGHTNING: return 8; - return 1; + default: + return 1; + } }; /* @@ -526,10 +480,10 @@ void(float old, float new) Deathmatch_Weapon = { local float or, nr; -// change self.weapon if desired + // change self.weapon if desired or = RankForWeapon (self.weapon); nr = RankForWeapon (new); - if ( nr < or ) + if (nr < or) self.weapon = new; }; @@ -552,12 +506,12 @@ void() weapon_touch = if (!(other.flags & FL_CLIENT)) return; - if ((stof(infokey(other,"w_switch"))) == 0) + if ((stof (infokey (other, "w_switch"))) == 0) w_switch = 8; else - w_switch = stof(infokey(other,"w_switch")); + w_switch = stof (infokey (other, "w_switch")); -// if the player was using his best weapon, change up to the new one if better + // if the player was using his best weapon, change to new one if better stemp = self; self = other; best = W_BestWeapon(); @@ -567,85 +521,77 @@ void() weapon_touch = leave = 1; else leave = 0; - - if (self.classname == "weapon_nailgun") - { + + switch (self.classname) { + case "weapon_nailgun": if (leave && (other.items & IT_NAILGUN) ) return; hadammo = other.ammo_nails; new = IT_NAILGUN; other.ammo_nails = other.ammo_nails + 30; - } - else if (self.classname == "weapon_supernailgun") - { + break; + case "weapon_supernailgun": if (leave && (other.items & IT_SUPER_NAILGUN) ) return; hadammo = other.ammo_rockets; new = IT_SUPER_NAILGUN; other.ammo_nails = other.ammo_nails + 30; - } - else if (self.classname == "weapon_supershotgun") - { + break; + case "weapon_supershotgun": if (leave && (other.items & IT_SUPER_SHOTGUN) ) return; hadammo = other.ammo_rockets; new = IT_SUPER_SHOTGUN; other.ammo_shells = other.ammo_shells + 5; - } - else if (self.classname == "weapon_rocketlauncher") - { + break; + case "weapon_rocketlauncher": if (leave && (other.items & IT_ROCKET_LAUNCHER) ) return; hadammo = other.ammo_rockets; new = IT_ROCKET_LAUNCHER; other.ammo_rockets = other.ammo_rockets + 5; - } - else if (self.classname == "weapon_grenadelauncher") - { + break; + case "weapon_grenadelauncher": if (leave && (other.items & IT_GRENADE_LAUNCHER) ) return; hadammo = other.ammo_rockets; new = IT_GRENADE_LAUNCHER; other.ammo_rockets = other.ammo_rockets + 5; - } - else if (self.classname == "weapon_lightning") - { + break; + case "weapon_lightning": if (leave && (other.items & IT_LIGHTNING)) return; hadammo = other.ammo_rockets; new = IT_LIGHTNING; other.ammo_cells = other.ammo_cells + 15; - } - else + break; + default: objerror ("weapon_touch: unknown classname"); + break; + } sprint (other, PRINT_LOW, "You got the "); sprint (other, PRINT_LOW, self.netname); sprint (other, PRINT_LOW, "\n"); -// weapon touch sound + // weapon touch sound sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM); stuffcmd (other, "bf\n"); bound_other_ammo (); -// change to the weapon + // change to the weapon old = other.items; other.items = other.items | new; stemp = self; self = other; - if ( WeaponCode(new) <= w_switch ) - { - if (self.flags & FL_INWATER) - { - if (new != IT_LIGHTNING) - { + if ( WeaponCode(new) <= w_switch ) { + if (self.flags & FL_INWATER) { + if (new != IT_LIGHTNING) { Deathmatch_Weapon (old, new); } - } - else - { + } else { Deathmatch_Weapon (old, new); } } @@ -665,169 +611,138 @@ void() weapon_touch = self.think = SUB_regen; activator = other; - SUB_UseTargets(); // fire all targets / killtargets + SUB_UseTargets (); // fire all targets / killtargets }; - /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32) */ - void() weapon_supershotgun = { -if (deathmatch <= 3) -{ - precache_model ("progs/g_shot.mdl"); - setmodel (self, "progs/g_shot.mdl"); - self.weapon = IT_SUPER_SHOTGUN; - self.netname = "Double-barrelled Shotgun"; - self.touch = weapon_touch; - setsize (self, '-16 -16 0', '16 16 56'); - StartItem (); -} + if (deathmatch <= 3) { + precache_model ("progs/g_shot.mdl"); + setmodel (self, "progs/g_shot.mdl"); + self.weapon = IT_SUPER_SHOTGUN; + self.netname = "Double-barrelled Shotgun"; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } }; /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32) */ - void() weapon_nailgun = { -if (deathmatch <= 3) -{ - precache_model ("progs/g_nail.mdl"); - setmodel (self, "progs/g_nail.mdl"); - self.weapon = IT_NAILGUN; - self.netname = "nailgun"; - self.touch = weapon_touch; - setsize (self, '-16 -16 0', '16 16 56'); - StartItem (); -} + if (deathmatch <= 3) { + precache_model ("progs/g_nail.mdl"); + setmodel (self, "progs/g_nail.mdl"); + self.weapon = IT_NAILGUN; + self.netname = "nailgun"; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } }; /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32) */ - void() weapon_supernailgun = { -if (deathmatch <= 3) -{ - precache_model ("progs/g_nail2.mdl"); - setmodel (self, "progs/g_nail2.mdl"); - self.weapon = IT_SUPER_NAILGUN; - self.netname = "Super Nailgun"; - self.touch = weapon_touch; - setsize (self, '-16 -16 0', '16 16 56'); - StartItem (); -} + if (deathmatch <= 3) { + precache_model ("progs/g_nail2.mdl"); + setmodel (self, "progs/g_nail2.mdl"); + self.weapon = IT_SUPER_NAILGUN; + self.netname = "Super Nailgun"; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } }; /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32) */ - void() weapon_grenadelauncher = { -if (deathmatch <= 3) -{ - precache_model ("progs/g_rock.mdl"); - setmodel (self, "progs/g_rock.mdl"); - self.weapon = 3; - self.netname = "Grenade Launcher"; - self.touch = weapon_touch; - setsize (self, '-16 -16 0', '16 16 56'); - StartItem (); -} + if (deathmatch <= 3) { + precache_model ("progs/g_rock.mdl"); + setmodel (self, "progs/g_rock.mdl"); + self.weapon = 3; + self.netname = "Grenade Launcher"; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } }; /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32) */ - void() weapon_rocketlauncher = { -if (deathmatch <= 3) -{ - precache_model ("progs/g_rock2.mdl"); - setmodel (self, "progs/g_rock2.mdl"); - self.weapon = 3; - self.netname = "Rocket Launcher"; - self.touch = weapon_touch; - setsize (self, '-16 -16 0', '16 16 56'); - StartItem (); -} + if (deathmatch <= 3) { + precache_model ("progs/g_rock2.mdl"); + setmodel (self, "progs/g_rock2.mdl"); + self.weapon = 3; + self.netname = "Rocket Launcher"; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } }; - /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32) */ - void() weapon_lightning = { -if (deathmatch <= 3) -{ - precache_model ("progs/g_light.mdl"); - setmodel (self, "progs/g_light.mdl"); - self.weapon = 3; - self.netname = "Thunderbolt"; - self.touch = weapon_touch; - setsize (self, '-16 -16 0', '16 16 56'); - StartItem (); -} + if (deathmatch <= 3) { + precache_model ("progs/g_light.mdl"); + setmodel (self, "progs/g_light.mdl"); + self.weapon = 3; + self.netname = "Thunderbolt"; + self.touch = weapon_touch; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); + } }; - -/* -=============================================================================== - -AMMO - -=============================================================================== -*/ +// AMMO ======================================================================= void() ammo_touch = { -local entity stemp; -local float best; + local entity stemp; + local float best; if (other.classname != "player") return; if (other.health <= 0) return; -// if the player was using his best weapon, change up to the new one if better + // if the player was using his best weapon, change to new one if better stemp = self; self = other; best = W_BestWeapon(); self = stemp; - -// shotgun - if (self.weapon == 1) - { + switch (self.weapon) { + case 1: // shotgun if (other.ammo_shells >= 100) return; other.ammo_shells = other.ammo_shells + self.aflag; - } - -// spikes - if (self.weapon == 2) - { + break; + case 2: // spikes if (other.ammo_nails >= 200) return; other.ammo_nails = other.ammo_nails + self.aflag; - } - -// rockets - if (self.weapon == 3) - { + break; + case 3: // rockets if (other.ammo_rockets >= 100) return; other.ammo_rockets = other.ammo_rockets + self.aflag; - } - -// cells - if (self.weapon == 4) - { + break; + case 4: // cells if (other.ammo_cells >= 100) return; other.ammo_cells = other.ammo_cells + self.aflag; + break; } bound_other_ammo (); @@ -835,14 +750,12 @@ local float best; sprint (other, PRINT_LOW, "You got the "); sprint (other, PRINT_LOW, self.netname); sprint (other, PRINT_LOW, "\n"); -// ammo touch sound + // ammo touch sound sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM); stuffcmd (other, "bf\n"); -// change to a better weapon if appropriate - - if ( other.weapon == best ) - { + // change to a better weapon if appropriate + if (other.weapon == best) { stemp = self; self = other; self.weapon = W_BestWeapon(); @@ -850,37 +763,32 @@ local float best; self = stemp; } -// if changed current ammo, update it + // if changed current ammo, update it stemp = self; self = other; W_SetCurrentAmmo(); self = stemp; -// remove it in single player, or setup for respawning in deathmatch + // remove it in single player, or setup for respawning in deathmatch self.model = string_null; self.solid = SOLID_NOT; if (deathmatch && deathmatch != 2) self.nextthink = time + 30; -// Xian -- If playing in DM 3.0 mode, halve the time ammo respawns - + // Xian -- If playing in DM 3.0 mode, halve the time ammo respawns if (deathmatch == 3 || deathmatch == 5) self.nextthink = time + 15; self.think = SUB_regen; activator = other; - SUB_UseTargets(); // fire all targets / killtargets + SUB_UseTargets (); // fire all targets / killtargets }; - - - float WEAPON_BIG2 = 1; /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big */ - void() item_shells = { if (deathmatch == 4) @@ -888,14 +796,11 @@ void() item_shells = self.touch = ammo_touch; - if (self.spawnflags & WEAPON_BIG2) - { + if (self.spawnflags & WEAPON_BIG2) { precache_model ("maps/b_shell1.bsp"); setmodel (self, "maps/b_shell1.bsp"); self.aflag = 40; - } - else - { + } else { precache_model ("maps/b_shell0.bsp"); setmodel (self, "maps/b_shell0.bsp"); self.aflag = 20; @@ -908,7 +813,6 @@ void() item_shells = /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big */ - void() item_spikes = { if (deathmatch == 4) @@ -916,14 +820,11 @@ void() item_spikes = self.touch = ammo_touch; - if (self.spawnflags & WEAPON_BIG2) - { + if (self.spawnflags & WEAPON_BIG2) { precache_model ("maps/b_nail1.bsp"); setmodel (self, "maps/b_nail1.bsp"); self.aflag = 50; - } - else - { + } else { precache_model ("maps/b_nail0.bsp"); setmodel (self, "maps/b_nail0.bsp"); self.aflag = 25; @@ -932,12 +833,10 @@ void() item_spikes = self.netname = "nails"; setsize (self, '0 0 0', '32 32 56'); StartItem (); - }; /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big */ - void() item_rockets = { if (deathmatch == 4) @@ -945,14 +844,11 @@ void() item_rockets = self.touch = ammo_touch; - if (self.spawnflags & WEAPON_BIG2) - { + if (self.spawnflags & WEAPON_BIG2) { precache_model ("maps/b_rock1.bsp"); setmodel (self, "maps/b_rock1.bsp"); self.aflag = 10; - } - else - { + } else { precache_model ("maps/b_rock0.bsp"); setmodel (self, "maps/b_rock0.bsp"); self.aflag = 5; @@ -961,13 +857,10 @@ void() item_rockets = self.netname = "rockets"; setsize (self, '0 0 0', '32 32 56'); StartItem (); - }; - /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big */ - void() item_cells = { if (deathmatch == 4) @@ -975,14 +868,11 @@ void() item_cells = self.touch = ammo_touch; - if (self.spawnflags & WEAPON_BIG2) - { + if (self.spawnflags & WEAPON_BIG2) { precache_model ("maps/b_batt1.bsp"); setmodel (self, "maps/b_batt1.bsp"); self.aflag = 12; - } - else - { + } else { precache_model ("maps/b_batt0.bsp"); setmodel (self, "maps/b_batt0.bsp"); self.aflag = 6; @@ -991,14 +881,11 @@ void() item_cells = self.netname = "cells"; setsize (self, '0 0 0', '32 32 56'); StartItem (); - }; - /*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big DO NOT USE THIS!!!! IT WILL BE REMOVED! */ - float WEAPON_SHOTGUN = 1; float WEAPON_ROCKET = 2; float WEAPON_SPIKES = 4; @@ -1007,16 +894,12 @@ void() item_weapon = { self.touch = ammo_touch; - if (self.spawnflags & WEAPON_SHOTGUN) - { - if (self.spawnflags & WEAPON_BIG) - { + if (self.spawnflags & WEAPON_SHOTGUN) { + if (self.spawnflags & WEAPON_BIG) { precache_model ("maps/b_shell1.bsp"); setmodel (self, "maps/b_shell1.bsp"); self.aflag = 40; - } - else - { + } else { precache_model ("maps/b_shell0.bsp"); setmodel (self, "maps/b_shell0.bsp"); self.aflag = 20; @@ -1025,19 +908,15 @@ void() item_weapon = self.netname = "shells"; } - if (self.spawnflags & WEAPON_SPIKES) - { + if (self.spawnflags & WEAPON_SPIKES) { if (deathmatch == 4) - return; + return; - if (self.spawnflags & WEAPON_BIG) - { + if (self.spawnflags & WEAPON_BIG) { precache_model ("maps/b_nail1.bsp"); setmodel (self, "maps/b_nail1.bsp"); self.aflag = 40; - } - else - { + } else { precache_model ("maps/b_nail0.bsp"); setmodel (self, "maps/b_nail0.bsp"); self.aflag = 20; @@ -1046,19 +925,15 @@ void() item_weapon = self.netname = "spikes"; } - if (self.spawnflags & WEAPON_ROCKET) - { + if (self.spawnflags & WEAPON_ROCKET) { if (deathmatch == 4) - return; + return; - if (self.spawnflags & WEAPON_BIG) - { + if (self.spawnflags & WEAPON_BIG) { precache_model ("maps/b_rock1.bsp"); setmodel (self, "maps/b_rock1.bsp"); self.aflag = 10; - } - else - { + } else { precache_model ("maps/b_rock0.bsp"); setmodel (self, "maps/b_rock0.bsp"); self.aflag = 5; @@ -1071,14 +946,7 @@ void() item_weapon = StartItem (); }; - -/* -=============================================================================== - -KEYS - -=============================================================================== -*/ +// KEYS ======================================================================= void() key_touch = { @@ -1091,39 +959,36 @@ void() key_touch = sprint (other, PRINT_LOW, "You got the "); sprint (other, PRINT_LOW, self.netname); - sprint (other,PRINT_LOW, "\n"); + sprint (other, PRINT_LOW, "\n"); sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM); stuffcmd (other, "bf\n"); other.items = other.items | self.items; - if (!coop) - { + if (!coop) { self.solid = SOLID_NOT; self.model = string_null; } activator = other; - SUB_UseTargets(); // fire all targets / killtargets + SUB_UseTargets (); // fire all targets / killtargets }; - void() key_setsounds = { - if (world.worldtype == 0) - { + switch (world.worldtype) { + case 0: precache_sound ("misc/medkey.wav"); self.noise = "misc/medkey.wav"; - } - if (world.worldtype == 1) - { + break; + case 1: precache_sound ("misc/runekey.wav"); self.noise = "misc/runekey.wav"; - } - if (world.worldtype == 2) - { + break; + case 2: precache_sound2 ("misc/basekey.wav"); self.noise = "misc/basekey.wav"; + break; } }; @@ -1137,26 +1002,24 @@ following: 1: metal 2: base */ - void() item_key1 = { - if (world.worldtype == 0) - { + switch (world.worldtype) { + case 0: precache_model ("progs/w_s_key.mdl"); setmodel (self, "progs/w_s_key.mdl"); self.netname = "silver key"; - } - else if (world.worldtype == 1) - { + break; + case 1: precache_model ("progs/m_s_key.mdl"); setmodel (self, "progs/m_s_key.mdl"); self.netname = "silver runekey"; - } - else if (world.worldtype == 2) - { + break; + case 2: precache_model2 ("progs/b_s_key.mdl"); setmodel (self, "progs/b_s_key.mdl"); self.netname = "silver keycard"; + break; } key_setsounds(); self.touch = key_touch; @@ -1175,26 +1038,24 @@ following: 1: metal 2: base */ - void() item_key2 = { - if (world.worldtype == 0) - { + switch (world.worldtype) { + case 0: precache_model ("progs/w_g_key.mdl"); setmodel (self, "progs/w_g_key.mdl"); self.netname = "gold key"; - } - if (world.worldtype == 1) - { + break; + case 1: precache_model ("progs/m_g_key.mdl"); setmodel (self, "progs/m_g_key.mdl"); self.netname = "gold runekey"; - } - if (world.worldtype == 2) - { + break; + case 2: precache_model2 ("progs/b_g_key.mdl"); setmodel (self, "progs/b_g_key.mdl"); self.netname = "gold keycard"; + break; } key_setsounds(); self.touch = key_touch; @@ -1203,15 +1064,7 @@ void() item_key2 = StartItem (); }; - - -/* -=============================================================================== - -END OF LEVEL RUNES - -=============================================================================== -*/ +// END OF LEVEL RUNES ========================================================= void() sigil_touch = { @@ -1227,17 +1080,15 @@ void() sigil_touch = self.solid = SOLID_NOT; self.model = string_null; serverflags = serverflags | (self.spawnflags & 15); - self.classname = ""; // so rune doors won't find it + self.classname = ""; // so rune doors won't find it activator = other; - SUB_UseTargets(); // fire all targets / killtargets + SUB_UseTargets (); // fire all targets / killtargets }; - /*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4 End of level sigil, pick up to end episode and return to jrstart. */ - void() item_sigil = { if (!self.spawnflags) @@ -1246,23 +1097,19 @@ void() item_sigil = precache_sound ("misc/runekey.wav"); self.noise = "misc/runekey.wav"; - if (self.spawnflags & 1) - { + if (self.spawnflags & 1) { precache_model ("progs/end1.mdl"); setmodel (self, "progs/end1.mdl"); } - if (self.spawnflags & 2) - { + if (self.spawnflags & 2) { precache_model2 ("progs/end2.mdl"); setmodel (self, "progs/end2.mdl"); } - if (self.spawnflags & 4) - { + if (self.spawnflags & 4) { precache_model2 ("progs/end3.mdl"); setmodel (self, "progs/end3.mdl"); } - if (self.spawnflags & 8) - { + if (self.spawnflags & 8) { precache_model2 ("progs/end4.mdl"); setmodel (self, "progs/end4.mdl"); } @@ -1272,16 +1119,7 @@ void() item_sigil = StartItem (); }; -/* -=============================================================================== - -POWERUPS - -=============================================================================== -*/ - -void() powerup_touch; - +// POWERUPS =================================================================== void() powerup_touch = { @@ -1291,11 +1129,10 @@ void() powerup_touch = return; sprint (other, PRINT_LOW, "You got the "); - sprint (other,PRINT_LOW, self.netname); - sprint (other,PRINT_LOW, "\n"); + sprint (other, PRINT_LOW, self.netname); + sprint (other, PRINT_LOW, "\n"); - if (deathmatch) - { + if (deathmatch) { self.mdl = self.model; if ((self.classname == "item_artifact_invulnerability") || @@ -1313,31 +1150,23 @@ void() powerup_touch = other.items = other.items | self.items; self.model = string_null; -// do the apropriate action - if (self.classname == "item_artifact_envirosuit") - { + // do the apropriate action + if (self.classname == "item_artifact_envirosuit") { other.rad_time = 1; other.radsuit_finished = time + 30; } - - if (self.classname == "item_artifact_invulnerability") - { + if (self.classname == "item_artifact_invulnerability") { other.invincible_time = 1; other.invincible_finished = time + 30; } - - if (self.classname == "item_artifact_invisibility") - { + if (self.classname == "item_artifact_invisibility") { other.invisible_time = 1; other.invisible_finished = time + 30; } - - if (self.classname == "item_artifact_super_damage") - { - if (deathmatch == 4) - { + if (self.classname == "item_artifact_super_damage") { + if (deathmatch == 4) { other.armortype = 0; - other.armorvalue = 0 * 0.01; + other.armorvalue = 0; other.ammo_cells = 0; } other.super_time = 1; @@ -1345,11 +1174,9 @@ void() powerup_touch = } activator = other; - SUB_UseTargets(); // fire all targets / killtargets + SUB_UseTargets (); // fire all targets / killtargets }; - - /*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32) Player is invulnerable for 30 seconds */ @@ -1389,7 +1216,6 @@ void() item_artifact_envirosuit = StartItem (); }; - /*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32) Player is invisible for 30 seconds */ @@ -1409,7 +1235,6 @@ void() item_artifact_invisibility = StartItem (); }; - /*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32) The next attack from the player will do 4x damage */ @@ -1434,44 +1259,32 @@ void() item_artifact_super_damage = StartItem (); }; - - -/* -=============================================================================== - -PLAYER BACKPACKS - -=============================================================================== -*/ +// PLAYER BACKPACKS =========================================================== void() BackpackTouch = { - local string s; - local float best, old, new; - local entity stemp; - local float acount; - local float b_switch; + local entity stemp; + local float acount, b_switch, best, old, new; + local string s; if (deathmatch == 4) if (other.invincible_time > 0) return; - if ((stof(infokey(other,"b_switch"))) == 0) + if ((stof (infokey (other, "b_switch"))) == 0) b_switch = 8; else - b_switch = stof(infokey(other,"b_switch")); - + b_switch = stof (infokey (other, "b_switch")); if (other.classname != "player") return; if (other.health <= 0) return; - + acount = 0; sprint (other, PRINT_LOW, "You get "); - - if (deathmatch == 4) - { + + if (deathmatch == 4) { other.health = other.health + 10; sprint (other, PRINT_LOW, "10 additional health\n"); if ((other.health > 250) && (other.health < 300)) @@ -1479,23 +1292,20 @@ void() BackpackTouch = else sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM); stuffcmd (other, "bf\n"); - remove(self); + remove (self); - if (other.health >299) - { - if (other.invincible_time != 1) - { + if (other.health > 299) { + if (other.invincible_time != 1) { other.invincible_time = 1; other.invincible_finished = time + 30; other.items = other.items | IT_INVULNERABILITY; - + other.super_time = 1; other.super_damage_finished = time + 30; other.items = other.items | IT_QUAD; other.ammo_cells = 0; - - + sound (other, CHAN_VOICE, "boss1/sight1.wav", 1, ATTN_NORM); stuffcmd (other, "bf\n"); bprint (PRINT_HIGH, other.netname); @@ -1506,20 +1316,19 @@ void() BackpackTouch = return; } if (self.items) - if ((other.items & self.items) == 0) - { + if ((other.items & self.items) == 0) { acount = 1; sprint (other, PRINT_LOW, "the "); sprint (other, PRINT_LOW, self.netname); } - -// if the player was using his best weapon, change up to the new one if better + + // if the player was using his best weapon, change to new one if better stemp = self; self = other; best = W_BestWeapon(); self = stemp; -// change weapons + // change weapons other.ammo_shells = other.ammo_shells + self.ammo_shells; other.ammo_nails = other.ammo_nails + self.ammo_nails; other.ammo_rockets = other.ammo_rockets + self.ammo_rockets; @@ -1530,71 +1339,61 @@ void() BackpackTouch = new = other.weapon; old = other.items; other.items = other.items | self.items; - + bound_other_ammo (); - if (self.ammo_shells) - { + if (self.ammo_shells) { if (acount) - sprint(other, PRINT_LOW, ", "); + sprint (other, PRINT_LOW, ", "); acount = 1; - s = ftos(self.ammo_shells); + s = ftos (self.ammo_shells); sprint (other, PRINT_LOW, s); sprint (other, PRINT_LOW, " shells"); } - if (self.ammo_nails) - { + if (self.ammo_nails) { if (acount) - sprint(other, PRINT_LOW, ", "); + sprint (other, PRINT_LOW, ", "); acount = 1; - s = ftos(self.ammo_nails); + s = ftos (self.ammo_nails); sprint (other, PRINT_LOW, s); sprint (other, PRINT_LOW, " nails"); } - if (self.ammo_rockets) - { + if (self.ammo_rockets) { if (acount) - sprint(other, PRINT_LOW, ", "); + sprint (other, PRINT_LOW, ", "); acount = 1; - s = ftos(self.ammo_rockets); + s = ftos (self.ammo_rockets); sprint (other, PRINT_LOW, s); sprint (other, PRINT_LOW, " rockets"); } - if (self.ammo_cells) - { + if (self.ammo_cells) { if (acount) - sprint(other, PRINT_LOW, ", "); + sprint (other, PRINT_LOW, ", "); acount = 1; - s = ftos(self.ammo_cells); + s = ftos (self.ammo_cells); sprint (other, PRINT_LOW, s); sprint (other,PRINT_LOW, " cells"); } - - if ( (deathmatch==3 || deathmatch == 5) & ( (WeaponCode(new)==6) || (WeaponCode(new)==7) ) & (other.ammo_rockets < 5) ) + + if ((deathmatch == 3 || deathmatch == 5) + & ((WeaponCode (new) == 6) || (WeaponCode (new) == 7)) + & (other.ammo_rockets < 5)) other.ammo_rockets = 5; sprint (other, PRINT_LOW, "\n"); -// backpack touch sound + // backpack touch sound sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM); stuffcmd (other, "bf\n"); - remove(self); + remove (self); self = other; - -// change to the weapon - - - if ( WeaponCode(new) <= b_switch ) - { - if (self.flags & FL_INWATER) - { + + // change to the weapon + if ( WeaponCode(new) <= b_switch ) { + if (self.flags & FL_INWATER) { if (new != IT_LIGHTNING) - { Deathmatch_Weapon (old, new); - } - } - else - { + } else { Deathmatch_Weapon (old, new); } } @@ -1602,49 +1401,56 @@ void() BackpackTouch = W_SetCurrentAmmo (); }; -/* -=============== -DropBackpack -=============== -*/ void() DropBackpack = { local entity item; - if (!(self.ammo_shells + self.ammo_nails + self.ammo_rockets + self.ammo_cells)) + if (!(self.ammo_shells + self.ammo_nails + self.ammo_rockets + + self.ammo_cells)) return; // nothing in it item = spawn(); item.origin = self.origin - '0 0 24'; item.items = self.weapon; - if (item.items == IT_AXE) + switch (item.items) { + case IT_AXE: item.netname = "Axe"; - else if (item.items == IT_SHOTGUN) + break; + case IT_SHOTGUN: item.netname = "Shotgun"; - else if (item.items == IT_SUPER_SHOTGUN) + break; + case IT_SUPER_SHOTGUN: item.netname = "Double-barrelled Shotgun"; - else if (item.items == IT_NAILGUN) + break; + case IT_NAILGUN: item.netname = "Nailgun"; - else if (item.items == IT_SUPER_NAILGUN) + break; + case IT_SUPER_NAILGUN: item.netname = "Super Nailgun"; - else if (item.items == IT_GRENADE_LAUNCHER) + break; + case IT_GRENADE_LAUNCHER: item.netname = "Grenade Launcher"; - else if (item.items == IT_ROCKET_LAUNCHER) + break; + case IT_ROCKET_LAUNCHER: item.netname = "Rocket Launcher"; - else if (item.items == IT_LIGHTNING) + break; + case IT_LIGHTNING: item.netname = "Thunderbolt"; - else + break; + default: item.netname = ""; + break; + } item.ammo_shells = self.ammo_shells; item.ammo_nails = self.ammo_nails; item.ammo_rockets = self.ammo_rockets; item.ammo_cells = self.ammo_cells; + item.velocity_x = -100 + (200 * random ()); + item.velocity_y = -100 + (200 * random ()); item.velocity_z = 300; - item.velocity_x = -100 + (random() * 200); - item.velocity_y = -100 + (random() * 200); item.flags = FL_ITEM; item.solid = SOLID_TRIGGER; @@ -1656,5 +1462,3 @@ void() DropBackpack = item.nextthink = time + 120; // remove after 2 minutes item.think = SUB_Remove; }; - - diff --git a/nqw/knight.qc b/nqw/knight.qc index 5b160c7..240f6f1 100644 --- a/nqw/knight.qc +++ b/nqw/knight.qc @@ -56,9 +56,10 @@ void() knight_stand8 =[ $stand8, knight_stand9 ] {ai_stand();}; void() knight_stand9 =[ $stand9, knight_stand1 ] {ai_stand();}; void() knight_walk1 =[ $walk1, knight_walk2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "knight/idle.wav", 1, ATTN_IDLE); -ai_walk(3);}; + if (random () < 0.2) + sound (self, CHAN_VOICE, "knight/idle.wav", 1, ATTN_IDLE); + ai_walk (3); +}; void() knight_walk2 =[ $walk2, knight_walk3 ] {ai_walk(2);}; void() knight_walk3 =[ $walk3, knight_walk4 ] {ai_walk(3);}; void() knight_walk4 =[ $walk4, knight_walk5 ] {ai_walk(4);}; @@ -75,9 +76,10 @@ void() knight_walk14 =[ $walk14, knight_walk1 ] {ai_walk(3);}; void() knight_run1 =[ $runb1, knight_run2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "knight/idle.wav", 1, ATTN_IDLE); -ai_run(16);}; + if (random () < 0.2) + sound (self, CHAN_VOICE, "knight/idle.wav", 1, ATTN_IDLE); + ai_run (16); +}; void() knight_run2 =[ $runb2, knight_run3 ] {ai_run(20);}; void() knight_run3 =[ $runb3, knight_run4 ] {ai_run(13);}; void() knight_run4 =[ $runb4, knight_run5 ] {ai_run(7);}; @@ -86,14 +88,12 @@ void() knight_run6 =[ $runb6, knight_run7 ] {ai_run(20);}; void() knight_run7 =[ $runb7, knight_run8 ] {ai_run(14);}; void() knight_run8 =[ $runb8, knight_run1 ] {ai_run(6);}; - -void() knight_runatk1 =[ $runattack1, knight_runatk2 ] -{ -if (random() > 0.5) - sound (self, CHAN_WEAPON, "knight/sword2.wav", 1, ATTN_NORM); -else - sound (self, CHAN_WEAPON, "knight/sword1.wav", 1, ATTN_NORM); -ai_charge(20); +void() knight_runatk1 =[ $runattack1, knight_runatk2 ] { + if (random () > 0.5) + sound (self, CHAN_WEAPON, "knight/sword2.wav", 1, ATTN_NORM); + else + sound (self, CHAN_WEAPON, "knight/sword1.wav", 1, ATTN_NORM); + ai_charge (20); }; void() knight_runatk2 =[ $runattack2, knight_runatk3 ] {ai_charge_side();}; void() knight_runatk3 =[ $runattack3, knight_runatk4 ] {ai_charge_side();}; @@ -106,18 +106,20 @@ void() knight_runatk9 =[ $runattack9, knight_runatk10 ] {ai_melee_side();}; void() knight_runatk10 =[ $runattack10, knight_runatk11 ] {ai_charge_side();}; void() knight_runatk11 =[ $runattack11, knight_run1 ] {ai_charge(10);}; -void() knight_atk1 =[ $attackb1, knight_atk2 ] -{ -sound (self, CHAN_WEAPON, "knight/sword1.wav", 1, ATTN_NORM); -ai_charge(0);}; +void() knight_atk1 =[ $attackb1, knight_atk2 ] { + sound (self, CHAN_WEAPON, "knight/sword1.wav", 1, ATTN_NORM); + ai_charge (0); +}; void() knight_atk2 =[ $attackb2, knight_atk3 ] {ai_charge(7);}; void() knight_atk3 =[ $attackb3, knight_atk4 ] {ai_charge(4);}; void() knight_atk4 =[ $attackb4, knight_atk5 ] {ai_charge(0);}; void() knight_atk5 =[ $attackb5, knight_atk6 ] {ai_charge(3);}; void() knight_atk6 =[ $attackb6, knight_atk7 ] {ai_charge(4); ai_melee();}; void() knight_atk7 =[ $attackb7, knight_atk8 ] {ai_charge(1); ai_melee();}; -void() knight_atk8 =[ $attackb8, knight_atk9 ] {ai_charge(3); -ai_melee();}; +void() knight_atk8 =[ $attackb8, knight_atk9 ] { + ai_charge (3); + ai_melee (); +}; void() knight_atk9 =[ $attackb9, knight_atk10] {ai_charge(1);}; void() knight_atk10=[ $attackb10, knight_run1 ] {ai_charge(5);}; @@ -150,20 +152,16 @@ void(entity attacker, float damage) knight_pain = if (self.pain_finished > time) return; - r = random(); + r = random (); sound (self, CHAN_VOICE, "knight/khurt.wav", 1, ATTN_NORM); - if (r < 0.85) - { + if (r < 0.85) { knight_pain1 (); self.pain_finished = time + 1; - } - else - { + } else { knight_painb1 (); self.pain_finished = time + 1; } - }; //=========================================================================== @@ -181,12 +179,9 @@ void() knight_bow8 =[ $kneel2, knight_bow9 ] {ai_turn();}; void() knight_bow9 =[ $kneel1, knight_bow10 ] {ai_turn();}; void() knight_bow10 =[ $walk1, knight_walk1 ] {ai_turn();}; - - void() knight_die1 =[ $death1, knight_die2 ] {}; void() knight_die2 =[ $death2, knight_die3 ] {}; -void() knight_die3 =[ $death3, knight_die4 ] -{self.solid = SOLID_NOT;}; +void() knight_die3 =[ $death3, knight_die4 ] {self.solid = SOLID_NOT;}; void() knight_die4 =[ $death4, knight_die5 ] {}; void() knight_die5 =[ $death5, knight_die6 ] {}; void() knight_die6 =[ $death6, knight_die7 ] {}; @@ -198,8 +193,7 @@ void() knight_die10=[ $death10, knight_die10] {}; void() knight_dieb1 =[ $deathb1, knight_dieb2 ] {}; void() knight_dieb2 =[ $deathb2, knight_dieb3 ] {}; -void() knight_dieb3 =[ $deathb3, knight_dieb4 ] -{self.solid = SOLID_NOT;}; +void() knight_dieb3 =[ $deathb3, knight_dieb4 ] {self.solid = SOLID_NOT;}; void() knight_dieb4 =[ $deathb4, knight_dieb5 ] {}; void() knight_dieb5 =[ $deathb5, knight_dieb6 ] {}; void() knight_dieb6 =[ $deathb6, knight_dieb7 ] {}; @@ -209,12 +203,10 @@ void() knight_dieb9 =[ $deathb9, knight_dieb10] {}; void() knight_dieb10 = [ $deathb10, knight_dieb11] {}; void() knight_dieb11 = [ $deathb11, knight_dieb11] {}; - void() knight_die = { -// check for gib - if (self.health < -40) - { + // check for gib + if (self.health < -40) { sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); ThrowHead ("progs/h_knight.mdl", self.health); ThrowGib ("progs/gib1.mdl", self.health); @@ -223,24 +215,23 @@ void() knight_die = return; } -// regular death + // regular death sound (self, CHAN_VOICE, "knight/kdeath.wav", 1, ATTN_NORM); - if (random() < 0.5) + if (random () < 0.5) knight_die1 (); else knight_dieb1 (); }; - /*QUAKED monster_knight (1 0 0) (-16 -16 -24) (16 16 40) Ambush */ void() monster_knight = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } + precache_model ("progs/knight.mdl"); precache_model ("progs/h_knight.mdl"); diff --git a/nqw/misc.qc b/nqw/misc.qc index 01b65b6..43b0aca 100644 --- a/nqw/misc.qc +++ b/nqw/misc.qc @@ -1,4 +1,3 @@ - /*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4) Used as a positional target for spotlights, etc. */ @@ -20,13 +19,10 @@ float START_OFF = 1; void() light_use = { - if (self.spawnflags & START_OFF) - { + if (self.spawnflags & START_OFF) { lightstyle(self.style, "m"); self.spawnflags = self.spawnflags - START_OFF; - } - else - { + } else { lightstyle(self.style, "a"); self.spawnflags = self.spawnflags + START_OFF; } @@ -40,14 +36,12 @@ If targeted, it will toggle between on or off. */ void() light = { - if (!self.targetname) - { // inert light - remove(self); + if (!self.targetname) { // inert light + remove (self); return; } - if (self.style >= 32) - { + if (self.style >= 32) { self.use = light_use; if (self.spawnflags & START_OFF) lightstyle(self.style, "a"); @@ -65,8 +59,7 @@ Makes steady fluorescent humming sound */ void() light_fluoro = { - if (self.style >= 32) - { + if (self.style >= 32) { self.use = light_use; if (self.spawnflags & START_OFF) lightstyle(self.style, "a"); @@ -108,7 +101,7 @@ void() light_globe = void() FireAmbient = { precache_sound ("ambience/fire1.wav"); -// attenuate fast + // attenuate fast ambientsound (self.origin, "ambience/fire1.wav", 0.5, ATTN_STATIC); }; @@ -161,19 +154,16 @@ void() light_flame_small_white = //============================================================================ - /*QUAKED misc_fireball (0 .5 .8) (-8 -8 -8) (8 8 8) Lava Balls */ - void() fire_fly; void() fire_touch; void() misc_fireball = { - precache_model ("progs/lavaball.mdl"); self.classname = "fireball"; - self.nextthink = time + (random() * 5); + self.nextthink = time + (random () * 5); self.think = fire_fly; if (!self.speed) self.speed = 1000; @@ -181,15 +171,15 @@ void() misc_fireball = void() fire_fly = { -local entity fireball; + local entity fireball; fireball = spawn(); fireball.solid = SOLID_TRIGGER; fireball.movetype = MOVETYPE_TOSS; fireball.velocity = '0 0 1000'; - fireball.velocity_x = (random() * 100) - 50; - fireball.velocity_y = (random() * 100) - 50; - fireball.velocity_z = self.speed + (random() * 200); + fireball.velocity_x = (100 * random ()) - 50; + fireball.velocity_y = (100 * random ()) - 50; + fireball.velocity_z = self.speed + (200 * random ()); fireball.classname = "fireball"; setmodel (fireball, "progs/lavaball.mdl"); setsize (fireball, '0 0 0', '0 0 0'); @@ -198,11 +188,10 @@ local entity fireball; fireball.think = SUB_Remove; fireball.touch = fire_touch; - self.nextthink = time + (random() * 5) + 3; + self.nextthink = time + (random () * 5) + 3; self.think = fire_fly; }; - void() fire_touch = { T_Damage (other, self, self, 20); @@ -211,28 +200,22 @@ void() fire_touch = //============================================================================ - void() barrel_explode = { self.takedamage = DAMAGE_NO; self.classname = "explo_box"; // did say self.owner T_RadiusDamage (self, self, 160, world, ""); - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_EXPLOSION); - WriteCoord (MSG_MULTICAST, self.origin_x); - WriteCoord (MSG_MULTICAST, self.origin_y); - WriteCoord (MSG_MULTICAST, self.origin_z+32); + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_EXPLOSION); + self.origin_z += 32; + WriteCoordV (MSG_MULTICAST, self.origin); multicast (self.origin, MULTICAST_PHS); remove (self); }; - - /*QUAKED misc_explobox (0 .5 .8) (0 0 0) (32 32 64) TESTING THING */ - void() misc_explobox = { local float oldz; @@ -250,22 +233,17 @@ void() misc_explobox = self.origin_z = self.origin_z + 2; oldz = self.origin_z; droptofloor(); - if (oldz - self.origin_z > 250) - { + if (oldz - self.origin_z > 250) { dprint ("item fell out of level at "); dprint (vtos(self.origin)); dprint ("\n"); - remove(self); + remove (self); } }; - - - /*QUAKED misc_explobox2 (0 .5 .8) (0 0 0) (32 32 64) Smaller exploding box, REGISTERED ONLY */ - void() misc_explobox2 = { local float oldz; @@ -283,12 +261,11 @@ void() misc_explobox2 = self.origin_z = self.origin_z + 2; oldz = self.origin_z; droptofloor(); - if (oldz - self.origin_z > 250) - { + if (oldz - self.origin_z > 250) { dprint ("item fell out of level at "); dprint (vtos(self.origin)); dprint ("\n"); - remove(self); + remove (self); } }; @@ -304,33 +281,25 @@ void() Laser_Touch = if (other == self.owner) return; // don't explode on owner - if (pointcontents(self.origin) == CONTENT_SKY) - { - remove(self); + if (pointcontents(self.origin) == CONTENT_SKY) { + remove (self); return; } sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC); org = self.origin - 8*normalize(self.velocity); - if (other.health) - { + if (other.health) { SpawnBlood (org, 15); other.deathtype = "laser"; T_Damage (other, self, self.owner, 15); - } - else - { - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_GUNSHOT); - WriteByte (MSG_MULTICAST, 5); - WriteCoord (MSG_MULTICAST, org_x); - WriteCoord (MSG_MULTICAST, org_y); - WriteCoord (MSG_MULTICAST, org_z); + } else { + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_GUNSHOT, 5.0); + WriteCoordV (MSG_MULTICAST, org); multicast (org, MULTICAST_PVS); } - remove(self); + remove (self); }; void(vector org, vector vec) LaunchLaser = @@ -340,7 +309,7 @@ void(vector org, vector vec) LaunchLaser = vec = normalize(vec); - newmis = spawn(); + newmis = spawn (); newmis.owner = self; newmis.movetype = MOVETYPE_FLY; newmis.solid = SOLID_BBOX; @@ -361,13 +330,10 @@ void(vector org, vector vec) LaunchLaser = void() spikeshooter_use = { - if (self.spawnflags & SPAWNFLAG_LASER) - { + if (self.spawnflags & SPAWNFLAG_LASER) { sound (self, CHAN_VOICE, "enforcer/enfire.wav", 1, ATTN_NORM); LaunchLaser (self.origin, self.movedir); - } - else - { + } else { sound (self, CHAN_VOICE, "weapons/spike2.wav", 1, ATTN_NORM); launch_spike (self.origin, self.movedir); newmis.velocity = self.movedir * 500; @@ -383,18 +349,15 @@ void() shooter_think = newmis.velocity = self.movedir * 500; }; - /*QUAKED trap_spikeshooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser When triggered, fires a spike in the direction set in QuakeEd. Laser is only for REGISTERED. */ - void() trap_spikeshooter = { SetMovedir (); self.use = spikeshooter_use; - if (self.spawnflags & SPAWNFLAG_LASER) - { + if (self.spawnflags & SPAWNFLAG_LASER) { precache_model2 ("progs/laser.mdl"); precache_sound2 ("enforcer/enfire.wav"); @@ -404,7 +367,6 @@ void() trap_spikeshooter = precache_sound ("weapons/spike2.wav"); }; - /*QUAKED trap_shooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser Continuously fires spikes. "wait" time between spike (1.0 default) @@ -420,16 +382,12 @@ void() trap_shooter = self.think = shooter_think; }; - - /* =============================================================================== - =============================================================================== */ - void() make_bubbles; void() bubble_remove; void() bubble_bob; @@ -438,7 +396,6 @@ void() bubble_bob; testing air bubbles */ - void() air_bubbles = { remove (self); @@ -446,7 +403,7 @@ void() air_bubbles = void() make_bubbles = { -local entity bubble; + local entity bubble; bubble = spawn(); setmodel (bubble, "progs/s_bubble.spr"); @@ -461,13 +418,14 @@ local entity bubble; bubble.frame = 0; bubble.cnt = 0; setsize (bubble, '-8 -8 -8', '8 8 8'); - self.nextthink = time + random() + 0.5; + self.nextthink = time + random () + 0.5; self.think = make_bubbles; }; void() bubble_split = { -local entity bubble; + local entity bubble; + bubble = spawn(); setmodel (bubble, "progs/s_bubble.spr"); setorigin (bubble, self.origin); @@ -489,27 +447,26 @@ local entity bubble; void() bubble_remove = { - if (other.classname == self.classname) - { -// dprint ("bump"); + if (other.classname == self.classname) { +// dprint ("bump"); return; } - remove(self); + remove (self); }; void() bubble_bob = { -local float rnd1, rnd2, rnd3; + local float rnd1, rnd2, rnd3; self.cnt = self.cnt + 1; if (self.cnt == 4) - bubble_split(); + bubble_split (); if (self.cnt == 20) remove(self); - rnd1 = self.velocity_x + (-10 + (random() * 20)); - rnd2 = self.velocity_y + (-10 + (random() * 20)); - rnd3 = self.velocity_z + 10 + random() * 10; + rnd1 = self.velocity_x - 10 + random () * 20; + rnd2 = self.velocity_y - 10 + random () * 20; + rnd3 = self.velocity_z + 10 + random () * 10; if (rnd1 > 10) rnd1 = 5; @@ -541,9 +498,7 @@ local float rnd1, rnd2, rnd3; Just for the debugging level. Don't use */ - void() viewthing = - { self.movetype = MOVETYPE_NONE; self.solid = SOLID_NOT; @@ -551,7 +506,6 @@ void() viewthing = setmodel (self, "progs/player.mdl"); }; - /* ============================================================================== @@ -577,12 +531,10 @@ void() func_wall = setmodel (self, self.model); }; - /*QUAKED func_illusionary (0 .5 .8) ? A simple entity that looks solid but lets you walk through it. */ void() func_illusionary = - { self.angles = '0 0 0'; self.movetype = MOVETYPE_NONE; @@ -595,7 +547,6 @@ void() func_illusionary = This bmodel will appear if the episode has allready been completed, so players can't reenter it. */ void() func_episodegate = - { if (!(serverflags & self.spawnflags)) return; // can still enter episode @@ -611,7 +562,6 @@ void() func_episodegate = This bmodel appears unless players have all of the episode sigils. */ void() func_bossgate = - { if ( (serverflags & 15) == 15) return; // all episodes completed @@ -646,6 +596,7 @@ void() ambient_flouro_buzz = precache_sound ("ambience/buzz1.wav"); ambientsound (self.origin, "ambience/buzz1.wav", 1, ATTN_STATIC); }; + /*QUAKED ambient_drip (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) */ void() ambient_drip = @@ -653,6 +604,7 @@ void() ambient_drip = precache_sound ("ambience/drip1.wav"); ambientsound (self.origin, "ambience/drip1.wav", 0.5, ATTN_STATIC); }; + /*QUAKED ambient_comp_hum (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) */ void() ambient_comp_hum = @@ -660,6 +612,7 @@ void() ambient_comp_hum = precache_sound ("ambience/comp1.wav"); ambientsound (self.origin, "ambience/comp1.wav", 1, ATTN_STATIC); }; + /*QUAKED ambient_thunder (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) */ void() ambient_thunder = @@ -667,6 +620,7 @@ void() ambient_thunder = precache_sound ("ambience/thunder1.wav"); ambientsound (self.origin, "ambience/thunder1.wav", 0.5, ATTN_STATIC); }; + /*QUAKED ambient_light_buzz (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) */ void() ambient_light_buzz = @@ -674,6 +628,7 @@ void() ambient_light_buzz = precache_sound ("ambience/fl_hum1.wav"); ambientsound (self.origin, "ambience/fl_hum1.wav", 0.5, ATTN_STATIC); }; + /*QUAKED ambient_swamp1 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) */ void() ambient_swamp1 = @@ -681,6 +636,7 @@ void() ambient_swamp1 = precache_sound ("ambience/swamp1.wav"); ambientsound (self.origin, "ambience/swamp1.wav", 0.5, ATTN_STATIC); }; + /*QUAKED ambient_swamp2 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) */ void() ambient_swamp2 = @@ -704,12 +660,9 @@ void() noise_think = }; /*QUAKED misc_noisemaker (1 0.5 0) (-10 -10 -10) (10 10 10) - -For optimzation testing, starts a lot of sounds. +For optimization testing, starts a lot of sounds. */ - void() misc_noisemaker = - { precache_sound2 ("enforcer/enfire.wav"); precache_sound2 ("enforcer/enfstop.wav"); @@ -722,6 +675,6 @@ void() misc_noisemaker = precache_sound2 ("enforcer/death1.wav"); precache_sound2 ("enforcer/idle1.wav"); - self.nextthink = time + 0.1 + random(); + self.nextthink = time + 0.1 + random (); self.think = noise_think; }; diff --git a/nqw/models.qc b/nqw/models.qc index 56f474d..d609a2c 100644 --- a/nqw/models.qc +++ b/nqw/models.qc @@ -1,4 +1,3 @@ - /* =============================================================================== @@ -582,4 +581,3 @@ $origin 0 0 24 $base base $skin skin $frame frame1 - diff --git a/nqw/monsters.qc b/nqw/monsters.qc index 6321e73..cc6b5dc 100644 --- a/nqw/monsters.qc +++ b/nqw/monsters.qc @@ -10,7 +10,6 @@ // // }; - /* ================ monster_use @@ -30,9 +29,8 @@ void() monster_use = return; if (activator.classname != "player") return; - -// delay reaction so if the monster is teleported, its sound is still -// heard + + // delay reaction so if the monster is teleported, its sound is still heard self.enemy = activator; self.nextthink = time + 0.1; self.think = FoundTarget; @@ -48,7 +46,7 @@ enemy as activator. */ void() monster_death_use = { -// fall to ground + // fall to ground if (self.flags & FL_FLY) self.flags = self.flags - FL_FLY; if (self.flags & FL_SWIM) @@ -61,7 +59,6 @@ void() monster_death_use = SUB_UseTargets (); }; - //============================================================================ void() walkmonster_start_go = @@ -69,8 +66,7 @@ void() walkmonster_start_go = self.origin_z = self.origin_z + 1; // raise off floor a bit droptofloor(); - if (!walkmove(0,0)) - { + if (!walkmove (0, 0)) { dprint ("walkmonster in wall at: "); dprint (vtos(self.origin)); dprint ("\n"); @@ -86,45 +82,39 @@ void() walkmonster_start_go = self.flags = self.flags | FL_MONSTER; - if (self.target) - { - self.goalentity = self.movetarget = find(world, targetname, self.target); - self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin); - if (!self.movetarget) - { + if (self.target) { + self.goalentity = self.movetarget = find (world, targetname, + self.target); + self.ideal_yaw = vectoyaw (self.goalentity.origin - self.origin); + if (!self.movetarget) { dprint ("Monster can't find target at "); dprint (vtos(self.origin)); dprint ("\n"); } -// this used to be an objerror + // this used to be an objerror if (self.movetarget.classname == "path_corner") self.th_walk (); else self.pausetime = 99999999; self.th_stand (); - } - else - { + } else { self.pausetime = 99999999; self.th_stand (); } -// spread think times so they don't all happen at same time - self.nextthink = self.nextthink + random()*0.5; + // spread think times so they don't all happen at same time + self.nextthink = self.nextthink + random () * 0.5; }; - void() walkmonster_start = { -// delay drop to floor to make sure all doors have been spawned -// spread think times so they don't all happen at same time - self.nextthink = self.nextthink + random()*0.5; + // delay drop to floor to make sure all doors have been spawned + // spread think times so they don't all happen at same time + self.nextthink = self.nextthink + random () * 0.5; self.think = walkmonster_start_go; total_monsters = total_monsters + 1; }; - - void() flymonster_start_go = { self.takedamage = DAMAGE_AIM; @@ -138,31 +128,27 @@ void() flymonster_start_go = self.flags = self.flags | FL_FLY; self.flags = self.flags | FL_MONSTER; - if (!walkmove(0,0)) - { + if (!walkmove (0, 0)) { dprint ("flymonster in wall at: "); dprint (vtos(self.origin)); dprint ("\n"); } - if (self.target) - { - self.goalentity = self.movetarget = find(world, targetname, self.target); - if (!self.movetarget) - { + if (self.target) { + self.goalentity = self.movetarget = find (world, targetname, + self.target); + if (!self.movetarget) { dprint ("Monster can't find target at "); dprint (vtos(self.origin)); dprint ("\n"); } -// this used to be an objerror + // this used to be an objerror if (self.movetarget.classname == "path_corner") self.th_walk (); else self.pausetime = 99999999; self.th_stand (); - } - else - { + } else { self.pausetime = 99999999; self.th_stand (); } @@ -170,18 +156,16 @@ void() flymonster_start_go = void() flymonster_start = { -// spread think times so they don't all happen at same time - self.nextthink = self.nextthink + random()*0.5; + // spread think times so they don't all happen at same time + self.nextthink = self.nextthink + 0.5 * random (); self.think = flymonster_start_go; total_monsters = total_monsters + 1; }; - void() swimmonster_start_go = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } @@ -197,35 +181,30 @@ void() swimmonster_start_go = self.flags = self.flags | FL_SWIM; self.flags = self.flags | FL_MONSTER; - if (self.target) - { - self.goalentity = self.movetarget = find(world, targetname, self.target); - if (!self.movetarget) - { + if (self.target) { + self.goalentity = self.movetarget = find (world, targetname, + self.target); + if (!self.movetarget) { dprint ("Monster can't find target at "); dprint (vtos(self.origin)); dprint ("\n"); } -// this used to be an objerror - self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin); + // this used to be an objerror + self.ideal_yaw = vectoyaw (self.goalentity.origin - self.origin); self.th_walk (); - } - else - { + } else { self.pausetime = 99999999; self.th_stand (); } -// spread think times so they don't all happen at same time - self.nextthink = self.nextthink + random()*0.5; + // spread think times so they don't all happen at same time + self.nextthink = self.nextthink + random () * 0.5; }; void() swimmonster_start = { -// spread think times so they don't all happen at same time - self.nextthink = self.nextthink + random()*0.5; + // spread think times so they don't all happen at same time + self.nextthink = self.nextthink + random () * 0.5; self.think = swimmonster_start_go; total_monsters = total_monsters + 1; }; - - diff --git a/nqw/ogre.qc b/nqw/ogre.qc index 18bfac4..6f08c31 100644 --- a/nqw/ogre.qc +++ b/nqw/ogre.qc @@ -49,17 +49,13 @@ $frame pull1 pull2 pull3 pull4 pull5 pull6 pull7 pull8 pull9 pull10 pull11 //============================================================================= - void() OgreGrenadeExplode = { T_RadiusDamage (self, self.owner, 40, world, "ogre"); sound (self, CHAN_VOICE, "weapons/r_exp3.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); + WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_EXPLOSION); + WriteCoordV (MSG_BROADCAST, self.origin); multicast (self.origin, MULTICAST_PHS); remove (self); @@ -69,12 +65,11 @@ void() OgreGrenadeTouch = { if (other == self.owner) return; // don't explode on owner - if (other.takedamage == DAMAGE_AIM) - { + if (other.takedamage == DAMAGE_AIM) { OgreGrenadeExplode(); return; } - sound (self, CHAN_VOICE, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound + sound (self, CHAN_VOICE, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound if (self.velocity == '0 0 0') self.avelocity = '0 0 0'; }; @@ -87,7 +82,7 @@ OgreFireGrenade void() OgreFireGrenade = { local entity missile; - + muzzleflash(); sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM); @@ -96,25 +91,19 @@ void() OgreFireGrenade = missile.owner = self; missile.movetype = MOVETYPE_BOUNCE; missile.solid = SOLID_BBOX; - -// set missile speed + // set missile speed makevectors (self.angles); - missile.velocity = normalize(self.enemy.origin - self.origin); missile.velocity = missile.velocity * 600; missile.velocity_z = 200; - missile.avelocity = '300 300 300'; - missile.angles = vectoangles(missile.velocity); - missile.touch = OgreGrenadeTouch; - -// set missile duration + + // set missile duration missile.nextthink = time + 2.5; missile.think = OgreGrenadeExplode; - setmodel (missile, "progs/grenade.mdl"); setsize (missile, '0 0 0', '0 0 0'); setorigin (missile, self.origin); @@ -132,44 +121,43 @@ FIXME */ void(float side) chainsaw = { -local vector delta; -local float ldmg; + local vector delta; + local float ldmg; if (!self.enemy) return; if (!CanDamage (self.enemy, self)) return; - ai_charge(10); + ai_charge (10); delta = self.enemy.origin - self.origin; if (vlen(delta) > 100) return; - - ldmg = (random() + random() + random()) * 4; + + ldmg = 4 * (random () + random () + random ()); self.enemy.deathtype = "ogre"; T_Damage (self.enemy, self, self, ldmg); - if (side) - { + if (side) { makevectors (self.angles); if (side == 1) - SpawnMeatSpray (self.origin + v_forward*16, crandom() * 100 * v_right); + SpawnMeatSpray (self.origin + v_forward * 16, + v_right * 200 * (random () - 0.5)); else - SpawnMeatSpray (self.origin + v_forward*16, side * v_right); + SpawnMeatSpray (self.origin + v_forward * 16, side * v_right); } }; - void() ogre_stand1 =[ $stand1, ogre_stand2 ] {ai_stand();}; void() ogre_stand2 =[ $stand2, ogre_stand3 ] {ai_stand();}; void() ogre_stand3 =[ $stand3, ogre_stand4 ] {ai_stand();}; void() ogre_stand4 =[ $stand4, ogre_stand5 ] {ai_stand();}; void() ogre_stand5 =[ $stand5, ogre_stand6 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "ogre/ogidle.wav", 1, ATTN_IDLE); -ai_stand(); + if (random () < 0.2) + sound (self, CHAN_VOICE, "ogre/ogidle.wav", 1, ATTN_IDLE); + ai_stand (); }; void() ogre_stand6 =[ $stand6, ogre_stand7 ] {ai_stand();}; void() ogre_stand7 =[ $stand7, ogre_stand8 ] {ai_stand();}; @@ -179,16 +167,16 @@ void() ogre_stand9 =[ $stand9, ogre_stand1 ] {ai_stand();}; void() ogre_walk1 =[ $walk1, ogre_walk2 ] {ai_walk(3);}; void() ogre_walk2 =[ $walk2, ogre_walk3 ] {ai_walk(2);}; void() ogre_walk3 =[ $walk3, ogre_walk4 ] { -ai_walk(2); -if (random() < 0.2) - sound (self, CHAN_VOICE, "ogre/ogidle.wav", 1, ATTN_IDLE); + ai_walk (2); + if (random () < 0.2) + sound (self, CHAN_VOICE, "ogre/ogidle.wav", 1, ATTN_IDLE); }; void() ogre_walk4 =[ $walk4, ogre_walk5 ] {ai_walk(2);}; void() ogre_walk5 =[ $walk5, ogre_walk6 ] {ai_walk(2);}; void() ogre_walk6 =[ $walk6, ogre_walk7 ] { -ai_walk(5); -if (random() < 0.1) - sound (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE); + ai_walk (5); + if (random () < 0.1) + sound (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE); }; void() ogre_walk7 =[ $walk7, ogre_walk8 ] {ai_walk(3);}; void() ogre_walk8 =[ $walk8, ogre_walk9 ] {ai_walk(2);}; @@ -201,9 +189,10 @@ void() ogre_walk14 =[ $walk14, ogre_walk15 ] {ai_walk(3);}; void() ogre_walk15 =[ $walk15, ogre_walk16 ] {ai_walk(3);}; void() ogre_walk16 =[ $walk16, ogre_walk1 ] {ai_walk(4);}; -void() ogre_run1 =[ $run1, ogre_run2 ] {ai_run(9); -if (random() < 0.2) - sound (self, CHAN_VOICE, "ogre/ogidle2.wav", 1, ATTN_IDLE); +void() ogre_run1 =[ $run1, ogre_run2 ] { + ai_run (9); + if (random () < 0.2) + sound (self, CHAN_VOICE, "ogre/ogidle2.wav", 1, ATTN_IDLE); }; void() ogre_run2 =[ $run2, ogre_run3 ] {ai_run(12);}; void() ogre_run3 =[ $run3, ogre_run4 ] {ai_run(8);}; @@ -213,37 +202,75 @@ void() ogre_run6 =[ $run6, ogre_run7 ] {ai_run(4);}; void() ogre_run7 =[ $run7, ogre_run8 ] {ai_run(13);}; void() ogre_run8 =[ $run8, ogre_run1 ] {ai_run(24);}; -void() ogre_swing1 =[ $swing1, ogre_swing2 ] {ai_charge(11); -sound (self, CHAN_WEAPON, "ogre/ogsawatk.wav", 1, ATTN_NORM); +void() ogre_swing1 =[ $swing1, ogre_swing2 ] { + ai_charge (11); + sound (self, CHAN_WEAPON, "ogre/ogsawatk.wav", 1, ATTN_NORM); }; void() ogre_swing2 =[ $swing2, ogre_swing3 ] {ai_charge(1);}; void() ogre_swing3 =[ $swing3, ogre_swing4 ] {ai_charge(4);}; void() ogre_swing4 =[ $swing4, ogre_swing5 ] {ai_charge(13);}; -void() ogre_swing5 =[ $swing5, ogre_swing6 ] {ai_charge(9); chainsaw(0);self.angles_y = self.angles_y + random()*25;}; -void() ogre_swing6 =[ $swing6, ogre_swing7 ] {chainsaw(200);self.angles_y = self.angles_y + random()* 25;}; -void() ogre_swing7 =[ $swing7, ogre_swing8 ] {chainsaw(0);self.angles_y = self.angles_y + random()* 25;}; -void() ogre_swing8 =[ $swing8, ogre_swing9 ] {chainsaw(0);self.angles_y = self.angles_y + random()* 25;}; -void() ogre_swing9 =[ $swing9, ogre_swing10 ] {chainsaw(0);self.angles_y = self.angles_y + random()* 25;}; -void() ogre_swing10 =[ $swing10, ogre_swing11 ] {chainsaw(-200);self.angles_y = self.angles_y + random()* 25;}; -void() ogre_swing11 =[ $swing11, ogre_swing12 ] {chainsaw(0);self.angles_y = self.angles_y + random()* 25;}; +void() ogre_swing5 =[ $swing5, ogre_swing6 ] { + ai_charge (9); + chainsaw (0); + self.angles_y = self.angles_y + random () * 25; +}; +void() ogre_swing6 =[ $swing6, ogre_swing7 ] { + chainsaw (200); + self.angles_y = self.angles_y + random () * 25; +}; +void() ogre_swing7 =[ $swing7, ogre_swing8 ] { + chainsaw (0); + self.angles_y = self.angles_y + random () * 25; +}; +void() ogre_swing8 =[ $swing8, ogre_swing9 ] { + chainsaw (0); + self.angles_y = self.angles_y + random () * 25;}; +void() ogre_swing9 =[ $swing9, ogre_swing10 ] { + chainsaw (0); + self.angles_y = self.angles_y + random () * 25; +}; +void() ogre_swing10 =[ $swing10, ogre_swing11 ] { + chainsaw (-200); + self.angles_y = self.angles_y + random () * 25; +}; +void() ogre_swing11 =[ $swing11, ogre_swing12 ] { + chainsaw (0); + self.angles_y = self.angles_y + random () * 25; +}; void() ogre_swing12 =[ $swing12, ogre_swing13 ] {ai_charge(3);}; void() ogre_swing13 =[ $swing13, ogre_swing14 ] {ai_charge(8);}; void() ogre_swing14 =[ $swing14, ogre_run1 ] {ai_charge(9);}; -void() ogre_smash1 =[ $smash1, ogre_smash2 ] {ai_charge(6); -sound (self, CHAN_WEAPON, "ogre/ogsawatk.wav", 1, ATTN_NORM); +void() ogre_smash1 =[ $smash1, ogre_smash2 ] { + ai_charge (6); + sound (self, CHAN_WEAPON, "ogre/ogsawatk.wav", 1, ATTN_NORM); }; void() ogre_smash2 =[ $smash2, ogre_smash3 ] {ai_charge(0);}; void() ogre_smash3 =[ $smash3, ogre_smash4 ] {ai_charge(0);}; void() ogre_smash4 =[ $smash4, ogre_smash5 ] {ai_charge(1);}; void() ogre_smash5 =[ $smash5, ogre_smash6 ] {ai_charge(4);}; -void() ogre_smash6 =[ $smash6, ogre_smash7 ] {ai_charge(4); chainsaw(0);}; -void() ogre_smash7 =[ $smash7, ogre_smash8 ] {ai_charge(4); chainsaw(0);}; -void() ogre_smash8 =[ $smash8, ogre_smash9 ] {ai_charge(10); chainsaw(0);}; -void() ogre_smash9 =[ $smash9, ogre_smash10 ] {ai_charge(13); chainsaw(0);}; +void() ogre_smash6 =[ $smash6, ogre_smash7 ] { + ai_charge (4); + chainsaw (0); +}; +void() ogre_smash7 =[ $smash7, ogre_smash8 ] { + ai_charge (4); + chainsaw (0); +}; +void() ogre_smash8 =[ $smash8, ogre_smash9 ] { + ai_charge (10); + chainsaw (0); +}; +void() ogre_smash9 =[ $smash9, ogre_smash10 ] { + ai_charge (13); + chainsaw (0); +}; void() ogre_smash10 =[ $smash10, ogre_smash11 ] {chainsaw(1);}; -void() ogre_smash11 =[ $smash11, ogre_smash12 ] {ai_charge(2); chainsaw(0); -self.nextthink = self.nextthink + random()*0.2;}; // slight variation +void() ogre_smash11 =[ $smash11, ogre_smash12 ] { + ai_charge (2); + chainsaw (0); + self.nextthink = self.nextthink + random () * 0.2; // slight variation +}; void() ogre_smash12 =[ $smash12, ogre_smash13 ] {ai_charge(0);}; void() ogre_smash13 =[ $smash13, ogre_smash14 ] {ai_charge(4);}; void() ogre_smash14 =[ $smash14, ogre_run1 ] {ai_charge(12);}; @@ -251,7 +278,10 @@ void() ogre_smash14 =[ $smash14, ogre_run1 ] {ai_charge(12);}; void() ogre_nail1 =[ $shoot1, ogre_nail2 ] {ai_face();}; void() ogre_nail2 =[ $shoot2, ogre_nail3 ] {ai_face();}; void() ogre_nail3 =[ $shoot2, ogre_nail4 ] {ai_face();}; -void() ogre_nail4 =[ $shoot3, ogre_nail5 ] {ai_face();OgreFireGrenade();}; +void() ogre_nail4 =[ $shoot3, ogre_nail5 ] { + ai_face (); + OgreFireGrenade(); +}; void() ogre_nail5 =[ $shoot4, ogre_nail6 ] {ai_face();}; void() ogre_nail6 =[ $shoot5, ogre_nail7 ] {ai_face();}; void() ogre_nail7 =[ $shoot6, ogre_run1 ] {ai_face();}; @@ -262,12 +292,10 @@ void() ogre_pain3 =[ $pain3, ogre_pain4 ] {}; void() ogre_pain4 =[ $pain4, ogre_pain5 ] {}; void() ogre_pain5 =[ $pain5, ogre_run1 ] {}; - void() ogre_painb1 =[ $painb1, ogre_painb2 ] {}; void() ogre_painb2 =[ $painb2, ogre_painb3 ] {}; void() ogre_painb3 =[ $painb3, ogre_run1 ] {}; - void() ogre_painc1 =[ $painc1, ogre_painc2 ] {}; void() ogre_painc2 =[ $painc2, ogre_painc3 ] {}; void() ogre_painc3 =[ $painc3, ogre_painc4 ] {}; @@ -275,7 +303,6 @@ void() ogre_painc4 =[ $painc4, ogre_painc5 ] {}; void() ogre_painc5 =[ $painc5, ogre_painc6 ] {}; void() ogre_painc6 =[ $painc6, ogre_run1 ] {}; - void() ogre_paind1 =[ $paind1, ogre_paind2 ] {}; void() ogre_paind2 =[ $paind2, ogre_paind3 ] {ai_pain(10);}; void() ogre_paind3 =[ $paind3, ogre_paind4 ] {ai_pain(9);}; @@ -309,41 +336,31 @@ void() ogre_paine13=[ $paine13, ogre_paine14 ] {}; void() ogre_paine14=[ $paine14, ogre_paine15 ] {}; void() ogre_paine15=[ $paine15, ogre_run1 ] {}; - void(entity attacker, float damage) ogre_pain = { local float r; -// don't make multiple pain sounds right after each other + // don't make multiple pain sounds right after each other if (self.pain_finished > time) return; sound (self, CHAN_VOICE, "ogre/ogpain1.wav", 1, ATTN_NORM); - r = random(); + r = random (); - if (r < 0.25) - { + if (r < 0.25) { ogre_pain1 (); self.pain_finished = time + 1; - } - else if (r < 0.5) - { + } else if (r < 0.5) { ogre_painb1 (); self.pain_finished = time + 1; - } - else if (r < 0.75) - { + } else if (r < 0.75) { ogre_painc1 (); self.pain_finished = time + 1; - } - else if (r < 0.88) - { + } else if (r < 0.88) { ogre_paind1 (); self.pain_finished = time + 2; - } - else - { + } else { ogre_paine1 (); self.pain_finished = time + 2; } @@ -351,9 +368,11 @@ void(entity attacker, float damage) ogre_pain = void() ogre_die1 =[ $death1, ogre_die2 ] {}; void() ogre_die2 =[ $death2, ogre_die3 ] {}; -void() ogre_die3 =[ $death3, ogre_die4 ] -{self.solid = SOLID_NOT; -self.ammo_rockets = 2;DropBackpack();}; +void() ogre_die3 =[ $death3, ogre_die4 ] { + self.solid = SOLID_NOT; + self.ammo_rockets = 2; + DropBackpack (); +}; void() ogre_die4 =[ $death4, ogre_die5 ] {}; void() ogre_die5 =[ $death5, ogre_die6 ] {}; void() ogre_die6 =[ $death6, ogre_die7 ] {}; @@ -368,9 +387,11 @@ void() ogre_die14 =[ $death14, ogre_die14 ] {}; void() ogre_bdie1 =[ $bdeath1, ogre_bdie2 ] {}; void() ogre_bdie2 =[ $bdeath2, ogre_bdie3 ] {ai_forward(5);}; -void() ogre_bdie3 =[ $bdeath3, ogre_bdie4 ] -{self.solid = SOLID_NOT; -self.ammo_rockets = 2;DropBackpack();}; +void() ogre_bdie3 =[ $bdeath3, ogre_bdie4 ] { + self.solid = SOLID_NOT; + self.ammo_rockets = 2; + DropBackpack (); +}; void() ogre_bdie4 =[ $bdeath4, ogre_bdie5 ] {ai_forward(1);}; void() ogre_bdie5 =[ $bdeath5, ogre_bdie6 ] {ai_forward(3);}; void() ogre_bdie6 =[ $bdeath6, ogre_bdie7 ] {ai_forward(7);}; @@ -381,9 +402,8 @@ void() ogre_bdie10 =[ $bdeath10, ogre_bdie10 ] {}; void() ogre_die = { -// check for gib - if (self.health < -80) - { + // check for gib + if (self.health < -80) { sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); ThrowHead ("progs/h_ogre.mdl", self.health); ThrowGib ("progs/gib3.mdl", self.health); @@ -394,7 +414,7 @@ void() ogre_die = sound (self, CHAN_VOICE, "ogre/ogdth.wav", 1, ATTN_NORM); - if (random() < 0.5) + if (random () < 0.5) ogre_die1 (); else ogre_bdie1 (); @@ -402,23 +422,21 @@ void() ogre_die = void() ogre_melee = { - if (random() > 0.5) + if (random () > 0.5) ogre_smash1 (); else ogre_swing1 (); }; - /*QUAKED monster_ogre (1 0 0) (-32 -32 -24) (32 32 64) Ambush - */ void() monster_ogre = { - if (deathmatch) - { + if (deathmatch) { remove(self); return; } + precache_model ("progs/ogre.mdl"); precache_model ("progs/h_ogre.mdl"); precache_model ("progs/grenade.mdl"); @@ -447,12 +465,10 @@ void() monster_ogre = self.th_missile = ogre_nail1; self.th_pain = ogre_pain; - walkmonster_start(); + walkmonster_start (); }; void() monster_ogre_marksman = { monster_ogre (); }; - - diff --git a/nqw/oldone.qc b/nqw/oldone.qc index d868067..061497c 100644 --- a/nqw/oldone.qc +++ b/nqw/oldone.qc @@ -16,7 +16,6 @@ void() finale_2; void() finale_3; void() finale_4; - entity shub; $frame old1 old2 old3 old4 old5 old6 old7 old8 old9 @@ -78,7 +77,6 @@ void() old_idle44 =[ $old44, old_idle45 ] {}; void() old_idle45 =[ $old45, old_idle46 ] {}; void() old_idle46 =[ $old46, old_idle1 ] {}; - void() old_thrash1 =[ $shake1, old_thrash2 ] {lightstyle(0, "m");}; void() old_thrash2 =[ $shake2, old_thrash3 ] {lightstyle(0, "k");}; void() old_thrash3 =[ $shake3, old_thrash4 ] {lightstyle(0, "k");}; @@ -93,10 +91,11 @@ void() old_thrash11 =[ $shake11, old_thrash12 ] {lightstyle(0, " void() old_thrash12 =[ $shake12, old_thrash13 ] {lightstyle(0, "i");}; void() old_thrash13 =[ $shake13, old_thrash14 ] {lightstyle(0, "k");}; void() old_thrash14 =[ $shake14, old_thrash15 ] {lightstyle(0, "m");}; -void() old_thrash15 =[ $shake15, old_thrash16 ] {lightstyle(0, "m"); -self.cnt = self.cnt + 1; -if (self.cnt != 3) - self.think = old_thrash1; +void() old_thrash15 =[ $shake15, old_thrash16 ] { + lightstyle (0, "m"); + self.cnt = self.cnt + 1; + if (self.cnt != 3) + self.think = old_thrash1; }; void() old_thrash16 =[ $shake16, old_thrash17 ] {lightstyle(0, "g");}; void() old_thrash17 =[ $shake17, old_thrash18 ] {lightstyle(0, "c");}; @@ -127,8 +126,7 @@ void() finale_1 = WriteString (MSG_ALL, ""); pl = find (world, classname, "player"); - while (pl != world) - { + while (pl != world) { pl.view_ofs = '0 0 0'; pl.angles = other.v_angle = pos.mangle; pl.fixangle = TRUE; // turn this way immediately @@ -158,11 +156,8 @@ void() finale_2 = // start a teleport splash inside shub o = shub.origin - '0 100 0'; - WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); - WriteByte (MSG_BROADCAST, TE_TELEPORT); - WriteCoord (MSG_BROADCAST, o_x); - WriteCoord (MSG_BROADCAST, o_y); - WriteCoord (MSG_BROADCAST, o_z); + WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_TELEPORT); + WriteCoordV (MSG_BROADCAST, o); sound (shub, CHAN_VOICE, "misc/r_tele1.wav", 1, ATTN_NORM); @@ -191,19 +186,16 @@ void() finale_4 = oldo = self.origin; z = 16; - while (z <= 144) - { + while (z <= 144) { x = -64; - while (x <= 64) - { + while (x <= 64) { y = -64; - while (y <= 64) - { + while (y <= 64) { self.origin_x = oldo_x + x; self.origin_y = oldo_y + y; self.origin_z = oldo_z + z; - r = random(); + r = random (); if (r < 0.3) ThrowGib ("progs/gib1.mdl", -999); else if (r < 0.6) @@ -220,7 +212,7 @@ void() finale_4 = WriteByte (MSG_ALL, SVC_FINALE); WriteString (MSG_ALL, "Congratulations and well done! You have\nbeaten the hideous Shub-Niggurath, and\nher hundreds of ugly changelings and\nmonsters. You have proven that your\nskill and your cunning are greater than\nall the powers of Quake. You are the\nmaster now. Id Software salutes you."); -// put a player model down + // put a player model down n = spawn(); setmodel (n, "progs/player.mdl"); oldo = oldo - '32 264 0'; @@ -230,10 +222,8 @@ void() finale_4 = remove (self); -// switch cd track - WriteByte (MSG_ALL, SVC_CDTRACK); - WriteByte (MSG_ALL, 3); -// WriteByte (MSG_ALL, 3); + // switch cd track + WriteBytes (MSG_ALL, SVC_CDTRACK, 3.0); lightstyle(0, "m"); }; @@ -246,13 +236,11 @@ void (entity attacker, float damage) nopain = //============================================================================ - /*QUAKED monster_oldone (1 0 0) (-16 -16 -24) (16 16 32) */ void() monster_oldone = { - if (deathmatch) - { + if (deathmatch) { remove(self); return; } @@ -280,4 +268,3 @@ void() monster_oldone = total_monsters = total_monsters + 1; }; - diff --git a/nqw/plats.qc b/nqw/plats.qc index df7171b..a7fb90a 100644 --- a/nqw/plats.qc +++ b/nqw/plats.qc @@ -1,5 +1,3 @@ - - void() plat_center_touch; void() plat_outside_touch; void() plat_trigger_use; @@ -13,9 +11,7 @@ void() plat_spawn_inside_trigger = local entity trigger; local vector tmin, tmax; -// -// middle trigger -// + // middle trigger trigger = spawn(); trigger.touch = plat_center_touch; trigger.movetype = MOVETYPE_NONE; @@ -28,13 +24,11 @@ void() plat_spawn_inside_trigger = if (self.spawnflags & PLAT_LOW_TRIGGER) tmax_z = tmin_z + 8; - if (self.size_x <= 50) - { + if (self.size_x <= 50) { tmin_x = (self.mins_x + self.maxs_x) / 2; tmax_x = tmin_x + 1; } - if (self.size_y <= 50) - { + if (self.size_y <= 50) { tmin_y = (self.mins_y + self.maxs_y) / 2; tmax_y = tmin_y + 1; } @@ -93,7 +87,7 @@ void() plat_outside_touch = if (other.health <= 0) return; -//dprint ("plat_outside_touch\n"); +// dprint ("plat_outside_touch\n"); self = self.enemy; if (self.state == STATE_TOP) plat_go_down (); @@ -109,7 +103,7 @@ void() plat_trigger_use = void() plat_crush = { -//dprint ("plat_crush\n"); +// dprint ("plat_crush\n"); other.deathtype = "squish"; T_Damage (other, self, self, 1); @@ -143,10 +137,7 @@ Set "sounds" to one of the following: 1) base fast 2) chain slow */ - - void() func_plat = - { if (!self.t_length) self.t_length = 80; @@ -155,25 +146,22 @@ void() func_plat = if (self.sounds == 0) self.sounds = 2; -// FIX THIS TO LOAD A GENERIC PLAT SOUND - if (self.sounds == 1) - { + // FIX THIS TO LOAD A GENERIC PLAT SOUND + if (self.sounds == 1) { precache_sound ("plats/plat1.wav"); precache_sound ("plats/plat2.wav"); self.noise = "plats/plat1.wav"; self.noise1 = "plats/plat2.wav"; } - if (self.sounds == 2) - { + if (self.sounds == 2) { precache_sound ("plats/medplat1.wav"); precache_sound ("plats/medplat2.wav"); self.noise = "plats/medplat1.wav"; self.noise1 = "plats/medplat2.wav"; } - self.mangle = self.angles; self.angles = '0 0 0'; @@ -188,7 +176,7 @@ void() func_plat = if (!self.speed) self.speed = 150; -// pos1 is the top position, pos2 is the bottom + // pos1 is the top position, pos2 is the bottom self.pos1 = self.origin; self.pos2 = self.origin; if (self.height) @@ -200,13 +188,10 @@ void() func_plat = plat_spawn_inside_trigger (); // the "start moving" trigger - if (self.targetname) - { + if (self.targetname) { self.state = STATE_UP; self.use = plat_use; - } - else - { + } else { setorigin (self, self.pos2); self.state = STATE_BOTTOM; } @@ -230,17 +215,15 @@ void() train_use = { if (self.think != func_train_find) return; // already activated - train_next(); + train_next (); }; void() train_wait = { - if (self.wait) - { + if (self.wait) { self.nextthink = self.ltime + self.wait; sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self.noise, 1, ATTN_NORM); - } - else + } else self.nextthink = self.ltime + 0.1; self.think = train_next; @@ -263,15 +246,13 @@ void() train_next = }; void() func_train_find = - { local entity targ; targ = find (world, targetname, self.target); self.target = targ.target; setorigin (self, targ.origin - self.mins); - if (!self.targetname) - { // not triggered, so start immediately + if (!self.targetname) { // not triggered, so start immediately self.nextthink = self.ltime + 0.1; self.think = train_next; } @@ -297,16 +278,14 @@ void() func_train = if (!self.dmg) self.dmg = 2; - if (self.sounds == 0) - { + if (self.sounds == 0) { self.noise = ("misc/null.wav"); precache_sound ("misc/null.wav"); self.noise1 = ("misc/null.wav"); precache_sound ("misc/null.wav"); } - if (self.sounds == 1) - { + if (self.sounds == 1) { self.noise = ("plats/train2.wav"); precache_sound ("plats/train2.wav"); self.noise1 = ("plats/train1.wav"); @@ -324,8 +303,8 @@ void() func_train = setsize (self, self.mins , self.maxs); setorigin (self, self.origin); -// start trains on the second frame, to make sure their targets have had -// a chance to spawn + // start trains on the second frame, to make sure their targets have had + // a chance to spawn self.nextthink = self.ltime + 0.1; self.think = func_train_find; }; @@ -357,9 +336,8 @@ void() misc_teleporttrain = setsize (self, self.mins , self.maxs); setorigin (self, self.origin); -// start trains on the second frame, to make sure their targets have had -// a chance to spawn + // start trains on the second frame, to make sure their targets have had + // a chance to spawn self.nextthink = self.ltime + 0.1; self.think = func_train_find; }; - diff --git a/nqw/player.qc b/nqw/player.qc index 4c04721..287a9ca 100644 --- a/nqw/player.qc +++ b/nqw/player.qc @@ -1,4 +1,3 @@ - void() bubble_bob; /* @@ -14,34 +13,23 @@ $origin 0 -6 24 $base base $skin skin -// // running -// $frame axrun1 axrun2 axrun3 axrun4 axrun5 axrun6 $frame rockrun1 rockrun2 rockrun3 rockrun4 rockrun5 rockrun6 -// // standing -// $frame stand1 stand2 stand3 stand4 stand5 $frame axstnd1 axstnd2 axstnd3 axstnd4 axstnd5 axstnd6 $frame axstnd7 axstnd8 axstnd9 axstnd10 axstnd11 axstnd12 - -// // pain -// $frame axpain1 axpain2 axpain3 axpain4 axpain5 axpain6 $frame pain1 pain2 pain3 pain4 pain5 pain6 - -// // death -// - $frame axdeth1 axdeth2 axdeth3 axdeth4 axdeth5 axdeth6 $frame axdeth7 axdeth8 axdeth9 @@ -60,9 +48,7 @@ $frame deathd8 deathd9 $frame deathe1 deathe2 deathe3 deathe4 deathe5 deathe6 deathe7 $frame deathe8 deathe9 -// // attacks -// $frame nailatt1 nailatt2 $frame light1 light2 @@ -79,7 +65,6 @@ $frame axattc1 axattc2 axattc3 axattc4 axattc5 axattc6 $frame axattd1 axattd2 axattd3 axattd4 axattd5 axattd6 - /* ============================================================================== PLAYER @@ -91,21 +76,17 @@ void() player_run; void() player_stand1 =[ $axstnd1, player_stand1 ] { self.weaponframe=0; - if (self.velocity_x || self.velocity_y) - { + if (self.velocity_x || self.velocity_y) { self.walkframe=0; player_run(); return; } - if (self.weapon == IT_AXE) - { + if (self.weapon == IT_AXE) { if (self.walkframe >= 12) self.walkframe = 0; self.frame = $axstnd1 + self.walkframe; - } - else - { + } else { if (self.walkframe >= 5) self.walkframe = 0; self.frame = $stand1 + self.walkframe; @@ -116,21 +97,17 @@ void() player_stand1 =[ $axstnd1, player_stand1 ] void() player_run =[ $rockrun1, player_run ] { self.weaponframe=0; - if (!self.velocity_x && !self.velocity_y) - { + if (!self.velocity_x && !self.velocity_y) { self.walkframe=0; player_stand1(); return; } - if (self.weapon == IT_AXE) - { + if (self.weapon == IT_AXE) { if (self.walkframe == 6) self.walkframe = 0; self.frame = $axrun1 + self.walkframe; - } - else - { + } else { if (self.walkframe == 6) self.walkframe = 0; self.frame = self.frame + self.walkframe; @@ -146,7 +123,10 @@ void()muzzleflash = }; -void() player_shot1 = [$shotatt1, player_shot2 ] {self.weaponframe=1;muzzleflash();}; +void() player_shot1 = [$shotatt1, player_shot2 ] { + self.weaponframe = 1; + muzzleflash (); +}; void() player_shot2 = [$shotatt2, player_shot3 ] {self.weaponframe=2;}; void() player_shot3 = [$shotatt3, player_shot4 ] {self.weaponframe=3;}; void() player_shot4 = [$shotatt4, player_shot5 ] {self.weaponframe=4;}; @@ -155,25 +135,36 @@ void() player_shot6 = [$shotatt6, player_run ] {self.weaponframe=6;}; void() player_axe1 = [$axatt1, player_axe2 ] {self.weaponframe=1;}; void() player_axe2 = [$axatt2, player_axe3 ] {self.weaponframe=2;}; -void() player_axe3 = [$axatt3, player_axe4 ] {self.weaponframe=3;W_FireAxe();}; +void() player_axe3 = [$axatt3, player_axe4 ] { + self.weaponframe = 3; + W_FireAxe (); +}; void() player_axe4 = [$axatt4, player_run ] {self.weaponframe=4;}; void() player_axeb1 = [$axattb1, player_axeb2 ] {self.weaponframe=5;}; void() player_axeb2 = [$axattb2, player_axeb3 ] {self.weaponframe=6;}; -void() player_axeb3 = [$axattb3, player_axeb4 ] {self.weaponframe=7;W_FireAxe();}; +void() player_axeb3 = [$axattb3, player_axeb4 ] { + self.weaponframe = 7; + W_FireAxe (); +}; void() player_axeb4 = [$axattb4, player_run ] {self.weaponframe=8;}; void() player_axec1 = [$axattc1, player_axec2 ] {self.weaponframe=1;}; void() player_axec2 = [$axattc2, player_axec3 ] {self.weaponframe=2;}; -void() player_axec3 = [$axattc3, player_axec4 ] {self.weaponframe=3;W_FireAxe();}; +void() player_axec3 = [$axattc3, player_axec4 ] { + self.weaponframe = 3; + W_FireAxe (); +}; void() player_axec4 = [$axattc4, player_run ] {self.weaponframe=4;}; void() player_axed1 = [$axattd1, player_axed2 ] {self.weaponframe=5;}; void() player_axed2 = [$axattd2, player_axed3 ] {self.weaponframe=6;}; -void() player_axed3 = [$axattd3, player_axed4 ] {self.weaponframe=7;W_FireAxe();}; +void() player_axed3 = [$axattd3, player_axed4 ] { + self.weaponframe = 7; + W_FireAxe (); +}; void() player_axed4 = [$axattd4, player_run ] {self.weaponframe=8;}; - //============================================================================ void() player_nail1 =[$nailatt1, player_nail2 ] @@ -189,6 +180,7 @@ void() player_nail1 =[$nailatt1, player_nail2 ] W_FireSpikes (4); self.attack_finished = time + 0.2; }; + void() player_nail2 =[$nailatt2, player_nail1 ] { muzzleflash(); @@ -218,6 +210,7 @@ void() player_light1 =[$light1, player_light2 ] W_FireLightning(); self.attack_finished = time + 0.2; }; + void() player_light2 =[$light2, player_light1 ] { muzzleflash(); @@ -234,7 +227,6 @@ void() player_light2 =[$light2, player_light1 ] //============================================================================ - void() player_rocket1 =[$rockatt1, player_rocket2 ] {self.weaponframe=1; muzzleflash();}; void() player_rocket2 =[$rockatt2, player_rocket3 ] {self.weaponframe=2;}; @@ -246,94 +238,99 @@ void(float num_bubbles) DeathBubbles; void() PainSound = { -local float rs; + local float rs; if (self.health < 0) return; - if (damage_attacker.classname == "teledeath") - { + if (damage_attacker.classname == "teledeath") { sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE); return; } -// water pain sounds - if (self.watertype == CONTENT_WATER && self.waterlevel == 3) - { - DeathBubbles(1); - if (random() > 0.5) + // water pain sounds + if (self.watertype == CONTENT_WATER && self.waterlevel == 3) { + DeathBubbles (1); + if (random () > 0.5) sound (self, CHAN_VOICE, "player/drown1.wav", 1, ATTN_NORM); else sound (self, CHAN_VOICE, "player/drown2.wav", 1, ATTN_NORM); return; } -// slime pain sounds - if (self.watertype == CONTENT_SLIME) - { -// FIX ME put in some steam here - if (random() > 0.5) + // slime pain sounds + if (self.watertype == CONTENT_SLIME) { + // FIXME put in some steam here + if (random () > 0.5) sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM); else sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM); return; } - if (self.watertype == CONTENT_LAVA) - { - if (random() > 0.5) + if (self.watertype == CONTENT_LAVA) { + // FIXME put in some steam here + if (random () > 0.5) sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM); else sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM); return; } - if (self.pain_finished > time) - { + if (self.pain_finished > time) { self.axhitme = 0; return; } self.pain_finished = time + 0.5; -// don't make multiple pain sounds right after each other + // don't make multiple pain sounds right after each other -// ax pain sound - if (self.axhitme == 1) - { + // ax pain sound + if (self.axhitme == 1) { self.axhitme = 0; sound (self, CHAN_VOICE, "player/axhit1.wav", 1, ATTN_NORM); return; } - - rs = rint((random() * 5) + 1); - - self.noise = ""; - if (rs == 1) + switch (rint (5 * random ())) { + case 0: self.noise = "player/pain1.wav"; - else if (rs == 2) + break; + case 1: self.noise = "player/pain2.wav"; - else if (rs == 3) + break; + case 2: self.noise = "player/pain3.wav"; - else if (rs == 4) + break; + case 3: self.noise = "player/pain4.wav"; - else if (rs == 5) + break; + case 4: self.noise = "player/pain5.wav"; - else + break; + default: + case 5: self.noise = "player/pain6.wav"; - + break; + } sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); return; }; -void() player_pain1 = [ $pain1, player_pain2 ] {PainSound();self.weaponframe=0;}; +void() player_pain1 = [ $pain1, player_pain2 ] { + PainSound (); + self.weaponframe = 0; +}; void() player_pain2 = [ $pain2, player_pain3 ] {}; void() player_pain3 = [ $pain3, player_pain4 ] {}; void() player_pain4 = [ $pain4, player_pain5 ] {}; void() player_pain5 = [ $pain5, player_pain6 ] {}; void() player_pain6 = [ $pain6, player_run ] {}; -void() player_axpain1 = [ $axpain1, player_axpain2 ] {PainSound();self.weaponframe=0;}; +void() player_axpain1 = [ $axpain1, player_axpain2 ] { + PainSound (); + self.weaponframe = 0; +}; void() player_axpain2 = [ $axpain2, player_axpain3 ] {}; void() player_axpain3 = [ $axpain3, player_axpain4 ] {}; void() player_axpain4 = [ $axpain4, player_axpain5 ] {}; @@ -363,10 +360,11 @@ void() player_die_ax1; void() DeathBubblesSpawn = { -local entity bubble; + local entity bubble; + if (self.owner.waterlevel != 3) return; - bubble = spawn(); + bubble = spawn (); setmodel (bubble, "progs/s_bubble.spr"); setorigin (bubble, self.owner.origin + '0 0 24'); bubble.movetype = MOVETYPE_NOCLIP; @@ -382,14 +380,14 @@ local entity bubble; self.think = DeathBubblesSpawn; self.air_finished = self.air_finished + 1; if (self.air_finished >= self.bubble_count) - remove(self); + remove (self); }; void(float num_bubbles) DeathBubbles = { -local entity bubble_spawner; - - bubble_spawner = spawn(); + local entity bubble_spawner; + + bubble_spawner = spawn (); setorigin (bubble_spawner, self.origin); bubble_spawner.movetype = MOVETYPE_NONE; bubble_spawner.solid = SOLID_NOT; @@ -401,20 +399,18 @@ local entity bubble_spawner; return; }; - void() DeathSound = { -local float rs; + local float rs; // water death sounds - if (self.waterlevel == 3) - { - DeathBubbles(5); + if (self.waterlevel == 3) { + DeathBubbles (5); sound (self, CHAN_VOICE, "player/h2odeath.wav", 1, ATTN_NONE); return; } - rs = rint ((random() * 4) + 1); + rs = rint ((random () * 4) + 1); if (rs == 1) self.noise = "player/death1.wav"; if (rs == 2) @@ -430,49 +426,37 @@ local float rs; return; }; - void() PlayerDead = { self.nextthink = -1; -// allow respawn after a certain time + // allow respawn after a certain time self.deadflag = DEAD_DEAD; }; vector(float dm) VelocityForDamage = { - local vector v; + local vector v; - if (vlen(damage_inflictor.velocity)>0) - { + if (vlen (damage_inflictor.velocity) > 0) { v = 0.5 * damage_inflictor.velocity; - v = v + (25 * normalize(self.origin-damage_inflictor.origin)); - v_z = 100 + 240 * random(); - v_x = v_x + (200 * crandom()); - v_y = v_y + (200 * crandom()); - //dprint ("Velocity gib\n"); - } - else - { - v_x = 100 * crandom(); - v_y = 100 * crandom(); - v_z = 200 + 100 * random(); + v += 25 * normalize (self.origin - damage_inflictor.origin); + v_x += 400 * (random () - 0.5); + v_y += 400 * (random () - 0.5); + v_z = 100 + 240 * random (); +// dprint ("Velocity gib\n"); + } else { + v_x = 200 * (random () - 0.5); + v_y = 200 * (random () - 0.5); + v_z = 200 + 100 * random (); } - //v_x = 100 * crandom(); - //v_y = 100 * crandom(); - //v_z = 200 + 100 * random(); - - if (dm > -50) - { - // dprint ("level 1\n"); + if (dm > -50) { +// dprint ("level 1\n"); v = v * 0.7; - } - else if (dm > -200) - { - // dprint ("level 3\n"); + } else if (dm > -200) { +// dprint ("level 3\n"); v = v * 2; - } - else + } else v = v * 10; return v; @@ -480,7 +464,7 @@ vector(float dm) VelocityForDamage = void(string gibname, float dm) ThrowGib = { - local entity new; + local entity new; new = spawn(); new.origin = self.origin; @@ -489,12 +473,12 @@ void(string gibname, float dm) ThrowGib = new.velocity = VelocityForDamage (dm); new.movetype = MOVETYPE_BOUNCE; new.solid = SOLID_NOT; - new.avelocity_x = random()*600; - new.avelocity_y = random()*600; - new.avelocity_z = random()*600; + new.avelocity_x = random () * 600; + new.avelocity_y = random () * 600; + new.avelocity_z = random () * 600; new.think = SUB_Remove; new.ltime = time; - new.nextthink = time + 10 + random()*10; + new.nextthink = time + 10 + random () * 10; new.frame = 0; new.flags = 0; }; @@ -512,10 +496,9 @@ void(string gibname, float dm) ThrowHead = self.velocity = VelocityForDamage (dm); self.origin_z = self.origin_z - 24; self.flags = self.flags - (self.flags & FL_ONGROUND); - self.avelocity = crandom() * '0 600 0'; + self.avelocity = (random () - 0.5) * '0 1200 0'; }; - void() GibPlayer = { ThrowHead ("progs/h_player.mdl", self.health); @@ -525,19 +508,17 @@ void() GibPlayer = self.deadflag = DEAD_DEAD; - if (damage_attacker.classname == "teledeath") - { + if (damage_attacker.classname == "teledeath") { sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE); return; } - if (damage_attacker.classname == "teledeath2") - { + if (damage_attacker.classname == "teledeath2") { sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE); return; } - if (random() < 0.5) + if (random () < 0.5) sound (self, CHAN_VOICE, "player/gib.wav", 1, ATTN_NONE); else sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NONE); @@ -549,29 +530,25 @@ void() PlayerDie = local string s; self.items = self.items - (self.items & IT_INVISIBILITY); - if ((stof(infokey(world,"dq"))) != 0) - { - if (self.super_damage_finished > 0) - { + if ((stof (infokey (world, "dq"))) != 0) { + if (self.super_damage_finished > 0) { DropQuad (self.super_damage_finished - time); bprint (PRINT_LOW, self.netname); if (deathmatch == 4) bprint (PRINT_LOW, " lost an OctaPower with "); else bprint (PRINT_LOW, " lost a quad with "); - s = ftos(rint(self.super_damage_finished - time)); + s = ftos (rint (self.super_damage_finished - time)); bprint (PRINT_LOW, s); bprint (PRINT_LOW, " seconds remaining\n"); } } - if ((stof(infokey(world,"dr"))) != 0) - { - if (self.invisible_finished > 0) - { + if ((stof (infokey (world, "dr"))) != 0) { + if (self.invisible_finished > 0) { bprint (PRINT_LOW, self.netname); bprint (PRINT_LOW, " lost a ring with "); - s = ftos(rint(self.invisible_finished - time)); + s = ftos (rint (self.invisible_finished - time)); bprint (PRINT_LOW, s); bprint (PRINT_LOW, " seconds remaining\n"); DropRing (self.invisible_finished - time); @@ -584,19 +561,18 @@ void() PlayerDie = self.radsuit_finished = 0; self.modelindex = modelindex_player; // don't use eyes - DropBackpack(); + DropBackpack (); - self.weaponmodel=""; + self.weaponmodel = ""; self.view_ofs = '0 0 -8'; self.deadflag = DEAD_DYING; self.solid = SOLID_NOT; self.flags = self.flags - (self.flags & FL_ONGROUND); self.movetype = MOVETYPE_TOSS; if (self.velocity_z < 10) - self.velocity_z = self.velocity_z + random()*300; + self.velocity_z = self.velocity_z + random () * 300; - if (self.health < -40) - { + if (self.health < -40) { GibPlayer (); return; } @@ -606,15 +582,14 @@ void() PlayerDie = self.angles_x = 0; self.angles_z = 0; - if (self.weapon == IT_AXE) - { + if (self.weapon == IT_AXE) { player_die_ax1 (); return; } i = cvar("temp1"); if (!i) - i = 1 + floor(random()*6); + i = 1 + floor (6 * random ()); if (i == 1) player_diea1(); diff --git a/nqw/q_subs.qc b/nqw/q_subs.qc index a3a39c7..d6d0e76 100644 --- a/nqw/q_subs.qc +++ b/nqw/q_subs.qc @@ -1,8 +1,6 @@ /* - in nightmare mode, all attack_finished times become 0 some monsters refire twice automatically - */ void(float normal) SUB_AttackFinished = diff --git a/nqw/server.qc b/nqw/server.qc index d724c20..54d0d54 100644 --- a/nqw/server.qc +++ b/nqw/server.qc @@ -1,6 +1,5 @@ void() monster_death_use; - void() monster_ogre = {remove(self);}; void() monster_demon1 = {remove(self);}; void() monster_shambler = {remove(self);}; @@ -20,7 +19,6 @@ void() event_lightning = {remove(self);}; /* ============================================================================== - MOVETARGET CODE The angle of the movetarget effects standing and bowing direction, but has no effect on movement, which allways heads to the next target. @@ -33,7 +31,6 @@ the next spot to move to. If not present, stop here for good. pausetime The number of seconds to spend standing or bowing for path_stand or path_bow - ============================================================================== */ @@ -47,11 +44,11 @@ moving towards it, change the next destination and continue. */ void() t_movetarget = { -local entity temp; + local entity temp; if (other.movetarget != self) return; - + if (other.enemy) return; // fighting, not following a path @@ -62,28 +59,24 @@ local entity temp; if (self.classname == "monster_ogre") sound (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE);// play chainsaw drag sound -//dprint ("t_movetarget\n"); +// dprint ("t_movetarget\n"); self.goalentity = self.movetarget = find (world, targetname, other.target); - self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin); - if (!self.movetarget) - { + self.ideal_yaw = vectoyaw (self.goalentity.origin - self.origin); + if (!self.movetarget) { self.pausetime = time + 999999; self.th_stand (); return; } }; - - void() movetarget_f = { if (!self.targetname) objerror ("monster_movetarget: no targetname"); - + self.solid = SOLID_TRIGGER; self.touch = t_movetarget; setsize (self, '-8 -8 -8', '8 8 8'); - }; /*QUAKED path_corner (0.5 0.3 0) (-8 -8 -8) (8 8 8) @@ -93,6 +86,3 @@ void() path_corner = { movetarget_f (); }; - - -//============================================================================ diff --git a/nqw/shalrath.qc b/nqw/shalrath.qc index 15320f4..4dbed42 100644 --- a/nqw/shalrath.qc +++ b/nqw/shalrath.qc @@ -26,9 +26,10 @@ void() ShalMissile; void() shal_stand =[ $walk1, shal_stand ] {ai_stand();}; void() shal_walk1 =[ $walk2, shal_walk2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "shalrath/idle.wav", 1, ATTN_IDLE); -ai_walk(6);}; + if (random () < 0.2) + sound (self, CHAN_VOICE, "shalrath/idle.wav", 1, ATTN_IDLE); + ai_walk (6); +}; void() shal_walk2 =[ $walk3, shal_walk3 ] {ai_walk(4);}; void() shal_walk3 =[ $walk4, shal_walk4 ] {ai_walk(0);}; void() shal_walk4 =[ $walk5, shal_walk5 ] {ai_walk(0);}; @@ -42,9 +43,10 @@ void() shal_walk11 =[ $walk12, shal_walk12 ] {ai_walk(4);}; void() shal_walk12 =[ $walk1, shal_walk1 ] {ai_walk(5);}; void() shal_run1 =[ $walk2, shal_run2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "shalrath/idle.wav", 1, ATTN_IDLE); -ai_run(6);}; + if (random () < 0.2) + sound (self, CHAN_VOICE, "shalrath/idle.wav", 1, ATTN_IDLE); + ai_run (6); +}; void() shal_run2 =[ $walk3, shal_run3 ] {ai_run(4);}; void() shal_run3 =[ $walk4, shal_run4 ] {ai_run(0);}; void() shal_run4 =[ $walk5, shal_run5 ] {ai_run(0);}; @@ -58,8 +60,8 @@ void() shal_run11 =[ $walk12, shal_run12 ] {ai_run(4);}; void() shal_run12 =[ $walk1, shal_run1 ] {ai_run(5);}; void() shal_attack1 =[ $attack1, shal_attack2 ] { -sound (self, CHAN_VOICE, "shalrath/attack.wav", 1, ATTN_NORM); -ai_face(); + sound (self, CHAN_VOICE, "shalrath/attack.wav", 1, ATTN_NORM); + ai_face (); }; void() shal_attack2 =[ $attack2, shal_attack3 ] {ai_face();}; void() shal_attack3 =[ $attack3, shal_attack4 ] {ai_face();}; @@ -93,15 +95,14 @@ void(entity attacker, float damage) shalrath_pain = return; sound (self, CHAN_VOICE, "shalrath/pain.wav", 1, ATTN_NORM); - shal_pain1(); + shal_pain1 (); self.pain_finished = time + 3; }; void() shalrath_die = { -// check for gib - if (self.health < -90) - { + // check for gib + if (self.health < -90) { sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); ThrowHead ("progs/h_shal.mdl", self.health); ThrowGib ("progs/gib1.mdl", self.health); @@ -111,9 +112,8 @@ void() shalrath_die = } sound (self, CHAN_VOICE, "shalrath/death.wav", 1, ATTN_NORM); - shal_death1(); + shal_death1 (); self.solid = SOLID_NOT; - // insert death sounds here }; /* @@ -135,7 +135,7 @@ void() ShalMissile = if (flytime < 0.1) flytime = 0.1; - muzzleflash(); + muzzleflash (); sound (self, CHAN_WEAPON, "shalrath/attack2.wav", 1, ATTN_NORM); missile = spawn (); @@ -160,8 +160,7 @@ void() ShalHome = { local vector dir, vtemp; vtemp = self.enemy.origin + '0 0 10'; - if (self.enemy.health < 1) - { + if (self.enemy.health < 1) { remove(self); return; } @@ -184,11 +183,8 @@ void() ShalMissileTouch = T_RadiusDamage (self, self.owner, 40, world, "shalrath"); sound (self, CHAN_WEAPON, "weapons/r_exp3.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); + WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_EXPLOSION); + WriteCoordV (MSG_BROADCAST, self.origin); multicast (self.origin, MULTICAST_PHS); remove (self); @@ -200,25 +196,25 @@ void() ShalMissileTouch = */ void() monster_shalrath = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } + precache_model2 ("progs/shalrath.mdl"); precache_model2 ("progs/h_shal.mdl"); precache_model2 ("progs/v_spike.mdl"); - + precache_sound2 ("shalrath/attack.wav"); precache_sound2 ("shalrath/attack2.wav"); precache_sound2 ("shalrath/death.wav"); precache_sound2 ("shalrath/idle.wav"); precache_sound2 ("shalrath/pain.wav"); precache_sound2 ("shalrath/sight.wav"); - + self.solid = SOLID_SLIDEBOX; self.movetype = MOVETYPE_STEP; - + setmodel (self, "progs/shalrath.mdl"); setsize (self, VEC_HULL2_MIN, VEC_HULL2_MAX); self.health = 400; @@ -231,6 +227,5 @@ void() monster_shalrath = self.th_missile = shal_attack1; self.think = walkmonster_start; - self.nextthink = time + 0.1 + random ()*0.1; - + self.nextthink = time + 0.1 + random () * 0.1; }; diff --git a/nqw/shambler.qc b/nqw/shambler.qc index 86519dc..4dd7d3e 100644 --- a/nqw/shambler.qc +++ b/nqw/shambler.qc @@ -65,23 +65,27 @@ void() sham_walk8 =[ $walk8, sham_walk9 ] {ai_walk(3);}; void() sham_walk9 =[ $walk9, sham_walk10] {ai_walk(13);}; void() sham_walk10 =[ $walk10, sham_walk11] {ai_walk(9);}; void() sham_walk11 =[ $walk11, sham_walk12] {ai_walk(7);}; -void() sham_walk12 =[ $walk12, sham_walk1 ] {ai_walk(7); -if (random() > 0.8) - sound (self, CHAN_VOICE, "shambler/sidle.wav", 1, ATTN_IDLE);}; +void() sham_walk12 =[ $walk12, sham_walk1 ] { + ai_walk (7); + if (random () > 0.8) + sound (self, CHAN_VOICE, "shambler/sidle.wav", 1, ATTN_IDLE); +}; void() sham_run1 =[ $run1, sham_run2 ] {ai_run(20);}; void() sham_run2 =[ $run2, sham_run3 ] {ai_run(24);}; void() sham_run3 =[ $run3, sham_run4 ] {ai_run(20);}; void() sham_run4 =[ $run4, sham_run5 ] {ai_run(20);}; void() sham_run5 =[ $run5, sham_run6 ] {ai_run(24);}; -void() sham_run6 =[ $run6, sham_run1 ] {ai_run(20); -if (random() > 0.8) - sound (self, CHAN_VOICE, "shambler/sidle.wav", 1, ATTN_IDLE); +void() sham_run6 =[ $run6, sham_run1 ] { + ai_run (20); + if (random () > 0.8) + sound (self, CHAN_VOICE, "shambler/sidle.wav", 1, ATTN_IDLE); }; void() sham_smash1 =[ $smash1, sham_smash2 ] { -sound (self, CHAN_VOICE, "shambler/melee1.wav", 1, ATTN_NORM); -ai_charge(2);}; + sound (self, CHAN_VOICE, "shambler/melee1.wav", 1, ATTN_NORM); + ai_charge (2); +}; void() sham_smash2 =[ $smash2, sham_smash3 ] {ai_charge(6);}; void() sham_smash3 =[ $smash3, sham_smash4 ] {ai_charge(6);}; void() sham_smash4 =[ $smash4, sham_smash5 ] {ai_charge(5);}; @@ -91,26 +95,29 @@ void() sham_smash7 =[ $smash7, sham_smash8 ] {ai_charge(0);}; void() sham_smash8 =[ $smash8, sham_smash9 ] {ai_charge(0);}; void() sham_smash9 =[ $smash9, sham_smash10 ] {ai_charge(0);}; void() sham_smash10 =[ $smash10, sham_smash11 ] { -local vector delta; -local float ldmg; + local vector delta; + local float ldmg; if (!self.enemy) return; - ai_charge(0); + + ai_charge (0); delta = self.enemy.origin - self.origin; - if (vlen(delta) > 100) + if (vlen (delta) > 100) return; if (!CanDamage (self.enemy, self)) return; - - ldmg = (random() + random() + random()) * 40; + + ldmg = 40 * (random () + random () + random ()); T_Damage (self.enemy, self, self, ldmg); sound (self, CHAN_VOICE, "shambler/smack.wav", 1, ATTN_NORM); - SpawnMeatSpray (self.origin + v_forward*16, crandom() * 100 * v_right); - SpawnMeatSpray (self.origin + v_forward*16, crandom() * 100 * v_right); + SpawnMeatSpray (self.origin + v_forward * 16, + v_right * (200 * (random () - 0.5)); + SpawnMeatSpray (self.origin + v_forward * 16, + v_right * (200 * (random () - 0.5)); }; void() sham_smash11 =[ $smash11, sham_smash12 ] {ai_charge(5);}; void() sham_smash12 =[ $smash12, sham_run1 ] {ai_charge(4);}; @@ -119,43 +126,46 @@ void() sham_swingr1; void(float side) ShamClaw = { -local vector delta; -local float ldmg; + local vector delta; + local float ldmg; if (!self.enemy) return; - ai_charge(10); + ai_charge (10); delta = self.enemy.origin - self.origin; - if (vlen(delta) > 100) + if (vlen (delta) > 100) return; - - ldmg = (random() + random() + random()) * 20; + + ldmg = 20 * (random () + random () + random ()); T_Damage (self.enemy, self, self, ldmg); sound (self, CHAN_VOICE, "shambler/smack.wav", 1, ATTN_NORM); - if (side) - { + if (side) { makevectors (self.angles); - SpawnMeatSpray (self.origin + v_forward*16, side * v_right); + SpawnMeatSpray (self.origin + v_forward * 16, side * v_right); } }; void() sham_swingl1 =[ $swingl1, sham_swingl2 ] { -sound (self, CHAN_VOICE, "shambler/melee2.wav", 1, ATTN_NORM); -ai_charge(5);}; + sound (self, CHAN_VOICE, "shambler/melee2.wav", 1, ATTN_NORM); + ai_charge (5); +}; void() sham_swingl2 =[ $swingl2, sham_swingl3 ] {ai_charge(3);}; void() sham_swingl3 =[ $swingl3, sham_swingl4 ] {ai_charge(7);}; void() sham_swingl4 =[ $swingl4, sham_swingl5 ] {ai_charge(3);}; void() sham_swingl5 =[ $swingl5, sham_swingl6 ] {ai_charge(7);}; void() sham_swingl6 =[ $swingl6, sham_swingl7 ] {ai_charge(9);}; -void() sham_swingl7 =[ $swingl7, sham_swingl8 ] {ai_charge(5); ShamClaw(250);}; +void() sham_swingl7 =[ $swingl7, sham_swingl8 ] { + ai_charge (5); + ShamClaw (250); +}; void() sham_swingl8 =[ $swingl8, sham_swingl9 ] {ai_charge(4);}; void() sham_swingl9 =[ $swingl9, sham_run1 ] { -ai_charge(8); -if (random()<0.5) - self.think = sham_swingr1; + ai_charge (8); + if (random () < 0.5) + self.think = sham_swingr1; }; void() sham_swingr1 =[ $swingr1, sham_swingr2 ] { @@ -170,23 +180,26 @@ void() sham_swingr7 =[ $swingr7, sham_swingr8 ] {ai_charge(6); ShamC void() sham_swingr8 =[ $swingr8, sham_swingr9 ] {ai_charge(3);}; void() sham_swingr9 =[ $swingr9, sham_run1 ] {ai_charge(1); ai_charge(10); -if (random()<0.5) +if (random () < 0.5) self.think = sham_swingl1; }; void() sham_melee = { local float chance; - - chance = random(); - if (chance > 0.6 || self.health == 600) - sham_smash1 (); - else if (chance > 0.3) - sham_swingr1 (); - else - sham_swingl1 (); -}; + if (self.health == 600) { + sham_smash1 (); + } else { + chance = random (); + if (chance > 0.6) + sham_smash1 (); + else if (chance > 0.3) + sham_swingr1 (); + else + sham_swingl1 (); + } +}; //============================================================================ @@ -203,62 +216,60 @@ void() CastLightning = dir = self.enemy.origin + '0 0 16' - org; dir = normalize (dir); - traceline (org, self.origin + dir*600, TRUE, self); + traceline (org, self.origin + dir * 600, TRUE, self); - WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); - WriteByte (MSG_BROADCAST, TE_LIGHTNING1); + WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_LIGHTNING1); 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); + WriteCoordV (MSG_BROADCAST, org); + WriteCoordV (MSG_BROADCAST, trace_endpos); LightningDamage (org, trace_endpos, self, 10); }; -void() sham_magic1 =[ $magic1, sham_magic2 ] {ai_face(); +void() sham_magic1 =[ $magic1, sham_magic2 ] { + ai_face(); sound (self, CHAN_WEAPON, "shambler/sattck1.wav", 1, ATTN_NORM); }; void() sham_magic2 =[ $magic2, sham_magic3 ] {ai_face();}; -void() sham_magic3 =[ $magic3, sham_magic4 ] {ai_face();self.nextthink = self.nextthink + 0.2; -local entity o; +void() sham_magic3 =[ $magic3, sham_magic4 ] { + ai_face(); + self.nextthink = self.nextthink + 0.2; + local entity o; -muzzleflash(); -ai_face(); -self.owner = spawn(); -o = self.owner; -setmodel (o, "progs/s_light.mdl"); -setorigin (o, self.origin); -o.angles = self.angles; -o.nextthink = time + 0.7; -o.think = SUB_Remove; + muzzleflash(); + ai_face(); + self.owner = spawn(); + o = self.owner; + setmodel (o, "progs/s_light.mdl"); + setorigin (o, self.origin); + o.angles = self.angles; + o.nextthink = time + 0.7; + o.think = SUB_Remove; }; void() sham_magic4 =[ $magic4, sham_magic5 ] { -muzzleflash(); -self.owner.frame = 1; + muzzleflash (); + self.owner.frame = 1; }; void() sham_magic5 =[ $magic5, sham_magic6 ] { -muzzleflash(); -self.owner.frame = 2; + muzzleflash (); + self.owner.frame = 2; }; void() sham_magic6 =[ $magic6, sham_magic9 ] { -remove (self.owner); -CastLightning(); -sound (self, CHAN_WEAPON, "shambler/sboom.wav", 1, ATTN_NORM); + remove (self.owner); + CastLightning(); + sound (self, CHAN_WEAPON, "shambler/sboom.wav", 1, ATTN_NORM); }; void() sham_magic9 =[ $magic9, sham_magic10 ] -{CastLightning();}; +{CastLightning ();}; void() sham_magic10 =[ $magic10, sham_magic11 ] -{CastLightning();}; +{CastLightning ();}; void() sham_magic11 =[ $magic11, sham_magic12 ] { -if (skill == 3) - CastLightning(); + if (skill == 3) + CastLightning (); }; void() sham_magic12 =[ $magic12, sham_run1 ] {}; @@ -278,7 +289,7 @@ void(entity attacker, float damage) sham_pain = if (self.health <= 0) return; // allready dying, don't go into pain frame - if (random()*400 > damage) + if (random () * 400 > damage) return; // didn't flinch if (self.pain_finished > time) @@ -305,9 +316,8 @@ void() sham_death11 =[ $death11, sham_death11 ] {}; void() sham_die = { -// check for gib - if (self.health < -60) - { + // check for gib + if (self.health < -60) { sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); ThrowHead ("progs/h_shams.mdl", self.health); ThrowGib ("progs/gib1.mdl", self.health); @@ -316,23 +326,22 @@ void() sham_die = return; } -// regular death + // regular death sound (self, CHAN_VOICE, "shambler/sdeath.wav", 1, ATTN_NORM); sham_death1 (); }; //============================================================================ - /*QUAKED monster_shambler (1 0 0) (-32 -32 -24) (32 32 64) Ambush */ void() monster_shambler = { - if (deathmatch) - { + if (deathmatch) { remove(self); return; } + precache_model ("progs/shambler.mdl"); precache_model ("progs/s_light.mdl"); precache_model ("progs/h_shams.mdl"); @@ -363,5 +372,5 @@ void() monster_shambler = self.th_missile = sham_magic1; self.th_pain = sham_pain; - walkmonster_start(); + walkmonster_start (); }; diff --git a/nqw/soldier.qc b/nqw/soldier.qc index 0bb306a..7edd44c 100644 --- a/nqw/soldier.qc +++ b/nqw/soldier.qc @@ -55,9 +55,10 @@ void() army_stand7 =[ $stand7, army_stand8 ] {ai_stand();}; void() army_stand8 =[ $stand8, army_stand1 ] {ai_stand();}; void() army_walk1 =[ $prowl_1, army_walk2 ] { -if (random() < 0.2) - sound (self, CHAN_VOICE, "soldier/idle.wav", 1, ATTN_IDLE); -ai_walk(1);}; + if (random () < 0.2) + sound (self, CHAN_VOICE, "soldier/idle.wav", 1, ATTN_IDLE); + ai_walk (1); +}; void() army_walk2 =[ $prowl_2, army_walk3 ] {ai_walk(1);}; void() army_walk3 =[ $prowl_3, army_walk4 ] {ai_walk(1);}; void() army_walk4 =[ $prowl_4, army_walk5 ] {ai_walk(1);}; @@ -83,9 +84,10 @@ void() army_walk23 =[ $prowl_23, army_walk24 ] {ai_walk(1);}; void() army_walk24 =[ $prowl_24, army_walk1 ] {ai_walk(1);}; void() army_run1 =[ $run1, army_run2 ] { -if (random() < 0.2) + if (random () < 0.2) sound (self, CHAN_VOICE, "soldier/idle.wav", 1, ATTN_IDLE); -ai_run(11);}; + ai_run (11); +}; void() army_run2 =[ $run2, army_run3 ] {ai_run(15);}; void() army_run3 =[ $run3, army_run4 ] {ai_run(10);}; void() army_run4 =[ $run4, army_run5 ] {ai_run(10);}; @@ -98,9 +100,16 @@ void() army_atk1 =[ $shoot1, army_atk2 ] {ai_face();}; void() army_atk2 =[ $shoot2, army_atk3 ] {ai_face();}; void() army_atk3 =[ $shoot3, army_atk4 ] {ai_face();}; void() army_atk4 =[ $shoot4, army_atk5 ] {ai_face();}; -void() army_atk5 =[ $shoot5, army_atk6 ] {ai_face();army_fire();muzzleflash();}; +void() army_atk5 =[ $shoot5, army_atk6 ] { + ai_face (); + army_fire (); + muzzleflash (); +}; void() army_atk6 =[ $shoot6, army_atk7 ] {ai_face();}; -void() army_atk7 =[ $shoot7, army_atk8 ] {ai_face();SUB_CheckRefire (army_atk1);}; +void() army_atk7 =[ $shoot7, army_atk8 ] { + ai_face (); + SUB_CheckRefire (army_atk1); +}; void() army_atk8 =[ $shoot8, army_atk9 ] {ai_face();}; void() army_atk9 =[ $shoot9, army_run1 ] {ai_face();}; @@ -148,53 +157,47 @@ void(entity attacker, float damage) army_pain = if (self.pain_finished > time) return; - r = random(); - - if (r < 0.2) - { + r = random (); + if (r < 0.2) { self.pain_finished = time + 0.6; army_pain1 (); sound (self, CHAN_VOICE, "soldier/pain1.wav", 1, ATTN_NORM); - } - else if (r < 0.6) - { + } else if (r < 0.6) { self.pain_finished = time + 1.1; army_painb1 (); sound (self, CHAN_VOICE, "soldier/pain2.wav", 1, ATTN_NORM); - } - else - { + } else { self.pain_finished = time + 1.1; army_painc1 (); sound (self, CHAN_VOICE, "soldier/pain2.wav", 1, ATTN_NORM); } }; - void() army_fire = { local vector dir; local entity en; - - ai_face(); - + + ai_face (); + sound (self, CHAN_WEAPON, "soldier/sattck1.wav", 1, ATTN_NORM); -// fire somewhat behind the player, so a dodging player is harder to hit + // fire somewhat behind the player, so a dodging player is harder to hit en = self.enemy; - - dir = en.origin - en.velocity*0.2; + + dir = en.origin - en.velocity * 0.2; dir = normalize (dir - self.origin); - + FireBullets (4, dir, '0.1 0.1 0'); }; - - void() army_die1 =[ $death1, army_die2 ] {}; void() army_die2 =[ $death2, army_die3 ] {}; -void() army_die3 =[ $death3, army_die4 ] -{self.solid = SOLID_NOT;self.ammo_shells = 5;DropBackpack();}; +void() army_die3 =[ $death3, army_die4 ] { + self.solid = SOLID_NOT; + self.ammo_shells = 5; + DropBackpack(); +}; void() army_die4 =[ $death4, army_die5 ] {}; void() army_die5 =[ $death5, army_die6 ] {}; void() army_die6 =[ $death6, army_die7 ] {}; @@ -205,8 +208,12 @@ void() army_die10 =[ $death10, army_die10 ] {}; void() army_cdie1 =[ $deathc1, army_cdie2 ] {}; void() army_cdie2 =[ $deathc2, army_cdie3 ] {ai_back(5);}; -void() army_cdie3 =[ $deathc3, army_cdie4 ] -{self.solid = SOLID_NOT;self.ammo_shells = 5;DropBackpack();ai_back(4);}; +void() army_cdie3 =[ $deathc3, army_cdie4 ] { + self.solid = SOLID_NOT; + self.ammo_shells = 5; + DropBackpack (); + ai_back (4); +}; void() army_cdie4 =[ $deathc4, army_cdie5 ] {ai_back(13);}; void() army_cdie5 =[ $deathc5, army_cdie6 ] {ai_back(3);}; void() army_cdie6 =[ $deathc6, army_cdie7 ] {ai_back(4);}; @@ -219,9 +226,8 @@ void() army_cdie11 =[ $deathc11, army_cdie11 ] {}; void() army_die = { -// check for gib - if (self.health < -35) - { + // check for gib + if (self.health < -35) { sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); ThrowHead ("progs/h_guard.mdl", self.health); ThrowGib ("progs/gib1.mdl", self.health); @@ -230,9 +236,9 @@ void() army_die = return; } -// regular death + // regular death sound (self, CHAN_VOICE, "soldier/death1.wav", 1, ATTN_NORM); - if (random() < 0.5) + if (random () < 0.5) army_die1 (); else army_cdie1 (); @@ -243,11 +249,11 @@ void() army_die = */ void() monster_army = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } + precache_model ("progs/soldier.mdl"); precache_model ("progs/h_guard.mdl"); precache_model ("progs/gib1.mdl"); @@ -263,7 +269,6 @@ void() monster_army = precache_sound ("player/udeath.wav"); // gib death - self.solid = SOLID_SLIDEBOX; self.movetype = MOVETYPE_STEP; diff --git a/nqw/spectate.qc b/nqw/spectate.qc index 81c6533..091e603 100644 --- a/nqw/spectate.qc +++ b/nqw/spectate.qc @@ -50,11 +50,12 @@ void() SpectatorImpulseCommand = { if (self.impulse == 1) { // teleport the spectator to the next spawn point - // note that if the spectator is tracking, this doesn't do - // much - self.goalentity = find(self.goalentity, classname, "info_player_deathmatch"); + // note that if the spectator is tracking, this doesn't do much + self.goalentity = find (self.goalentity, classname, + "info_player_deathmatch"); if (self.goalentity == world) - self.goalentity = find(self.goalentity, classname, "info_player_deathmatch"); + self.goalentity = find (self.goalentity, classname, + "info_player_deathmatch"); if (self.goalentity != world) { setorigin(self, self.goalentity.origin); self.angles = self.goalentity.angles; @@ -76,9 +77,6 @@ void() SpectatorThink = { // self.origin, etc contains spectator position, so you could // do some neat stuff here - if (self.impulse) SpectatorImpulseCommand(); }; - - diff --git a/nqw/sprites.qc b/nqw/sprites.qc index f1bb605..a276d4c 100644 --- a/nqw/sprites.qc +++ b/nqw/sprites.qc @@ -1,4 +1,3 @@ - // these are the only sprites still in the game... $spritename s_explod @@ -11,16 +10,13 @@ $frame 24 88 56 56 $frame 120 88 56 56 $frame 216 88 56 56 - $spritename s_bubble $type vp_parallel $load /raid/quake/id1/gfx/sprites/bubble.lbm $frame 16 16 16 16 $frame 40 16 16 16 - $spritename s_light $type vp_parallel $load /raid/quake/id1/gfx/sprites/light.lbm $frame 104 32 32 32 - diff --git a/nqw/subs.qc b/nqw/subs.qc index 20a6cee..50ef543 100644 --- a/nqw/subs.qc +++ b/nqw/subs.qc @@ -1,10 +1,7 @@ - - void() SUB_Null = {}; void() SUB_Remove = {remove(self);}; - /* QuakeEd only writes a single float for angles (bad idea), so up and down are just constant angles. @@ -15,8 +12,7 @@ vector() SetMovedir = self.movedir = '0 0 1'; else if (self.angles == '0 -2 0') self.movedir = '0 0 -1'; - else - { + else { makevectors (self.angles); self.movedir = v_forward; } @@ -52,7 +48,8 @@ self.origin traveling at speed */ void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt = { -local entity stemp; + local entity stemp; + stemp = self; self = ent; @@ -62,8 +59,8 @@ local entity stemp; void(vector tdest, float tspeed, void() func) SUB_CalcMove = { -local vector vdestdelta; -local float len, traveltime; + local vector vdestdelta; + local float len, traveltime; if (!tspeed) objerror("No speed is defined!"); @@ -72,30 +69,29 @@ local float len, traveltime; self.finaldest = tdest; self.think = SUB_CalcMoveDone; - if (tdest == self.origin) - { + if (tdest == self.origin) { self.velocity = '0 0 0'; self.nextthink = self.ltime + 0.1; return; } - -// set destdelta to the vector needed to move + + // set destdelta to the vector needed to move vdestdelta = tdest - self.origin; - -// calculate length of vector + + // calculate length of vector len = vlen (vdestdelta); - -// divide by speed to get time to reach dest + + // divide by speed to get time to reach dest traveltime = len / tspeed; if (traveltime < 0.03) traveltime = 0.03; - -// set nextthink to trigger a think when dest is reached + + // set nextthink to trigger a think when dest is reached self.nextthink = self.ltime + traveltime; -// scale the destdelta vector by the time spent traveling to get velocity - self.velocity = vdestdelta * (1/traveltime); // qcc won't take vec/float + // scale the destdelta vector by the time spent traveling to get velocity + self.velocity = vdestdelta * (1 / traveltime); // qcc won't take vec/float }; /* @@ -112,7 +108,6 @@ void() SUB_CalcMoveDone = self.think1(); }; - /* ============= SUB_CalcAngleMove @@ -125,7 +120,8 @@ The calling function should make sure self.think is valid */ void(entity ent, vector destangle, float tspeed, void() func) SUB_CalcAngleMoveEnt = { -local entity stemp; + local entity stemp; + stemp = self; self = ent; SUB_CalcAngleMove (destangle, tspeed, func); @@ -134,25 +130,25 @@ local entity stemp; void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove = { -local vector destdelta; -local float len, traveltime; + local vector destdelta; + local float len, traveltime; if (!tspeed) objerror("No speed is defined!"); - -// set destdelta to the vector needed to move + + // set destdelta to the vector needed to move destdelta = destangle - self.angles; - -// calculate length of vector + + // calculate length of vector len = vlen (destdelta); - -// divide by speed to get time to reach dest + + // divide by speed to get time to reach dest traveltime = len / tspeed; -// set nextthink to trigger a think when dest is reached + // set nextthink to trigger a think when dest is reached self.nextthink = self.ltime + traveltime; -// scale the destdelta vector by the time spent traveling to get velocity + // scale the destdelta vector by the time spent traveling to get velocity self.avelocity = destdelta * (1 / traveltime); self.think1 = func; @@ -171,10 +167,9 @@ void() SUB_CalcAngleMoveDone = self.avelocity = '0 0 0'; self.nextthink = -1; if (self.think1) - self.think1(); + self.think1 (); }; - //============================================================================= void() DelayThink = @@ -183,7 +178,7 @@ void() DelayThink = activator = self.enemy; SUB_UseTargets (); if (rem) - remove(self); + remove (self); }; /* @@ -202,20 +197,16 @@ and removes them, so some events can remove other triggers. Search for (string)targetname in all entities that match (string)self.target and call their .use function - ============================== */ void() SUB_UseTargets = { local entity t, stemp, otemp, act; -// -// check for a delay -// - if (self.delay) - { - // create a temp object to fire at a later time - t = spawn(); + // check for a delay + if (self.delay) { + // create a temp object to fire at a later time + t = spawn (); t.classname = "DelayedUse"; t.nextthink = time + self.delay; t.think = DelayThink; @@ -225,63 +216,45 @@ void() SUB_UseTargets = t.target = self.target; return; } - - -// -// print the message -// - if (activator.classname == "player" && self.message != "") - { + + // print the message + if (activator.classname == "player" && self.message != "") { centerprint (activator, self.message); if (!self.noise) sound (activator, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NORM); } -// -// kill the killtagets -// - if (self.killtarget) - { + // kill the killtagets + if (self.killtarget) { local string kt = self.killtarget; t = world; - do - { + do { t = find (t, targetname, kt); if (!t) return; remove (t); - } while ( 1 ); + } while (1); } - -// -// fire targets -// - if (self.target) - { + + // fire targets + if (self.target) { act = activator; t = world; - do - { + do { t = find (t, targetname, self.target); if (!t) - { return; - } stemp = self; otemp = other; self = t; other = stemp; - if (self.use != SUB_Null) - { + if (self.use != SUB_Null) { if (self.use) self.use (); } self = stemp; other = otemp; activator = act; - } while ( 1 ); + } while (1); } - - }; - diff --git a/nqw/tarbaby.qc b/nqw/tarbaby.qc index 0c527ff..d9fba63 100644 --- a/nqw/tarbaby.qc +++ b/nqw/tarbaby.qc @@ -82,21 +82,17 @@ void() tbaby_run23 =[ $run23, tbaby_run24 ] {ai_run(2);}; void() tbaby_run24 =[ $run24, tbaby_run25 ] {ai_run(2);}; void() tbaby_run25 =[ $run25, tbaby_run1 ] {ai_run(2);}; - //============================================================================ - void() tbaby_jump1; void() Tar_JumpTouch = { local float ldmg; - if (other.takedamage && other.classname != self.classname) - { - if ( vlen(self.velocity) > 400 ) - { - ldmg = 10 + 10*random(); + if (other.takedamage && other.classname != self.classname) { + if (vlen (self.velocity) > 400) { + ldmg = 10 + 10 * random (); T_Damage (other, self, self, ldmg); sound (self, CHAN_WEAPON, "blob/hit1.wav", 1, ATTN_NORM); } @@ -104,19 +100,15 @@ void() Tar_JumpTouch = else sound (self, CHAN_WEAPON, "blob/land1.wav", 1, ATTN_NORM); - - if (!checkbottom(self)) - { - if (self.flags & FL_ONGROUND) - { // jump randomly to not get hung up -//dprint ("popjump\n"); - self.touch = SUB_Null; - self.think = tbaby_run1; - self.movetype = MOVETYPE_STEP; - self.nextthink = time + 0.1; - -// self.velocity_x = (random() - 0.5) * 600; -// self.velocity_y = (random() - 0.5) * 600; + if (!checkbottom (self)) { + if (self.flags & FL_ONGROUND) { // jump randomly to not get hung up +// dprint ("popjump\n"); + self.touch = SUB_Null; + self.think = tbaby_run1; + self.movetype = MOVETYPE_STEP; + self.nextthink = time + 0.1; +// self.velocity_x = (random () - 0.5) * 600; +// self.velocity_y = (random () - 0.5) * 600; // self.velocity_z = 200; // self.flags = self.flags - FL_ONGROUND; } @@ -134,12 +126,11 @@ void() tbaby_fly1 =[ $fly1, tbaby_fly2 ] {}; void() tbaby_fly2 =[ $fly2, tbaby_fly3 ] {}; void() tbaby_fly3 =[ $fly3, tbaby_fly4 ] {}; void() tbaby_fly4 =[ $fly4, tbaby_fly1 ] { -self.cnt = self.cnt + 1; -if (self.cnt == 4) -{ -//dprint ("spawn hop\n"); -tbaby_jump5 (); -} + self.cnt = self.cnt + 1; + if (self.cnt == 4) { +// dprint ("spawn hop\n"); + tbaby_jump5 (); + } }; void() tbaby_jump1 =[ $jump1, tbaby_jump2 ] {ai_face();}; @@ -153,32 +144,28 @@ void() tbaby_jump5 =[ $jump5, tbaby_jump6 ] makevectors (self.angles); self.origin_z = self.origin_z + 1; self.velocity = v_forward * 600 + '0 0 200'; - self.velocity_z = self.velocity_z + random()*150; + self.velocity_z = self.velocity_z + random () * 150; if (self.flags & FL_ONGROUND) self.flags = self.flags - FL_ONGROUND; self.cnt = 0; }; void() tbaby_jump6 =[ $jump6,tbaby_fly1 ] {}; - - //============================================================================= void() tbaby_die1 =[ $exp, tbaby_die2 ] { -self.takedamage = DAMAGE_NO; + self.takedamage = DAMAGE_NO; }; + void() tbaby_die2 =[ $exp, tbaby_run1 ] { T_RadiusDamage (self, self, 120, world, "tarbaby"); sound (self, CHAN_VOICE, "blob/death1.wav", 1, ATTN_NORM); - self.origin = self.origin - 8*normalize(self.velocity); + self.origin = self.origin - 8 * normalize (self.velocity); - WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); - WriteByte (MSG_BROADCAST, TE_TAREXPLOSION); - WriteCoord (MSG_BROADCAST, self.origin_x); - WriteCoord (MSG_BROADCAST, self.origin_y); - WriteCoord (MSG_BROADCAST, self.origin_z); + WriteBytes (MSG_BROADCAST, SVC_TEMPENTITY, TE_TAREXPLOSION); + WriteCoordV (MSG_BROADCAST, self.origin); multicast (self.origin, MULTICAST_PHS); remove (self); @@ -186,23 +173,22 @@ void() tbaby_die2 =[ $exp, tbaby_run1 ] //============================================================================= - /*QUAKED monster_tarbaby (1 0 0) (-16 -16 -24) (16 16 24) Ambush */ void() monster_tarbaby = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } + precache_model2 ("progs/tarbaby.mdl"); precache_sound2 ("blob/death1.wav"); precache_sound2 ("blob/hit1.wav"); precache_sound2 ("blob/land1.wav"); precache_sound2 ("blob/sight1.wav"); - + self.solid = SOLID_SLIDEBOX; self.movetype = MOVETYPE_STEP; @@ -217,7 +203,6 @@ void() monster_tarbaby = self.th_missile = tbaby_jump1; self.th_melee = tbaby_jump1; self.th_die = tbaby_die1; - + walkmonster_start (); }; - diff --git a/nqw/triggers.qc b/nqw/triggers.qc index 96e3604..b5d6921 100644 --- a/nqw/triggers.qc +++ b/nqw/triggers.qc @@ -29,13 +29,11 @@ void() multi_wait = // so wait for the delay time before firing void() multi_trigger = { - if (self.nextthink > time) - { + if (self.nextthink > time) { return; // allready been triggered } - if (self.classname == "trigger_secret") - { + if (self.classname == "trigger_secret") { if (self.enemy.classname != "player") return; found_secrets = found_secrets + 1; @@ -279,10 +277,11 @@ float SILENT = 2; void() play_teleport = { - local float v; - local string tmpstr; + local float v; + local string tmpstr; + + v = 5 * random (); - v = random() * 5; if (v < 1) tmpstr = "misc/r_tele1.wav"; else if (v < 2) @@ -305,15 +304,11 @@ void(vector org) spawn_tfog = s.nextthink = time + 0.2; s.think = play_teleport; - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_TELEPORT); - WriteCoord (MSG_MULTICAST, org_x); - WriteCoord (MSG_MULTICAST, org_y); - WriteCoord (MSG_MULTICAST, org_z); + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_TELEPORT); + WriteCoordV (MSG_MULTICAST, org); multicast (org, MULTICAST_PHS); }; - void() tdeath_touch = { local entity other2; diff --git a/nqw/weapons.qc b/nqw/weapons.qc index a054132..36887a0 100644 --- a/nqw/weapons.qc +++ b/nqw/weapons.qc @@ -1,11 +1,9 @@ -/* -*/ void (entity targ, entity inflictor, entity attacker, float damage) T_Damage; void () player_run; -void(entity bomb, entity attacker, float rad, entity ignore, string dtype) T_RadiusDamage; -void(vector org, float damage) SpawnBlood; -void() SuperDamageSound; - +void (entity bomb, entity attacker, float rad, entity ignore, string dtype) + T_RadiusDamage; +void (vector org, float damage) SpawnBlood; +void () SuperDamageSound; // called by worldspawn void() W_Precache = @@ -24,74 +22,48 @@ void() W_Precache = precache_sound ("weapons/shotgn2.wav"); // super shotgun }; -float() crandom = -{ - return 2*(random() - 0.5); -}; - -/* -================ -W_FireAxe -================ -*/ void() W_FireAxe = { - local vector source; - local vector org; + local vector org, source; makevectors (self.v_angle); source = self.origin + '0 0 16'; - traceline (source, source + v_forward*64, FALSE, self); + traceline (source, source + v_forward * 64, FALSE, self); if (trace_fraction == 1.0) return; org = trace_endpos - v_forward*4; - if (trace_ent.takedamage) - { + if (trace_ent.takedamage) { trace_ent.axhitme = 1; SpawnBlood (org, 20); if (deathmatch > 3) T_Damage (trace_ent, self, self, 75); else T_Damage (trace_ent, self, self, 20); - } - else - { // hit wall + } else { // hit wall sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM); - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_GUNSHOT); - WriteByte (MSG_MULTICAST, 3); - WriteCoord (MSG_MULTICAST, org_x); - WriteCoord (MSG_MULTICAST, org_y); - WriteCoord (MSG_MULTICAST, org_z); + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_GUNSHOT, 3.0); + WriteCoordV (MSG_MULTICAST, org); multicast (org, MULTICAST_PVS); } }; - //============================================================================ - vector() wall_velocity = { - local vector vel; - + 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; + vel = normalize (vel + v_up * (random () - 0.5) + v_right + * (random () - 0.5)); + vel = (vel + 2 * trace_plane_normal) * 200; return vel; }; - -/* -================ -SpawnMeatSpray -================ -*/ void(vector org, vector vel) SpawnMeatSpray = { local entity missile; @@ -104,11 +76,11 @@ void(vector org, vector vel) SpawnMeatSpray = makevectors (self.angles); missile.velocity = vel; - missile.velocity_z = missile.velocity_z + 250 + 50*random(); + missile.velocity_z = missile.velocity_z + 250 + 50 * random (); missile.avelocity = '3000 1000 2000'; - -// set missile duration + + // set missile duration missile.nextthink = time + 1; missile.think = SUB_Remove; @@ -124,12 +96,8 @@ SpawnBlood */ void(vector org, float damage) SpawnBlood = { - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_BLOOD); - WriteByte (MSG_MULTICAST, 1); - WriteCoord (MSG_MULTICAST, org_x); - WriteCoord (MSG_MULTICAST, org_y); - WriteCoord (MSG_MULTICAST, org_z); + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_BLOOD, 1.0); + WriteCoordV (MSG_MULTICAST, org); multicast (org, MULTICAST_PVS); }; @@ -143,28 +111,22 @@ void(float damage) spawn_touchblood = local vector vel; vel = wall_velocity () * 0.2; - SpawnBlood (self.origin + vel*0.01, damage); + SpawnBlood (self.origin + vel * 0.01, damage); }; /* ============================================================================== - MULTI-DAMAGE Collects multiple small damages into a single damage - ============================================================================== */ - entity multi_ent; float multi_damage; - vector blood_org; float blood_count; - vector puff_org; float puff_count; - void() ClearMultiDamage = { multi_ent = world; @@ -185,70 +147,46 @@ void(entity hit, float damage) AddMultiDamage = if (!hit) return; - if (hit != multi_ent) - { + if (hit != multi_ent) { ApplyMultiDamage (); multi_damage = damage; multi_ent = hit; - } - else + } else multi_damage = multi_damage + damage; }; void() Multi_Finish = { - if (puff_count) - { - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_GUNSHOT); - WriteByte (MSG_MULTICAST, puff_count); - WriteCoord (MSG_MULTICAST, puff_org_x); - WriteCoord (MSG_MULTICAST, puff_org_y); - WriteCoord (MSG_MULTICAST, puff_org_z); + if (puff_count) { + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_GUNSHOT, puff_count); + WriteCoordV (MSG_MULTICAST, puff_org); multicast (puff_org, MULTICAST_PVS); } - if (blood_count) - { - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_BLOOD); - WriteByte (MSG_MULTICAST, blood_count); - WriteCoord (MSG_MULTICAST, blood_org_x); - WriteCoord (MSG_MULTICAST, blood_org_y); - WriteCoord (MSG_MULTICAST, blood_org_z); + if (blood_count) { + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_BLOOD, blood_count); + WriteCoordV (MSG_MULTICAST, blood_org); multicast (puff_org, MULTICAST_PVS); } }; -/* -============================================================================== -BULLETS -============================================================================== -*/ +// BULLETS ==================================================================== -/* -================ -TraceAttack -================ -*/ void(float damage, vector dir) TraceAttack = { - local vector vel, org; + local vector org, vel; - vel = normalize(dir + v_up*crandom() + v_right*crandom()); - vel = vel + 2*trace_plane_normal; - vel = vel * 200; + vel = normalize (dir + 2 * (v_up * (random () - 0.5) + + v_right * (random () - 0.5))); + vel = (vel + 2 * trace_plane_normal) * 200; org = trace_endpos - dir*4; - if (trace_ent.takedamage) - { + if (trace_ent.takedamage) { blood_count = blood_count + 1; blood_org = org; AddMultiDamage (trace_ent, damage); - } - else - { + } else { puff_count = puff_count + 1; } }; @@ -263,23 +201,22 @@ 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; + local vector direction, src; - makevectors(self.v_angle); + makevectors (self.v_angle); - src = self.origin + v_forward*10; + src = self.origin + v_forward * 10; src_z = self.absmin_z + self.size_z * 0.7; ClearMultiDamage (); - traceline (src, src + dir*2048, FALSE, self); - puff_org = trace_endpos - dir*4; + traceline (src, src + dir * 2048, FALSE, self); + puff_org = trace_endpos - dir * 4; - while (shotcount > 0) - { - direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up; - traceline (src, src + direction*2048, FALSE, self); + while (shotcount > 0) { + direction = dir + 2 * (spread_x * v_right * (random () - 0.5) + + spread_y * v_up * (random () - 0.5)); + traceline (src, src + direction * 2048, FALSE, self); if (trace_fraction != 1.0) TraceAttack (4, direction); @@ -310,7 +247,6 @@ void() W_FireShotgun = FireBullets (6, dir, '0.04 0.04 0'); }; - /* ================ W_FireSuperShotgun @@ -320,8 +256,7 @@ void() W_FireSuperShotgun = { local vector dir; - if (self.currentammo == 1) - { + if (self.currentammo == 1) { W_FireShotgun (); return; } @@ -337,89 +272,63 @@ void() W_FireSuperShotgun = FireBullets (14, dir, '0.14 0.08 0'); }; - -/* -============================================================================== - -ROCKETS - -============================================================================== -*/ +// ROCKETS ==================================================================== void() T_MissileTouch = { local float damg; -// if (deathmatch == 4) -// { -// if ( ((other.weapon == 32) || (other.weapon == 16))) -// { -// if (random() < 0.1) -// { -// if (other != world) -// { -// // bprint (PRINT_HIGH, "Got here\n"); +// if (deathmatch == 4) { +// if ( ((other.weapon == 32) || (other.weapon == 16))) { +// if (random () < 0.1) { +// if (other != world) { +// bprint (PRINT_HIGH, "Got here\n"); // other.deathtype = "blaze"; // T_Damage (other, self, self.owner, 1000 ); // T_RadiusDamage (self, self.owner, 1000, other); // } // } -// } +// } // } if (other == self.owner) return; // don't explode on owner - if (self.voided) { + if (self.voided) return; - } self.voided = 1; - if (pointcontents(self.origin) == CONTENT_SKY) - { - remove(self); + if (pointcontents (self.origin) == CONTENT_SKY) { + remove (self); return; } - damg = 100 + random()*20; + damg = 100 + random () * 20; - if (other.health) - { + if (other.health) { other.deathtype = "rocket"; - T_Damage (other, self, self.owner, damg ); + 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, "rocket"); -// sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM); +// sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM); self.origin = self.origin - 8 * normalize(self.velocity); - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_EXPLOSION); - WriteCoord (MSG_MULTICAST, self.origin_x); - WriteCoord (MSG_MULTICAST, self.origin_y); - WriteCoord (MSG_MULTICAST, self.origin_z); + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_EXPLOSION); + WriteCoordV (MSG_MULTICAST, self.origin); multicast (self.origin, MULTICAST_PHS); remove(self); }; - - -/* -================ -W_FireRocket -================ -*/ void() W_FireRocket = { if (deathmatch != 4) self.currentammo = self.ammo_rockets = self.ammo_rockets - 1; - + sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM); msg_entity = self; @@ -429,18 +338,16 @@ void() W_FireRocket = newmis.owner = self; newmis.movetype = MOVETYPE_FLYMISSILE; newmis.solid = SOLID_BBOX; - -// set newmis speed + // set newmis speed makevectors (self.v_angle); - newmis.velocity = aim(self, 1000); + newmis.velocity = aim (self, 1000); newmis.velocity = newmis.velocity * 1000; - newmis.angles = vectoangles(newmis.velocity); - + newmis.angles = vectoangles (newmis.velocity); newmis.touch = T_MissileTouch; newmis.voided = 0; - -// set newmis duration + + // set newmis duration newmis.nextthink = time + 5; newmis.think = SUB_Remove; newmis.classname = "rocket"; @@ -450,50 +357,36 @@ void() W_FireRocket = setorigin (newmis, self.origin + v_forward*8 + '0 0 16'); }; -/* -=============================================================================== -LIGHTNING -=============================================================================== -*/ +// LIGHTNING ================================================================== void(entity from, float damage) LightningHit = { - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_LIGHTNINGBLOOD); - WriteCoord (MSG_MULTICAST, trace_endpos_x); - WriteCoord (MSG_MULTICAST, trace_endpos_y); - WriteCoord (MSG_MULTICAST, trace_endpos_z); + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_LIGHTNINGBLOOD); + WriteCoordV (MSG_MULTICAST, trace_endpos); multicast (trace_endpos, MULTICAST_PVS); T_Damage (trace_ent, from, from, damage); }; -/* -================= -LightningDamage -================= -*/ void(vector p1, vector p2, entity from, float damage) LightningDamage = { - local entity e1, e2; - local vector f; + 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; + f = f * 16; e1 = e2 = world; traceline (p1, p2, FALSE, self); - if (trace_ent.takedamage) - { + if (trace_ent.takedamage) { LightningHit (from, damage); - if (self.classname == "player") - { + if (self.classname == "player") { if (other.classname == "player") trace_ent.velocity_z = trace_ent.velocity_z + 400; } @@ -502,62 +395,48 @@ void(vector p1, vector p2, entity from, float damage) LightningDamage = traceline (p1 + f, p2 + f, FALSE, self); if (trace_ent != e1 && trace_ent.takedamage) - { LightningHit (from, damage); - } e2 = trace_ent; traceline (p1 - f, p2 - f, FALSE, self); if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage) - { LightningHit (from, damage); - } }; - void() W_FireLightning = { - local vector org; - local float cells; + local vector org; + local float cells; - if (self.ammo_cells < 1) - { + if (self.ammo_cells < 1) { self.weapon = W_BestWeapon (); W_SetCurrentAmmo (); return; } -// explode if under water - if (self.waterlevel > 1) - { - if (deathmatch > 3) - { - if (random() <= 0.5) - { + // explode if under water + if (self.waterlevel > 1) { + if (deathmatch > 3) { + if (random () <= 0.5) { self.deathtype = "selfwater"; - T_Damage (self, self, self.owner, 4000 ); - } - else - { + T_Damage (self, self, self.owner, 4000); + } else { cells = self.ammo_cells; self.ammo_cells = 0; W_SetCurrentAmmo (); - T_RadiusDamage (self, self, 35*cells, world, ""); + T_RadiusDamage (self, self, 35 * cells, world, ""); return; } - } - else - { + } else { cells = self.ammo_cells; self.ammo_cells = 0; W_SetCurrentAmmo (); - T_RadiusDamage (self, self, 35*cells, world,""); + T_RadiusDamage (self, self, 35 * cells, world, ""); return; } } - if (self.t_width < time) - { + if (self.t_width < time) { sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM); self.t_width = time + 0.6; } @@ -569,40 +448,29 @@ void() W_FireLightning = org = self.origin + '0 0 16'; - traceline (org, org + v_forward*600, TRUE, self); + traceline (org, org + v_forward * 600, TRUE, self); - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_LIGHTNING2); + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_LIGHTNING2); WriteEntity (MSG_MULTICAST, self); - WriteCoord (MSG_MULTICAST, org_x); - WriteCoord (MSG_MULTICAST, org_y); - WriteCoord (MSG_MULTICAST, org_z); - WriteCoord (MSG_MULTICAST, trace_endpos_x); - WriteCoord (MSG_MULTICAST, trace_endpos_y); - WriteCoord (MSG_MULTICAST, trace_endpos_z); + WriteCoordV (MSG_MULTICAST, org); + WriteCoordV (MSG_MULTICAST, trace_endpos); multicast (org, MULTICAST_PHS); - LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30); + LightningDamage (self.origin, trace_endpos + v_forward * 4, self, 30); }; - //============================================================================= - void() GrenadeExplode = { - if (self.voided) { + if (self.voided) return; - } self.voided = 1; T_RadiusDamage (self, self.owner, 120, world, "grenade"); - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_EXPLOSION); - WriteCoord (MSG_MULTICAST, self.origin_x); - WriteCoord (MSG_MULTICAST, self.origin_y); - WriteCoord (MSG_MULTICAST, self.origin_z); + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_EXPLOSION); + WriteCoordV (MSG_MULTICAST, self.origin); multicast (self.origin, MULTICAST_PHS); remove (self); @@ -612,23 +480,17 @@ void() GrenadeTouch = { if (other == self.owner) return; // don't explode on owner - if (other.takedamage == DAMAGE_AIM) - { + if (other.takedamage == DAMAGE_AIM) { GrenadeExplode(); return; } - sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound + 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 = -{ +{ if (deathmatch != 4) self.currentammo = self.ammo_rockets = self.ammo_rockets - 1; @@ -638,56 +500,50 @@ void() W_FireGrenade = WriteByte (MSG_ONE, SVC_SMALLKICK); newmis = spawn (); - newmis.voided=0; + newmis.voided = 0; newmis.owner = self; newmis.movetype = MOVETYPE_BOUNCE; newmis.solid = SOLID_BBOX; newmis.classname = "grenade"; - -// set newmis speed + // set newmis speed makevectors (self.v_angle); if (self.v_angle_x) - newmis.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10; - else - { - newmis.velocity = aim(self, 10000); + newmis.velocity = v_forward * 600 + v_up * 200 + + 20 * (v_right * (random () - 0.5) + v_up * (random () - 0.5)); + else { + newmis.velocity = aim (self, 10000); newmis.velocity = newmis.velocity * 600; newmis.velocity_z = 200; } newmis.avelocity = '300 300 300'; - newmis.angles = vectoangles(newmis.velocity); - + newmis.angles = vectoangles (newmis.velocity); + newmis.touch = GrenadeTouch; - -// set newmis duration - if (deathmatch == 4) - { - newmis.nextthink = time + 2.5; + + // set newmis duration + if (deathmatch == 4) { + newmis.nextthink = time + 2.5; self.attack_finished = time + 1.1; -// self.health = self.health - 1; - T_Damage (self, self, self.owner, 10 ); - } - else + T_Damage (self, self, self.owner, 10); + } else newmis.nextthink = time + 2.5; newmis.think = GrenadeExplode; setmodel (newmis, "progs/grenade.mdl"); - setsize (newmis, '0 0 0', '0 0 0'); + setsize (newmis, '0 0 0', '0 0 0'); setorigin (newmis, self.origin); }; - //============================================================================= void() spike_touch; void() superspike_touch; - /* =============== launch_spike @@ -739,14 +595,12 @@ void(float ox) W_FireSpikes = makevectors (self.v_angle); - if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN) - { + if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN) { W_FireSuperSpikes (); return; } - if (self.ammo_nails < 1) - { + if (self.ammo_nails < 1) { self.weapon = W_BestWeapon (); W_SetCurrentAmmo (); return; @@ -757,58 +611,55 @@ void(float ox) W_FireSpikes = if (deathmatch != 4) self.currentammo = self.ammo_nails = self.ammo_nails - 1; dir = aim (self, 1000); - launch_spike (self.origin + '0 0 16' + v_right*ox, dir); + launch_spike (self.origin + '0 0 16' + v_right * ox, dir); msg_entity = self; WriteByte (MSG_ONE, SVC_SMALLKICK); }; - - .float hit_z; void() spike_touch = { if (other == self.owner) return; - if (self.voided) { + if (self.voided) return; - } self.voided = 1; if (other.solid == SOLID_TRIGGER) return; // trigger field, do nothing - if (pointcontents(self.origin) == CONTENT_SKY) - { + if (pointcontents(self.origin) == CONTENT_SKY) { remove(self); return; } - -// hit something that bleeds - if (other.takedamage) - { + + // hit something that bleeds + if (other.takedamage) { spawn_touchblood (9); other.deathtype = "nail"; T_Damage (other, self, self.owner, 9); - } - else - { - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - if (self.classname == "wizspike") - WriteByte (MSG_MULTICAST, TE_WIZSPIKE); - else if (self.classname == "knightspike") - WriteByte (MSG_MULTICAST, TE_KNIGHTSPIKE); - else - WriteByte (MSG_MULTICAST, TE_SPIKE); - WriteCoord (MSG_MULTICAST, self.origin_x); - WriteCoord (MSG_MULTICAST, self.origin_y); - WriteCoord (MSG_MULTICAST, self.origin_z); + } else { + local float foo = TE_SPIKE; + + switch (self.classname) { + case "wizspike": + foo = TE_WIZSPIKE; + break; + case "knightspike": + foo = TE_KNIGHTSPIKE; + break; + default: +// foo = TE_SPIKE; + break; + } + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, foo); + WriteCoordV (MSG_MULTICAST, self.origin); multicast (self.origin, MULTICAST_PHS); } - remove(self); - + remove (self); }; void() superspike_touch = @@ -816,145 +667,118 @@ void() superspike_touch = if (other == self.owner) return; - if (self.voided) { + if (self.voided) return; - } self.voided = 1; - if (other.solid == SOLID_TRIGGER) return; // trigger field, do nothing - if (pointcontents(self.origin) == CONTENT_SKY) - { + if (pointcontents (self.origin) == CONTENT_SKY) { remove(self); return; } - -// hit something that bleeds - if (other.takedamage) - { + + // hit something that bleeds + if (other.takedamage) { spawn_touchblood (18); other.deathtype = "supernail"; T_Damage (other, self, self.owner, 18); - } - else - { - WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); - WriteByte (MSG_MULTICAST, TE_SUPERSPIKE); - WriteCoord (MSG_MULTICAST, self.origin_x); - WriteCoord (MSG_MULTICAST, self.origin_y); - WriteCoord (MSG_MULTICAST, self.origin_z); + } else { + WriteBytes (MSG_MULTICAST, SVC_TEMPENTITY, TE_SUPERSPIKE); + WriteCoordV (MSG_MULTICAST, self.origin); multicast (self.origin, MULTICAST_PHS); } - remove(self); - + remove (self); }; - -/* -=============================================================================== - -PLAYER WEAPON USE - -=============================================================================== -*/ +// 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) ); + self.items = self.items - (self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS)); - if (self.weapon == IT_AXE) - { + switch (self.weapon) { + case IT_AXE: self.currentammo = 0; self.weaponmodel = "progs/v_axe.mdl"; self.weaponframe = 0; - } - else if (self.weapon == IT_SHOTGUN) - { + break; + case 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) - { + break; + case 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) - { + break; + case 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) - { + break; + case IT_SUPER_NAILGUN: self.currentammo = self.ammo_nails; self.weaponmodel = "progs/v_nail2.mdl"; self.weaponframe = 0; self.items = self.items | IT_NAILS; - } - else if (self.weapon == IT_GRENADE_LAUNCHER) - { + break; + case 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) - { + break; + case 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) - { + break; + case IT_LIGHTNING: self.currentammo = self.ammo_cells; self.weaponmodel = "progs/v_light.mdl"; self.weaponframe = 0; self.items = self.items | IT_CELLS; - } - else - { + break; + default: self.currentammo = 0; self.weaponmodel = ""; self.weaponframe = 0; + break; } }; float() W_BestWeapon = { - local float it; + local float it; it = self.items; - if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & IT_LIGHTNING) ) + if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & IT_LIGHTNING)) return IT_LIGHTNING; - else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) ) + else if (self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN)) return IT_SUPER_NAILGUN; - else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) ) + else if (self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN)) return IT_SUPER_SHOTGUN; - else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) ) + else if (self.ammo_nails >= 1 && (it & IT_NAILGUN)) return IT_NAILGUN; - else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) ) + else if (self.ammo_shells >= 1 && (it & IT_SHOTGUN)) return IT_SHOTGUN; - /* - if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) ) + if (self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER)) return IT_ROCKET_LAUNCHER; - else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) ) + else if (self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER)) return IT_GRENADE_LAUNCHER; - */ - return IT_AXE; }; @@ -962,15 +786,14 @@ 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 + + // drop the weapon down return FALSE; }; @@ -992,175 +815,79 @@ void() player_rocket1; void() W_Attack = { - local float r; + local float r; if (!W_CheckNoAmmo ()) return; - makevectors (self.v_angle); // calculate forward angle for velocity + makevectors (self.v_angle); // calculate forward angle for velocity self.show_hostile = time + 1; // wake monsters up - if (self.weapon == IT_AXE) - { + switch (self.weapon) { + case IT_AXE: self.attack_finished = time + 0.5; sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM); - r = random(); + r = random (); if (r < 0.25) player_axe1 (); - else if (r<0.5) + else if (r < 0.5) player_axeb1 (); - else if (r<0.75) + else if (r < 0.75) player_axec1 (); else player_axed1 (); - } - else if (self.weapon == IT_SHOTGUN) - { + break; + case IT_SHOTGUN: player_shot1 (); self.attack_finished = time + 0.5; W_FireShotgun (); - } - else if (self.weapon == IT_SUPER_SHOTGUN) - { + break; + case IT_SUPER_SHOTGUN: player_shot1 (); self.attack_finished = time + 0.7; W_FireSuperShotgun (); - } - else if (self.weapon == IT_NAILGUN) - { + break; + case IT_NAILGUN: player_nail1 (); - } - else if (self.weapon == IT_SUPER_NAILGUN) - { + break; + case IT_SUPER_NAILGUN: player_nail1 (); - } - else if (self.weapon == IT_GRENADE_LAUNCHER) - { - player_rocket1(); + break; + case IT_GRENADE_LAUNCHER: + player_rocket1 (); self.attack_finished = time + 0.6; - W_FireGrenade(); - } - else if (self.weapon == IT_ROCKET_LAUNCHER) - { - player_rocket1(); + W_FireGrenade (); + break; + case IT_ROCKET_LAUNCHER: + player_rocket1 (); self.attack_finished = time + 0.8; - W_FireRocket(); - } - else if (self.weapon == IT_LIGHTNING) - { + W_FireRocket (); + break; + case IT_LIGHTNING: self.attack_finished = time + 0.1; sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM); - player_light1(); + player_light1 (); + break; } }; -/* -============ -W_ChangeWeapon - -============ -*/ -void() W_ChangeWeapon = -{ - local float it, am, fl = 0; - - it = self.items; - am = 0; - - if (self.impulse == 1) - { - fl = IT_AXE; - } - else if (self.impulse == 2) - { - fl = IT_SHOTGUN; - if (self.ammo_shells < 1) - am = 1; - } - else if (self.impulse == 3) - { - fl = IT_SUPER_SHOTGUN; - if (self.ammo_shells < 2) - am = 1; - } - else if (self.impulse == 4) - { - fl = IT_NAILGUN; - if (self.ammo_nails < 1) - am = 1; - } - else if (self.impulse == 5) - { - fl = IT_SUPER_NAILGUN; - if (self.ammo_nails < 2) - am = 1; - } - else if (self.impulse == 6) - { - fl = IT_GRENADE_LAUNCHER; - if (self.ammo_rockets < 1) - am = 1; - } - else if (self.impulse == 7) - { - fl = IT_ROCKET_LAUNCHER; - if (self.ammo_rockets < 1) - am = 1; - } - else if (self.impulse == 8) - { - fl = IT_LIGHTNING; - if (self.ammo_cells < 1) - am = 1; - } - - self.impulse = 0; - - if (!(self.items & fl)) - { // don't have the weapon or the ammo - sprint (self, PRINT_HIGH, "no weapon.\n"); - return; - } - - if (am) - { // don't have the ammo - sprint (self, PRINT_HIGH, "not enough ammo.\n"); - return; - } - -// -// set weapon, set ammo -// - self.weapon = fl; - W_SetCurrentAmmo (); -}; - -/* -============ -CheatCommand -============ -*/ void() CheatCommand = { if (deathmatch || coop) return; + self.ammo_cells = 200; self.ammo_rockets = 100; self.ammo_nails = 200; self.ammo_shells = 100; - self.items = self.items | + self.items = self.items | IT_AXE | - IT_SHOTGUN | - IT_SUPER_SHOTGUN | - IT_NAILGUN | - IT_SUPER_NAILGUN | - IT_GRENADE_LAUNCHER | - IT_ROCKET_LAUNCHER | + IT_SHOTGUN | IT_SUPER_SHOTGUN | + IT_NAILGUN | IT_SUPER_NAILGUN | + IT_GRENADE_LAUNCHER | IT_ROCKET_LAUNCHER | + IT_LIGHTNING | IT_KEY1 | IT_KEY2; - self.ammo_cells = 200; - self.items = self.items | IT_LIGHTNING; - self.weapon = IT_ROCKET_LAUNCHER; self.impulse = 0; W_SetCurrentAmmo (); @@ -1175,72 +902,62 @@ Go to the next weapon with ammo */ void() CycleWeaponCommand = { - local float it, am; + local float it, am; it = self.items; self.impulse = 0; - while (1) - { + while (1) { am = 0; - if (self.weapon == IT_LIGHTNING) - { + switch (self.weapon) { + case IT_LIGHTNING: self.weapon = IT_AXE; - } - else if (self.weapon == IT_AXE) - { + break; + case IT_AXE: self.weapon = IT_SHOTGUN; if (self.ammo_shells < 1) am = 1; - } - else if (self.weapon == IT_SHOTGUN) - { + break; + case IT_SHOTGUN: self.weapon = IT_SUPER_SHOTGUN; if (self.ammo_shells < 2) am = 1; - } - else if (self.weapon == IT_SUPER_SHOTGUN) - { + break; + case IT_SUPER_SHOTGUN: self.weapon = IT_NAILGUN; if (self.ammo_nails < 1) am = 1; - } - else if (self.weapon == IT_NAILGUN) - { + break; + case IT_NAILGUN: self.weapon = IT_SUPER_NAILGUN; if (self.ammo_nails < 2) am = 1; - } - else if (self.weapon == IT_SUPER_NAILGUN) - { + break; + case IT_SUPER_NAILGUN: self.weapon = IT_GRENADE_LAUNCHER; if (self.ammo_rockets < 1) am = 1; - } - else if (self.weapon == IT_GRENADE_LAUNCHER) - { + break; + case IT_GRENADE_LAUNCHER: self.weapon = IT_ROCKET_LAUNCHER; if (self.ammo_rockets < 1) am = 1; - } - else if (self.weapon == IT_ROCKET_LAUNCHER) - { + break; + case IT_ROCKET_LAUNCHER: self.weapon = IT_LIGHTNING; if (self.ammo_cells < 1) am = 1; + break; } - if ( (self.items & self.weapon) && am == 0) - { + if ((self.items & self.weapon) && am == 0) { W_SetCurrentAmmo (); return; } } - }; - /* ============ CycleWeaponReverseCommand @@ -1250,72 +967,62 @@ Go to the prev weapon with ammo */ void() CycleWeaponReverseCommand = { - local float it, am; + local float it, am; it = self.items; self.impulse = 0; - while (1) - { + while (1) { am = 0; - if (self.weapon == IT_LIGHTNING) - { + switch (self.weapon) { + case IT_LIGHTNING: self.weapon = IT_ROCKET_LAUNCHER; if (self.ammo_rockets < 1) am = 1; - } - else if (self.weapon == IT_ROCKET_LAUNCHER) - { + break; + case IT_ROCKET_LAUNCHER: self.weapon = IT_GRENADE_LAUNCHER; if (self.ammo_rockets < 1) am = 1; - } - else if (self.weapon == IT_GRENADE_LAUNCHER) - { + break; + case IT_GRENADE_LAUNCHER: self.weapon = IT_SUPER_NAILGUN; if (self.ammo_nails < 2) am = 1; - } - else if (self.weapon == IT_SUPER_NAILGUN) - { + break; + case IT_SUPER_NAILGUN: self.weapon = IT_NAILGUN; if (self.ammo_nails < 1) am = 1; - } - else if (self.weapon == IT_NAILGUN) - { + break; + case IT_NAILGUN: self.weapon = IT_SUPER_SHOTGUN; if (self.ammo_shells < 2) am = 1; - } - else if (self.weapon == IT_SUPER_SHOTGUN) - { + break; + case IT_SUPER_SHOTGUN: self.weapon = IT_SHOTGUN; if (self.ammo_shells < 1) am = 1; - } - else if (self.weapon == IT_SHOTGUN) - { + break; + case IT_SHOTGUN: self.weapon = IT_AXE; - } - else if (self.weapon == IT_AXE) - { + break; + case IT_AXE: self.weapon = IT_LIGHTNING; if (self.ammo_cells < 1) am = 1; + break; } - if ( (it & self.weapon) && am == 0) - { + if ((it & self.weapon) && am == 0) { W_SetCurrentAmmo (); return; } } - }; - /* ============ ServerflagsCommand @@ -1328,28 +1035,82 @@ void() ServerflagsCommand = serverflags = serverflags * 2 + 1; }; - -/* -============ -ImpulseCommands - -============ -*/ void() ImpulseCommands = { - if (self.impulse >= 1 && self.impulse <= 8) - W_ChangeWeapon (); + local float it, am, fl = 0; + + it = self.items; + am = 0; - if (self.impulse == 9) + switch (self.impulse) { + case 1: + fl = IT_AXE; + break; + case 2: + fl = IT_SHOTGUN; + if (self.ammo_shells < 1) + am = 1; + break; + case 3: + fl = IT_SUPER_SHOTGUN; + if (self.ammo_shells < 2) + am = 1; + break; + case 4: + fl = IT_NAILGUN; + if (self.ammo_nails < 1) + am = 1; + break; + case 5: + fl = IT_SUPER_NAILGUN; + if (self.ammo_nails < 2) + am = 1; + break; + case 6: + fl = IT_GRENADE_LAUNCHER; + if (self.ammo_rockets < 1) + am = 1; + break; + case 7: + fl = IT_ROCKET_LAUNCHER; + if (self.ammo_rockets < 1) + am = 1; + break; + case 8: + fl = IT_LIGHTNING; + if (self.ammo_cells < 1) + am = 1; + break; + case 9: CheatCommand (); - if (self.impulse == 10) + break; + case 10: CycleWeaponCommand (); - if (self.impulse == 11) + break; + case 11: ServerflagsCommand (); - if (self.impulse == 12) + break; + case 12: CycleWeaponReverseCommand (); - + break; + default: + break; + } self.impulse = 0; + + if (!(self.items & fl)) { // don't have the weapon or the ammo + sprint (self, PRINT_HIGH, "no weapon.\n"); + return; + } + + if (am) { // don't have the ammo + sprint (self, PRINT_HIGH, "not enough ammo.\n"); + return; + } + + // set weapon, set ammo + self.weapon = fl; + W_SetCurrentAmmo (); }; /* @@ -1365,10 +1126,9 @@ void() W_WeaponFrame = return; ImpulseCommands (); - -// check for attack - if (self.button0) - { + + // check for attack + if (self.button0) { SuperDamageSound (); W_Attack (); } @@ -1383,15 +1143,11 @@ Plays sound if needed */ void() SuperDamageSound = { - if (self.super_damage_finished > time) - { - if (self.super_sound < time) - { + 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; }; - - diff --git a/nqw/wizard.qc b/nqw/wizard.qc index ce60707..9b7eaaf 100644 --- a/nqw/wizard.qc +++ b/nqw/wizard.qc @@ -26,7 +26,6 @@ $frame death1 death2 death3 death4 death5 death6 death7 death8 /* ============================================================================== - WIZARD If the player moves behind cover before the missile is launched, launch it @@ -46,61 +45,55 @@ if self.enemy maintains it's current velocity */ void(entity missile, float mspeed, float accuracy) LaunchMissile = { - local vector vec, move; - local float fly; + local float fly; + local vector vec, move; makevectors (self.angles); - -// set missile speed - vec = self.enemy.origin + self.enemy.mins + self.enemy.size * 0.7 - missile.origin; -// calc aproximate time for missile to reach vec + // set missile speed + vec = self.enemy.origin + self.enemy.mins + self.enemy.size * 0.7 + - missile.origin; + + // calc aproximate time for missile to reach vec fly = vlen (vec) / mspeed; - -// get the entities xy velocity + + // get the entities xy velocity move = self.enemy.velocity; move_z = 0; -// project the target forward in time + // project the target forward in time vec = vec + move * fly; - vec = normalize(vec); - vec = vec + accuracy*v_up*(random()- 0.5) + accuracy*v_right*(random()- 0.5); + vec = normalize (vec); + vec = vec + (2 * accuracy) * (v_up * (random () - 0.5) + v_right + * (random () - 0.5)); missile.velocity = vec * mspeed; missile.angles = '0 0 0'; - missile.angles_y = vectoyaw(missile.velocity); + missile.angles_y = vectoyaw (missile.velocity); -// set missile duration + // set missile duration missile.nextthink = time + 5; missile.think = SUB_Remove; }; - void() wiz_run1; void() wiz_side1; -/* -================= -WizardCheckAttack -================= -*/ float() WizardCheckAttack = { - local vector spot1, spot2; local entity targ; local float chance; + local vector spot1, spot2; if (time < self.attack_finished) return FALSE; if (!enemy_vis) return FALSE; - if (enemy_range == RANGE_FAR) - { - if (self.attack_state != AS_STRAIGHT) - { + if (enemy_range == RANGE_FAR) { + if (self.attack_state != AS_STRAIGHT) { self.attack_state = AS_STRAIGHT; wiz_run1 (); } @@ -108,50 +101,48 @@ float() WizardCheckAttack = } targ = self.enemy; - -// see if any entities are in the way of the shot + + // see if any entities are in the way of the shot spot1 = self.origin + self.view_ofs; spot2 = targ.origin + targ.view_ofs; traceline (spot1, spot2, FALSE, self); - if (trace_ent != targ) - { // don't have a clear shot, so move to a side - if (self.attack_state != AS_STRAIGHT) - { + if (trace_ent != targ) { // don't have a clear shot, so move to a side + if (self.attack_state != AS_STRAIGHT) { self.attack_state = AS_STRAIGHT; wiz_run1 (); } return FALSE; } - if (enemy_range == RANGE_MELEE) + switch (enemy_range) { + case RANGE_MELEE: chance = 0.9; - else if (enemy_range == RANGE_NEAR) + break; + case RANGE_NEAR: chance = 0.6; - else if (enemy_range == RANGE_MID) + break; + case RANGE_MID: chance = 0.2; - else + break; + default: + case RANGE_FAR: chance = 0; + } - if (random () < chance) - { + if (random () < chance) { self.attack_state = AS_MISSILE; return TRUE; } - if (enemy_range == RANGE_MID) - { - if (self.attack_state != AS_STRAIGHT) - { + if (enemy_range == RANGE_MID) { + if (self.attack_state != AS_STRAIGHT) { self.attack_state = AS_STRAIGHT; wiz_run1 (); } - } - else - { - if (self.attack_state != AS_SLIDING) - { + } else { + if (self.attack_state != AS_SLIDING) { self.attack_state = AS_SLIDING; wiz_side1 (); } @@ -160,49 +151,33 @@ float() WizardCheckAttack = return FALSE; }; -/* -================= -WizardAttackFinished -================= -*/ float() WizardAttackFinished = { - if (enemy_range >= RANGE_MID || !enemy_vis) - { + if (enemy_range >= RANGE_MID || !enemy_vis) { self.attack_state = AS_STRAIGHT; self.think = wiz_run1; - } - else - { + } else { self.attack_state = AS_SLIDING; self.think = wiz_side1; } }; -/* -============================================================================== - -FAST ATTACKS - -============================================================================== -*/ +// FAST ATTACKS =============================================================== void() Wiz_FastFire = { - local vector vec; - local vector dst; + local vector dst, vec; - if (self.owner.health > 0) - { + if (self.owner.health > 0) { muzzleflash(); - makevectors (self.enemy.angles); - dst = self.enemy.origin - 13*self.movedir; + makevectors (self.enemy.angles); + dst = self.enemy.origin - 13 * self.movedir; - vec = normalize(dst - self.origin); + vec = normalize (dst - self.origin); sound (self, CHAN_WEAPON, "wizard/wattack.wav", 1, ATTN_NORM); launch_spike (self.origin, vec); - newmis.velocity = vec*600; + newmis.velocity = vec * 600; newmis.owner = self.owner; newmis.classname = "wizspike"; setmodel (newmis, "progs/w_spike.mdl"); @@ -212,10 +187,9 @@ void() Wiz_FastFire = remove (self); }; - void() Wiz_StartFast = { - local entity missile; + local entity missile; sound (self, CHAN_WEAPON, "wizard/wattack.wav", 1, ATTN_NORM); self.v_angle = self.angles; @@ -224,8 +198,9 @@ void() Wiz_StartFast = missile = spawn (); missile.owner = self; missile.nextthink = time + 0.6; - setsize (missile, '0 0 0', '0 0 0'); - setorigin (missile, self.origin + '0 0 30' + v_forward*14 + v_right*14); + setsize (missile, '0 0 0', '0 0 0'); + setorigin (missile, self.origin + '0 0 30' + v_forward * 14 + v_righ + * 14); missile.enemy = self.enemy; missile.nextthink = time + 0.8; missile.think = Wiz_FastFire; @@ -235,26 +210,25 @@ void() Wiz_StartFast = missile.owner = self; missile.nextthink = time + 1; setsize (missile, '0 0 0', '0 0 0'); - setorigin (missile, self.origin + '0 0 30' + v_forward*14 + v_right* -14); + setorigin (missile, self.origin + '0 0 30' + v_forward * 14 + v_right + * -14); missile.enemy = self.enemy; missile.nextthink = time + 0.3; missile.think = Wiz_FastFire; missile.movedir = VEC_ORIGIN - v_right; }; - - void() Wiz_idlesound = { -local float wr; - wr = random() * 5; + local float wr; - if (self.waitmin < time) - { + wr = random () * 5; + + if (self.waitmin < time) { self.waitmin = time + 2; - if (wr > 4.5) + if (wr > 4.5) sound (self, CHAN_VOICE, "wizard/widle1.wav", 1, ATTN_IDLE); - if (wr < 1.5) + else if (wr < 1.5) sound (self, CHAN_VOICE, "wizard/widle2.wav", 1, ATTN_IDLE); } return; @@ -269,8 +243,10 @@ void() wiz_stand6 =[ $hover6, wiz_stand7 ] {ai_stand();}; void() wiz_stand7 =[ $hover7, wiz_stand8 ] {ai_stand();}; void() wiz_stand8 =[ $hover8, wiz_stand1 ] {ai_stand();}; -void() wiz_walk1 =[ $hover1, wiz_walk2 ] {ai_walk(8); -Wiz_idlesound();}; +void() wiz_walk1 =[ $hover1, wiz_walk2 ] { + ai_walk (8); + Wiz_idlesound (); +}; void() wiz_walk2 =[ $hover2, wiz_walk3 ] {ai_walk(8);}; void() wiz_walk3 =[ $hover3, wiz_walk4 ] {ai_walk(8);}; void() wiz_walk4 =[ $hover4, wiz_walk5 ] {ai_walk(8);}; @@ -279,8 +255,10 @@ void() wiz_walk6 =[ $hover6, wiz_walk7 ] {ai_walk(8);}; void() wiz_walk7 =[ $hover7, wiz_walk8 ] {ai_walk(8);}; void() wiz_walk8 =[ $hover8, wiz_walk1 ] {ai_walk(8);}; -void() wiz_side1 =[ $hover1, wiz_side2 ] {ai_run(8); -Wiz_idlesound();}; +void() wiz_side1 =[ $hover1, wiz_side2 ] { + ai_run (8); + Wiz_idlesound (); +}; void() wiz_side2 =[ $hover2, wiz_side3 ] {ai_run(8);}; void() wiz_side3 =[ $hover3, wiz_side4 ] {ai_run(8);}; void() wiz_side4 =[ $hover4, wiz_side5 ] {ai_run(8);}; @@ -289,8 +267,9 @@ void() wiz_side6 =[ $hover6, wiz_side7 ] {ai_run(8);}; void() wiz_side7 =[ $hover7, wiz_side8 ] {ai_run(8);}; void() wiz_side8 =[ $hover8, wiz_side1 ] {ai_run(8);}; -void() wiz_run1 =[ $fly1, wiz_run2 ] {ai_run(16); -Wiz_idlesound(); +void() wiz_run1 =[ $fly1, wiz_run2 ] { + ai_run (16); + Wiz_idlesound (); }; void() wiz_run2 =[ $fly2, wiz_run3 ] {ai_run(16);}; void() wiz_run3 =[ $fly3, wiz_run4 ] {ai_run(16);}; @@ -306,7 +285,10 @@ void() wiz_run12 =[ $fly12, wiz_run13 ] {ai_run(16);}; void() wiz_run13 =[ $fly13, wiz_run14 ] {ai_run(16);}; void() wiz_run14 =[ $fly14, wiz_run1 ] {ai_run(16);}; -void() wiz_fast1 =[ $magatt1, wiz_fast2 ] {ai_face();Wiz_StartFast();}; +void() wiz_fast1 =[ $magatt1, wiz_fast2 ] { + ai_face (); + Wiz_StartFast (); +}; void() wiz_fast2 =[ $magatt2, wiz_fast3 ] {ai_face();}; void() wiz_fast3 =[ $magatt3, wiz_fast4 ] {ai_face();}; void() wiz_fast4 =[ $magatt4, wiz_fast5 ] {ai_face();}; @@ -315,7 +297,11 @@ void() wiz_fast6 =[ $magatt6, wiz_fast7 ] {ai_face();}; void() wiz_fast7 =[ $magatt5, wiz_fast8 ] {ai_face();}; void() wiz_fast8 =[ $magatt4, wiz_fast9 ] {ai_face();}; void() wiz_fast9 =[ $magatt3, wiz_fast10 ] {ai_face();}; -void() wiz_fast10 =[ $magatt2, wiz_run1 ] {ai_face();SUB_AttackFinished(2);WizardAttackFinished ();}; +void() wiz_fast10 =[ $magatt2, wiz_run1 ] { + ai_face (); + SUB_AttackFinished (2); + WizardAttackFinished (); +}; void() wiz_pain1 =[ $pain1, wiz_pain2 ] {}; void() wiz_pain2 =[ $pain2, wiz_pain3 ] {}; @@ -323,12 +309,11 @@ void() wiz_pain3 =[ $pain3, wiz_pain4 ] {}; void() wiz_pain4 =[ $pain4, wiz_run1 ] {}; void() wiz_death1 =[ $death1, wiz_death2 ] { - -self.velocity_x = -200 + 400*random(); -self.velocity_y = -200 + 400*random(); -self.velocity_z = 100 + 100*random(); -self.flags = self.flags - (self.flags & FL_ONGROUND); -sound (self, CHAN_VOICE, "wizard/wdeath.wav", 1, ATTN_NORM); + self.velocity_x = -200 + 400 * random (); + self.velocity_y = -200 + 400 * random (); + self.velocity_z = 100 + 100 * random (); + self.flags = self.flags - (self.flags & FL_ONGROUND); + sound (self, CHAN_VOICE, "wizard/wdeath.wav", 1, ATTN_NORM); }; void() wiz_death2 =[ $death2, wiz_death3 ] {}; void() wiz_death3 =[ $death3, wiz_death4 ]{self.solid = SOLID_NOT;}; @@ -340,9 +325,8 @@ void() wiz_death8 =[ $death8, wiz_death8 ] {}; void() wiz_die = { -// check for gib - if (self.health < -40) - { + // check for gib + if (self.health < -40) { sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); ThrowHead ("progs/h_wizard.mdl", self.health); ThrowGib ("progs/gib2.mdl", self.health); @@ -358,13 +342,12 @@ void() wiz_die = void(entity attacker, float damage) Wiz_Pain = { sound (self, CHAN_VOICE, "wizard/wpain.wav", 1, ATTN_NORM); - if (random()*70 > damage) + if (random () * 70 > damage) return; // didn't flinch wiz_pain1 (); }; - void() Wiz_Missile = { wiz_fast1(); @@ -374,11 +357,11 @@ void() Wiz_Missile = */ void() monster_wizard = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } + precache_model ("progs/wizard.mdl"); precache_model ("progs/h_wizard.mdl"); precache_model ("progs/w_spike.mdl"); diff --git a/nqw/world.qc b/nqw/world.qc index f74fd35..0c03a13 100644 --- a/nqw/world.qc +++ b/nqw/world.qc @@ -1,159 +1,4 @@ - -void() InitBodyQue; - - -void() main = -{ - dprint ("main function\n"); - -// these are just commands the the prog compiler to copy these files - - precache_file ("progs.dat"); - precache_file ("gfx.wad"); - precache_file ("quake.rc"); - precache_file ("default.cfg"); - - precache_file ("end1.bin"); - precache_file2 ("end2.bin"); - - precache_file ("demo1.dem"); - precache_file ("demo2.dem"); - precache_file ("demo3.dem"); - -// -// these are all of the lumps from the cached.ls files -// - precache_file ("gfx/palette.lmp"); - precache_file ("gfx/colormap.lmp"); - - precache_file2 ("gfx/pop.lmp"); - - precache_file ("gfx/complete.lmp"); - precache_file ("gfx/inter.lmp"); - - precache_file ("gfx/ranking.lmp"); - precache_file ("gfx/vidmodes.lmp"); - precache_file ("gfx/finale.lmp"); - precache_file ("gfx/conback.lmp"); - precache_file ("gfx/qplaque.lmp"); - - precache_file ("gfx/menudot1.lmp"); - precache_file ("gfx/menudot2.lmp"); - precache_file ("gfx/menudot3.lmp"); - precache_file ("gfx/menudot4.lmp"); - precache_file ("gfx/menudot5.lmp"); - precache_file ("gfx/menudot6.lmp"); - - precache_file ("gfx/menuplyr.lmp"); - precache_file ("gfx/bigbox.lmp"); - precache_file ("gfx/dim_modm.lmp"); - precache_file ("gfx/dim_drct.lmp"); - precache_file ("gfx/dim_ipx.lmp"); - precache_file ("gfx/dim_tcp.lmp"); - precache_file ("gfx/dim_mult.lmp"); - precache_file ("gfx/mainmenu.lmp"); - - precache_file ("gfx/box_tl.lmp"); - precache_file ("gfx/box_tm.lmp"); - precache_file ("gfx/box_tr.lmp"); - - precache_file ("gfx/box_ml.lmp"); - precache_file ("gfx/box_mm.lmp"); - precache_file ("gfx/box_mm2.lmp"); - precache_file ("gfx/box_mr.lmp"); - - precache_file ("gfx/box_bl.lmp"); - precache_file ("gfx/box_bm.lmp"); - precache_file ("gfx/box_br.lmp"); - - precache_file ("gfx/sp_menu.lmp"); - precache_file ("gfx/ttl_sgl.lmp"); - precache_file ("gfx/ttl_main.lmp"); - precache_file ("gfx/ttl_cstm.lmp"); - - precache_file ("gfx/mp_menu.lmp"); - - precache_file ("gfx/netmen1.lmp"); - precache_file ("gfx/netmen2.lmp"); - precache_file ("gfx/netmen3.lmp"); - precache_file ("gfx/netmen4.lmp"); - precache_file ("gfx/netmen5.lmp"); - - precache_file ("gfx/sell.lmp"); - - precache_file ("gfx/help0.lmp"); - precache_file ("gfx/help1.lmp"); - precache_file ("gfx/help2.lmp"); - precache_file ("gfx/help3.lmp"); - precache_file ("gfx/help4.lmp"); - precache_file ("gfx/help5.lmp"); - - precache_file ("gfx/pause.lmp"); - precache_file ("gfx/loading.lmp"); - - precache_file ("gfx/p_option.lmp"); - precache_file ("gfx/p_load.lmp"); - precache_file ("gfx/p_save.lmp"); - precache_file ("gfx/p_multi.lmp"); - -// sounds loaded by C code - precache_sound ("misc/menu1.wav"); - precache_sound ("misc/menu2.wav"); - precache_sound ("misc/menu3.wav"); - - precache_sound ("ambience/water1.wav"); - precache_sound ("ambience/wind2.wav"); - -// shareware - precache_file ("maps/start.bsp"); - - precache_file ("maps/e1m1.bsp"); - precache_file ("maps/e1m2.bsp"); - precache_file ("maps/e1m3.bsp"); - precache_file ("maps/e1m4.bsp"); - precache_file ("maps/e1m5.bsp"); - precache_file ("maps/e1m6.bsp"); - precache_file ("maps/e1m7.bsp"); - precache_file ("maps/e1m8.bsp"); - -// registered - precache_file2 ("gfx/pop.lmp"); - - precache_file2 ("maps/e2m1.bsp"); - precache_file2 ("maps/e2m2.bsp"); - precache_file2 ("maps/e2m3.bsp"); - precache_file2 ("maps/e2m4.bsp"); - precache_file2 ("maps/e2m5.bsp"); - precache_file2 ("maps/e2m6.bsp"); - precache_file2 ("maps/e2m7.bsp"); - - precache_file2 ("maps/e3m1.bsp"); - precache_file2 ("maps/e3m2.bsp"); - precache_file2 ("maps/e3m3.bsp"); - precache_file2 ("maps/e3m4.bsp"); - precache_file2 ("maps/e3m5.bsp"); - precache_file2 ("maps/e3m6.bsp"); - precache_file2 ("maps/e3m7.bsp"); - - precache_file2 ("maps/e4m1.bsp"); - precache_file2 ("maps/e4m2.bsp"); - precache_file2 ("maps/e4m3.bsp"); - precache_file2 ("maps/e4m4.bsp"); - precache_file2 ("maps/e4m5.bsp"); - precache_file2 ("maps/e4m6.bsp"); - precache_file2 ("maps/e4m7.bsp"); - precache_file2 ("maps/e4m8.bsp"); - - precache_file2 ("maps/end.bsp"); - - precache_file2 ("maps/dm1.bsp"); - precache_file2 ("maps/dm2.bsp"); - precache_file2 ("maps/dm3.bsp"); - precache_file2 ("maps/dm4.bsp"); - precache_file2 ("maps/dm5.bsp"); - precache_file2 ("maps/dm6.bsp"); -}; - +void() InitBodyQueue; entity lastspawn; @@ -172,29 +17,28 @@ World Types: void() worldspawn = { lastspawn = world; - InitBodyQue (); + InitBodyQueue (); -// custom map attributes + // custom map attributes if (self.model == "maps/e1m8.bsp") cvar_set ("sv_gravity", "100"); else cvar_set ("sv_gravity", "800"); + // the area based ambient sounds MUST be the first precache_sounds -// the area based ambient sounds MUST be the first precache_sounds - -// player precaches + // player precaches W_Precache (); // get weapon precaches -// sounds used from C physics code + // sounds used from C physics code precache_sound ("demon/dland2.wav"); // landing thud precache_sound ("misc/h2ohit1.wav"); // landing splash -// setup precaches allways needed + // setup precaches allways needed precache_sound ("items/itembk2.wav"); // item respawn sound precache_sound ("player/plyrjmp8.wav"); // player jump - precache_sound ("player/land.wav"); // player landing + precache_sound ("player/land.wav"); // player landing precache_sound ("player/land2.wav"); // player hurt landing precache_sound ("player/drown1.wav"); // drowning pain precache_sound ("player/drown2.wav"); // drowning pain @@ -202,7 +46,7 @@ void() worldspawn = precache_sound ("player/gasp2.wav"); // taking breath precache_sound ("player/h2odeath.wav"); // drowning death - precache_sound ("misc/talk.wav"); // talk + precache_sound ("misc/talk.wav"); // talk precache_sound ("player/teledth1.wav"); // telefrag precache_sound ("misc/r_tele1.wav"); // teleport sounds precache_sound ("misc/r_tele2.wav"); @@ -216,10 +60,10 @@ void() worldspawn = precache_sound ("weapons/lstart.wav"); //lightning start precache_sound ("items/damage3.wav"); - precache_sound ("misc/power.wav"); //lightning for boss + precache_sound ("misc/power.wav"); //lightning for boss // player gib sounds - precache_sound ("player/gib.wav"); // player gib sound + precache_sound ("player/gib.wav"); // player gib sound precache_sound ("player/udeath.wav"); // player gib sound precache_sound ("player/tornoff2.wav"); // gib sound @@ -241,8 +85,8 @@ void() worldspawn = precache_sound ("boss1/sight1.wav"); -// ax sounds - precache_sound ("weapons/ax1.wav"); // ax swoosh +// ax sounds + precache_sound ("weapons/ax1.wav"); // ax swoosh precache_sound ("player/axhit1.wav"); // ax hit meat precache_sound ("player/axhit2.wav"); // ax hit world @@ -255,8 +99,8 @@ void() worldspawn = precache_sound ("player/lburn1.wav"); // lava burn precache_sound ("player/lburn2.wav"); // lava burn - precache_sound ("misc/water1.wav"); // swimming - precache_sound ("misc/water2.wav"); // swimming + precache_sound ("misc/water1.wav"); // swimming + precache_sound ("misc/water2.wav"); // swimming // Invulnerability sounds precache_sound ("items/protect.wav"); @@ -285,8 +129,8 @@ void() worldspawn = precache_model ("progs/bolt.mdl"); // for lightning gun precache_model ("progs/bolt2.mdl"); // for lightning gun precache_model ("progs/bolt3.mdl"); // for boss shock - precache_model ("progs/lavaball.mdl"); // for testing - + precache_model ("progs/lavaball.mdl"); // for testing + precache_model ("progs/missile.mdl"); precache_model ("progs/grenade.mdl"); precache_model ("progs/spike.mdl"); @@ -297,11 +141,8 @@ void() worldspawn = precache_model ("progs/zom_gib.mdl"); precache_model ("progs/v_light.mdl"); - -// -// Setup light animation tables. 'a' is total darkness, 'z' is maxbright. -// + // Setup light animation tables. 'a' is total darkness, 'z' is maxbright. // 0 normal lightstyle(0, "m"); @@ -366,42 +207,38 @@ BODY QUE ============================================================================== */ -entity bodyque_head; +entity bodyqueue_head; -void() bodyque = -{ // just here so spawn functions don't complain after the world - // creates bodyques -}; - -void() InitBodyQue = +void() bodyqueue = { - bodyque_head = spawn(); - bodyque_head.classname = "bodyque"; - bodyque_head.owner = spawn(); - bodyque_head.owner.classname = "bodyque"; - bodyque_head.owner.owner = spawn(); - bodyque_head.owner.owner.classname = "bodyque"; - bodyque_head.owner.owner.owner = spawn(); - bodyque_head.owner.owner.owner.classname = "bodyque"; - bodyque_head.owner.owner.owner.owner = bodyque_head; +// just here so spawn functions don't complain after world creates bodyqueues }; - -// make a body que entry for the given ent so the ent can be -// respawned elsewhere -void(entity ent) CopyToBodyQue = +void() InitBodyQueue = { - bodyque_head.angles = ent.angles; - bodyque_head.model = ent.model; - bodyque_head.modelindex = ent.modelindex; - bodyque_head.frame = ent.frame; - bodyque_head.colormap = ent.colormap; - bodyque_head.movetype = ent.movetype; - bodyque_head.velocity = ent.velocity; - bodyque_head.flags = 0; - setorigin (bodyque_head, ent.origin); - setsize (bodyque_head, ent.mins, ent.maxs); - bodyque_head = bodyque_head.owner; + bodyqueue_head = spawn(); + bodyqueue_head.classname = "bodyqueue"; + bodyqueue_head.owner = spawn(); + bodyqueue_head.owner.classname = "bodyqueue"; + bodyqueue_head.owner.owner = spawn(); + bodyqueue_head.owner.owner.classname = "bodyqueue"; + bodyqueue_head.owner.owner.owner = spawn(); + bodyqueue_head.owner.owner.owner.classname = "bodyqueue"; + bodyqueue_head.owner.owner.owner.owner = bodyqueue_head; }; - +// make a body queue entry for the given ent so it can be respawned elsewhere +void(entity ent) CopyToBodyQueue = +{ + bodyqueue_head.angles = ent.angles; + bodyqueue_head.model = ent.model; + bodyqueue_head.modelindex = ent.modelindex; + bodyqueue_head.frame = ent.frame; + bodyqueue_head.colormap = ent.colormap; + bodyqueue_head.movetype = ent.movetype; + bodyqueue_head.velocity = ent.velocity; + bodyqueue_head.flags = 0; + setorigin (bodyqueue_head, ent.origin); + setsize (bodyqueue_head, ent.mins, ent.maxs); + bodyqueue_head = bodyqueue_head.owner; +}; diff --git a/nqw/zombie.qc b/nqw/zombie.qc index 62d5ec8..0f64d5b 100644 --- a/nqw/zombie.qc +++ b/nqw/zombie.qc @@ -73,13 +73,24 @@ void() zombie_stand14 =[ $stand14, zombie_stand15 ] {ai_stand();}; void() zombie_stand15 =[ $stand15, zombie_stand1 ] {ai_stand();}; void() zombie_cruc1 = [ $cruc_1, zombie_cruc2 ] { -if (random() < 0.1) - sound (self, CHAN_VOICE, "zombie/idle_w2.wav", 1, ATTN_STATIC);}; -void() zombie_cruc2 = [ $cruc_2, zombie_cruc3 ] {self.nextthink = time + 0.1 + random()*0.1;}; -void() zombie_cruc3 = [ $cruc_3, zombie_cruc4 ] {self.nextthink = time + 0.1 + random()*0.1;}; -void() zombie_cruc4 = [ $cruc_4, zombie_cruc5 ] {self.nextthink = time + 0.1 + random()*0.1;}; -void() zombie_cruc5 = [ $cruc_5, zombie_cruc6 ] {self.nextthink = time + 0.1 + random()*0.1;}; -void() zombie_cruc6 = [ $cruc_6, zombie_cruc1 ] {self.nextthink = time + 0.1 + random()*0.1;}; + if (random () < 0.1) + sound (self, CHAN_VOICE, "zombie/idle_w2.wav", 1, ATTN_STATIC); +}; +void() zombie_cruc2 = [ $cruc_2, zombie_cruc3 ] { + self.nextthink = time + 0.1 + random () * 0.1; +}; +void() zombie_cruc3 = [ $cruc_3, zombie_cruc4 ] { + self.nextthink = time + 0.1 + random () * 0.1; +}; +void() zombie_cruc4 = [ $cruc_4, zombie_cruc5 ] { + self.nextthink = time + 0.1 + random () * 0.1; +}; +void() zombie_cruc5 = [ $cruc_5, zombie_cruc6 ] { + self.nextthink = time + 0.1 + random () * 0.1; +}; +void() zombie_cruc6 = [ $cruc_6, zombie_cruc1 ] { + self.nextthink = time + 0.1 + random () * 0.1; +}; void() zombie_walk1 =[ $walk1, zombie_walk2 ] {ai_walk(0);}; void() zombie_walk2 =[ $walk2, zombie_walk3 ] {ai_walk(2);}; @@ -100,11 +111,15 @@ void() zombie_walk16 =[ $walk16, zombie_walk17 ] {ai_walk(0);}; void() zombie_walk17 =[ $walk17, zombie_walk18 ] {ai_walk(0);}; void() zombie_walk18 =[ $walk18, zombie_walk19 ] {ai_walk(0);}; void() zombie_walk19 =[ $walk19, zombie_walk1 ] { -ai_walk(0); -if (random() < 0.2) - sound (self, CHAN_VOICE, "zombie/z_idle.wav", 1, ATTN_IDLE);}; + ai_walk (0); + if (random () < 0.2) + sound (self, CHAN_VOICE, "zombie/z_idle.wav", 1, ATTN_IDLE); +}; -void() zombie_run1 =[ $run1, zombie_run2 ] {ai_run(1);self.inpain = 0;}; +void() zombie_run1 =[ $run1, zombie_run2 ] { + ai_run (1); + self.inpain = 0; +}; void() zombie_run2 =[ $run2, zombie_run3 ] {ai_run(1);}; void() zombie_run3 =[ $run3, zombie_run4 ] {ai_run(0);}; void() zombie_run4 =[ $run4, zombie_run5 ] {ai_run(1);}; @@ -122,11 +137,11 @@ void() zombie_run15 =[ $run15, zombie_run16 ] {ai_run(6);}; void() zombie_run16 =[ $run16, zombie_run17 ] {ai_run(7);}; void() zombie_run17 =[ $run17, zombie_run18 ] {ai_run(3);}; void() zombie_run18 =[ $run18, zombie_run1 ] { -ai_run(8); -if (random() < 0.2) - sound (self, CHAN_VOICE, "zombie/z_idle.wav", 1, ATTN_IDLE); -if (random() > 0.8) - sound (self, CHAN_VOICE, "zombie/z_idle1.wav", 1, ATTN_IDLE); + ai_run (8); + if (random () < 0.2) + sound (self, CHAN_VOICE, "zombie/z_idle.wav", 1, ATTN_IDLE); + if (random () > 0.8) + sound (self, CHAN_VOICE, "zombie/z_idle1.wav", 1, ATTN_IDLE); }; /* @@ -141,14 +156,13 @@ void() ZombieGrenadeTouch = { if (other == self.owner) return; // don't explode on owner - if (other.takedamage) - { + if (other.takedamage) { T_Damage (other, self, self.owner, 10 ); sound (self, CHAN_WEAPON, "zombie/z_hit.wav", 1, ATTN_NORM); remove (self); return; } - sound (self, CHAN_WEAPON, "zombie/z_miss.wav", 1, ATTN_NORM); // bounce sound + sound (self, CHAN_WEAPON, "zombie/z_miss.wav", 1, ATTN_NORM); // bounce sound self.velocity = '0 0 0'; self.avelocity = '0 0 0'; self.touch = SUB_Remove; @@ -171,22 +185,18 @@ void(vector st) ZombieFireGrenade = missile.movetype = MOVETYPE_BOUNCE; missile.solid = SOLID_BBOX; -// calc org + // calc org org = self.origin + st_x * v_forward + st_y * v_right + (st_z - 24) * v_up; -// set missile speed - + // set missile speed makevectors (self.angles); - missile.velocity = normalize(self.enemy.origin - org); missile.velocity = missile.velocity * 600; missile.velocity_z = 200; - missile.avelocity = '3000 1000 2000'; - missile.touch = ZombieGrenadeTouch; - -// set missile duration + + // set missile duration missile.nextthink = time + 2.5; missile.think = SUB_Remove; @@ -195,7 +205,6 @@ void(vector st) ZombieFireGrenade = setorigin (missile, org); }; - void() zombie_atta1 =[ $atta1, zombie_atta2 ] {ai_face();}; void() zombie_atta2 =[ $atta2, zombie_atta3 ] {ai_face();}; void() zombie_atta3 =[ $atta3, zombie_atta4 ] {ai_face();}; @@ -208,7 +217,10 @@ void() zombie_atta9 =[ $atta9, zombie_atta10 ] {ai_face();}; void() zombie_atta10 =[ $atta10, zombie_atta11 ] {ai_face();}; void() zombie_atta11 =[ $atta11, zombie_atta12 ] {ai_face();}; void() zombie_atta12 =[ $atta12, zombie_atta13 ] {ai_face();}; -void() zombie_atta13 =[ $atta13, zombie_run1 ] {ai_face();ZombieFireGrenade('-10 -22 30');}; +void() zombie_atta13 =[ $atta13, zombie_run1 ] { + ai_face (); + ZombieFireGrenade ('-10 -22 30'); +}; void() zombie_attb1 =[ $attb1, zombie_attb2 ] {ai_face();}; void() zombie_attb2 =[ $attb2, zombie_attb3 ] {ai_face();}; @@ -223,7 +235,10 @@ void() zombie_attb10 =[ $attb10, zombie_attb11 ] {ai_face();}; void() zombie_attb11 =[ $attb11, zombie_attb12 ] {ai_face();}; void() zombie_attb12 =[ $attb12, zombie_attb13 ] {ai_face();}; void() zombie_attb13 =[ $attb13, zombie_attb14 ] {ai_face();}; -void() zombie_attb14 =[ $attb13, zombie_run1 ] {ai_face();ZombieFireGrenade('-10 -24 29');}; +void() zombie_attb14 =[ $attb13, zombie_run1 ] { + ai_face (); + ZombieFireGrenade ('-10 -24 29'); +}; void() zombie_attc1 =[ $attc1, zombie_attc2 ] {ai_face();}; void() zombie_attc2 =[ $attc2, zombie_attc3 ] {ai_face();}; @@ -236,13 +251,16 @@ void() zombie_attc8 =[ $attc8, zombie_attc9 ] {ai_face();}; void() zombie_attc9 =[ $attc9, zombie_attc10 ] {ai_face();}; void() zombie_attc10 =[ $attc10, zombie_attc11 ] {ai_face();}; void() zombie_attc11 =[ $attc11, zombie_attc12 ] {ai_face();}; -void() zombie_attc12 =[ $attc12, zombie_run1 ] {ai_face();ZombieFireGrenade('-12 -19 29');}; +void() zombie_attc12 =[ $attc12, zombie_run1 ] { + ai_face (); + ZombieFireGrenade ('-12 -19 29'); +}; void() zombie_missile = { local float r; - r = random(); + r = random (); if (r < 0.3) zombie_atta1 (); @@ -252,7 +270,6 @@ void() zombie_missile = zombie_attc1 (); }; - /* ============================================================================= @@ -261,7 +278,9 @@ PAIN ============================================================================= */ -void() zombie_paina1 =[ $paina1, zombie_paina2 ] {sound (self, CHAN_VOICE, "zombie/z_pain.wav", 1, ATTN_NORM);}; +void() zombie_paina1 =[ $paina1, zombie_paina2 ] { + sound (self, CHAN_VOICE, "zombie/z_pain.wav", 1, ATTN_NORM); +}; void() zombie_paina2 =[ $paina2, zombie_paina3 ] {ai_painforward(3);}; void() zombie_paina3 =[ $paina3, zombie_paina4 ] {ai_painforward(1);}; void() zombie_paina4 =[ $paina4, zombie_paina5 ] {ai_pain(1);}; @@ -274,7 +293,9 @@ void() zombie_paina10 =[ $paina10, zombie_paina11 ] {}; void() zombie_paina11 =[ $paina11, zombie_paina12 ] {}; void() zombie_paina12 =[ $paina12, zombie_run1 ] {}; -void() zombie_painb1 =[ $painb1, zombie_painb2 ] {sound (self, CHAN_VOICE, "zombie/z_pain1.wav", 1, ATTN_NORM);}; +void() zombie_painb1 =[ $painb1, zombie_painb2 ] { + sound (self, CHAN_VOICE, "zombie/z_pain1.wav", 1, ATTN_NORM); +}; void() zombie_painb2 =[ $painb2, zombie_painb3 ] {ai_pain(2);}; void() zombie_painb3 =[ $painb3, zombie_painb4 ] {ai_pain(8);}; void() zombie_painb4 =[ $painb4, zombie_painb5 ] {ai_pain(6);}; @@ -282,7 +303,9 @@ void() zombie_painb5 =[ $painb5, zombie_painb6 ] {ai_pain(2);}; void() zombie_painb6 =[ $painb6, zombie_painb7 ] {}; void() zombie_painb7 =[ $painb7, zombie_painb8 ] {}; void() zombie_painb8 =[ $painb8, zombie_painb9 ] {}; -void() zombie_painb9 =[ $painb9, zombie_painb10 ] {sound (self, CHAN_BODY, "zombie/z_fall.wav", 1, ATTN_NORM);}; +void() zombie_painb9 =[ $painb9, zombie_painb10 ] { + sound (self, CHAN_BODY, "zombie/z_fall.wav", 1, ATTN_NORM); +}; void() zombie_painb10 =[ $painb10, zombie_painb11 ] {}; void() zombie_painb11 =[ $painb11, zombie_painb12 ] {}; void() zombie_painb12 =[ $painb12, zombie_painb13 ] {}; @@ -303,7 +326,9 @@ void() zombie_painb26 =[ $painb26, zombie_painb27 ] {}; void() zombie_painb27 =[ $painb27, zombie_painb28 ] {}; void() zombie_painb28 =[ $painb28, zombie_run1 ] {}; -void() zombie_painc1 =[ $painc1, zombie_painc2 ] {sound (self, CHAN_VOICE, "zombie/z_pain1.wav", 1, ATTN_NORM);}; +void() zombie_painc1 =[ $painc1, zombie_painc2 ] { + sound (self, CHAN_VOICE, "zombie/z_pain1.wav", 1, ATTN_NORM); +}; void() zombie_painc2 =[ $painc2, zombie_painc3 ] {}; void() zombie_painc3 =[ $painc3, zombie_painc4 ] {ai_pain(3);}; void() zombie_painc4 =[ $painc4, zombie_painc5 ] {ai_pain(1);}; @@ -322,7 +347,9 @@ void() zombie_painc16 =[ $painc16, zombie_painc17 ] {}; void() zombie_painc17 =[ $painc17, zombie_painc18 ] {}; void() zombie_painc18 =[ $painc18, zombie_run1 ] {}; -void() zombie_paind1 =[ $paind1, zombie_paind2 ] {sound (self, CHAN_VOICE, "zombie/z_pain.wav", 1, ATTN_NORM);}; +void() zombie_paind1 =[ $paind1, zombie_paind2 ] { + sound (self, CHAN_VOICE, "zombie/z_pain.wav", 1, ATTN_NORM); +}; void() zombie_paind2 =[ $paind2, zombie_paind3 ] {}; void() zombie_paind3 =[ $paind3, zombie_paind4 ] {}; void() zombie_paind4 =[ $paind4, zombie_paind5 ] {}; @@ -337,8 +364,8 @@ void() zombie_paind12 =[ $paind12, zombie_paind13 ] {}; void() zombie_paind13 =[ $paind13, zombie_run1 ] {}; void() zombie_paine1 =[ $paine1, zombie_paine2 ] { -sound (self, CHAN_VOICE, "zombie/z_pain.wav", 1, ATTN_NORM); -self.health = 60; + sound (self, CHAN_VOICE, "zombie/z_pain.wav", 1, ATTN_NORM); + self.health = 60; }; void() zombie_paine2 =[ $paine2, zombie_paine3 ] {ai_pain(8);}; void() zombie_paine3 =[ $paine3, zombie_paine4 ] {ai_pain(5);}; @@ -349,21 +376,22 @@ void() zombie_paine7 =[ $paine7, zombie_paine8 ] {ai_pain(1);}; void() zombie_paine8 =[ $paine8, zombie_paine9 ] {ai_pain(1);}; void() zombie_paine9 =[ $paine9, zombie_paine10 ] {ai_pain(2);}; void() zombie_paine10 =[ $paine10, zombie_paine11 ] { -sound (self, CHAN_BODY, "zombie/z_fall.wav", 1, ATTN_NORM); -self.solid = SOLID_NOT; -}; -void() zombie_paine11 =[ $paine11, zombie_paine12 ] {self.nextthink = self.nextthink + 5;self.health = 60;}; -void() zombie_paine12 =[ $paine12, zombie_paine13 ]{ -// see if ok to stand up -self.health = 60; -sound (self, CHAN_VOICE, "zombie/z_idle.wav", 1, ATTN_IDLE); -self.solid = SOLID_SLIDEBOX; -if (!walkmove (0, 0)) -{ - self.think = zombie_paine11; + sound (self, CHAN_BODY, "zombie/z_fall.wav", 1, ATTN_NORM); self.solid = SOLID_NOT; - return; -} +}; +void() zombie_paine11 =[ $paine11, zombie_paine12 ] { + self.nextthink = self.nextthink + 5;self.health = 60; +}; +void() zombie_paine12 =[ $paine12, zombie_paine13 ]{ + // see if ok to stand up + self.health = 60; + sound (self, CHAN_VOICE, "zombie/z_idle.wav", 1, ATTN_IDLE); + self.solid = SOLID_SLIDEBOX; + if (!walkmove (0, 0)) { + self.think = zombie_paine11; + self.solid = SOLID_NOT; + return; + } }; void() zombie_paine13 =[ $paine13, zombie_paine14 ] {}; void() zombie_paine14 =[ $paine14, zombie_paine15 ] {}; @@ -424,33 +452,30 @@ void(entity attacker, float take) zombie_pain = if (self.inpain == 2) return; // down on ground, so don't reset any counters -// go down immediately if a big enough hit - if (take >= 25) - { + // go down immediately if a big enough hit + if (take >= 25) { self.inpain = 2; zombie_paine1 (); return; } - if (self.inpain) - { -// if hit again in next gre seconds while not in pain frames, definately drop + if (self.inpain) { + // if hit again in next gre seconds while not in pain frames, definately drop self.pain_finished = time + 3; return; // currently going through an animation, don't change } - if (self.pain_finished > time) - { -// hit again, so drop down + if (self.pain_finished > time) { + // hit again, so drop down self.inpain = 2; zombie_paine1 (); return; } -// gp into one of the fast pain animations + // gp into one of the fast pain animations self.inpain = 1; - r = random(); + r = random (); if (r < 0.25) zombie_paina1 (); else if (r < 0.5) @@ -469,9 +494,8 @@ If crucified, stick the bounding box 12 pixels back into a wall to look right. */ void() monster_zombie = { - if (deathmatch) - { - remove(self); + if (deathmatch) { + remove (self); return; } @@ -505,11 +529,9 @@ void() monster_zombie = self.th_die = zombie_die; self.th_missile = zombie_missile; - if (self.spawnflags & SPAWN_CRUCIFIED) - { + if (self.spawnflags & SPAWN_CRUCIFIED) { self.movetype = MOVETYPE_NONE; zombie_cruc1 (); - } - else - walkmonster_start(); + } else + walkmonster_start (); };