diff --git a/quakec/fallout2/ai.qc b/quakec/fallout2/ai.qc new file mode 100644 index 000000000..ae76733e3 --- /dev/null +++ b/quakec/fallout2/ai.qc @@ -0,0 +1,745 @@ +void() movetarget_f; +void() t_movetarget; +void() knight_walk1; +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. + +.movetarget +The next path spot to walk toward. If .enemy, ignore .movetarget. +When an enemy is killed, the monster will try to return to it's path. + +.huntt_ime +Set to time + something when the player is in sight, but movement straight for +him is blocked. This causes the monster to use wall following code for +movement direction instead of sighting on the player. + +.ideal_yaw +A yaw angle of the intended direction, which will be turned towards at up +to 45 deg / state. If the enemy is in view and hunt_time is not active, +this will be the exact line towards the enemy. + +.pausetime +A monster will leave it's stand state and head towards it's .movetarget when +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; + +float(float v) anglemod = +{ + while (v >= 360) + v = v - 360; + while (v < 0) + v = v + 360; + return v; +}; + +/* +============================================================================== + +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. + +targetname +must be present. The name of this movetarget. + +target +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'); + +}; + +void() path_corner = +{ + movetarget_f (); +}; + + +/* +============= +t_movetarget + +Something has bumped into a movetarget. If it is a monster +moving towards it, change the next destination and continue. +============== +*/ +void() t_movetarget = +{ +local entity temp; + + if (other.movetarget != self) + return; + + if (other.enemy) + return; // fighting, not following a path + + temp = self; + self = other; + other = temp; + + if (self.classname == "monster_ogre") + sound (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE);// play chainsaw drag sound + +//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.pausetime = time + 999999; + self.th_stand (); + return; + } +}; + + + +//============================================================================ + +/* +============= +range + +returns the range catagorization of an entity reletive to self +0 melee range, will become hostile even if back is turned +1 visibility and infront, or visibility and show hostile +2 infront and show hostile +3 only triggered by damage +============= +*/ +float(entity targ) range = +{ +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; + if (r < 500) + return RANGE_NEAR; + if (r < 1000) + return RANGE_MID; + return RANGE_FAR; +}; + +/* +============= +visible + +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 + + if (trace_fraction == 1) + return TRUE; + return FALSE; +}; + + +/* +============= +infront + +returns 1 if the entity is in front (in sight) of self +============= +*/ +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) + { + return TRUE; + } + return FALSE; +}; + + +//============================================================================ + +/* +=========== +ChangeYaw + +Turns towards self.ideal_yaw at self.yaw_speed +Sets the global variable current_yaw +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 ); + ideal = self.ideal_yaw; + + if (current_yaw == ideal) + return; + + move = ideal - current_yaw; + if (ideal > current_yaw) + { + if (move > 180) + move = move - 360; + } + else + { + if (move < -180) + move = move + 360; + } + + if (move > 0) + { + if (move > self.yaw_speed) + move = 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 = +{ + self.goalentity = self.enemy; + self.think = self.th_run; + self.ideal_yaw = vectoyaw(self.enemy.origin - self.origin); + self.nextthink = time + 0.1; + SUB_AttackFinished (1); // wait a while before first attack +}; + +void() SightSound = +{ +local float rsnd; + + if (self.classname == "monster_ogre") + sound (self, CHAN_VOICE, "ogre/ogwake.wav", 1, ATTN_NORM); + else if (self.classname == "monster_knight") + sound (self, CHAN_VOICE, "knight/ksight.wav", 1, ATTN_NORM); + else if (self.classname == "monster_shambler") + sound (self, CHAN_VOICE, "shambler/ssight.wav", 1, ATTN_NORM); + else if (self.classname == "monster_demon1") + sound (self, CHAN_VOICE, "demon/sight2.wav", 1, ATTN_NORM); + else if (self.classname == "monster_wizard") + sound (self, CHAN_VOICE, "wizard/wsight.wav", 1, ATTN_NORM); + else if (self.classname == "monster_zombie") + sound (self, CHAN_VOICE, "zombie/z_idle.wav", 1, ATTN_NORM); + else if (self.classname == "monster_dog") + sound (self, CHAN_VOICE, "dog/dsight.wav", 1, ATTN_NORM); + else if (self.classname == "monster_hell_knight") + sound (self, CHAN_VOICE, "hknight/sight1.wav", 1, ATTN_NORM); + else if (self.classname == "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) + sound (self, CHAN_VOICE, "enforcer/sight1.wav", 1, ATTN_NORM); + else if (rsnd == 2) + sound (self, CHAN_VOICE, "enforcer/sight2.wav", 1, ATTN_NORM); + else if (rsnd == 0) + 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") + sound (self, CHAN_VOICE, "soldier/sight1.wav", 1, ATTN_NORM); + else if (self.classname == "monster_shalrath") + sound (self, CHAN_VOICE, "shalrath/sight.wav", 1, ATTN_NORM); +}; + +void() FoundTarget = +{ + 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 (); + HuntTarget (); +}; + +/* +=========== +FindTarget + +Self is currently not attacking anything, so try to find a target + +Returns TRUE if an enemy was sighted + +When a player fires a missile, the point of impact becomes a fakeplayer so +that monsters that see the impact will respond as if they had seen the +player. + +To avoid spending too much time, only a single client (or fakeclient) is +checked each frame. This means multi player games will have slightly +slower noticing monsters. +============ +*/ +float() FindTarget = +{ + local entity client; + local float r; + +// if the first spawnflag bit is set, the monster will only wake up on +// really seeing the player, not another monster getting angry + +// 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) ) + { + client = sight_entity; + if (client.enemy == self.enemy) + return FALSE; + } + else + { + client = checkclient (); + if (!client) + return FALSE; // current check entity isn't in PVS + } + + if (client == self.enemy) + return FALSE; + + if (client.flags & FL_NOTARGET) + return FALSE; + if (client.items & IT_INVISIBILITY) + return FALSE; + + r = range (client); + if (r == RANGE_FAR) + return FALSE; + + if (!visible (client)) + return FALSE; + + if (r == RANGE_NEAR) + { + if (client.show_hostile < time && !infront (client)) + return FALSE; + } + else if (r == RANGE_MID) + { + if ( /* client.show_hostile < time || */ !infront (client)) + return FALSE; + } + +// +// got one +// + self.enemy = client; + if (self.enemy.classname != "player") + { + self.enemy = self.enemy.enemy; + if (self.enemy.classname != "player") + { + self.enemy = world; + return FALSE; + } + } + + FoundTarget (); + + return TRUE; +}; + + +//============================================================================= + +void(float dist) ai_forward = +{ + walkmove (self.angles_y, dist); +}; + +void(float dist) ai_back = +{ + walkmove ( (self.angles_y+180), dist); +}; + + +/* +============= +ai_pain + +stagger back a bit +============= +*/ +void(float dist) ai_pain = +{ + ai_back (dist); +/* + local float away; + + away = anglemod (vectoyaw (self.origin - self.enemy.origin) + + 180*(random()- 0.5) ); + + walkmove (away, dist); +*/ +}; + +/* +============= +ai_painforward + +stagger back a bit +============= +*/ +void(float dist) ai_painforward = +{ + walkmove (self.ideal_yaw, dist); +}; + +/* +============= +ai_walk + +The monster is walking it's beat +============= +*/ +void(float dist) ai_walk = +{ + local vector mtemp; + + movedist = dist; + + if (self.classname == "monster_dragon") + { + movetogoal (dist); + return; + } + // check for noticing a player + if (FindTarget ()) + return; + + movetogoal (dist); +}; + + +/* +============= +ai_stand + +The monster is staying in one place for a while, with slight angle turns +============= +*/ +void() ai_stand = +{ + if (FindTarget ()) + return; + + if (time > self.pausetime) + { + self.th_walk (); + return; + } + +// change angle slightly + +}; + +/* +============= +ai_turn + +don't move, but turn towards ideal_yaw +============= +*/ +void() ai_turn = +{ + if (FindTarget ()) + return; + + ChangeYaw (); +}; + +//============================================================================= + +/* +============= +ChooseTurn +============= +*/ +void(vector dest3) ChooseTurn = +{ + local vector dir, newdir; + + dir = self.origin - dest3; + + newdir_x = trace_plane_normal_y; + newdir_y = 0 - trace_plane_normal_x; + newdir_z = 0; + + if (dir * newdir > 0) + { + dir_x = 0 - trace_plane_normal_y; + dir_y = trace_plane_normal_x; + } + else + { + dir_x = trace_plane_normal_y; + dir_y = 0 - trace_plane_normal_x; + } + + dir_z = 0; + self.ideal_yaw = vectoyaw(dir); +}; + +/* +============ +FacingIdeal + +============ +*/ +float() FacingIdeal = +{ + local float delta; + + delta = anglemod(self.angles_y - self.ideal_yaw); + if (delta > 45 && delta < 315) + return FALSE; + return TRUE; +}; + + +//============================================================================= + +float() WizardCheckAttack; +float() DogCheckAttack; + +float() CheckAnyAttack = +{ + if (!enemy_vis) + return FALSE; + 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 (); +}; + + +/* +============= +ai_run_melee + +Turn and close until within an angle to launch a melee attack +============= +*/ +void() ai_run_melee = +{ + self.ideal_yaw = enemy_yaw; + ChangeYaw (); + + if (FacingIdeal()) + { + self.th_melee (); + self.attack_state = AS_STRAIGHT; + } +}; + + +/* +============= +ai_run_missile + +Turn in place until within an angle to launch a missile attack +============= +*/ +void() ai_run_missile = +{ + self.ideal_yaw = enemy_yaw; + ChangeYaw (); + if (FacingIdeal()) + { + self.th_missile (); + self.attack_state = AS_STRAIGHT; + } +}; + + +/* +============= +ai_run_slide + +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 + +The monster has an enemy it is trying to kill +============= +*/ +void(float dist) ai_run = +{ + local vector delta; + local float axis; + local float direct, ang_rint, ang_floor, ang_ceil; + + movedist = dist; +// 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) + { + self.enemy = self.oldenemy; + HuntTarget (); + } + else + { + if (self.movetarget) + self.th_walk (); + else + self.th_stand (); + return; + } + } + + self.show_hostile = time + 1; // wake up other monsters + +// check knowledge of enemy + enemy_vis = visible(self.enemy); + if (enemy_vis) + self.search_time = time + 5; + +// look for other coop players + if (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); + + 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"); + ai_run_melee (); + return; + } + + if (CheckAnyAttack ()) + return; // beginning an attack + + if (self.attack_state == AS_SLIDING) + { + ai_run_slide (); + return; + } + +// head straight in + movetogoal (dist); // done in C code... +}; + diff --git a/quakec/fallout2/boss.qc b/quakec/fallout2/boss.qc new file mode 100644 index 000000000..72528082a --- /dev/null +++ b/quakec/fallout2/boss.qc @@ -0,0 +1,377 @@ +/* +============================================================================== + +BOSS-ONE + +============================================================================== +*/ +$cd id1/models/boss1 +$origin 0 0 -15 +$base base +$skin skin +$scale 5 + +$frame rise1 rise2 rise3 rise4 rise5 rise6 rise7 rise8 rise9 rise10 +$frame rise11 rise12 rise13 rise14 rise15 rise16 rise17 + +$frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8 +$frame walk9 walk10 walk11 walk12 walk13 walk14 walk15 +$frame walk16 walk17 walk18 walk19 walk20 walk21 walk22 +$frame walk23 walk24 walk25 walk26 walk27 walk28 walk29 walk30 walk31 + +$frame death1 death2 death3 death4 death5 death6 death7 death8 death9 + +$frame attack1 attack2 attack3 attack4 attack5 attack6 attack7 attack8 +$frame attack9 attack10 attack11 attack12 attack13 attack14 attack15 +$frame attack16 attack17 attack18 attack19 attack20 attack21 attack22 +$frame attack23 + +$frame shocka1 shocka2 shocka3 shocka4 shocka5 shocka6 shocka7 shocka8 +$frame shocka9 shocka10 + +$frame shockb1 shockb2 shockb3 shockb4 shockb5 shockb6 + +$frame shockc1 shockc2 shockc3 shockc4 shockc5 shockc6 shockc7 shockc8 +$frame shockc9 shockc10 + + +void(vector p) boss_missile; + +void() boss_face = +{ + +// go for another player if multi player + if (self.enemy.health <= 0 || random() < 0.02 || self.enemy.class == 0 || self.enemy.team == 0) + { + self.enemy = find(self.enemy, classname, "player"); + if (!self.enemy) + self.enemy = find(self.enemy, classname, "player"); + } + ai_face(); +}; + +void() boss_rise1 =[ $rise1, boss_rise2 ] { +sound (self, CHAN_WEAPON, "boss1/out1.wav", 1, ATTN_NORM); +}; +void() boss_rise2 =[ $rise2, boss_rise3 ] { +sound (self, CHAN_VOICE, "boss1/sight1.wav", 1, ATTN_NORM); +}; +void() boss_rise3 =[ $rise3, boss_rise4 ] {}; +void() boss_rise4 =[ $rise4, boss_rise5 ] {}; +void() boss_rise5 =[ $rise5, boss_rise6 ] {}; +void() boss_rise6 =[ $rise6, boss_rise7 ] {}; +void() boss_rise7 =[ $rise7, boss_rise8 ] {}; +void() boss_rise8 =[ $rise8, boss_rise9 ] {}; +void() boss_rise9 =[ $rise9, boss_rise10 ] {}; +void() boss_rise10 =[ $rise10, boss_rise11 ] {}; +void() boss_rise11 =[ $rise11, boss_rise12 ] {}; +void() boss_rise12 =[ $rise12, boss_rise13 ] {}; +void() boss_rise13 =[ $rise13, boss_rise14 ] {}; +void() boss_rise14 =[ $rise14, boss_rise15 ] {}; +void() boss_rise15 =[ $rise15, boss_rise16 ] {}; +void() boss_rise16 =[ $rise16, boss_rise17 ] {}; +void() boss_rise17 =[ $rise17, boss_missile1 ] {}; + +void() boss_idle1 =[ $walk1, boss_idle2 ] +{ + if (self.enemy) + boss_missile1(); + +// look for other players +}; +void() boss_idle2 =[ $walk2, boss_idle3 ] {boss_face();}; +void() boss_idle3 =[ $walk3, boss_idle4 ] {boss_face();}; +void() boss_idle4 =[ $walk4, boss_idle5 ] {boss_face();}; +void() boss_idle5 =[ $walk5, boss_idle6 ] {boss_face();}; +void() boss_idle6 =[ $walk6, boss_idle7 ] {boss_face();}; +void() boss_idle7 =[ $walk7, boss_idle8 ] {boss_face();}; +void() boss_idle8 =[ $walk8, boss_idle9 ] {boss_face();}; +void() boss_idle9 =[ $walk9, boss_idle10 ] {boss_face();}; +void() boss_idle10 =[ $walk10, boss_idle11 ] {boss_face();}; +void() boss_idle11 =[ $walk11, boss_idle12 ] {boss_face();}; +void() boss_idle12 =[ $walk12, boss_idle13 ] {boss_face();}; +void() boss_idle13 =[ $walk13, boss_idle14 ] {boss_face();}; +void() boss_idle14 =[ $walk14, boss_idle15 ] {boss_face();}; +void() boss_idle15 =[ $walk15, boss_idle16 ] {boss_face();}; +void() boss_idle16 =[ $walk16, boss_idle17 ] {boss_face();}; +void() boss_idle17 =[ $walk17, boss_idle18 ] {boss_face();}; +void() boss_idle18 =[ $walk18, boss_idle19 ] {boss_face();}; +void() boss_idle19 =[ $walk19, boss_idle20 ] {boss_face();}; +void() boss_idle20 =[ $walk20, boss_idle21 ] {boss_face();}; +void() boss_idle21 =[ $walk21, boss_idle22 ] {boss_face();}; +void() boss_idle22 =[ $walk22, boss_idle23 ] {boss_face();}; +void() boss_idle23 =[ $walk23, boss_idle24 ] {boss_face();}; +void() boss_idle24 =[ $walk24, boss_idle25 ] {boss_face();}; +void() boss_idle25 =[ $walk25, boss_idle26 ] {boss_face();}; +void() boss_idle26 =[ $walk26, boss_idle27 ] {boss_face();}; +void() boss_idle27 =[ $walk27, boss_idle28 ] {boss_face();}; +void() boss_idle28 =[ $walk28, boss_idle29 ] {boss_face();}; +void() boss_idle29 =[ $walk29, boss_idle30 ] {boss_face();}; +void() boss_idle30 =[ $walk30, boss_idle31 ] {boss_face();}; +void() boss_idle31 =[ $walk31, boss_idle1 ] {boss_face();}; + +void() boss_missile1 =[ $attack1, boss_missile2 ] {boss_face();}; +void() boss_missile2 =[ $attack2, boss_missile3 ] {boss_face();}; +void() boss_missile3 =[ $attack3, boss_missile4 ] {boss_face();}; +void() boss_missile4 =[ $attack4, boss_missile5 ] {boss_face();}; +void() boss_missile5 =[ $attack5, boss_missile6 ] {boss_face();}; +void() boss_missile6 =[ $attack6, boss_missile7 ] {boss_face();}; +void() boss_missile7 =[ $attack7, boss_missile8 ] {boss_face();}; +void() boss_missile8 =[ $attack8, boss_missile9 ] {boss_face();}; +void() boss_missile9 =[ $attack9, boss_missile10 ] {boss_missile('100 100 200');}; +void() boss_missile10 =[ $attack10, boss_missile11 ] {boss_face();}; +void() boss_missile11 =[ $attack11, boss_missile12 ] {boss_face();}; +void() boss_missile12 =[ $attack12, boss_missile13 ] {boss_face();}; +void() boss_missile13 =[ $attack13, boss_missile14 ] {boss_face();}; +void() boss_missile14 =[ $attack14, boss_missile15 ] {boss_face();}; +void() boss_missile15 =[ $attack15, boss_missile16 ] {boss_face();}; +void() boss_missile16 =[ $attack16, boss_missile17 ] {boss_face();}; +void() boss_missile17 =[ $attack17, boss_missile18 ] {boss_face();}; +void() boss_missile18 =[ $attack18, boss_missile19 ] {boss_face();}; +void() boss_missile19 =[ $attack19, boss_missile20 ] {boss_face();}; +void() boss_missile20 =[ $attack20, boss_missile21 ] {boss_missile('100 -100 200');}; +void() boss_missile21 =[ $attack21, boss_missile22 ] {boss_face();}; +void() boss_missile22 =[ $attack22, boss_missile23 ] {boss_face();}; +void() boss_missile23 =[ $attack23, boss_missile1 ] {boss_face();}; + +void() boss_shocka1 =[ $shocka1, boss_shocka2 ] {}; +void() boss_shocka2 =[ $shocka2, boss_shocka3 ] {}; +void() boss_shocka3 =[ $shocka3, boss_shocka4 ] {}; +void() boss_shocka4 =[ $shocka4, boss_shocka5 ] {}; +void() boss_shocka5 =[ $shocka5, boss_shocka6 ] {}; +void() boss_shocka6 =[ $shocka6, boss_shocka7 ] {}; +void() boss_shocka7 =[ $shocka7, boss_shocka8 ] {}; +void() boss_shocka8 =[ $shocka8, boss_shocka9 ] {}; +void() boss_shocka9 =[ $shocka9, boss_shocka10 ] {}; +void() boss_shocka10 =[ $shocka10, boss_missile1 ] {}; + +void() boss_shockb1 =[ $shockb1, boss_shockb2 ] {}; +void() boss_shockb2 =[ $shockb2, boss_shockb3 ] {}; +void() boss_shockb3 =[ $shockb3, boss_shockb4 ] {}; +void() boss_shockb4 =[ $shockb4, boss_shockb5 ] {}; +void() boss_shockb5 =[ $shockb5, boss_shockb6 ] {}; +void() boss_shockb6 =[ $shockb6, boss_shockb7 ] {}; +void() boss_shockb7 =[ $shockb1, boss_shockb8 ] {}; +void() boss_shockb8 =[ $shockb2, boss_shockb9 ] {}; +void() boss_shockb9 =[ $shockb3, boss_shockb10 ] {}; +void() boss_shockb10 =[ $shockb4, boss_missile1 ] {}; + +void() boss_shockc1 =[ $shockc1, boss_shockc2 ] {}; +void() boss_shockc2 =[ $shockc2, boss_shockc3 ] {}; +void() boss_shockc3 =[ $shockc3, boss_shockc4 ] {}; +void() boss_shockc4 =[ $shockc4, boss_shockc5 ] {}; +void() boss_shockc5 =[ $shockc5, boss_shockc6 ] {}; +void() boss_shockc6 =[ $shockc6, boss_shockc7 ] {}; +void() boss_shockc7 =[ $shockc7, boss_shockc8 ] {}; +void() boss_shockc8 =[ $shockc8, boss_shockc9 ] {}; +void() boss_shockc9 =[ $shockc9, boss_shockc10 ] {}; +void() boss_shockc10 =[ $shockc10, boss_death1 ] {}; + +void() boss_death1 = [$death1, boss_death2] { +sound (self, CHAN_VOICE, "boss1/death.wav", 1, ATTN_NORM); +}; +void() boss_death2 = [$death2, boss_death3] {}; +void() boss_death3 = [$death3, boss_death4] {}; +void() boss_death4 = [$death4, boss_death5] {}; +void() boss_death5 = [$death5, boss_death6] {}; +void() boss_death6 = [$death6, boss_death7] {}; +void() boss_death7 = [$death7, boss_death8] {}; +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); +}; + +void() boss_death10 = [$death9, boss_death10] +{ + killed_monsters = killed_monsters + 1; + WriteByte (MSG_ALL, SVC_KILLEDMONSTER); // FIXME: reliable broadcast + SUB_UseTargets (); + remove (self); +}; + +void () LavaExplode = +{ + local float r; + + sound (self, CHAN_VOICE, "ambience/gunfire7.wav", 1, ATTN_NONE); + self.origin = (self.origin + '0 0 16'); + 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); + Explosion (2); + T_RadiusDamage (self, self.owner, 60, world, ""); + remove (self); +}; + +void(vector p) boss_missile = +{ + local vector offang; + local vector org, vec, d; + local float t; + + 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'; + + + t = vlen(self.enemy.origin - org) / 1200; + vec = self.enemy.velocity; + vec_z = 0; + d = self.enemy.origin + t * vec; + + + vec = normalize (d - org); + + launch_spike (org, vec); + setmodel (newmis, "progs/lavaball.mdl"); + newmis.avelocity = '200 100 300'; + setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); + newmis.velocity = vec*300; + newmis.touch = LavaExplode; // rocket explosion + sound (self, CHAN_WEAPON, "boss1/throw.wav", 1, ATTN_NORM); + +// check for dead enemy + if (self.enemy.health <= 0) + boss_idle1 (); +}; + + +void() boss_awake = +{ + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_STEP; + self.takedamage = DAMAGE_YES; + self.health = 8000; + self.th_die = boss_death1; + + setmodel (self, "progs/boss.mdl"); + setsize (self, '-128 -128 -24', '128 128 256'); + + 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); + + self.yaw_speed = 20; + boss_rise1 (); +}; + +void() monster_boss = +{ + precache_model ("progs/boss.mdl"); + precache_model ("progs/lavaball.mdl"); + + precache_sound ("weapons/rocket1i.wav"); + precache_sound ("boss1/out1.wav"); + precache_sound ("boss1/sight1.wav"); + precache_sound ("misc/power.wav"); + precache_sound ("boss1/throw.wav"); + precache_sound ("boss1/pain.wav"); + precache_sound ("boss1/death.wav"); + + total_monsters = total_monsters + 1; + + self.think = boss_awake; + self.nextthink = time + 1; +}; + +//=========================================================================== + +entity le1, le2; +float lightning_end; + +void() lightning_fire = +{ + local vector p1, p2; + + 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; + + self.nextthink = time + 0.1; + self.think = lightning_fire; + + WriteByte (MSG_ALL, SVC_TEMPENTITY); + WriteByte (MSG_ALL, 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); +}; + +void() lightning_use = +{ + if (lightning_end >= time + 1) + return; + + 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) ) + { +// dprint ("not aligned\n"); + return; + } + +// 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 (); + +// 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) + { + sound (self, CHAN_VOICE, "boss1/pain.wav", 1, ATTN_NORM); + self.health = self.health - 1; + if (self.health >= 2) + boss_shocka1(); + else if (self.health == 1) + boss_shockb1(); + else if (self.health == 0) + boss_shockc1(); + } +}; + + diff --git a/quakec/fallout2/buttons.qc b/quakec/fallout2/buttons.qc new file mode 100644 index 000000000..016ce6e87 --- /dev/null +++ b/quakec/fallout2/buttons.qc @@ -0,0 +1,141 @@ +// button and multiple button + +void() button_wait; +void() button_return; + +void() button_wait = +{ + self.state = STATE_TOP; + self.nextthink = self.ltime + self.wait; + self.think = button_return; + activator = self.enemy; + SUB_UseTargets(); + self.frame = 1; // use alternate textures +}; + +void() button_done = +{ + self.state = STATE_BOTTOM; +}; + +void() button_return = +{ + self.state = STATE_DOWN; + SUB_CalcMove (self.pos1, self.speed, button_done); + self.frame = 0; // use normal textures + if (self.health) + self.takedamage = DAMAGE_YES; // can be shot again +}; + + +void() button_blocked = +{ // do nothing, just don't ome all the way back out +}; + + +void() button_fire = +{ + if (self.state == STATE_UP || self.state == STATE_TOP) + return; + + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); + + self.state = STATE_UP; + SUB_CalcMove (self.pos2, self.speed, button_wait); +}; + + +void() button_use = +{ + self.enemy = activator; + button_fire (); +}; + +void() button_touch = +{ + if (other.classname != "player") + return; + self.enemy = other; + button_fire (); +}; + +void() button_killed = +{ + self.enemy = damage_attacker; + self.health = self.max_health; + self.takedamage = DAMAGE_NO; // wil be reset upon return + 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. + +"angle" determines the opening direction +"target" all entities with a matching targetname will be used +"speed" override the default 40 speed +"wait" override the default 1 second wait (-1 = never return) +"lip" override the default 4 pixel lip remaining at end of move +"health" if set, the button must be killed instead of touched +"sounds" +0) steam metal +1) wooden clunk +2) metallic click +3) in-out +*/ +void() func_button = +{ +local float gtemp, ftemp; + + if (self.sounds == 0) + { + precache_sound ("buttons/airbut1.wav"); + self.noise = "buttons/airbut1.wav"; + } + if (self.sounds == 1) + { + precache_sound ("buttons/switch21.wav"); + self.noise = "buttons/switch21.wav"; + } + if (self.sounds == 2) + { + precache_sound ("buttons/switch02.wav"); + self.noise = "buttons/switch02.wav"; + } + if (self.sounds == 3) + { + precache_sound ("buttons/switch04.wav"); + self.noise = "buttons/switch04.wav"; + } + + SetMovedir (); + + self.movetype = MOVETYPE_PUSH; + self.solid = SOLID_BSP; + setmodel (self, self.model); + + self.blocked = button_blocked; + self.use = button_use; + + if (self.health) + { + self.max_health = self.health; + self.th_die = button_killed; + self.takedamage = DAMAGE_YES; + } + else + self.touch = button_touch; + + if (!self.speed) + self.speed = 40; + if (!self.wait) + self.wait = 1; + if (!self.lip) + self.lip = 4; + + self.state = STATE_BOTTOM; + + self.pos1 = self.origin; + self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip); +}; + diff --git a/quakec/fallout2/client.qc b/quakec/fallout2/client.qc new file mode 100644 index 000000000..5a3234d37 --- /dev/null +++ b/quakec/fallout2/client.qc @@ -0,0 +1,1633 @@ + +// prototypes +void () W_WeaponFrame; +void() W_SetCurrentAmmo; +void() player_pain; +void() player_stand1; +void (vector org) spawn_tfog; +void (vector org, entity death_owner) spawn_tdeath; +void(float slot) WeaponAmmo; + +float modelindex_dead, modelindex_sneak, modelindex_prone, modelindex_eyes, modelindex_player, modelindex_gone; + +/* +============================================================================= + + LEVEL CHANGING / INTERMISSION + +============================================================================= +*/ + +string nextmap; + +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. +Use mangle instead of angle, so you can set pitch or roll as well as yaw. 'pitch roll yaw' +*/ +void() info_intermission = +{ + self.angles = self.mangle; // so C can get at it +}; + + + +void() SetChangeParms = +{ + 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 + if (self.health > 100) + self.health = 100; + if (self.health < 50) + self.health = 50; + parm1 = self.items; + parm2 = self.health; + parm3 = self.armorvalue; + if (self.ammo_shells < 25) + parm4 = 25; + else + parm4 = self.ammo_shells; + parm5 = self.ammo_nails; + parm6 = self.ammo_rockets; + parm7 = self.ammo_cells; + parm8 = self.weapon; + parm9 = self.armortype * 100; +}; + +void() SetNewParms = +{ + parm1 = IT_SHOTGUN | IT_AXE; + parm2 = 100; + parm3 = 0; + parm4 = 25; + parm5 = 0; + parm6 = 0; + parm7 = 0; + parm8 = 1; + parm9 = 0; +}; + +void() DecodeLevelParms = +{ + if (serverflags) + { + if (world.model == "maps/start.bsp") + SetNewParms (); // take away all stuff on starting new episode + } + + self.items = parm1; + self.health = parm2; + self.armorvalue = parm3; + self.ammo_shells = parm4; + self.ammo_nails = parm5; + self.ammo_rockets = parm6; + self.ammo_cells = parm7; + self.weapon = parm8; + self.armortype = parm9 * 0.01; +}; + +/* +============ +FindIntermission + +Returns the entity to view from +============ +*/ +entity() FindIntermission = +{ + local entity spot; + local float cyc; + +// look for info_intermission first + spot = find (world, classname, "info_intermission"); + if (spot) + { // pick a random one + cyc = random() * 4; + while (cyc > 1) + { + spot = find (spot, classname, "info_intermission"); + if (!spot) + spot = find (spot, classname, "info_intermission"); + cyc = cyc - 1; + } + return spot; + } + +// 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 + + 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 + // serverinfo/localinfo var + newmap = infokey(world, mapname); + if (newmap != "") + changelevel (newmap); + else + changelevel (nextmap); + } +}; + + + +/* +============ +IntermissionThink + +When the player presses attack or jump, change to the next level +============ +*/ +void() IntermissionThink = +{ + if (time < intermission_exittime) + return; + + if (!self.button0 && !self.button1 && !self.button2) + return; + + GotoNextMap (); +}; + +/* +============ +execute_changelevel + +The global "nextmap" has been set previously. +Take the players to the intermission spot +============ +*/ +void() execute_changelevel = +{ + local entity pos; + + intermission_running = 1; + +// 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); + + other = find (world, classname, "player"); + while (other != world) + { + other.takedamage = DAMAGE_NO; + other.solid = SOLID_NOT; + other.movetype = MOVETYPE_NONE; + other.modelindex = 0; + other = find (other, classname, "player"); + } + +}; + + +void() changelevel_touch = +{ + local entity pos; + + if (other.classname != "player") + return; + +// 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"))) + { + T_Damage (other, self, self, 50000); + return; + } + + bprint (PRINT_HIGH, other.netname); + bprint (PRINT_HIGH," exited the level\n"); + + nextmap = self.map; + + SUB_UseTargets (); + + 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 + self.think = execute_changelevel; + self.nextthink = time + 0.1; +}; + +/*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION +When the player touches this, he gets sent to the map listed in the "map" variable. Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats. +*/ +void() trigger_changelevel = +{ + if (!self.map) + objerror ("chagnelevel trigger doesn't have map"); + + InitTrigger (); + self.touch = changelevel_touch; +}; + + +/* +============================================================================= + + PLAYER GAME EDGE FUNCTIONS + +============================================================================= +*/ + +void() set_suicide_frame; + +// called by ClientKill and DeadThink +void() respawn = +{ + // make a copy of the dead body for appearances sake + CopyToBodyQue (self); + // set default spawn parms + SetNewParms (); + // respawn + PutClientInServer (); +}; + + +/* +============ +ClientKill + +Player entered the suicide command +============ +*/ +void() ClientKill = +{ + bprint (PRINT_MEDIUM, self.netname); + bprint (PRINT_MEDIUM, " suicides\n"); + set_suicide_frame (); + self.modelindex = modelindex_player; + logfrag (self, self); + self.frags = self.frags - 2; // extra penalty + respawn (); +}; + +float(vector v) CheckSpawnPoint = +{ + return FALSE; +}; + +/* +============ +SelectSpawnPoint + +Returns the entity to spawn at +============ +*/ +entity() SelectSpawnPoint = +{ + local entity spot, newspot, thing; + local float numspots, totalspots; + local float rnum, pcount, xcount; + local float rs, cooperate; + local entity spots, ent2, xspot; + local string ent1; + local vector warp, xdir, org; + + numspots = 0; + totalspots = 0; + +// testinfo_player_start is only found in regioned levels + + spot = find (world, classname, "testplayerstart"); + if (spot) + return spot; + + ent1 = "info_player_start"; + + spot = find (world, classname, "info_player_start"); + + if (spot) + cooperate = 1; + + spot = find (world, classname, "spawn3"); + + if (spot) + ent1 = "spawn3"; + + if (spot) + { + if (self.team == 1) + ent1 = "spawn1"; + if (self.team == 2) + ent1 = "spawn2"; + } + +// choose a info_player_deathmatch point + +// ok, find all spots that don't have players nearby + + spots = world; + spot = find (world, classname, ent1); + while (spot) + { + totalspots = totalspots + 1; + + thing=findradius(spot.origin, 40); + pcount=0; + while (thing) + { + if (thing.classname == "player") + pcount=pcount + 1; + thing=thing.chain; + } + if (pcount == 0) + { + spot.goalentity = spots; + spots = spot; + numspots = numspots + 1; + } + + // Get the next spot in the chain + spot = find (spot, classname, ent1); + } + + + totalspots=totalspots - 1; + if (!numspots)//full, find random spot + { + totalspots = rint((random() * totalspots)); + spot = find (world, classname, ent1); + while (totalspots > 0) + { + totalspots = totalspots - 1; + spot = find (spot, classname, ent1); + } + return spot; + } + +// 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 ) ); + + spot = spots; + while (numspots > 0) + { + spot = spot.goalentity; + numspots = numspots - 1; + } + return spot; + +}; + + +void() DecodeLevelParms; +void() PlayerDie; + +/* +=========== +ValidateUser + + +============ +*/ +float(entity e) ValidateUser = +{ +/* + local string s; + local string userclan; + 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 (s == userclan) + return true; + 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 +// + s = masterinfo (e, "rank"); + rank = stof (s); + + s = serverinfo("rankmin"); + if (s) + { + rankmin = stof (s); + if (rank < rankmin) + return false; + } + s = serverinfo("rankmax"); + if (s) + { + rankmax = stof (s); + if (rankmax < rank) + return false; + } + + return true; +*/ +}; + + +/* +=========== +PutClientInServer + +called each time a player enters a new level +============ +*/ +void() PutClientInServer = +{ + local entity spot; + local string s; + + self.classname = "player"; + self.health = 100; + self.takedamage = DAMAGE_AIM; + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_WALK; + self.show_hostile = 0; + self.max_health = 100; + self.flags = FL_CLIENT; + self.air_finished = time + 12; + self.dmg = 2; // initial water damage + self.super_damage_finished = 0; + self.radsuit_finished = 0; + self.invisible_finished = 0; + self.currentmenu = "none"; + self.invincible_finished = 0; + self.effects = 0; + self.invincible_time = 0; + self.active = 1; + + DecodeLevelParms (); + + W_SetCurrentAmmo (); + + self.attack_finished = time; + self.th_pain = player_pain; + self.th_die = PlayerDie; + self.slot1 = 17; + self.slot2 = 19; + self.current_slot = 1; + WeaponAmmo(1); + WeaponAmmo(2); + self.deadflag = DEAD_NO; +// paustime is set by teleporters to keep the player from moving a while + self.pausetime = 0; + + spot = SelectSpawnPoint (); + + self.origin = spot.origin + '0 0 1'; + self.angles = spot.angles; + self.fixangle = TRUE; // turn this way immediately + +// oh, this is a hack! + setmodel (self, "progs/eyes.mdl"); + modelindex_eyes = self.modelindex; + + setmodel (self, "progs/lay.mdl"); + modelindex_prone = self.modelindex; + + setmodel (self, "progs/sneak.mdl"); + modelindex_sneak = self.modelindex; + + setmodel (self, "progs/dead.mdl"); + modelindex_dead = self.modelindex; + + setmodel (self, ""); + modelindex_gone = self.modelindex; + + setmodel (self, "progs/guy.mdl"); + modelindex_player = self.modelindex; + + setsize (self, VEC_HULL_MIN, VEC_HULL_MAX); + + self.view_ofs = '0 0 22'; + +// 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_tdeath (self.origin, self); + + // Set Rocket Jump Modifiers + if (stof(infokey(world, "rj")) != 0) + { + rj = stof(infokey(world, "rj")); + } + + if (deathmatch == 4) + { + self.ammo_shells = 0; + if (stof(infokey(world, "axe")) == 0) + { + self.ammo_nails = 255; + self.ammo_shells = 255; + self.ammo_rockets = 255; + self.ammo_cells = 255; + self.items = self.items | IT_NAILGUN; + 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_LIGHTNING; + } + self.items = self.items - (self.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR3; + self.armorvalue = 200; + self.armortype = 0.8; + self.health = 250; + self.items = self.items | IT_INVULNERABILITY; + self.invincible_time = 1; + self.invincible_finished = time + 3; + } + + if (deathmatch == 5) + { + self.ammo_nails = 80; + self.ammo_shells = 30; + self.ammo_rockets = 10; + self.ammo_cells = 30; + self.items = self.items | IT_NAILGUN; + 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_LIGHTNING; + self.items = self.items - (self.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR3; + self.armorvalue = 200; + self.armortype = 0.8; + self.health = 200; + self.items = self.items | IT_INVULNERABILITY; + self.invincible_time = 1; + self.invincible_finished = time + 3; + } + + +}; + + +/* +============================================================================= + + QUAKED FUNCTIONS + +============================================================================= +*/ + + +/*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24) +The normal starting point for a level. +*/ +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. +*/ +void() info_player_start2 = +{ + local entity start; + local float x; + + x = 10; + + while (x > 0) + { + bprint(2, "hi\n"); + start = spawn(); + setsize(start, '-16 -16 -24', '16 16 32'); + setorigin(start, self.origin + '0 0 4'); + start.solid = SOLID_BBOX; + start.health = 0; + start.movetype = MOVETYPE_BOUNCE; + start.velocity = '500 100 9000'; + setmodel (start, "progs/guy.mdl"); + start.avelocity = '3000 1000 2000'; + start.frame = 1; + //start.think = become_startpoint; + //start.nextthink = time + 2; + + x = x - 1; + } + +}; + +/*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24) +potential spawning position for deathmatch games +*/ +void() info_player_deathmatch = +{ +}; + +/*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24) +potential spawning position for coop games +*/ +void() info_player_coop = +{ +}; + +/* +=============================================================================== + +RULES + +=============================================================================== +*/ + +/* +go to the next level for deathmatch +*/ +void() NextLevel = +{ + local entity o; + local string newmap; + + if (nextmap != "") + return; // already done + + if (mapname == "start") + { + if (!cvar("registered")) + { + mapname = "e1m1"; + } + else if (!(serverflags & 1)) + { + mapname = "e1m1"; + serverflags = serverflags | 1; + } + else if (!(serverflags & 2)) + { + mapname = "e2m1"; + serverflags = serverflags | 2; + } + else if (!(serverflags & 4)) + { + mapname = "e3m1"; + serverflags = serverflags | 4; + } + else if (!(serverflags & 8)) + { + mapname = "e4m1"; + serverflags = serverflags - 7; + } + + o = spawn(); + o.map = mapname; + } + else + { + // find a trigger changelevel + o = find(world, classname, "trigger_changelevel"); + if (!o || mapname == "start") + { // go back to same map if no trigger_changelevel + o = spawn(); + o.map = mapname; + } + } + + nextmap = o.map; + + if (o.nextthink < time) + { + o.think = execute_changelevel; + o.nextthink = time + 0.1; + } +}; + +/* +============ +CheckRules + +Exit deathmatch games upon conditions +============ +*/ +void() CheckRules = +{ + if (timelimit && time >= timelimit) + NextLevel (); + + if (fraglimit && self.frags >= fraglimit) + NextLevel (); +}; + +//============================================================================ + +void() PlayerDeathThink = +{ + local entity old_self; + local float forward; + + 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); + } + +// 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 + if (!self.button2 && !self.button1 && !self.button0) + return; + + self.button0 = 0; + self.button1 = 0; + self.button2 = 0; + respawn(); +}; + + +void() PlayerJump = +{ + local vector start, end; + + if (self.flags & FL_WATERJUMP) + return; + + if (self.waterlevel >= 2) + { +// play swiming sound + if (self.swim_flag < time) + { + self.swim_flag = time + 1; + 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); + } + + return; + } + + if (!(self.flags & FL_ONGROUND)) + return; + + if ( !(self.flags & FL_JUMPRELEASED) ) + return; // don't pogo stick + + self.flags = self.flags - (self.flags & FL_JUMPRELEASED); + self.button2 = 0; + +// player jumping sound + sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM); +}; + + +/* +=========== +WaterMove + +============ +*/ +.float dmgtime; + +void() WaterMove = +{ +//dprint (ftos(self.waterlevel)); + if (self.movetype == MOVETYPE_NOCLIP) + return; + if (self.health < 0) + return; + + 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) + { + self.dmg = self.dmg + 2; + if (self.dmg > 15) + self.dmg = 10; + T_Damage (self, world, world, self.dmg); + self.pain_finished = time + 1; + } + } + + 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; + } + return; + } + + if (self.watertype == CONTENT_LAVA) + { // do damage + if (self.dmgtime < time) + { + if (self.radsuit_finished > time) + self.dmgtime = time + 1; + else + self.dmgtime = time + 0.2; + + T_Damage (self, world, world, 10*self.waterlevel); + } + } + 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) + sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM); + if (self.watertype == CONTENT_WATER) + sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM); + if (self.watertype == CONTENT_SLIME) + sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM); + + self.flags = self.flags + FL_INWATER; + self.dmgtime = 0; + } +}; + +void() CheckWaterJump = +{ + local vector start, end; + +// 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; + traceline (start, end, TRUE, self); + if (trace_fraction < 1) + { // solid at waist + start_z = start_z + self.maxs_z - 8; + end = start + v_forward*24; + self.movedir = trace_plane_normal * -50; + traceline (start, end, TRUE, self); + 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); + self.teleport_time = time + 2; // safety net + return; + } + } +}; + +void () PositionControl = +{ + local string img; + + if (self.position == 0) + self.view_ofs = '0 0 22'; + if (self.position == 1) + self.view_ofs = '0 0 5'; + if (self.position == 2) + self.view_ofs = '0 0 -10'; + + if (self.position == 0) + setsize (self, '-16 -16 -24', '16 16 32'); + if (self.position == 1) + setsize (self, '-16 -16 -24', '16 16 16'); + if (self.position == 2) + setsize (self, '-16 -16 -24', '16 16 0'); + + if (self.position == 0) + self.maxspeed = 300; + if (self.position == 1) + self.maxspeed = 150; + if (self.position == 2) + self.maxspeed = 75; +}; + +/* +================ +PlayerPreThink + +Called every frame before physics are run +================ +*/ +void() PlayerPreThink = +{ + local float mspeed, aspeed; + local float r; + + if (intermission_running) + { + IntermissionThink (); // otherwise a button could be missed between + return; // the think tics + } + + if (self.view_ofs == '0 0 0') + return; // intermission or finale + + makevectors (self.v_angle); // is this still used + + + + self.recoil = self.recoil - 0.2; + + if (self.recoil <= 0) + self.recoil = 0; + + self.deathtype = ""; + + + if (self.cycle1 < time) + { + PositionControl(); + Crosshair(); + if (self.currentmenu != "none") + DisplayMenu(); + + if (self.health > self.max_health) + self.health = self.max_health; + + self.cycle1 = time + 0.5; + } + + if (self.cycle2 < time) + { + self.cycle2 = time + 2; + } + + + CheckRules (); + WaterMove (); + + if (self.deadflag >= DEAD_DEAD) + { + PlayerDeathThink (); + return; + } + + if (self.deadflag == DEAD_DYING) + return; // dying, so do nothing + + if (self.button2) + { + PlayerJump (); + } + else + self.flags = self.flags | FL_JUMPRELEASED; + +// teleporters can force a non-moving pause time + if (time < self.pausetime) + self.velocity = '0 0 0'; +}; + +/* +================ +CheckPowerups + +Check for turning off powerups +================ +*/ +void() CheckPowerups = +{ + 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) + { + sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE); + self.invisible_sound = time + ((random() * 3) + 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) + { + self.invisible_time = time + 1; + stuffcmd (self, "bf\n"); + } + } + + if (self.invisible_finished < time) + { // just stopped + self.items = self.items - IT_INVISIBILITY; + self.invisible_finished = 0; + self.invisible_time = 0; + } + + // use the eyes + self.frame = 0; + self.modelindex = modelindex_eyes; + } + else + if (self.position <= 1) + self.modelindex = modelindex_player; + if (self.position == 2) + self.modelindex = modelindex_prone; + if (self.sneak == 1 || self.sneak == 3 && coop == 0) + self.modelindex = modelindex_gone; + if (self.sneak == 1 || self.sneak == 3 && coop == 1) + self.modelindex = modelindex_sneak; + if (self.health <= 0) + self.modelindex = modelindex_dead; + if (self.ghost == 1 || self.class == 0 || self.team == 0) + self.modelindex = modelindex_gone; + + +// 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) + { + self.invincible_time = time + 1; + stuffcmd (self, "bf\n"); + } + } + + 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); + } + } + +// 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 + sprint (self, PRINT_HIGH, "Quad Damage is wearing off\n"); + stuffcmd (self, "bf\n"); + sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM); + self.super_time = time + 1; + } + + if (self.super_time < time) + { + self.super_time = time + 1; + stuffcmd (self, "bf\n"); + } + } + + if (self.super_damage_finished < time) + { // just stopped + self.items = self.items - IT_QUAD; + if (deathmatch == 4) + { + self.ammo_cells = 255; + self.armorvalue = 1; + self.armortype = 0.8; + self.health = 100; + } + 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); + } + } + +// 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) + { + 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) + { + self.rad_time = time + 1; + stuffcmd (self, "bf\n"); + } + } + + if (self.radsuit_finished < time) + { // just stopped + self.items = self.items - IT_SUIT; + self.rad_time = 0; + self.radsuit_finished = 0; + } + } + +}; + + +/* +================ +PlayerPostThink + +Called every frame after physics are run +================ +*/ +void() PlayerPostThink = +{ + local float mspeed, aspeed; + local float r; + +//dprint ("post think\n"); + if (self.view_ofs == '0 0 0') + return; // intermission or finale + if (self.deadflag) + return; + +// 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) + { + self.deathtype = "falling"; + T_Damage (self, world, world, 5); + sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM); + } + else + sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM); + } + + self.jump_flag = self.velocity_z; + + CheckPowerups (); + + W_WeaponFrame (); + +}; + + +/* +=========== +ClientConnect + +called when a player connects to a server +============ +*/ +void() ClientConnect = +{ + bprint (PRINT_HIGH, self.netname); + bprint (PRINT_HIGH, " entered the game\n"); + + + stuffcmd(self, "bind shift impulse 200\n"); + stuffcmd(self, "bind ctrl impulse 201\n"); + stuffcmd(self, "alias duck impulse 200\n"); + stuffcmd(self, "alias prone impulse 201\n"); + + stuffcmd(self, "exec fallout.cfg\n"); + +// a client connecting during an intermission can cause problems + if (intermission_running) + GotoNextMap (); +}; + + +/* +=========== +ClientDisconnect + +called when a player disconnects from a server +============ +*/ +void() ClientDisconnect = +{ + // let everyone else know + bprint (PRINT_HIGH, self.netname); + bprint (PRINT_HIGH, " left the game with "); + bprint (PRINT_HIGH, ftos(self.frags)); + bprint (PRINT_HIGH, " frags\n"); + sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE); + set_suicide_frame (); +}; + +/* +=========== +ClientObituary + +called when a player dies +============ +*/ + +void(entity targ, entity attacker) ClientObituary = +{ + local float rnum; + local string deathstring, deathstring2; + local string s; + local string attackerteam, targteam; + + rnum = random(); + //ZOID 12-13-96: self.team doesn't work in QW. Use keys + attackerteam = infokey(attacker, "team"); + targteam = infokey(targ, "team"); + + 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; + return; + } + } + + 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"); + 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"); + + 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); + 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) + { + 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"); + logfrag (attacker, targ); + attacker.frags = attacker.frags + 1; + return; + } + else + { + logfrag (targ, targ); + targ.frags = targ.frags - 1; // killed self + bprint (PRINT_MEDIUM,targ.netname); + bprint (PRINT_MEDIUM," was squished\n"); + return; + } + } + + if (attacker.classname == "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"); + else if (targ.deathtype == "rocket") + 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"); + else if (targ.watertype == CONTENT_LAVA) + 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"); + return; + } + else if ( (teamplay == 2) && (targteam == attackerteam) && + (attackerteam != "") ) + { + if (rnum < 0.25) + deathstring = " mows down a teammate\n"; + else if (rnum < 0.50) + deathstring = " checks his glasses\n"; + else if (rnum < 0.75) + deathstring = " gets a frag for the other team\n"; + else + deathstring = " loses another friend\n"; + bprint (PRINT_MEDIUM, attacker.netname); + bprint (PRINT_MEDIUM, deathstring); + attacker.frags = attacker.frags - 1; + //ZOID 12-13-96: killing a teammate logs as suicide + logfrag (attacker, attacker); + return; + } + else + { + logfrag (attacker, targ); + attacker.frags = attacker.frags + 1; + + rnum = attacker.weapon; + if (targ.deathtype == "nail") + { + deathstring = " was nailed by "; + deathstring2 = "\n"; + } + else if (targ.deathtype == "supernail") + { + deathstring = " was punctured by "; + deathstring2 = "\n"; + } + else if (targ.deathtype == "grenade") + { + deathstring = " eats "; + deathstring2 = "'s pineapple\n"; + 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) + deathstring = " was brutalized by "; + else if (rnum < 0.6) + deathstring = " was smeared by "; + else + { + bprint (PRINT_MEDIUM, attacker.netname); + bprint (PRINT_MEDIUM, " rips "); + bprint (PRINT_MEDIUM, targ.netname); + bprint (PRINT_MEDIUM, " a new one\n"); + return; + } + deathstring2 = "'s quad rocket\n"; + } + else + { + deathstring = " rides "; + deathstring2 = "'s rocket\n"; + if (targ.health < -40) + { + deathstring = " was gibbed by "; + deathstring2 = "'s rocket\n" ; + } + } + } + else if (rnum == IT_AXE) + { + deathstring = " was ax-murdered by "; + deathstring2 = "\n"; + } + else if (rnum == IT_SHOTGUN) + { + deathstring = " chewed on "; + deathstring2 = "'s boomstick\n"; + } + else if (rnum == IT_SUPER_SHOTGUN) + { + deathstring = " ate 2 loads of "; + deathstring2 = "'s buckshot\n"; + } + else if (rnum == IT_LIGHTNING) + { + deathstring = " accepts "; + if (attacker.waterlevel > 1) + deathstring2 = "'s discharge\n"; + else + deathstring2 = "'s shaft\n"; + } + bprint (PRINT_MEDIUM,targ.netname); + bprint (PRINT_MEDIUM,deathstring); + bprint (PRINT_MEDIUM,attacker.netname); + bprint (PRINT_MEDIUM,deathstring2); + } + return; + } + else + { + logfrag (targ, targ); + targ.frags = targ.frags - 1; // killed self + rnum = targ.watertype; + + bprint (PRINT_MEDIUM,targ.netname); + if (rnum == -3) + { + if (random() < 0.5) + bprint (PRINT_MEDIUM," sleeps with the fishes\n"); + else + 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"); + else + 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"); + return; + } + if (random() < 0.5) + bprint (PRINT_MEDIUM," turned into hot slag\n"); + else + bprint (PRINT_MEDIUM," visits the Volcano God\n"); + return; + } + + if (attacker.classname == "explo_box") + { + bprint (PRINT_MEDIUM," blew up\n"); + return; + } + if (targ.deathtype == "falling") + { + bprint (PRINT_MEDIUM," fell to his death\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"); + return; + } + + bprint (PRINT_MEDIUM," died\n"); + } + } +}; diff --git a/quakec/fallout2/combat.qc b/quakec/fallout2/combat.qc new file mode 100644 index 000000000..636785297 --- /dev/null +++ b/quakec/fallout2/combat.qc @@ -0,0 +1,324 @@ + +void() T_MissileTouch; +void() info_player_start; +void(entity targ, entity attacker) ClientObituary; +void(entity inflictor, entity attacker, float damage, entity ignore, string dtype) T_RadiusDamage; + +/*SERVER +void() monster_death_use; +*/ + +//============================================================================ + +/* +============ +CanDamage + +Returns true if the inflictor can directly damage the target. Used for +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 (trace_fraction == 1) + return TRUE; + if (trace_ent == targ) + return TRUE; + return FALSE; + } + + traceline(inflictor.origin, targ.origin, TRUE, self); + if (trace_fraction == 1) + return TRUE; + 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); + if (trace_fraction == 1) + return TRUE; + 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); + if (trace_fraction == 1) + return TRUE; + + return FALSE; +}; + + +/* +============ +Killed +============ +*/ +void(entity targ, entity attacker) Killed = +{ + local entity oself; + + oself = self; + self = targ; + + 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 + self.th_die (); + self = oself; + return; + } + + self.enemy = attacker; + +// bump the monster counter + if (self.flags & FL_MONSTER) + { + killed_monsters = killed_monsters + 1; + WriteByte (MSG_ALL, SVC_KILLEDMONSTER); + } + + ClientObituary(self, attacker); + + self.takedamage = DAMAGE_NO; + self.touch = SUB_Null; + self.effects = 0; + +/*SERVER + monster_death_use(); +*/ + self.th_die (); + + self = oself; +}; + + +/* +============ +T_Damage + +The damage is coming from inflictor, but get mad at attacker +This should be the only function that ever reduces health. +============ +*/ +void(entity targ, entity inflictor, entity attacker, float damage) T_Damage= +{ + local vector dir; + local entity oldself; + local float save; + local float take; + local string s; + local string attackerteam, targteam; + + + if (!targ.takedamage) + return; + +// used by buttons and triggers to set activator for target firing + damage_attacker = attacker; + + +// check for quad damage powerup on the attacker + if (attacker.super_damage_finished > time && inflictor.classname != "door") + if (deathmatch == 4) + damage = damage * 8; + else + damage = damage * 4; + +// save damage based on the target's armor level + + save = ceil(targ.armortype*damage); + 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)); + } + + 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) + { + targ.dmg_take = targ.dmg_take + take; + targ.dmg_save = targ.dmg_save + save; + targ.dmg_inflictor = inflictor; + } + + damage_inflictor = inflictor; + + +// 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 +//Zoid -- use normal NQ kickback +// // Read: only if it's not yourself doing the 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 + // for blast velocity + 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 + if (targ.flags & FL_GODMODE) + return; + 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 + attackerteam = infokey(attacker, "team"); + targteam = infokey(targ, "team"); + + if ((teamplay == 1) && (targteam == attackerteam) && + (attacker.classname == "player") && (attackerteam != "") && + inflictor.classname !="door") + return; + + if ((teamplay == 3) && (targteam == attackerteam) && + (attacker.classname == "player") && (attackerteam != "") && + (targ != attacker)&& inflictor.classname !="door") + return; + +// do the damage + targ.health = targ.health - take; + + if (targ.health <= 0) + { + Killed (targ, attacker); + return; + } + +// react to the damage + oldself = self; + self = targ; + +/*SERVER + 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.enemy.classname == "player") + self.oldenemy = self.enemy; + self.enemy = attacker; + FoundTarget (); + } + } + } +*/ + if (self.th_pain) + { + self.th_pain (attacker, take); + } + + self = oldself; +}; + +/* +============ +T_RadiusDamage +============ +*/ +void(entity inflictor, entity attacker, float damage, entity ignore, string dtype) T_RadiusDamage = +{ + local float points; + local entity head; + local vector org; + + 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"); + + 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) + points = 0; + points = damage - points; + + if (head == attacker) + points = points * 0.5; + if (points > 0) + { + if (CanDamage (head, inflictor)) + { + head.deathtype = dtype; + T_Damage (head, inflictor, attacker, points); + } + } + } + } + head = head.chain; + } +}; + +/* +============ +T_BeamDamage +============ +*/ +void(entity attacker, float damage) T_BeamDamage = +{ + local float points; + local entity head; + + head = findradius(attacker.origin, damage+40); + + 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)) + T_Damage (head, attacker, attacker, points); + } + } + head = head.chain; + } +}; + diff --git a/quakec/fallout2/defs.qc b/quakec/fallout2/defs.qc new file mode 100644 index 000000000..59f95188a --- /dev/null +++ b/quakec/fallout2/defs.qc @@ -0,0 +1,840 @@ + +/* +============================================================================== + + SOURCE FOR GLOBALVARS_T C STRUCTURE + +============================================================================== +*/ + +// +// system globals +// +entity self; +entity other; +entity world; +float time; +float frametime; + +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 + // next frame. this is needed because + // non-moving things don't normally scan + // for triggers, and when a trigger is + // created (like a teleport trigger), it + // needs to catch everything. + // decremented each frame, so set to 2 + // to guarantee everything is touched +string mapname; + +float serverflags; // propagated from level to level, used to + // keep track of completed episodes + +float total_secrets; +float total_monsters; + +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; + +// +// global variables set by built in functions +// +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; + +entity msg_entity; // destination of single entity writes + +// +// required prog functions +// +void() main; // only for testing + +void() StartFrame; + +void() PlayerPreThink; +void() PlayerPostThink; + +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 + // be saved for a level transition + + +//================================================ +void end_sys_globals; // flag for structure dumping +//================================================ + +/* +============================================================================== + + 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 ltime; // local time for entity +.float lastruntime; // *** to allow entities to run out of sequence + +.float movetype; +.float solid; + +.vector origin; // *** +.vector oldorigin; // *** +.vector velocity; +.vector angles; +.vector avelocity; + +.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; + + + +// 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 items; // bit flags + +.float takedamage; +.entity chain; +.float deadflag; + +.vector view_ofs; // add to origin to get eye point + + +.float button0; // fire +.float button1; // use +.float button2; // jump + +.float impulse; // weapon changes + +.float fixangle; +.vector v_angle; // view / targeting angle for players + +.string netname; + +.entity enemy; + +.float flags; + +.float colormap; +.float team; + +.float max_health; // players maximum health is stored here + +.float teleport_time; // don't back up + +.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 ideal_yaw; +.float yaw_speed; + +.entity aiment; + +.entity goalentity; // a movetarget or an enemy + +.float spawnflags; + +.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; + +.entity owner; // who launched a missile +.vector movedir; // mostly for doors, but also used for waterjump + +.string message; // trigger messages + +.float sounds; // either a cd track number or sound number + +.string noise, noise1, noise2, noise3; // contains names of wavs to play + +//================================================ +void end_sys_fields; // flag for structure dumping +//================================================ + +/* +============================================================================== + + VARS NOT REFERENCED BY C CODE + +============================================================================== +*/ + + +// +// constants +// + +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 + +// 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 + +// edict.solid values +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_SLIDEBOX = 3; // touch on edge, but not an onground +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; + +// deadflag values + +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; + +// items +float IT_AXE = 4096; +float IT_SHOTGUN = 1; +float IT_SUPER_SHOTGUN = 2; +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_ARMOR1 = 8192; +float IT_ARMOR2 = 16384; +float IT_ARMOR3 = 32768; +float IT_SUPERHEALTH = 65536; + +float IT_KEY1 = 131072; +float IT_KEY2 = 262144; + +float IT_INVISIBILITY = 524288; +float IT_INVULNERABILITY = 1048576; +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 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_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 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 IDLE1 = 3; +float IDLE2 = 4; +float IDLE3 = 5; +float IDLE4 = 6; +float IDLE5 = 7; +float IDLE6 = 8; +float IDLE7 = 9; +float IDLE8 = 10; +float IDLE9 = 11; +float IDLE10 = 12; +float IDLE1A = 13; +float IDLE2A = 14; +float IDLE3A = 15; +float IDLE4A = 16; +float IDLE5A = 17; +float IDLE6A = 18; +float IDLE7A = 19; +float IDLE8A = 20; +float IDLE9A = 21; +float IDLE10A = 22; + +float DRAW1 = 23; +float DRAW2 = 24; +float DRAW3 = 25; +float DRAW4 = 26; + +// 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 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; + +// 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; +// GLQuakeWorld Stuff +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 + +// 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 + +// 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 + + + + +//================================================ + +// +// 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; + +// +// cvars checked each frame +// +float teamplay; +float timelimit; +float fraglimit; +float deathmatch; +float coop; +float rj = 1; + +//================================================ + +// +// world fields (FIXME: make globals) +// +.string wad; +.string map; +.float worldtype; // 0=medieval 1=metal 2=base + +//================================================ + +.string killtarget; + +// +// quakeed fields +// +.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_die; + +.entity oldenemy; // mad at this player before taking damage + +.float speed; + +.float lefty; + +.float search_time; +.float attack_state; + +float AS_STRAIGHT = 1; +float AS_SLIDING = 2; +float AS_MELEE = 3; +float AS_MISSILE = 4; + +// +// player only fields +// +.float voided; +.float walkframe; + +// Zoid Additions +.float maxspeed; // Used to set Maxspeed on a player +.float gravity; // Gravity Multiplier (0 to 1.0) + + + +.float attack_finished; +.float pain_finished; + +.float invincible_finished; +.float invisible_finished; +.float super_damage_finished; +.float radsuit_finished; + +.float invincible_time, invincible_sound; +.float invisible_time, invisible_sound; +.float super_time, super_sound; +.float rad_time; +.float fly_sound; +.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 POS_STAND = 0; +float POS_DUCK = 0; +float POS_PRONE = 0; + +float blue_gadget; +float red_gadget; +float blue_weapon; +float red_weapon; +float blue_armor; +float red_armor; + +.float ghost; +.float active; +.float class; +.float vote1; +.float vote2; +.float vote3; +.float vote4; +.float vote5; +.float vote6; +.float vote7; +.float override; +.entity track; +.float recharge; +.float processed; +.float current_slot; +.float attack; +.float position; +.float recoil; +.float ammo1; +.float ammo2; +.float mag1; +.float mag2; +.float maxmag1; +.float maxmag2; +.float critical; +.float helmet; +.float rtime; +.float regen; +.float rage; +.float ragetime; +.float action_points; +.float handgrenade; +.float grenadetype; +.float pcamera; +.float pcamera2; +.float equipment_state; +.float select; +.float grenade_hold; +.float grab; +.float vehicle; +.float slot1_weight; +.float slot2_weight; +.float armor_weight; +.float max_weight; +.float sneak; +.float rescued; +.float scale; +.float bandages; +.float scraps; +.float armor; +.float slot1; +.float slot2; +.float cycle1; +.float cycle2; +.float c4; +.float trait; +.float protect; +.float perk; +.float equipment; +.float chem; +.float chemcount; +.float buildtype; +.float ctimer; +.float flash; +.float oldteam; + +.string ammotype1; +.string ammotype2; +.string deathsound; +.string currentmenu; + +.entity friend; +.entity view2; +.vector oldorg; + +// +// object stuff +// +.string mdl; +.vector mangle; // angle at start + +.vector oldorigin; // only used by secret door + +.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 +// + +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(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; + +// sets trace_* globals +// nomonsters can be: +// An entity will also be ignored for testing if forent == test, +// 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(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; +entity(vector org, float rad) findradius = #22; +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 +float(float yaw, float dist) walkmove = #32; // returns TRUE or FALSE +// #33 was removed +float(float yaw, float dist) 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; + +// +// 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; + +// several removed + +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(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 + +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 + +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 + +//============================================================================ + +// +// 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; +void() SUB_CalcMoveDone; +void() SUB_CalcAngleMoveDone; +void() SUB_Null; +void() SUB_UseTargets; +void() SUB_Remove; + +// +// 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 targ, entity inflictor) CanDamage; + + diff --git a/quakec/fallout2/demon.qc b/quakec/fallout2/demon.qc new file mode 100644 index 000000000..593e80466 --- /dev/null +++ b/quakec/fallout2/demon.qc @@ -0,0 +1,384 @@ +/* +============================================================================== + +DEMON + +============================================================================== +*/ + +$cd id1/models/demon3 +$scale 0.8 +$origin 0 0 24 +$base base +$skin base + +$frame stand1 stand2 stand3 stand4 stand5 stand6 stand7 stand8 stand9 +$frame stand10 stand11 stand12 stand13 + +$frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8 + +$frame run1 run2 run3 run4 run5 run6 + +$frame leap1 leap2 leap3 leap4 leap5 leap6 leap7 leap8 leap9 leap10 +$frame leap11 leap12 + +$frame pain1 pain2 pain3 pain4 pain5 pain6 + +$frame death1 death2 death3 death4 death5 death6 death7 death8 death9 + +$frame attacka1 attacka2 attacka3 attacka4 attacka5 attacka6 attacka7 attacka8 +$frame attacka9 attacka10 attacka11 attacka12 attacka13 attacka14 attacka15 + +//============================================================================ + +void(float side) Demon_Melee; + +void() Demon_JumpTouch; + +void() demon1_stand1 =[ $stand1, demon1_stand2 ] {ai_stand();}; +void() demon1_stand2 =[ $stand2, demon1_stand3 ] {ai_stand();}; +void() demon1_stand3 =[ $stand3, demon1_stand4 ] {ai_stand();}; +void() demon1_stand4 =[ $stand4, demon1_stand5 ] {ai_stand();}; +void() demon1_stand5 =[ $stand5, demon1_stand6 ] {ai_stand();}; +void() demon1_stand6 =[ $stand6, demon1_stand7 ] {ai_stand();}; +void() demon1_stand7 =[ $stand7, demon1_stand8 ] {ai_stand();}; +void() demon1_stand8 =[ $stand8, demon1_stand9 ] {ai_stand();}; +void() demon1_stand9 =[ $stand9, demon1_stand10 ] {ai_stand();}; +void() demon1_stand10 =[ $stand10, demon1_stand11 ] {ai_stand();}; +void() demon1_stand11 =[ $stand11, demon1_stand12 ] {ai_stand();}; +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); +}; +void() demon1_walk2 =[ $walk2, demon1_walk3 ] {ai_walk(6);}; +void() demon1_walk3 =[ $walk3, demon1_walk4 ] {ai_walk(6);}; +void() demon1_walk4 =[ $walk4, demon1_walk5 ] {ai_walk(7);}; +void() demon1_walk5 =[ $walk5, demon1_walk6 ] {ai_walk(4);}; +void() demon1_walk6 =[ $walk6, demon1_walk7 ] {ai_walk(6);}; +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);}; +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);}; +void() demon1_run5 =[ $run5, demon1_run6 ] {ai_run(15);}; +void() demon1_run6 =[ $run6, demon1_run1 ] {ai_run(36);}; + +void() demon1_jump1 =[ $leap1, demon1_jump2 ] { +sound (self, CHAN_VOICE, "demon/djump.wav", 1, ATTN_NORM); +ai_face();}; +void() demon1_jump2 =[ $leap2, demon1_jump3 ] {ai_face();}; +void() demon1_jump3 =[ $leap3, demon1_jump4 ] {ai_face();}; +void() demon1_jump4 =[ $leap4, demon1_jump5 ] +{ + ai_face(); + + self.touch = Demon_JumpTouch; + makevectors (self.angles); + self.origin_z = self.origin_z + 1; + self.velocity = v_forward * 600 + '0 0 250'; + if (self.flags & FL_ONGROUND) + self.flags = self.flags - FL_ONGROUND; +}; +void() demon1_jump5 =[ $leap5, demon1_jump6 ] {}; +void() demon1_jump6 =[ $leap6, demon1_jump7 ] {}; +void() demon1_jump7 =[ $leap7, demon1_jump8 ] {}; +void() demon1_jump8 =[ $leap8, demon1_jump9 ] {}; +void() demon1_jump9 =[ $leap9, demon1_jump10 ] {}; +void() demon1_jump10 =[ $leap10, demon1_jump1 ] { +self.nextthink = time + 3; +// if three seconds pass, assume demon is stuck and jump again +}; + +void() demon1_jump11 =[ $leap11, demon1_jump12 ] {}; +void() demon1_jump12 =[ $leap12, demon1_run1 ] {}; + +void() ClawSound = +{ + local float r; + + r = random(); + if (r <= 0.33) + sound (self, CHAN_VOICE, "demon/attack1.wav", 1, ATTN_NORM); + else if (r <= 0.67) + sound (self, CHAN_VOICE, "demon/attack2.wav", 1, ATTN_NORM); + else + sound (self, CHAN_VOICE, "demon/attack3.wav", 1, ATTN_NORM); +}; + +void() demon1_atta1 =[ $attacka1, demon1_atta2 ] { +ClawSound(); +ai_charge(4);}; +void() demon1_atta2 =[ $attacka2, demon1_atta3 ] {ai_charge(0);}; +void() demon1_atta3 =[ $attacka3, demon1_atta4 ] {ai_charge(0);}; +void() demon1_atta4 =[ $attacka4, demon1_atta5 ] {ai_charge(1);}; +void() demon1_atta5 =[ $attacka5, demon1_atta6 ] {ai_charge(2); Demon_Melee(200);}; +void() demon1_atta6 =[ $attacka6, demon1_atta7 ] {ai_charge(1);}; +void() demon1_atta7 =[ $attacka7, demon1_atta8 ] {ai_charge(6);}; +void() demon1_atta8 =[ $attacka8, demon1_atta9 ] {ai_charge(8);}; +void() demon1_atta9 =[ $attacka9, demon1_atta10] {ai_charge(4);}; +void() demon1_atta10 =[ $attacka10, demon1_atta11] { +ClawSound(); +ai_charge(2);}; +void() demon1_atta11 =[ $attacka11, demon1_atta12] {Demon_Melee(-200);}; +void() demon1_atta12 =[ $attacka12, demon1_atta13] {ai_charge(5);}; +void() demon1_atta13 =[ $attacka13, demon1_atta14] {ai_charge(8);}; +void() demon1_atta14 =[ $attacka14, demon1_atta15] {ai_charge(4);}; +void() demon1_atta15 =[ $attacka15, demon1_run1] {ai_charge(4);}; + +void() demon1_pain1 =[ $pain1, demon1_pain2 ] {}; +void() demon1_pain2 =[ $pain2, demon1_pain3 ] {}; +void() demon1_pain3 =[ $pain3, demon1_pain4 ] {}; +void() demon1_pain4 =[ $pain4, demon1_pain5 ] {}; +void() demon1_pain5 =[ $pain5, demon1_pain6 ] {}; +void() demon1_pain6 =[ $pain6, demon1_run1 ] {}; + +void(entity attacker, float damage) demon1_pain = +{ + if (self.touch == Demon_JumpTouch) + return; + + if (self.pain_finished > time) + return; + + self.pain_finished = time + 10; + sound (self, CHAN_VOICE, "demon/dpain1.wav", 1, ATTN_NORM); + + if (random()*200 > damage) + return; // didn't flinch + + demon1_pain1 (); +}; + +void() demon1_die1 =[ $death1, demon1_die2 ] { +sound (self, CHAN_VOICE, "demon/death1.wav", 1, ATTN_NORM);}; +void() demon1_die2 =[ $death2, demon1_die3 ] {}; +void() demon1_die3 =[ $death3, demon1_die4 ] {}; +void() demon1_die4 =[ $death4, demon1_die5 ] {}; +void() demon1_die5 =[ $death5, demon1_die6 ] {}; +void() demon1_die6 =[ $death6, demon1_die7 ] +{self.solid = SOLID_NOT;}; +void() demon1_die7 =[ $death7, demon1_die8 ] {}; +void() demon1_die8 =[ $death8, demon1_die9 ] {}; +void() demon1_die9 =[ $death9, demon1_die9 ] {}; + +void() demon_die = +{ +// check for gib + if (self.health < -80) + { + sound (self, CHAN_VOICE, "demon/death2.wav", 1, ATTN_NORM); + ThrowHead ("progs/h_demon.mdl", self.health); + ThrowGib ("progs/gib1.mdl", self.health); + ThrowGib ("progs/gib1.mdl", self.health); + ThrowGib ("progs/gib1.mdl", self.health); + return; + } + +// regular death + demon1_die1 (); +}; + + +void() Demon_MeleeAttack = +{ + demon1_atta1 (); +}; + +void() monster_demon1 = +{ + precache_model ("progs/demon.mdl"); + precache_model ("progs/h_demon.mdl"); + + precache_sound ("demon/dhit2.wav"); + precache_sound ("demon/djump.wav"); + precache_sound ("demon/dpain1.wav"); + precache_sound ("demon/idle1.wav"); + precache_sound ("demon/sight2.wav"); + precache_sound ("demon/death1.wav"); + precache_sound ("demon/death2.wav"); + precache_sound ("demon/attack1.wav"); + precache_sound ("demon/attack2.wav"); + precache_sound ("demon/attack3.wav"); + + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_STEP; + + setmodel (self, "progs/demon.mdl"); + + setsize (self, VEC_HULL2_MIN, VEC_HULL2_MAX); + self.health = 1200; + self.team = 3; + self.classname = "monster"; + self.netname = "deathclaw"; + self.th_stand = demon1_stand1; + self.th_walk = demon1_walk1; + self.th_run = demon1_run1; + self.th_die = demon_die; + self.th_melee = Demon_MeleeAttack; // one of two attacks + self.th_missile = demon1_jump1; // jump attack + self.th_pain = demon1_pain; + + walkmonster_start(); +}; + + +/* +============================================================================== + +DEMON + +============================================================================== +*/ + +/* +============== +CheckDemonMelee + +Returns TRUE if a melee attack would hit right now +============== +*/ +float() CheckDemonMelee = +{ + if (enemy_range == RANGE_MELEE) + { // FIXME: check canreach + self.attack_state = AS_MELEE; + return TRUE; + } + return FALSE; +}; + +/* +============== +CheckDemonJump + +============== +*/ +float() CheckDemonJump = +{ + 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) + return FALSE; + + if (self.origin_z + self.maxs_z < self.enemy.origin_z + self.enemy.mins_z + + 0.25 * self.enemy.size_z) + return FALSE; + + dist = self.enemy.origin - self.origin; + dist_z = 0; + + d = vlen(dist); + + if (d < 100) + return FALSE; + + if (d > 200) + { + if (random() < 0.9) + return FALSE; + } + + return TRUE; +}; + +float() DemonCheckAttack = +{ + local vector vec; + +// if close enough for slashing, go for it + if (CheckDemonMelee ()) + { + self.attack_state = AS_MELEE; + return TRUE; + } + + if (CheckDemonJump ()) + { + self.attack_state = AS_MISSILE; + return TRUE; + } + + return FALSE; +}; + + +//=========================================================================== + +void(float side) Demon_Melee = +{ + local float ldmg; + local vector delta; + + ai_face (); + walkmove (self.ideal_yaw, 12); // allow a little closing + + delta = self.enemy.origin - self.origin; + + 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(); + 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; + + if (self.health <= 0) + return; + + if (other.takedamage) + { + if ( vlen(self.velocity) > 400 ) + { + ldmg = 40 + 10*random(); + ldmg = ldmg / 4; + T_Damage (other, self, self, ldmg); + T_Damage (other, self, self, ldmg); + T_Damage (other, self, self, ldmg); + 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; + +// self.velocity_x = (random() - 0.5) * 600; +// self.velocity_y = (random() - 0.5) * 600; +// self.velocity_z = 200; +// self.flags = self.flags - FL_ONGROUND; + } + return; // not on ground yet + } + + self.touch = SUB_Null; + self.think = demon1_jump11; + self.nextthink = time + 0.1; +}; + diff --git a/quakec/fallout2/dog.qc b/quakec/fallout2/dog.qc new file mode 100644 index 000000000..cd83be212 --- /dev/null +++ b/quakec/fallout2/dog.qc @@ -0,0 +1,540 @@ +/* +============================================================================== + +DOG + +============================================================================== +*/ +$cd id1/models/dog +$origin 0 0 24 +$base base +$skin skin + +$frame attack1 attack2 attack3 attack4 attack5 attack6 attack7 attack8 + +$frame death1 death2 death3 death4 death5 death6 death7 death8 death9 + +$frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8 +$frame deathb9 + +$frame pain1 pain2 pain3 pain4 pain5 pain6 + +$frame painb1 painb2 painb3 painb4 painb5 painb6 painb7 painb8 painb9 painb10 +$frame painb11 painb12 painb13 painb14 painb15 painb16 + +$frame run1 run2 run3 run4 run5 run6 run7 run8 run9 run10 run11 run12 + +$frame leap1 leap2 leap3 leap4 leap5 leap6 leap7 leap8 leap9 + +$frame stand1 stand2 stand3 stand4 stand5 stand6 stand7 stand8 stand9 + +$frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8 + + +void() dog_leap1; +void() dog_run1; + +/* +================ +dog_bite + +================ +*/ +void() Sniff; + +void() dog_bite = +{ +local vector delta; +local float ldmg; + + if (!self.enemy) + return; + + self.goalentity = self.enemy; + + ai_charge(10); + + if (!CanDamage (self.enemy, self)) + return; + + delta = self.enemy.origin - self.origin; + + if (vlen(delta) > (100*self.scale)) + return; + + ldmg = 8+random()*8; + + if (self.classname == "robofang") + ldmg = 4+random()*4; + + T_Damage (self.enemy, self, self, ldmg); + T_Damage (self.enemy, self, self, ldmg); +}; + +void() Dog_JumpTouch = +{ + local float ldmg; + + if (self.health <= 0) + return; + + 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; + +// self.velocity_x = (random() - 0.5) * 600; +// self.velocity_y = (random() - 0.5) * 600; +// self.velocity_z = 200; +// self.flags = self.flags - FL_ONGROUND; + } + return; // not on ground yet + } + + self.touch = SUB_Null; + self.think = dog_run1; + self.nextthink = time + 0.1; +}; + +void() BackDown = +{ + if (self.enemy == world && self.classname == "robofang") + { + self.goalentity = self.owner; + self.th_walk(); + } +/* + if (self.enemy.team == self.team) + { + self.enemy = world; + self.goalentity = self.owner; + self.th_walk(); + }*/ +}; + + + +void() dog_stand1 =[ $stand1, dog_stand2 ] {ai_stand();}; +void() dog_stand2 =[ $stand2, dog_stand3 ] {ai_stand();}; +void() dog_stand3 =[ $stand3, dog_stand4 ] {ai_stand(); + +}; +void() dog_stand4 =[ $stand4, dog_stand5 ] {ai_stand();}; +void() dog_stand5 =[ $stand5, dog_stand6 ] {ai_stand();}; +void() dog_stand6 =[ $stand6, dog_stand7 ] {ai_stand();}; +void() dog_stand7 =[ $stand7, dog_stand8 ] {ai_stand();}; +void() dog_stand8 =[ $stand8, dog_stand9 ] {ai_stand();}; +void() dog_stand9 =[ $stand9, dog_stand1 ] {ai_stand(); + + Sniff(); + BackDown(); +}; + +void() dog_walk1 =[ $walk1 , dog_walk2 ] { +if (random() < 0.1) + 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);}; +void() dog_walk5 =[ $walk5 , dog_walk6 ] {ai_walk(8); + + Sniff(); + BackDown(); +}; +void() dog_walk6 =[ $walk6 , dog_walk7 ] {ai_walk(8);}; +void() dog_walk7 =[ $walk7 , dog_walk8 ] {ai_walk(8);}; +void() dog_walk8 =[ $walk8 , dog_walk1 ] {ai_walk(8);}; + +void() Sniff = +{ + local entity te; + local float x; + + if (self.classname != "robofang") + return; + + x = 20; + te = findradius (self.origin, 500); + while (te) + { + if (te.classname == "monster" && te.enemy == self.owner) + { + if (self.rtime < time) + sound (self, CHAN_VOICE, "dog/dsight.wav", 1, ATTN_NORM); + self.rtime = time + 5; + self.enemy = te; + FoundTarget(); + return; + } + te = te.chain; + } +}; + +void() dog_run1 =[ $run1 , dog_run2 ] { + + + Sniff(); + BackDown(); + +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);}; +void() dog_run5 =[ $run5 , dog_run6 ] {ai_run(64);}; +void() dog_run6 =[ $run6 , dog_run7 ] { + +if (self.enemy == self.owner) + self.enemy = self.enemy.enemy; + +ai_run(32);}; +void() dog_run7 =[ $run7 , dog_run8 ] {ai_run(16);}; +void() dog_run8 =[ $run8 , dog_run9 ] {ai_run(32);}; +void() dog_run9 =[ $run9 , dog_run10 ] {ai_run(32);}; +void() dog_run10 =[ $run10 , dog_run11 ] {ai_run(20);}; +void() dog_run11 =[ $run11 , dog_run12 ] {ai_run(64);}; +void() dog_run12 =[ $run12 , dog_run1 ] {ai_run(32);}; + +void() dog_atta1 =[ $attack1, dog_atta2 ] { + +ai_charge(10);}; +void() dog_atta2 =[ $attack2, dog_atta3 ] {ai_charge(10);}; +void() dog_atta3 =[ $attack3, dog_atta4 ] {ai_charge(10);}; +void() dog_atta4 =[ $attack4, dog_atta5 ] { +sound (self, CHAN_VOICE, "dog/dattack1.wav", 1, ATTN_NORM); +dog_bite();}; +void() dog_atta5 =[ $attack5, dog_atta6 ] {ai_charge(10);}; +void() dog_atta6 =[ $attack6, dog_atta7 ] {ai_charge(10);}; +void() dog_atta7 =[ $attack7, dog_atta8 ] {ai_charge(10);}; +void() dog_atta8 =[ $attack8, dog_run1 ] {ai_charge(10);}; + +void() dog_leap1 =[ $leap1, dog_leap2 ] {ai_face();}; +void() dog_leap2 =[ $leap2, dog_leap3 ] +{ + ai_face(); + + self.touch = Dog_JumpTouch; + makevectors (self.angles); + self.origin_z = self.origin_z + 1; + self.velocity = v_forward * 300 + '0 0 200'; + if (self.flags & FL_ONGROUND) + self.flags = self.flags - FL_ONGROUND; +}; + +void() dog_leap3 =[ $leap3, dog_leap4 ] {}; +void() dog_leap4 =[ $leap4, dog_leap5 ] {}; +void() dog_leap5 =[ $leap5, dog_leap6 ] {}; +void() dog_leap6 =[ $leap6, dog_leap7 ] {}; +void() dog_leap7 =[ $leap7, dog_leap8 ] {}; +void() dog_leap8 =[ $leap8, dog_leap9 ] {}; +void() dog_leap9 =[ $leap9, dog_leap9 ] {}; + +void() dog_pain1 =[ $pain1 , dog_pain2 ] {}; +void() dog_pain2 =[ $pain2 , dog_pain3 ] {}; +void() dog_pain3 =[ $pain3 , dog_pain4 ] {}; +void() dog_pain4 =[ $pain4 , dog_pain5 ] {}; +void() dog_pain5 =[ $pain5 , dog_pain6 ] {}; +void() dog_pain6 =[ $pain6 , dog_run1 ] {}; + +void() dog_painb1 =[ $painb1 , dog_painb2 ] {}; +void() dog_painb2 =[ $painb2 , dog_painb3 ] {}; +void() dog_painb3 =[ $painb3 , dog_painb4 ] {ai_pain(4);}; +void() dog_painb4 =[ $painb4 , dog_painb5 ] {ai_pain(12);}; +void() dog_painb5 =[ $painb5 , dog_painb6 ] {ai_pain(12);}; +void() dog_painb6 =[ $painb6 , dog_painb7 ] {ai_pain(2);}; +void() dog_painb7 =[ $painb7 , dog_painb8 ] {}; +void() dog_painb8 =[ $painb8 , dog_painb9 ] {ai_pain(4);}; +void() dog_painb9 =[ $painb9 , dog_painb10 ] {}; +void() dog_painb10 =[ $painb10 , dog_painb11 ] {ai_pain(10);}; +void() dog_painb11 =[ $painb11 , dog_painb12 ] {}; +void() dog_painb12 =[ $painb12 , dog_painb13 ] {}; +void() dog_painb13 =[ $painb13 , dog_painb14 ] {}; +void() dog_painb14 =[ $painb14 , dog_painb15 ] {}; +void() dog_painb15 =[ $painb15 , dog_painb16 ] {}; +void() dog_painb16 =[ $painb16 , dog_run1 ] {}; + +void() dog_pain = +{ + sound (self, CHAN_VOICE, "dog/dpain1.wav", 1, ATTN_NORM); + + if (random() > 0.5) + dog_pain1 (); + else + dog_painb1 (); +}; + +void() dog_die1 =[ $death1, dog_die2 ] {}; +void() dog_die2 =[ $death2, dog_die3 ] {}; +void() dog_die3 =[ $death3, dog_die4 ] {}; +void() dog_die4 =[ $death4, dog_die5 ] {}; +void() dog_die5 =[ $death5, dog_die6 ] {}; +void() dog_die6 =[ $death6, dog_die7 ] {}; +void() dog_die7 =[ $death7, dog_die8 ] {}; +void() dog_die8 =[ $death8, dog_die9 ] { +self.solid = SOLID_NOT; +}; +void() dog_die9 =[ $death9, dog_die9 ] {}; + +void() dog_dieb1 =[ $deathb1, dog_dieb2 ] {}; +void() dog_dieb2 =[ $deathb2, dog_dieb3 ] {}; +void() dog_dieb3 =[ $deathb3, dog_dieb4 ] {}; +void() dog_dieb4 =[ $deathb4, dog_dieb5 ] {}; +void() dog_dieb5 =[ $deathb5, dog_dieb6 ] {}; +void() dog_dieb6 =[ $deathb6, dog_dieb7 ] {}; +void() dog_dieb7 =[ $deathb7, dog_dieb8 ] {}; +void() dog_dieb8 =[ $deathb8, dog_dieb9 ] { +self.solid = SOLID_NOT; +}; +void() dog_dieb9 =[ $deathb9, dog_dieb9 ] {}; + +void () woof_pain = +{ + if (self.frame == 26) + { + self.frame = 27; + self.health = 180; + self.think = dog_die1; + self.nextthink = time + 0.12; + } + else + { + ThrowGib2 ("progs/zom_gib.mdl", -35); + self.frame = 26; + self.health = 180; + self.think = dog_dieb1; + self.nextthink = time + 0.12; + } + + self.attack = self.attack + 1; + + if (self.attack >= 4) + { + if (random()*4 <= 2) + sound (self, CHAN_VOICE, "zombie/z_gib.wav", 1, ATTN_NORM); + else + sound (self, CHAN_VOICE, "dog/death2.wav", 1, ATTN_NORM); + + ThrowHead ("progs/h_dog.mdl", -30); + ThrowGib ("progs/gib1.mdl", -30); + ThrowGib ("progs/gib2.mdl", -30); + ThrowGib ("progs/gib3.mdl", -30); + ThrowGib2 ("progs/zom_gib.mdl", -45); + ThrowGib2 ("progs/zom_gib.mdl", -45); + } +}; + +void (vector stuff) spawn_live_dog = +{ + local entity dog; + local entity te; + + dog = spawn (); + dog.origin = stuff; + dog.enemy = world; + dog.attack_finished = time + 10; + dog.solid = SOLID_SLIDEBOX; + dog.movetype = MOVETYPE_STEP; + dog.takedamage = DAMAGE_YES; + setmodel (dog, "progs/dog.mdl"); + setsize (dog, VEC_HULL_MIN, '16 16 40'); + dog.classname = "body"; + dog.netname = "dead"; + dog.health = 180; + dog.max_health = dog.health; + dog.th_pain = woof_pain; + dog.think = woof_pain; + dog.nextthink = time + 0.05; +}; + +void () dog_die = +{ + if (self.enemy.classname == "player") + self.enemy.frags = self.enemy.frags + 1; + + if (self.health < -35) + { + self.solid = SOLID_NOT; + sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); + dog_die1 (); + } + else + { + sound (self, CHAN_VOICE, "dog/ddeath.wav", 1, ATTN_NORM); + self.solid = SOLID_NOT; + spawn_live_dog(self.origin); + remove(self); + } +}; + +//============================================================================ + +/* +============== +CheckDogMelee + +Returns TRUE if a melee attack would hit right now +============== +*/ +float() CheckDogMelee = +{ + if (enemy_range == RANGE_MELEE) + { // FIXME: check canreach + self.attack_state = AS_MELEE; + return TRUE; + } + return FALSE; +}; + +/* +============== +CheckDogJump + +============== +*/ +float() CheckDogJump = +{ + 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) + return FALSE; + + if (self.origin_z + self.maxs_z < self.enemy.origin_z + self.enemy.mins_z + + 0.25 * self.enemy.size_z) + return FALSE; + + dist = self.enemy.origin - self.origin; + dist_z = 0; + + d = vlen(dist); + + if (d < 80) + return FALSE; + + if (d > 150) + return FALSE; + + return TRUE; +}; + +float() DogCheckAttack = +{ + local vector vec; + +// if close enough for slashing, go for it + if (CheckDogMelee ()) + { + self.attack_state = AS_MELEE; + return TRUE; + } + + if (CheckDogJump ()) + { + self.attack_state = AS_MISSILE; + return TRUE; + } + + return FALSE; +}; + + +//=========================================================================== + +void() monster_dog = +{ + precache_model ("progs/h_dog.mdl"); + precache_model ("progs/dog.mdl"); + + precache_sound ("dog/dattack1.wav"); + precache_sound ("dog/ddeath.wav"); + precache_sound ("dog/death2.wav"); + precache_sound ("dog/dpain1.wav"); + precache_sound ("dog/dsight.wav"); + precache_sound ("dog/idle.wav"); + + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_STEP; + + setmodel (self, "progs/dog.mdl"); + + setsize (self, '-24 -24 -24', '24 24 24'); + self.health = 75; + self.scale = 1; + self.team = 3; + self.takedamage = DAMAGE_YES; + self.classname = "monster"; + self.netname = "radwolf"; + self.th_stand = dog_stand1; + self.th_walk = dog_walk1; + self.th_run = dog_run1; + self.th_pain = dog_pain; + self.th_die = dog_die; + self.th_melee = dog_atta1; + + walkmonster_start(); +}; + +void (vector org) spawn_dog = +{ + local entity dog, oself; + local entity te; + + makevectors (self.v_angle); + org = ((org + (v_forward * 96)) + (v_up * 72)); + self.impulse = 0; + te = findradius (org, 80); + while (te) + { + if (te.classname == "player" && te.health > 0) + return; + + te = te.chain; + } + + dog = spawn(); + oself = self; + self = dog; + self.scale = 1; + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_STEP; + + setmodel (self, "progs/dog.mdl"); + setorigin(self, org); + setsize (self, '-24 -24 -24', '24 24 24'); + self.health = 150; + self.helmet = 1; + self.armortype = 0.3; + self.takedamage = DAMAGE_YES; + self.classname = "robofang"; + self.netname = "robofang"; + self.th_stand = dog_stand1; + self.th_walk = dog_walk1; + self.th_run = dog_run1; + self.th_pain = dog_pain; + self.th_die = station_die; + self.th_melee = dog_atta1; + self.think = self.th_walk; + self.owner = oself; + self.track = oself; + self.nextthink = time + 0.1; + walkmonster_start(); + + self = oself; +}; + diff --git a/quakec/fallout2/doors.qc b/quakec/fallout2/doors.qc new file mode 100644 index 000000000..8be65c771 --- /dev/null +++ b/quakec/fallout2/doors.qc @@ -0,0 +1,735 @@ +float DOOR_START_OPEN = 1; +float DOOR_DONT_LINK = 4; +float DOOR_GOLD_KEY = 8; +float DOOR_SILVER_KEY = 16; +float DOOR_TOGGLE = 32; +void () door_go_down; +void () door_go_up; + +void () door_blocked = +{ + T_Damage (other, self, self, self.dmg); + if ((self.wait >= MULTICAST_ALL)) + { + if ((self.state == STATE_DOWN)) + { + door_go_up (); + } + else + { + door_go_down (); + } + } +}; + +void () door_hit_top = +{ + sound (self, (CHAN_NO_PHS_ADD + CHAN_VOICE), self.noise1, DOOR_START_OPEN, ATTN_NORM); + self.state = STATE_TOP; + if ((self.spawnflags & DOOR_TOGGLE)) + { + return; + } + if (self.owner.rtime == 0) + { + self.think = door_go_down; + self.nextthink = (self.ltime + self.wait); + } +}; + +void () door_hit_bottom = +{ + sound (self, (CHAN_NO_PHS_ADD + CHAN_VOICE), self.noise1, DOOR_START_OPEN, ATTN_NORM); + self.state = STATE_BOTTOM; +}; + +void () door_go_down = +{ + sound (self, CHAN_VOICE, self.noise2, DOOR_START_OPEN, ATTN_NORM); + if (self.max_health) + { + self.takedamage = DAMAGE_YES; + self.health = self.max_health; + } + self.state = STATE_DOWN; + SUB_CalcMove (self.pos1, self.speed, door_hit_bottom); +}; + +void () door_go_up = +{ + if (self.state == STATE_UP) + return; // allready going up + + if (self.state == STATE_TOP) + { // reset top wait time + self.nextthink = self.ltime + self.wait; + return; + } + + sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM); + self.state = STATE_UP; + SUB_CalcMove (self.pos2, self.speed, door_hit_top); + SUB_UseTargets(); +}; + +void () door_fire = +{ + local entity oself; + local entity starte; + + if ((self.owner != self)) + { + objerror ("door_fire: self.owner != self"); + } + if (self.items) + { + sound (self, CHAN_VOICE, self.noise4, DOOR_START_OPEN, ATTN_NORM); + } + self.message = string_null; + oself = self; + if ((self.spawnflags & DOOR_TOGGLE)) + { + if (((self.state == STATE_UP) || (self.state == STATE_TOP))) + { + starte = self; + do + { + door_go_down (); + self = self.enemy; + + } while (((self != starte) && (self != world))); + self = oself; + return; + } + } + starte = self; + do + { + door_go_up (); + self = self.enemy; + + } while (((self != starte) && (self != world))); + self = oself; +}; + +void () door_use = +{ + local entity oself; + + self.message = ""; + self.owner.message = ""; + self.enemy.message = ""; + oself = self; + self = self.owner; + door_fire (); + self = oself; +}; + +void () door_trigger_touch = +{ + if ((other.health <= MULTICAST_ALL)) + { + return; + } + if ((time < self.attack_finished)) + { + return; + } + self.attack_finished = (time + DOOR_START_OPEN); + activator = other; + self = self.owner; + door_use (); +}; + +void () door_killed = +{ + local entity oself; + + oself = self; + self = self.owner; + self.health = self.max_health; + self.takedamage = DAMAGE_NO; + door_use (); + self = oself; +}; + + +void () OpenDoorBeep = +{ + local float r; + local string stuff; + + r = range (self.enemy); + + if (r != RANGE_MELEE) + { + self.think = OpenDoorBeep; + self.nextthink = time + 0.5; + return; + } + + if (random()*3<1) + sound (self, CHAN_BODY, "misc/build1.wav", 1, ATTN_NORM); + else if (random()*3<2) + sound (self, CHAN_BODY, "misc/build2.wav", 1, ATTN_NORM); + else + sound (self, CHAN_BODY, "misc/build3.wav", 1, ATTN_NORM); + + self.think = OpenDoorBeep; + self.nextthink = time + 0.5; + self.owner.owner.rtime = self.owner.owner.rtime + 1; + self.frame = floor ((self.owner.owner.rtime / 12) * 7); + + if (self.owner.owner.rtime >= 12) + { + sound (self, CHAN_BODY, "misc/basekey.wav", 1, ATTN_NORM); + self.think = SUB_Remove; + self.nextthink = time + 1; + return; + } +}; + +void (entity portal, entity toucher) SpawnOpenDoor = +{ + local entity open, oself; + + open = spawn(); + setorigin (open, toucher.origin + '0 0 48'); + setmodel (open, "progs/hbar.spr"); + setsize (open, VEC_ORIGIN, VEC_ORIGIN); + open.think = OpenDoorBeep; + open.nextthink = time + 1; + open.enemy = toucher; + open.owner = portal; +}; + + +void () door_touch = +{ + local float x; + local string stuff; + + if (other.classname != "player") + return; + + if (self.owner.attack_finished > time) + return; + + if (self.state != STATE_BOTTOM) + return; + + if (self.size_y > 64 && self.size_x > 64) + return; + + self.owner.attack_finished = (time + WEAPON_ROCKET); + if ((self.owner.message != "")) + { + centerprint (other, self.owner.message); + sound (other, CHAN_VOICE, "misc/talk.wav", DOOR_START_OPEN, ATTN_NORM); + } + if (!self.items) + return; + + if (self.owner.rtime > 0 && self.owner.rtime < 12) + return; + + if ((self.size_z <= 160) && self.owner.rtime == 0 && self.items & other.items != self.items) + { + if (self.size_y <= 128 && self.size_x <= 128) + { + if (other.class == 6) + { + SpawnOpenDoor(self, other); + return; + } + + if (self.owner.items == IT_KEY1) + sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); + + if (self.owner.items == IT_KEY2) + sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM); + + return; + } + } + if (self.owner.rtime >= 12) + { + door_use (); + return; + } + + door_use (); +}; + +entity (vector fmins, vector fmaxs) spawn_field = +{ + local entity trigger; + local vector t1; + local vector t2; + + trigger = spawn (); + trigger.movetype = MOVETYPE_NONE; + trigger.solid = SOLID_TRIGGER; + trigger.owner = self; + trigger.touch = door_trigger_touch; + t1 = fmins; + t2 = fmaxs; + setsize (trigger, (t1 - '60 60 8'), (t2 + '60 60 8')); + return (trigger); +}; + +float (entity e1, entity e2) EntitiesTouching = +{ + if ((e1.mins_x > e2.maxs_x)) + { + return (FALSE); + } + if ((e1.mins_y > e2.maxs_y)) + { + return (FALSE); + } + if ((e1.mins_z > e2.maxs_z)) + { + return (FALSE); + } + if ((e1.maxs_x < e2.mins_x)) + { + return (FALSE); + } + if ((e1.maxs_y < e2.mins_y)) + { + return (FALSE); + } + if ((e1.maxs_z < e2.mins_z)) + { + return (FALSE); + } + return (TRUE); +}; + +void () LinkDoors = +{ + local entity t; + local entity starte; + local vector cmins; + local vector cmaxs; + + if (self.enemy) + { + return; + } + if ((self.spawnflags & DOOR_DONT_LINK)) + { + self.enemy = self; + self.owner = self; + return; + } + cmins = self.mins; + cmaxs = self.maxs; + starte = self; + t = self; + do + { + self.owner = starte; + if (self.health) + { + starte.health = self.health; + } + if (self.targetname) + { + starte.targetname = self.targetname; + } + if ((self.message != "")) + { + starte.message = self.message; + } + t = find (t, classname, self.classname); + if (!t) + { + self.enemy = starte; + self = self.owner; + if (self.health) + { + return; + } + if (self.targetname) + { + return; + } + if (self.items) + { + return; + } + self.owner.trigger_field = spawn_field (cmins, cmaxs); + return; + } + if (EntitiesTouching (self, t)) + { + if (t.enemy) + { + objerror ("cross connected doors"); + } + self.enemy = t; + self = t; + if ((t.mins_x < cmins_x)) + { + cmins_x = t.mins_x; + } + if ((t.mins_y < cmins_y)) + { + cmins_y = t.mins_y; + } + if ((t.mins_z < cmins_z)) + { + cmins_z = t.mins_z; + } + if ((t.maxs_x > cmaxs_x)) + { + cmaxs_x = t.maxs_x; + } + if ((t.maxs_y > cmaxs_y)) + { + cmaxs_y = t.maxs_y; + } + if ((t.maxs_z > cmaxs_z)) + { + cmaxs_z = t.maxs_z; + } + } + + } while (DOOR_START_OPEN); +}; + +void () func_door = +{ + local float r; + + if ((world.worldtype == MULTICAST_ALL)) + { + precache_sound ("doors/medtry.wav"); + precache_sound ("doors/meduse.wav"); + self.noise3 = "doors/medtry.wav"; + self.noise4 = "doors/meduse.wav"; + } + else + { + if ((world.worldtype == DOOR_START_OPEN)) + { + precache_sound ("doors/runetry.wav"); + precache_sound ("doors/runeuse.wav"); + self.noise3 = "doors/runetry.wav"; + self.noise4 = "doors/runeuse.wav"; + } + else + { + if ((world.worldtype == WEAPON_ROCKET)) + { + precache_sound ("doors/basetry.wav"); + precache_sound ("doors/baseuse.wav"); + self.noise3 = "doors/basetry.wav"; + self.noise4 = "doors/baseuse.wav"; + } + else + { + dprint ("no worldtype set!\n"); + } + } + } + if ((self.sounds == MULTICAST_ALL)) + { + precache_sound ("misc/null.wav"); + precache_sound ("misc/null.wav"); + self.noise1 = "misc/null.wav"; + self.noise2 = "misc/null.wav"; + } + if ((self.sounds == DOOR_START_OPEN)) + { + precache_sound ("doors/drclos4.wav"); + precache_sound ("doors/doormv1.wav"); + self.noise1 = "doors/drclos4.wav"; + self.noise2 = "doors/doormv1.wav"; + } + if ((self.sounds == WEAPON_ROCKET)) + { + precache_sound ("doors/hydro1.wav"); + precache_sound ("doors/hydro2.wav"); + self.noise2 = "doors/hydro1.wav"; + self.noise1 = "doors/hydro2.wav"; + } + if ((self.sounds == AS_MELEE)) + { + precache_sound ("doors/stndr1.wav"); + precache_sound ("doors/stndr2.wav"); + self.noise2 = "doors/stndr1.wav"; + self.noise1 = "doors/stndr2.wav"; + } + if ((self.sounds == DOOR_DONT_LINK)) + { + 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; + self.solid = SOLID_BSP; + self.movetype = MOVETYPE_PUSH; + setorigin (self, self.origin); + setmodel (self, self.model); + self.classname = "door"; + self.blocked = door_blocked; + self.use = door_use; + + if (coop == 0) + { + if ((self.spawnflags & DOOR_SILVER_KEY)) + self.items = IT_KEY1; + if ((self.spawnflags & DOOR_GOLD_KEY)) + self.items = IT_KEY2; + } + + if (coop == 1) + { + r = random()*10; + + if (r <= 7) + self.items = IT_KEY1; + else + self.items = IT_KEY2; + } + if (!self.speed) + { + self.speed = 100; + } + if (!self.wait) + { + self.wait = AS_MELEE; + } + if (!self.lip) + { + self.lip = DOOR_GOLD_KEY; + } + if (!self.dmg) + { + self.dmg = WEAPON_ROCKET; + } + self.pos1 = self.origin; + self.pos2 = (self.pos1 + (self.movedir * (fabs ((self.movedir * self.size)) - self.lip))); + if ((self.spawnflags & DOOR_START_OPEN)) + { + setorigin (self, self.pos2); + self.pos2 = self.pos1; + self.pos1 = self.origin; + } + self.state = STATE_BOTTOM; + if (self.health) + { + self.takedamage = DAMAGE_YES; + self.th_die = door_killed; + } + self.touch = door_touch; + self.think = LinkDoors; + self.nextthink = (self.ltime + 0.1); +}; +void () fd_secret_move1; +void () fd_secret_move2; +void () fd_secret_move3; +void () fd_secret_move4; +void () fd_secret_move5; +void () fd_secret_move6; +void () fd_secret_done; +float SECRET_OPEN_ONCE = 1; +float SECRET_1ST_LEFT = 2; +float SECRET_1ST_DOWN = 4; +float SECRET_NO_SHOOT = 8; +float SECRET_YES_SHOOT = 16; + +void () fd_secret_use = +{ + local float temp; + + self.health = 10000; + if ((self.origin != self.oldorigin)) + { + return; + } + self.message = string_null; + SUB_UseTargets (); + if (!(self.spawnflags & SECRET_NO_SHOOT)) + { + self.th_pain = SUB_Null; + self.takedamage = DAMAGE_NO; + } + self.velocity = VEC_ORIGIN; + sound (self, CHAN_VOICE, self.noise1, SECRET_OPEN_ONCE, ATTN_NORM); + self.nextthink = (self.ltime + 0.1); + temp = (SECRET_OPEN_ONCE - (self.spawnflags & SECRET_1ST_LEFT)); + makevectors (self.mangle); + if (!self.t_width) + { + if ((self.spawnflags & SECRET_1ST_DOWN)) + { + self.t_width = fabs ((v_up * self.size)); + } + else + { + self.t_width = fabs ((v_right * self.size)); + } + } + if (!self.t_length) + { + self.t_length = fabs ((v_forward * self.size)); + } + if ((self.spawnflags & SECRET_1ST_DOWN)) + { + self.dest1 = (self.origin - (v_up * self.t_width)); + } + else + { + self.dest1 = (self.origin + (v_right * (self.t_width * temp))); + } + self.dest2 = (self.dest1 + (v_forward * self.t_length)); + SUB_CalcMove (self.dest1, self.speed, fd_secret_move1); + sound (self, CHAN_VOICE, self.noise2, SECRET_OPEN_ONCE, ATTN_NORM); +}; + +void () fd_secret_move1 = +{ + self.nextthink = (self.ltime + SECRET_OPEN_ONCE); + self.think = fd_secret_move2; + sound (self, CHAN_VOICE, self.noise3, SECRET_OPEN_ONCE, ATTN_NORM); +}; + +void () fd_secret_move2 = +{ + sound (self, CHAN_VOICE, self.noise2, SECRET_OPEN_ONCE, ATTN_NORM); + SUB_CalcMove (self.dest2, self.speed, fd_secret_move3); +}; + +void () fd_secret_move3 = +{ + sound (self, CHAN_VOICE, self.noise3, SECRET_OPEN_ONCE, ATTN_NORM); + if (!(self.spawnflags & SECRET_OPEN_ONCE)) + { + self.nextthink = (self.ltime + self.wait); + self.think = fd_secret_move4; + } +}; + +void () fd_secret_move4 = +{ + sound (self, CHAN_VOICE, self.noise2, SECRET_OPEN_ONCE, ATTN_NORM); + SUB_CalcMove (self.dest1, self.speed, fd_secret_move5); +}; + +void () fd_secret_move5 = +{ + self.nextthink = (self.ltime + SECRET_OPEN_ONCE); + self.think = fd_secret_move6; + sound (self, CHAN_VOICE, self.noise3, SECRET_OPEN_ONCE, ATTN_NORM); +}; + +void () fd_secret_move6 = +{ + sound (self, CHAN_VOICE, self.noise2, SECRET_OPEN_ONCE, ATTN_NORM); + SUB_CalcMove (self.oldorigin, self.speed, fd_secret_done); +}; + +void () fd_secret_done = +{ + if ((!self.targetname || (self.spawnflags & SECRET_YES_SHOOT))) + { + self.health = 10000; + self.takedamage = DAMAGE_YES; + self.th_pain = fd_secret_use; + self.th_die = fd_secret_use; + } + sound (self, (CHAN_NO_PHS_ADD + CHAN_VOICE), self.noise3, SECRET_OPEN_ONCE, ATTN_NORM); +}; + +void () secret_blocked = +{ + if ((time < self.attack_finished)) + { + return; + } + self.attack_finished = (time + 0.5); + T_Damage (other, self, self, self.dmg); +}; + +void () secret_touch = +{ + if ((other.classname != "player")) + { + return; + } + if ((self.attack_finished > time)) + { + return; + } + self.attack_finished = (time + SECRET_1ST_LEFT); + if (self.message) + { + centerprint (other, self.message); + sound (other, CHAN_BODY, "misc/talk.wav", SECRET_OPEN_ONCE, ATTN_NORM); + } +}; + +void () func_door_secret = +{ + if ((self.sounds == MULTICAST_ALL)) + { + self.sounds = AS_MELEE; + } + if ((self.sounds == SECRET_OPEN_ONCE)) + { + precache_sound ("doors/latch2.wav"); + precache_sound ("doors/winch2.wav"); + precache_sound ("doors/drclos4.wav"); + self.noise1 = "doors/latch2.wav"; + self.noise2 = "doors/winch2.wav"; + self.noise3 = "doors/drclos4.wav"; + } + if ((self.sounds == SECRET_1ST_LEFT)) + { + 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 == AS_MELEE)) + { + precache_sound ("doors/basesec1.wav"); + precache_sound ("doors/basesec2.wav"); + self.noise2 = "doors/basesec1.wav"; + self.noise1 = "doors/basesec2.wav"; + self.noise3 = "doors/basesec2.wav"; + } + if (!self.dmg) + { + self.dmg = SECRET_1ST_LEFT; + } + self.mangle = self.angles; + self.angles = VEC_ORIGIN; + self.solid = SOLID_BSP; + self.movetype = MOVETYPE_PUSH; + 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))) + { + self.health = 10000; + self.takedamage = DAMAGE_YES; + self.th_pain = fd_secret_use; + } + self.oldorigin = self.origin; + if (!self.wait) + { + self.wait = MULTICAST_PVS_R; + } +}; diff --git a/quakec/fallout2/enforcer.qc b/quakec/fallout2/enforcer.qc new file mode 100644 index 000000000..df64f062d --- /dev/null +++ b/quakec/fallout2/enforcer.qc @@ -0,0 +1,394 @@ +/* +============================================================================== + +SOLDIER / PLAYER + +============================================================================== +*/ + +$cd id1/models/enforcer +$origin 0 -6 24 +$base base +$skin skin + +$frame stand1 stand2 stand3 stand4 stand5 stand6 stand7 + +$frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8 walk9 walk10 +$frame walk11 walk12 walk13 walk14 walk15 walk16 + +$frame run1 run2 run3 run4 run5 run6 run7 run8 + +$frame attack1 attack2 attack3 attack4 attack5 attack6 +$frame attack7 attack8 attack9 attack10 + +$frame death1 death2 death3 death4 death5 death6 death7 death8 +$frame death9 death10 death11 death12 death13 death14 + +$frame fdeath1 fdeath2 fdeath3 fdeath4 fdeath5 fdeath6 fdeath7 fdeath8 +$frame fdeath9 fdeath10 fdeath11 + +$frame paina1 paina2 paina3 paina4 + +$frame painb1 painb2 painb3 painb4 painb5 + +$frame painc1 painc2 painc3 painc4 painc5 painc6 painc7 painc8 + +$frame paind1 paind2 paind3 paind4 paind5 paind6 paind7 paind8 +$frame paind9 paind10 paind11 paind12 paind13 paind14 paind15 paind16 +$frame paind17 paind18 paind19 + + +void () enforcer_assault_rifle; +void () enf_reload1; + +void() enforcer_fire = +{ + local vector org; + + makevectors (self.angles); + + org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 16'; + +}; + +void (float var, float dam) enforcer_single = +{ + local vector src; + local vector dir; + local vector direction; + local entity en; + local float var; + local float r; + local vector targ; + local vector org; + local vector org2; + local float zdif; + local float ydif; + local float xdif; + local float true; + local float zdif; + + if (self.enemy.sneak == 1) + var = var * 2; + + if (self.mag1 == 0) + { + sound (self, CHAN_WEAPON, "weapons/reload.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + enf_reload1(); + self.mag1 = self.maxmag1; + return; + } + + self.mag1 = self.mag1 - 1; + + makevectors (self.angles); + + src = self.origin + v_forward*10; + src_z = self.absmin_z + self.size_z * 0.7; + + en = self.enemy; + + dir = en.origin - en.velocity*0.2; + dir = normalize (dir - self.origin); + + direction = dir; + + traceline (src, src + direction*4000 + v_right*crandom()*var + v_up*crandom()*var, FALSE, self); + + if (trace_fraction == PLAT_LOW_TRIGGER) + return; + + if (trace_ent.takedamage) + { + SpawnBlood (org, PLAT_LOW_TRIGGER); + dam = dam + random()*dam; + dam = dam * (1 - (trace_fraction)); + T_Damage (trace_ent, self, self, dam); + } + else + { + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SPIKE); + WriteCoord (MSG_MULTICAST, trace_endpos_x); + WriteCoord (MSG_MULTICAST, trace_endpos_y); + WriteCoord (MSG_MULTICAST, trace_endpos_z); + multicast (trace_endpos, MULTICAST_PVS); + } +}; + +//============================================================================ + +void() enf_stand1 =[ $stand1, enf_stand2 ] {ai_stand();}; +void() enf_stand2 =[ $stand2, enf_stand3 ] {ai_stand();}; +void() enf_stand3 =[ $stand3, enf_stand4 ] {ai_stand();}; +void() enf_stand4 =[ $stand4, enf_stand5 ] {ai_stand();}; +void() enf_stand5 =[ $stand5, enf_stand6 ] {ai_stand();}; +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);}; +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);}; +void() enf_walk5 =[ $walk5 , enf_walk6 ] {ai_walk(1);}; +void() enf_walk6 =[ $walk6 , enf_walk7 ] {ai_walk(2);}; +void() enf_walk7 =[ $walk7 , enf_walk8 ] {ai_walk(2);}; +void() enf_walk8 =[ $walk8 , enf_walk9 ] {ai_walk(1);}; +void() enf_walk9 =[ $walk9 , enf_walk10 ] {ai_walk(2);}; +void() enf_walk10 =[ $walk10, enf_walk11 ] {ai_walk(4);}; +void() enf_walk11 =[ $walk11, enf_walk12 ] {ai_walk(4);}; +void() enf_walk12 =[ $walk12, enf_walk13 ] {ai_walk(1);}; +void() enf_walk13 =[ $walk13, enf_walk14 ] {ai_walk(2);}; +void() enf_walk14 =[ $walk14, enf_walk15 ] {ai_walk(3);}; +void() enf_walk15 =[ $walk15, enf_walk16 ] {ai_walk(4);}; +void() enf_walk16 =[ $walk16, enf_walk1 ] {ai_walk(2);}; + +void() enf_run1 =[ $run1 , enf_run2 ] {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);}; +void() enf_run5 =[ $run5 , enf_run6 ] {ai_run(14);}; +void() enf_run6 =[ $run6 , enf_run7 ] {ai_run(14);}; +void() enf_run7 =[ $run7 , enf_run8 ] {ai_run(7);}; +void() enf_run8 =[ $run8 , enf_run1 ] {ai_run(11);}; + + +void() enf_atk1 =[ $attack1, enf_atk2 ] {ai_face();}; +void() enf_atk2 =[ $attack2, enf_atk3 ] {ai_face();}; +void() enf_atk3 =[ $attack3, enf_atk4 ] {ai_face();}; +void() enf_atk4 =[ $attack4, enf_atk5 ] {ai_face();}; +void() enf_atk5 =[ $attack5, enf_atk6 ] {enforcer_assault_rifle();}; +void() enf_atk6 =[ $attack6, enf_atk7 ] {ai_face();}; +void() enf_atk7 =[ $attack4, enf_atk8 ] {ai_face();}; +void() enf_atk8 =[ $attack3, enf_atk9 ] {ai_face();}; +void() enf_atk9 =[ $attack2, enf_atk10 ] {ai_face();}; +void() enf_atk10 =[ $attack1, enf_run1 ] {ai_face();}; + +void() enf_burst1 =[ $attack5, enf_burst2 ] {enforcer_single(400, 16);}; +void() enf_burst2 =[ $attack6, enf_burst3 ] {enforcer_single(400, 16);ai_face();}; +void() enf_burst3 =[ $attack5, enf_burst4 ] {enforcer_single(400, 16);}; +void() enf_burst4 =[ $attack6, enf_burst5 ] {enforcer_single(450, 16);ai_face();}; +void() enf_burst5 =[ $attack5, enf_burst6 ] {enforcer_single(450, 16);}; +void() enf_burst6 =[ $attack6, enf_burst7 ] {enforcer_single(500, 16);ai_face();}; +void() enf_burst7 =[ $attack5, enf_burst8 ] {enforcer_single(550, 16);}; +void() enf_burst8 =[ $attack4, enf_burst9 ] {enforcer_single(600, 16);ai_face();}; +void() enf_burst9 =[ $attack3, enf_burst10 ] {ai_face();}; +void() enf_burst10 =[ $attack2, enf_run1 ] {ai_face();}; + + + +void() enf_reload1 =[ $attack10, enf_reload2 ] {}; +void() enf_reload2 =[ $attack9, enf_reload3 ] {}; +void() enf_reload3 =[ $attack8, enf_reload4 ] {}; +void() enf_reload4 =[ $attack7, enf_reload5 ] {}; +void() enf_reload5 =[ $attack8, enf_reload6 ] {}; +void() enf_reload6 =[ $attack9, enf_reload7 ] {}; +void() enf_reload7 =[ $attack10, enf_run1 ] {}; + +void() enf_paina1 =[ $paina1, enf_paina2 ] {}; +void() enf_paina2 =[ $paina2, enf_paina3 ] {}; +void() enf_paina3 =[ $paina3, enf_paina4 ] {}; +void() enf_paina4 =[ $paina4, enf_run1 ] {}; + +void() enf_painb1 =[ $painb1, enf_painb2 ] {}; +void() enf_painb2 =[ $painb2, enf_painb3 ] {}; +void() enf_painb3 =[ $painb3, enf_painb4 ] {}; +void() enf_painb4 =[ $painb4, enf_painb5 ] {}; +void() enf_painb5 =[ $painb5, enf_run1 ] {}; + +void() enf_painc1 =[ $painc1, enf_painc2 ] {}; +void() enf_painc2 =[ $painc2, enf_painc3 ] {}; +void() enf_painc3 =[ $painc3, enf_painc4 ] {}; +void() enf_painc4 =[ $painc4, enf_painc5 ] {}; +void() enf_painc5 =[ $painc5, enf_painc6 ] {}; +void() enf_painc6 =[ $painc6, enf_painc7 ] {}; +void() enf_painc7 =[ $painc7, enf_painc8 ] {}; +void() enf_painc8 =[ $painc8, enf_run1 ] {}; + +void() enf_paind1 =[ $paind1, enf_paind2 ] {}; +void() enf_paind2 =[ $paind2, enf_paind3 ] {}; +void() enf_paind3 =[ $paind3, enf_paind4 ] {}; +void() enf_paind4 =[ $paind4, enf_paind5 ] {ai_painforward(2);}; +void() enf_paind5 =[ $paind5, enf_paind6 ] {ai_painforward(1);}; +void() enf_paind6 =[ $paind6, enf_paind7 ] {}; +void() enf_paind7 =[ $paind7, enf_paind8 ] {}; +void() enf_paind8 =[ $paind8, enf_paind9 ] {}; +void() enf_paind9 =[ $paind9, enf_paind10 ] {}; +void() enf_paind10 =[ $paind10, enf_paind11 ] {}; +void() enf_paind11 =[ $paind11, enf_paind12 ] {ai_painforward(1);}; +void() enf_paind12 =[ $paind12, enf_paind13 ] {ai_painforward(1);}; +void() enf_paind13 =[ $paind13, enf_paind14 ] {ai_painforward(1);}; +void() enf_paind14 =[ $paind14, enf_paind15 ] {}; +void() enf_paind15 =[ $paind15, enf_paind16 ] {}; +void() enf_paind16 =[ $paind16, enf_paind17 ] {ai_pain(1);}; +void() enf_paind17 =[ $paind17, enf_paind18 ] {ai_pain(1);}; +void() enf_paind18 =[ $paind18, enf_paind19 ] {}; +void() enf_paind19 =[ $paind19, enf_run1 ] {}; + +void(entity attacker, float damage) enf_pain = +{ + local float r; + + r = random (); + if (self.pain_finished > time) + { + sound (self, CHAN_BODY, "misc/thud.wav", 1, ATTN_NORM); + return; + } + + 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.1) + { + self.pain_finished = time + 3; + enf_paina1 (); + } + else if (r < 0.2) + { + self.pain_finished = time + 3; + enf_painb1 (); + } + else if (r < 0.3) + { + self.pain_finished = time + 3; + enf_painc1 (); + } + else + { + self.pain_finished = time + 3; + } +}; + +//============================================================================ + + + + +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_die4 =[ $death4, enf_die5 ] {ai_forward(14);}; +void() enf_die5 =[ $death5, enf_die6 ] {ai_forward(2);}; +void() enf_die6 =[ $death6, enf_die7 ] {}; +void() enf_die7 =[ $death7, enf_die8 ] {}; +void() enf_die8 =[ $death8, enf_die9 ] {}; +void() enf_die9 =[ $death9, enf_die10 ] {ai_forward(3);}; +void() enf_die10 =[ $death10, enf_die11 ] {ai_forward(5);}; +void() enf_die11 =[ $death11, enf_die12 ] {ai_forward(5);}; +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_fdie2 =[ $fdeath2, enf_fdie3 ] {}; +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 ] {}; +void() enf_fdie7 =[ $fdeath7, enf_fdie8 ] {}; +void() enf_fdie8 =[ $fdeath8, enf_fdie9 ] {}; +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) + { + sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); + if (random() > 0.5) + enf_die1 (); + else + enf_fdie1 (); + return; + } + +// regular death + sound (self, CHAN_VOICE, "enforcer/death1.wav", 1, ATTN_NORM); + if (random() > 0.5) + enf_die1 (); + else + enf_fdie1 (); +}; + +void () enforcer_assault_rifle = +{ + local float r; + + r = range (self.enemy); + + if (r == RANGE_FAR || r == RANGE_MID)//single shot at range + { + if (self.weapon == 5) + sound (self, CHAN_WEAPON, "weapons/ak112.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + if (self.weapon == 6) + sound (self, CHAN_WEAPON, "weapons/ak47.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + enforcer_single(200, 18); + } + if (r == RANGE_NEAR || r == RANGE_MELEE)//open up when close + { + if (self.weapon == 5) + sound (self, CHAN_WEAPON, "weapons/auto.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + if (self.weapon == 6) + sound (self, CHAN_WEAPON, "weapons/auto2.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + enf_burst1(); + } +}; + +void() monster_enforcer = +{ + precache_model2 ("progs/enforcer.mdl"); + precache_model2 ("progs/h_mega.mdl"); + precache_model2 ("progs/laser.mdl"); + + precache_sound2 ("enforcer/death1.wav"); + precache_sound2 ("enforcer/enfire.wav"); + precache_sound2 ("enforcer/enfstop.wav"); + precache_sound2 ("enforcer/idle1.wav"); + precache_sound2 ("enforcer/pain1.wav"); + precache_sound2 ("enforcer/pain2.wav"); + precache_sound2 ("enforcer/sight1.wav"); + precache_sound2 ("enforcer/sight2.wav"); + precache_sound2 ("enforcer/sight3.wav"); + precache_sound2 ("enforcer/sight4.wav"); + + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_STEP; + self.team = 3; + + setmodel (self, "progs/enforcer.mdl"); + self.classname = "monster"; + self.netname = "enforcer"; + + setsize (self, '-12 -12 -24', '12 12 32'); + self.health = 100; + self.armor = 5; + self.armortype = 0.5; + self.helmet = 1; + self.th_stand = enf_stand1; + self.th_walk = enf_walk1; + self.th_run = enf_run1; + self.th_pain = enf_pain; + self.th_die = enf_die; + self.th_missile = enf_atk1; + + self.weapon = 6; + self.th_missile = enf_atk1; + self.mag1 = 24; + self.maxmag1 = self.mag1; + + walkmonster_start(); + return; +}; diff --git a/quakec/fallout2/fight.qc b/quakec/fallout2/fight.qc new file mode 100644 index 000000000..23466f89b --- /dev/null +++ b/quakec/fallout2/fight.qc @@ -0,0 +1,401 @@ + +/* + +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. + +*/ + +void() knight_atk1; +void() knight_runatk1; +float() DemonCheckAttack; + +float(float v) anglemod; + +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)); + + if (len<80) + knight_atk1 (); + else + knight_runatk1 (); +}; + +//============================================================================= + +/* +=========== +CheckAttack + +The player is in view, so decide to move or launch an attack +Returns FALSE if movement should continue +============ +*/ +float() CheckAttack = +{ + local vector spot1, spot2; + local entity targ; + local float chance; + + targ = self.enemy; + +// 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) + return FALSE; // don't have a clear shot + + if (trace_inopen && trace_inwater) + return FALSE; // sight line crossed contents + + if (enemy_range == RANGE_MELEE) + { // melee attack + if (self.th_melee) + { + if (self.classname == "monster_knight") + knight_attack (); + else + self.th_melee (); + return TRUE; + } + } + +// missile attack + if (!self.th_missile) + return FALSE; + + if (time < self.attack_finished) + return FALSE; + + if (enemy_range == RANGE_FAR) + return FALSE; + + if (enemy_range == RANGE_MELEE) + { + chance = 0.9; + self.attack_finished = 0; + } + else if (enemy_range == RANGE_NEAR) + { + if (self.th_melee) + chance = 0.2; + else + chance = 0.4; + } + else if (enemy_range == RANGE_MID) + { + if (self.th_melee) + chance = 0.05; + else + chance = 0.1; + } + else + chance = 0; + + if (random () < chance) + { + self.th_missile (); + SUB_AttackFinished (2*random()); + return TRUE; + } + + return FALSE; +}; + + +/* +============= +ai_face + +Stay facing the enemy +============= +*/ +void() ai_face = +{ + self.ideal_yaw = vectoyaw(self.enemy.origin - self.origin); + ChangeYaw (); +}; + +/* +============= +ai_charge + +The monster is in a melee attack, so get as close as possible to .enemy +============= +*/ +float (entity targ) visible; +float(entity targ) infront; +float(entity targ) range; + +void(float d) ai_charge = +{ + ai_face (); + movetogoal (d); // done in C code... +}; + +void() ai_charge_side = +{ + local vector dtemp; + local float heading; + +// aim to the left of the enemy for a flyby + + self.ideal_yaw = vectoyaw(self.enemy.origin - self.origin); + ChangeYaw (); + + makevectors (self.angles); + dtemp = self.enemy.origin - 30*v_right; + heading = vectoyaw(dtemp - self.origin); + + walkmove(heading, 20); +}; + + +/* +============= +ai_melee + +============= +*/ +void() ai_melee = +{ + local vector delta; + local float ldmg; + + if (!self.enemy) + return; // removed before stroke + + delta = self.enemy.origin - self.origin; + + if (vlen(delta) > 60) + return; + + ldmg = (random() + random() + random()) * 3; + T_Damage (self.enemy, self, self, ldmg); +}; + + +void() ai_melee_side = +{ + local vector delta; + local float ldmg; + + if (!self.enemy) + return; // removed before stroke + + ai_charge_side(); + + delta = self.enemy.origin - self.origin; + + if (vlen(delta) > 60) + return; + if (!CanDamage (self.enemy, self)) + return; + ldmg = (random() + random() + random()) * 3; + T_Damage (self.enemy, self, self, ldmg); +}; + + +//============================================================================= + +/* +=========== +SoldierCheckAttack + +The player is in view, so decide to move or launch an attack +Returns FALSE if movement should continue +============ +*/ +float() SoldierCheckAttack = +{ + local vector spot1, spot2; + local entity targ; + local float chance; + + targ = self.enemy; + +// 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_inopen && trace_inwater) + return FALSE; // sight line crossed contents + + if (trace_ent != targ) + return FALSE; // don't have a clear shot + + +// 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) + chance = 0.4; + else if (enemy_range == RANGE_MID) + chance = 0.05; + else + chance = 0; + + if (random () < chance) + { + self.th_missile (); + SUB_AttackFinished (1 + random()); + if (random() < 0.3) + self.lefty = !self.lefty; + + return TRUE; + } + + return FALSE; +}; +//============================================================================= + +/* +=========== +ShamCheckAttack + +The player is in view, so decide to move or launch an attack +Returns FALSE if movement should continue +============ +*/ +float() ShamCheckAttack = +{ + local vector spot1, spot2; + local entity targ; + local float chance; + local float enemy_yaw; + + if (enemy_range == RANGE_MELEE) + { + if (CanDamage (self.enemy, self)) + { + self.attack_state = AS_MELEE; + return TRUE; + } + } + + if (time < self.attack_finished) + return FALSE; + + if (!enemy_vis) + return FALSE; + + targ = self.enemy; + +// see if any entities are in the way of the shot + spot1 = self.origin + self.view_ofs; + spot2 = targ.origin + targ.view_ofs; + + if (vlen(spot1 - spot2) > 600) + return FALSE; + + traceline (spot1, spot2, FALSE, self); + + if (trace_inopen && trace_inwater) + return FALSE; // sight line crossed contents + + if (trace_ent != targ) + { + return FALSE; // don't have a clear shot + } + +// missile attack + if (enemy_range == RANGE_FAR) + return FALSE; + + self.attack_state = AS_MISSILE; + SUB_AttackFinished (2 + 2*random()); + return TRUE; +}; + +//============================================================================ + +/* +=========== +OgreCheckAttack + +The player is in view, so decide to move or launch an attack +Returns FALSE if movement should continue +============ +*/ +float() OgreCheckAttack = +{ + local vector spot1, spot2; + local entity targ; + local float chance; + + if (enemy_range == RANGE_MELEE) + { + if (CanDamage (self.enemy, self)) + { + self.attack_state = AS_MELEE; + return TRUE; + } + } + + if (time < self.attack_finished) + return FALSE; + + if (!enemy_vis) + return FALSE; + + targ = self.enemy; + +// 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_inopen && trace_inwater) + return FALSE; // sight line crossed contents + + if (trace_ent != targ) + { + return FALSE; // don't have a clear shot + } + +// missile attack + if (time < self.attack_finished) + return FALSE; + + if (enemy_range == RANGE_FAR) + return FALSE; + + else if (enemy_range == RANGE_NEAR) + chance = 0.10; + else if (enemy_range == RANGE_MID) + chance = 0.05; + else + chance = 0; + + self.attack_state = AS_MISSILE; + SUB_AttackFinished (1 + 2*random()); + return TRUE; +}; + diff --git a/quakec/fallout2/hos.qc b/quakec/fallout2/hos.qc new file mode 100644 index 000000000..89221397f --- /dev/null +++ b/quakec/fallout2/hos.qc @@ -0,0 +1,220 @@ +void (float xx) hos_forward; + +void () hos_stand1 = [ 11, hos_stand2 ] +{ +}; + +void () hos_stand2 = [ 12, hos_stand3 ] +{ +}; + +void () hos_stand3 = [ 13, hos_stand4 ] +{ +}; + +void () hos_stand4 = [ 14, hos_stand5 ] +{ +}; + +void () hos_stand5 = [ 15, hos_stand1 ] +{ +}; + +void () hos_run1 = [ 0, hos_run2 ] +{ + hos_forward (MULTICAST_PVS_R); +}; + +void () hos_run2 = [ 1, hos_run3 ] +{ + hos_forward (AS_MELEE); +}; + +void () hos_run3 = [ 2, hos_run4 ] +{ + hos_forward (MULTICAST_PVS_R); +}; + +void () hos_run4 = [ 3, hos_run5 ] +{ + hos_forward (AS_MELEE); +}; + +void () hos_run5 = [ 4, hos_run6 ] +{ + hos_forward (MULTICAST_PVS_R); +}; + +void () hos_run6 = [ 5, hos_run1 ] +{ + hos_forward (AS_MELEE); +}; + +void () hos_walk1 = [ 16, hos_walk2 ] +{ + hos_forward (MULTICAST_PVS_R); +}; + +void () hos_walk2 = [ 17, hos_walk3 ] +{ + hos_forward (AS_MELEE); +}; + +void () hos_walk3 = [ 18, hos_walk4 ] +{ + hos_forward (MULTICAST_PVS_R); +}; + +void () hos_walk4 = [ 19, hos_walk5 ] +{ + hos_forward (AS_MELEE); +}; + +void () hos_walk5 = [ 20, hos_walk6 ] +{ + hos_forward (MULTICAST_PVS_R); +}; + +void () hos_walk6 = [ 21, hos_walk7 ] +{ + hos_forward (AS_MELEE); +}; + +void () hos_walk7 = [ 22, hos_walk8 ] +{ + hos_forward (MULTICAST_PVS_R); +}; + +void () hos_walk8 = [ 23, hos_walk9 ] +{ + hos_forward (AS_MELEE); +}; + +void () hos_walk9 = [ 24, hos_walk10 ] +{ + hos_forward (MULTICAST_PVS_R); +}; + +void () hos_walk10 = [ 25, hos_walk1 ] +{ + hos_forward (AS_MELEE); +}; + +void () hos_deatha1 = [ 6, hos_deatha2 ] +{ +}; + +void () hos_deatha2 = [ 7, hos_deatha3 ] +{ +}; + +void () hos_deatha3 = [ 8, hos_deatha4 ] +{ +}; + +void () hos_deatha4 = [ 9, hos_deatha5 ] +{ +}; + +void () hos_deatha5 = [ 10, hos_deatha5 ] +{ +}; + +void (float xx) hos_forward = +{ + local vector dir; + local float rng; + local entity te; + local string qqq; + local float qq; + local float dir1; + local float dir2; + + self.movetype = MOVETYPE_STEP; + if ((self.cnt == MULTICAST_ALL)) + { + return; + } + self.goalentity = self.friend; + if ((vlen ((self.origin - self.goalentity.origin)) > 96)) + { + movetogoal ((SECRET_1ST_DOWN * xx)); + self.angles = vectoangles ((self.goalentity.origin - self.origin)); + traceline (self.origin, ((self.origin + (v_right * SVC_BIGKICK)) + (v_forward * 90)), FALSE, self); + dir1 = trace_fraction; + traceline (self.origin, ((self.origin + (v_right * 50)) + (v_forward * 90)), FALSE, self); + dir1 = (dir1 + trace_fraction); + traceline (self.origin, ((self.origin + (v_right * 70)) + (v_forward * 90)), FALSE, self); + dir1 = (dir1 + trace_fraction); + traceline (self.origin, ((self.origin + (v_right * 90)) + (v_forward * 90)), FALSE, self); + dir1 = (dir1 + trace_fraction); + traceline (self.origin, ((self.origin + (v_right * 110)) + (v_forward * 90)), FALSE, self); + dir1 = (dir1 + trace_fraction); + traceline (self.origin, ((self.origin - (v_right * SVC_BIGKICK)) + (v_forward * 90)), FALSE, self); + dir2 = trace_fraction; + traceline (self.origin, ((self.origin - (v_right * 50)) + (v_forward * 90)), FALSE, self); + dir2 = (dir2 + trace_fraction); + traceline (self.origin, ((self.origin - (v_right * 70)) + (v_forward * 90)), FALSE, self); + dir2 = (dir2 + trace_fraction); + traceline (self.origin, ((self.origin - (v_right * 90)) + (v_forward * 90)), FALSE, self); + dir2 = (dir2 + trace_fraction); + traceline (self.origin, ((self.origin - (v_right * 110)) + (v_forward * 90)), FALSE, self); + dir2 = (dir2 + trace_fraction); + if ((self.oldorg == self.origin)) + { + if ((dir1 > dir2)) + { + self.angles_y = (self.angles_y - ((AS_MELEE * random ()) * SVC_INTERMISSION)); + } + else + { + if ((dir2 > dir1)) + { + self.angles_y = (self.angles_y + ((AS_MELEE * random ()) * SVC_INTERMISSION)); + } + else + { + self.oldorg = (self.oldorg + '0 0 1'); + } + } + walkmove (self.angles_y, (SECRET_1ST_DOWN * xx)); + } + } + if ((vlen ((self.origin - self.goalentity.origin)) < IT_LIGHTNING)) + { + self.angles = vectoangles ((self.goalentity.origin - self.origin)); + walkmove (self.angles_y, (-7 * xx)); + } + if ((self.friend.team == PLAT_LOW_TRIGGER)) + { + te = find (world, classname, "buyzone1"); + } + if ((self.friend.team == SILENT)) + { + te = find (world, classname, "buyzone2"); + } + while (te) + { + rng = range (te); + if (((rng <= RANGE_NEAR) && (self.rescued == MULTICAST_ALL))) + { + sound (self, CHAN_BODY, "misc/rescued.wav", PLAT_LOW_TRIGGER, ATTN_NONE); + te = find (world, classname, "hostage"); + while (te) + { + if (((te.health > MULTICAST_ALL) && (te.rescued == MULTICAST_ALL))) + { + qq = (qq + PLAT_LOW_TRIGGER); + } + te = find (te, classname, "hostage"); + } + self.rescued = PLAT_LOW_TRIGGER; + qqq = ftos ((qq - PLAT_LOW_TRIGGER)); + bprint (SILENT, qqq); + bprint (SILENT, " hostages left\n"); + setorigin (self, (self.origin - '0 0 512')); + } + te = find (te, classname, "buyzone"); + } + self.oldorg = self.origin; +}; diff --git a/quakec/fallout2/items.qc b/quakec/fallout2/items.qc new file mode 100644 index 000000000..4ae0766ac --- /dev/null +++ b/quakec/fallout2/items.qc @@ -0,0 +1,1660 @@ +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 + self.solid = SOLID_TRIGGER; // allow it to be touched again + sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM); // play respawn sound + setorigin (self, self.origin); +}; + + + +/*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8) +prints a warning message when spawned +*/ +void() noclass = +{ + dprint ("noclass spawned at"); + dprint (vtos(self.origin)); + dprint ("\n"); + remove (self); +}; + +void() q_touch; + +void() q_touch = +{ +local entity stemp; +local float best; +local string s; + + if (other.classname != "player") + return; + if (other.health <= 0) + return; + + self.mdl = self.model; + + sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + 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; + } + +// do the apropriate action + other.super_time = 1; + other.super_damage_finished = self.cnt; + + s=ftos(rint(other.super_damage_finished - time)); + + bprint (PRINT_LOW, other.netname); + if (deathmatch == 4) + bprint (PRINT_LOW, " recovered an OctaPower with "); + else + bprint (PRINT_LOW, " recovered a Quad with "); + bprint (PRINT_LOW, s); + bprint (PRINT_LOW, " seconds remaining!\n"); + + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + + +void(float timeleft) DropQuad = +{ + local entity item; + + item = spawn(); + item.origin = self.origin; + + item.velocity_z = 300; + item.velocity_x = -100 + (random() * 200); + item.velocity_y = -100 + (random() * 200); + + item.flags = FL_ITEM; + item.solid = SOLID_TRIGGER; + item.movetype = MOVETYPE_TOSS; + item.noise = "items/damage.wav"; + setmodel (item, "progs/quaddama.mdl"); + setsize (item, '-16 -16 -24', '16 16 32'); + item.cnt = time + timeleft; + item.touch = q_touch; + item.nextthink = time + timeleft; // remove it with the time left on it + item.think = SUB_Remove; +}; + + +void() r_touch; + +void() r_touch = +{ +local entity stemp; +local float best; +local string s; + + if (other.classname != "player") + return; + if (other.health <= 0) + return; + + self.mdl = self.model; + + sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + self.solid = SOLID_NOT; + other.items = other.items | IT_INVISIBILITY; + self.model = string_null; + +// do the apropriate action + other.invisible_time = 1; + other.invisible_finished = self.cnt; + 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 +}; + + +void(float timeleft) DropRing = +{ + local entity item; + + item = spawn(); + item.origin = self.origin; + + item.velocity_z = 300; + item.velocity_x = -100 + (random() * 200); + item.velocity_y = -100 + (random() * 200); + + item.flags = FL_ITEM; + item.solid = SOLID_TRIGGER; + item.movetype = MOVETYPE_TOSS; + item.noise = "items/inv1.wav"; + setmodel (item, "progs/invisibl.mdl"); + setsize (item, '-16 -16 -24', '16 16 32'); + item.cnt = time + timeleft; + item.touch = r_touch; + item.nextthink = time + timeleft; // remove after 30 seconds + item.think = SUB_Remove; +}; + +/* +============ +PlaceItem + +plants the object on the floor +============ +*/ +void() PlaceItem = +{ + local float oldz; + + self.mdl = self.model; // so it can be restored on respawn + self.flags = FL_ITEM; // make extra wide + self.solid = SOLID_TRIGGER; + self.movetype = MOVETYPE_TOSS; + self.velocity = '0 0 0'; + self.origin_z = self.origin_z + 6; + oldz = self.origin_z; + if (!droptofloor()) + { + dprint ("Bonus item fell out of level at "); + dprint (vtos(self.origin)); + dprint ("\n"); + remove(self); + return; + } +}; + +/* +============ +StartItem + +Sets the clipping size and plants the object on the floor +============ +*/ +void() StartItem = +{ + self.nextthink = time + 0.2; // items start after other solids + self.think = PlaceItem; +}; + +/* +========================================================================= + +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) + return 0; + if ((!ignore) && (e.health >= other.max_health)) + return 0; + healamount = ceil(healamount); + + e.health = e.health + healamount; + if ((!ignore) && (e.health >= other.max_health)) + e.health = other.max_health; + + if (e.health > 250) + e.health = 250; + return 1; +}; + +/*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth +Health box. Normally gives 25 points. +Rotten box heals 5-10 points, +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; +void() health_touch; +void() item_megahealth_rot; + +void() item_health = +{ + self.touch = health_touch; + + 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) + { + 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 + { + precache_model("maps/b_bh25.bsp"); + precache_sound("items/health1.wav"); + setmodel(self, "maps/b_bh25.bsp"); + self.noise = "items/health1.wav"; + self.healamount = 25; + self.healtype = 1; + } + setsize (self, '0 0 0', '32 32 56'); + StartItem (); +}; + + +void() health_touch = +{ + local float amount; + local string s; + + if (deathmatch == 4) + if (other.invincible_time > 0) + return; + + if (other.classname != "player") + return; + + if (self.healtype == 2) // Megahealth? Ignore max_health... + { + if (other.health >= 250) + return; + if (!T_Heal(other, self.healamount, 1)) + return; + } + 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 + 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) + { + other.items = other.items | IT_SUPERHEALTH; + if (deathmatch != 4) + { + self.nextthink = time + 5; + self.think = item_megahealth_rot; + } + self.owner = other; + } + else + { + if (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 +}; + +void() item_megahealth_rot = +{ + other = self.owner; + + 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 + other.items = other.items - (other.items & IT_SUPERHEALTH); + + if (deathmatch != 2) // deathmatch 2 is silly old rules + { + self.nextthink = time + 20; + self.think = SUB_regen; + } +}; + +/* +=============================================================================== + +ARMOR + +=============================================================================== +*/ + +void() armor_touch; + +void() armor_touch = +{ + local float type, value, bit; + + if (other.health <= 0) + return; + if (other.classname != "player") + return; + + if (deathmatch == 4) + if (other.invincible_time > 0) + return; + + if (self.classname == "item_armor1") + { + type = 0.3; + value = 100; + bit = IT_ARMOR1; + } + if (self.classname == "item_armor2") + { + type = 0.6; + value = 150; + bit = IT_ARMOR2; + } + if (self.classname == "item_armorInv") + { + type = 0.8; + value = 200; + bit = IT_ARMOR3; + } + 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; + + self.solid = SOLID_NOT; + self.model = string_null; + if (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); + stuffcmd (other, "bf\n"); + + activator = other; + 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; + precache_model ("progs/armor.mdl"); + setmodel (self, "progs/armor.mdl"); + self.skin = 0; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); +}; + +/*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() item_armor2 = +{ + self.touch = armor_touch; + precache_model ("progs/armor.mdl"); + setmodel (self, "progs/armor.mdl"); + self.skin = 1; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); +}; + +/*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32) +*/ + +void() item_armorInv = +{ + self.touch = armor_touch; + precache_model ("progs/armor.mdl"); + setmodel (self, "progs/armor.mdl"); + self.skin = 2; + setsize (self, '-16 -16 0', '16 16 56'); + StartItem (); +}; + +/* +=============================================================================== + +WEAPONS + +=============================================================================== +*/ + +void() bound_other_ammo = +{ + if (other.ammo_shells > 100) + other.ammo_shells = 100; + if (other.ammo_nails > 200) + other.ammo_nails = 200; + if (other.ammo_rockets > 100) + other.ammo_rockets = 100; + if (other.ammo_cells > 100) + other.ammo_cells = 100; +}; + + +float(float w) RankForWeapon = +{ + if (w == IT_LIGHTNING) + return 1; + if (w == IT_ROCKET_LAUNCHER) + return 2; + if (w == IT_SUPER_NAILGUN) + return 3; + if (w == IT_GRENADE_LAUNCHER) + return 4; + if (w == IT_SUPER_SHOTGUN) + return 5; + if (w == IT_NAILGUN) + return 6; + return 7; +}; + +float (float w) WeaponCode = +{ + if (w == IT_SUPER_SHOTGUN) + return 3; + if (w == IT_NAILGUN) + return 4; + if (w == IT_SUPER_NAILGUN) + return 5; + if (w == IT_GRENADE_LAUNCHER) + return 6; + if (w == IT_ROCKET_LAUNCHER) + return 7; + if (w == IT_LIGHTNING) + return 8; + return 1; +}; + +/* +============= +Deathmatch_Weapon + +Deathmatch weapon change rules for picking up a weapon + +.float ammo_shells, ammo_nails, ammo_rockets, ammo_cells; +============= +*/ +void(float old, float new) Deathmatch_Weapon = +{ + local float or, nr; + +// change self.weapon if desired + or = RankForWeapon (self.weapon); + nr = RankForWeapon (new); + if ( nr < or ) + self.weapon = new; +}; + +/* +============= +weapon_touch +============= +*/ +float() W_BestWeapon; + +void() weapon_touch = +{ + local float hadammo, best, new, old; + local entity stemp; + local float leave; + + // For client weapon_switch + local float w_switch; + + if (!(other.flags & FL_CLIENT)) + return; + + if ((stof(infokey(other,"w_switch"))) == 0) + w_switch = 8; + else + w_switch = stof(infokey(other,"w_switch")); + +// if the player was using his best weapon, change up to the new one if better + stemp = self; + self = other; + best = W_BestWeapon(); + self = stemp; + + if (deathmatch == 2 || deathmatch == 3 || deathmatch == 5) + leave = 1; + else + leave = 0; + + if (self.classname == "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") + { + 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") + { + 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") + { + 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") + { + 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") + { + if (leave && (other.items & IT_LIGHTNING)) + return; + hadammo = other.ammo_rockets; + new = IT_LIGHTNING; + other.ammo_cells = other.ammo_cells + 15; + } + else + objerror ("weapon_touch: unknown classname"); + + sprint (other, PRINT_LOW, "You got the "); + sprint (other, PRINT_LOW, self.netname); + sprint (other, PRINT_LOW, "\n"); +// weapon touch sound + sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + + bound_other_ammo (); + +// 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) + { + Deathmatch_Weapon (old, new); + } + } + else + { + Deathmatch_Weapon (old, new); + } + } + + W_SetCurrentAmmo(); + + self = stemp; + + if (leave) + return; + + if (deathmatch!=3 || deathmatch !=5) + { + // remove it in single player, or setup for respawning in deathmatch + self.model = string_null; + self.solid = SOLID_NOT; + if (deathmatch != 2) + self.nextthink = time + 30; + self.think = SUB_regen; + } + activator = other; + 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 (); +} +}; + +/*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 (); +} +}; + +/*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 (); +} +}; + +/*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 (); +} +}; + +/*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 (); +} +}; + + +/*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 (); +} +}; + + +/* +=============================================================================== + +AMMO + +=============================================================================== +*/ + +void() ammo_touch = +{ +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 + stemp = self; + self = other; + best = W_BestWeapon(); + self = stemp; + + +// shotgun + if (self.weapon == 1) + { + if (other.ammo_shells >= 100) + return; + other.ammo_shells = other.ammo_shells + self.aflag; + } + +// spikes + if (self.weapon == 2) + { + if (other.ammo_nails >= 200) + return; + other.ammo_nails = other.ammo_nails + self.aflag; + } + +// rockets + if (self.weapon == 3) + { + if (other.ammo_rockets >= 100) + return; + other.ammo_rockets = other.ammo_rockets + self.aflag; + } + +// cells + if (self.weapon == 4) + { + if (other.ammo_cells >= 100) + return; + other.ammo_cells = other.ammo_cells + self.aflag; + } + + bound_other_ammo (); + + sprint (other, PRINT_LOW, "You got the "); + sprint (other, PRINT_LOW, self.netname); + sprint (other, PRINT_LOW, "\n"); +// 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 ) + { + stemp = self; + self = other; + self.weapon = W_BestWeapon(); + W_SetCurrentAmmo (); + self = stemp; + } + +// 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 + self.model = string_null; + self.solid = SOLID_NOT; + if (deathmatch != 2) + self.nextthink = time + 30; + +// 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 +}; + + + + +float WEAPON_BIG2 = 1; + +/*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big +*/ + +void() item_shells = +{ + if (deathmatch == 4) + return; + + self.touch = ammo_touch; + + if (self.spawnflags & WEAPON_BIG2) + { + precache_model ("maps/b_shell1.bsp"); + setmodel (self, "maps/b_shell1.bsp"); + self.aflag = 40; + } + else + { + precache_model ("maps/b_shell0.bsp"); + setmodel (self, "maps/b_shell0.bsp"); + self.aflag = 20; + } + self.weapon = 1; + self.netname = "shells"; + setsize (self, '0 0 0', '32 32 56'); + StartItem (); +}; + +/*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big +*/ + +void() item_spikes = +{ + if (deathmatch == 4) + return; + + self.touch = ammo_touch; + + if (self.spawnflags & WEAPON_BIG2) + { + precache_model ("maps/b_nail1.bsp"); + setmodel (self, "maps/b_nail1.bsp"); + self.aflag = 50; + } + else + { + precache_model ("maps/b_nail0.bsp"); + setmodel (self, "maps/b_nail0.bsp"); + self.aflag = 25; + } + self.weapon = 2; + 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) + return; + + self.touch = ammo_touch; + + if (self.spawnflags & WEAPON_BIG2) + { + precache_model ("maps/b_rock1.bsp"); + setmodel (self, "maps/b_rock1.bsp"); + self.aflag = 10; + } + else + { + precache_model ("maps/b_rock0.bsp"); + setmodel (self, "maps/b_rock0.bsp"); + self.aflag = 5; + } + self.weapon = 3; + 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) + return; + + self.touch = ammo_touch; + + if (self.spawnflags & WEAPON_BIG2) + { + precache_model ("maps/b_batt1.bsp"); + setmodel (self, "maps/b_batt1.bsp"); + self.aflag = 12; + } + else + { + precache_model ("maps/b_batt0.bsp"); + setmodel (self, "maps/b_batt0.bsp"); + self.aflag = 6; + } + self.weapon = 4; + 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; +float WEAPON_BIG = 8; +void() item_weapon = +{ + self.touch = ammo_touch; + + 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 + { + precache_model ("maps/b_shell0.bsp"); + setmodel (self, "maps/b_shell0.bsp"); + self.aflag = 20; + } + self.weapon = 1; + self.netname = "shells"; + } + + if (self.spawnflags & WEAPON_SPIKES) + { + if (self.spawnflags & WEAPON_BIG) + { + precache_model ("maps/b_nail1.bsp"); + setmodel (self, "maps/b_nail1.bsp"); + self.aflag = 40; + } + else + { + precache_model ("maps/b_nail0.bsp"); + setmodel (self, "maps/b_nail0.bsp"); + self.aflag = 20; + } + self.weapon = 2; + self.netname = "spikes"; + } + + if (self.spawnflags & WEAPON_ROCKET) + { + if (self.spawnflags & WEAPON_BIG) + { + precache_model ("maps/b_rock1.bsp"); + setmodel (self, "maps/b_rock1.bsp"); + self.aflag = 10; + } + else + { + precache_model ("maps/b_rock0.bsp"); + setmodel (self, "maps/b_rock0.bsp"); + self.aflag = 5; + } + self.weapon = 3; + self.netname = "rockets"; + } + + setsize (self, '0 0 0', '32 32 56'); + StartItem (); +}; + + +/* +=============================================================================== + +KEYS + +=============================================================================== +*/ + +void() key_touch = +{ +local entity stemp; +local float best; + + if (other.classname != "player") + return; + if (other.health <= 0) + return; + if (other.items & self.items) + return; + + sprint (other, PRINT_LOW, "You got the "); + sprint (other, PRINT_LOW, self.netname); + sprint (other,PRINT_LOW, "\n"); + + sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + other.items = other.items | self.items; + + self.solid = SOLID_NOT; + self.model = string_null; + + activator = other; + SUB_UseTargets(); // fire all targets / killtargets +}; + + +void() key_setsounds = +{ + if (world.worldtype == 0) + { + precache_sound ("misc/medkey.wav"); + self.noise = "misc/medkey.wav"; + } + if (world.worldtype == 1) + { + precache_sound ("misc/runekey.wav"); + self.noise = "misc/runekey.wav"; + } + if (world.worldtype == 2) + { + precache_sound2 ("misc/basekey.wav"); + self.noise = "misc/basekey.wav"; + } +}; + +/*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32) +SILVER key +In order for keys to work +you MUST set your maps +worldtype to one of the +following: +0: medieval +1: metal +2: base +*/ + +void() item_key1 = +{ + if (world.worldtype == 0) + { + precache_model ("progs/w_s_key.mdl"); + setmodel (self, "progs/w_s_key.mdl"); + self.netname = "silver key"; + } + else if (world.worldtype == 1) + { + precache_model ("progs/m_s_key.mdl"); + setmodel (self, "progs/m_s_key.mdl"); + self.netname = "silver runekey"; + } + else if (world.worldtype == 2) + { + precache_model2 ("progs/b_s_key.mdl"); + setmodel (self, "progs/b_s_key.mdl"); + self.netname = "silver keycard"; + } + key_setsounds(); + self.touch = key_touch; + self.items = IT_KEY1; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + +/*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32) +GOLD key +In order for keys to work +you MUST set your maps +worldtype to one of the +following: +0: medieval +1: metal +2: base +*/ + +void() item_key2 = +{ + if (world.worldtype == 0) + { + precache_model ("progs/w_g_key.mdl"); + setmodel (self, "progs/w_g_key.mdl"); + self.netname = "gold key"; + } + if (world.worldtype == 1) + { + precache_model ("progs/m_g_key.mdl"); + setmodel (self, "progs/m_g_key.mdl"); + self.netname = "gold runekey"; + } + if (world.worldtype == 2) + { + precache_model2 ("progs/b_g_key.mdl"); + setmodel (self, "progs/b_g_key.mdl"); + self.netname = "gold keycard"; + } + key_setsounds(); + self.touch = key_touch; + self.items = IT_KEY2; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + + + +/* +=============================================================================== + +END OF LEVEL RUNES + +=============================================================================== +*/ + +void() sigil_touch = +{ +local entity stemp; +local float best; + + if (other.classname != "player") + return; + if (other.health <= 0) + return; + + centerprint (other, "You got the rune!"); + + sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + self.solid = SOLID_NOT; + self.model = string_null; + serverflags = serverflags | (self.spawnflags & 15); + self.classname = ""; // so rune doors won't find it + + activator = other; + 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) + objerror ("no spawnflags"); + + precache_sound ("misc/runekey.wav"); + self.noise = "misc/runekey.wav"; + + if (self.spawnflags & 1) + { + precache_model ("progs/end1.mdl"); + setmodel (self, "progs/end1.mdl"); + } + if (self.spawnflags & 2) + { + precache_model2 ("progs/end2.mdl"); + setmodel (self, "progs/end2.mdl"); + } + if (self.spawnflags & 4) + { + precache_model2 ("progs/end3.mdl"); + setmodel (self, "progs/end3.mdl"); + } + if (self.spawnflags & 8) + { + precache_model2 ("progs/end4.mdl"); + setmodel (self, "progs/end4.mdl"); + } + + self.touch = sigil_touch; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + +/* +=============================================================================== + +POWERUPS + +=============================================================================== +*/ + +void() powerup_touch; + + +void() powerup_touch = +{ +local entity stemp; +local float best; + + if (other.classname != "player") + return; + if (other.health <= 0) + return; + + sprint (other, PRINT_LOW, "You got the "); + sprint (other,PRINT_LOW, self.netname); + sprint (other,PRINT_LOW, "\n"); + + self.mdl = self.model; + + if ((self.classname == "item_artifact_invulnerability") || + (self.classname == "item_artifact_invisibility")) + self.nextthink = time + 60*5; + else + self.nextthink = time + 60; + + self.think = SUB_regen; + + sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + self.solid = SOLID_NOT; + other.items = other.items | self.items; + self.model = string_null; + +// 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") + { + other.invincible_time = 1; + other.invincible_finished = time + 30; + } + + 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) + { + other.armortype = 0; + other.armorvalue = 0 * 0.01; + other.ammo_cells = 0; + } + other.super_time = 1; + other.super_damage_finished = time + 30; + } + + activator = other; + 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 +*/ +void() item_artifact_invulnerability = +{ + self.touch = powerup_touch; + + precache_model ("progs/invulner.mdl"); + precache_sound ("items/protect.wav"); + precache_sound ("items/protect2.wav"); + precache_sound ("items/protect3.wav"); + self.noise = "items/protect.wav"; + setmodel (self, "progs/invulner.mdl"); + self.netname = "Pentagram of Protection"; + self.effects = self.effects | EF_RED; + self.items = IT_INVULNERABILITY; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + +/*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32) +Player takes no damage from water or slime for 30 seconds +*/ +void() item_artifact_envirosuit = +{ + self.touch = powerup_touch; + + precache_model ("progs/suit.mdl"); + precache_sound ("items/suit.wav"); + precache_sound ("items/suit2.wav"); + self.noise = "items/suit.wav"; + setmodel (self, "progs/suit.mdl"); + self.netname = "Biosuit"; + self.items = IT_SUIT; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + + +/*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32) +Player is invisible for 30 seconds +*/ +void() item_artifact_invisibility = +{ + self.touch = powerup_touch; + + precache_model ("progs/invisibl.mdl"); + precache_sound ("items/inv1.wav"); + precache_sound ("items/inv2.wav"); + precache_sound ("items/inv3.wav"); + self.noise = "items/inv1.wav"; + setmodel (self, "progs/invisibl.mdl"); + self.netname = "Ring of Shadows"; + self.items = IT_INVISIBILITY; + setsize (self, '-16 -16 -24', '16 16 32'); + 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 +*/ +void() item_artifact_super_damage = +{ + self.touch = powerup_touch; + + precache_model ("progs/quaddama.mdl"); + precache_sound ("items/damage.wav"); + precache_sound ("items/damage2.wav"); + precache_sound ("items/damage3.wav"); + self.noise = "items/damage.wav"; + setmodel (self, "progs/quaddama.mdl"); + if (deathmatch == 4) + self.netname = "OctaPower"; + else + self.netname = "Quad Damage"; + self.items = IT_QUAD; + self.effects = self.effects | EF_BLUE; + setsize (self, '-16 -16 -24', '16 16 32'); + StartItem (); +}; + + + +/* +=============================================================================== + +PLAYER BACKPACKS + +=============================================================================== +*/ + +void() BackpackTouch = +{ + local string s; + local float best, old, new; + local entity stemp; + local float acount; + local float b_switch; + + if (deathmatch == 4) + if (other.invincible_time > 0) + return; + + if ((stof(infokey(other,"b_switch"))) == 0) + b_switch = 8; + else + 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) + { + other.health = other.health + 10; + sprint (other, PRINT_LOW, "10 additional health\n"); + if ((other.health > 250) && (other.health < 300)) + sound (other, CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM); + else + sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + remove(self); + + 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); + bprint (PRINT_HIGH, " attains bonus powers!!!\n"); + } + } + self = other; + return; + } + if (self.items) + 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 + stemp = self; + self = other; + best = W_BestWeapon(); + self = stemp; + +// 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; + other.ammo_cells = other.ammo_cells + self.ammo_cells; + + new = self.items; + if (!new) + new = other.weapon; + old = other.items; + other.items = other.items | self.items; + + bound_other_ammo (); + + if (self.ammo_shells) + { + if (acount) + sprint(other, PRINT_LOW, ", "); + acount = 1; + s = ftos(self.ammo_shells); + sprint (other, PRINT_LOW, s); + sprint (other, PRINT_LOW, " shells"); + } + if (self.ammo_nails) + { + if (acount) + sprint(other, PRINT_LOW, ", "); + acount = 1; + s = ftos(self.ammo_nails); + sprint (other, PRINT_LOW, s); + sprint (other, PRINT_LOW, " nails"); + } + if (self.ammo_rockets) + { + if (acount) + sprint(other, PRINT_LOW, ", "); + acount = 1; + s = ftos(self.ammo_rockets); + sprint (other, PRINT_LOW, s); + sprint (other, PRINT_LOW, " rockets"); + } + if (self.ammo_cells) + { + if (acount) + sprint(other, PRINT_LOW, ", "); + acount = 1; + 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) ) + other.ammo_rockets = 5; + + sprint (other, PRINT_LOW, "\n"); +// backpack touch sound + sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM); + stuffcmd (other, "bf\n"); + + remove(self); + self = other; + +// change to the weapon + + + if ( WeaponCode(new) <= b_switch ) + { + if (self.flags & FL_INWATER) + { + if (new != IT_LIGHTNING) + { + Deathmatch_Weapon (old, new); + } + } + else + { + Deathmatch_Weapon (old, new); + } + } + + W_SetCurrentAmmo (); +}; + +/* +=============== +DropBackpack +=============== +*/ +void() DropBackpack = +{ + local entity item; + + 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) + item.netname = "Axe"; + else if (item.items == IT_SHOTGUN) + item.netname = "Shotgun"; + else if (item.items == IT_SUPER_SHOTGUN) + item.netname = "Double-barrelled Shotgun"; + else if (item.items == IT_NAILGUN) + item.netname = "Nailgun"; + else if (item.items == IT_SUPER_NAILGUN) + item.netname = "Super Nailgun"; + else if (item.items == IT_GRENADE_LAUNCHER) + item.netname = "Grenade Launcher"; + else if (item.items == IT_ROCKET_LAUNCHER) + item.netname = "Rocket Launcher"; + else if (item.items == IT_LIGHTNING) + item.netname = "Thunderbolt"; + else + item.netname = ""; + + 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_z = 300; + item.velocity_x = -100 + (random() * 200); + item.velocity_y = -100 + (random() * 200); + + item.flags = FL_ITEM; + item.solid = SOLID_TRIGGER; + item.movetype = MOVETYPE_TOSS; + setmodel (item, "progs/backpack.mdl"); + setsize (item, '-16 -16 0', '16 16 56'); + item.touch = BackpackTouch; + + item.nextthink = time + 120; // remove after 2 minutes + item.think = SUB_Remove; +}; + + diff --git a/quakec/fallout2/knight.qc b/quakec/fallout2/knight.qc new file mode 100644 index 000000000..beec2c7b7 --- /dev/null +++ b/quakec/fallout2/knight.qc @@ -0,0 +1,267 @@ +/* +============================================================================== + +KNIGHT + +============================================================================== +*/ + +$cd id1/models/knight +$origin 0 0 24 +$base base +$skin badass3 + +$frame stand1 stand2 stand3 stand4 stand5 stand6 stand7 stand8 stand9 + +$frame runb1 runb2 runb3 runb4 runb5 runb6 runb7 runb8 + +//frame runc1 runc2 runc3 runc4 runc5 runc6 + +$frame runattack1 runattack2 runattack3 runattack4 runattack5 +$frame runattack6 runattack7 runattack8 runattack9 runattack10 +$frame runattack11 + +$frame pain1 pain2 pain3 + +$frame painb1 painb2 painb3 painb4 painb5 painb6 painb7 painb8 painb9 +$frame painb10 painb11 + +//frame attack1 attack2 attack3 attack4 attack5 attack6 attack7 +//frame attack8 attack9 attack10 attack11 + +$frame attackb1 attackb1 attackb2 attackb3 attackb4 attackb5 +$frame attackb6 attackb7 attackb8 attackb9 attackb10 + +$frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8 walk9 +$frame walk10 walk11 walk12 walk13 walk14 + +$frame kneel1 kneel2 kneel3 kneel4 kneel5 + +$frame standing2 standing3 standing4 standing5 + +$frame death1 death2 death3 death4 death5 death6 death7 death8 +$frame death9 death10 + +$frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8 +$frame deathb9 deathb10 deathb11 + +void() knight_stand1 =[ $stand1, knight_stand2 ] {ai_stand();}; +void() knight_stand2 =[ $stand2, knight_stand3 ] {ai_stand();}; +void() knight_stand3 =[ $stand3, knight_stand4 ] {ai_stand();}; +void() knight_stand4 =[ $stand4, knight_stand5 ] {ai_stand();}; +void() knight_stand5 =[ $stand5, knight_stand6 ] {ai_stand();}; +void() knight_stand6 =[ $stand6, knight_stand7 ] {ai_stand();}; +void() knight_stand7 =[ $stand7, knight_stand8 ] {ai_stand();}; +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);}; +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);}; +void() knight_walk5 =[ $walk5, knight_walk6 ] {ai_walk(3);}; +void() knight_walk6 =[ $walk6, knight_walk7 ] {ai_walk(3);}; +void() knight_walk7 =[ $walk7, knight_walk8 ] {ai_walk(3);}; +void() knight_walk8 =[ $walk8, knight_walk9 ] {ai_walk(4);}; +void() knight_walk9 =[ $walk9, knight_walk10 ] {ai_walk(3);}; +void() knight_walk10 =[ $walk10, knight_walk11 ] {ai_walk(3);}; +void() knight_walk11 =[ $walk11, knight_walk12 ] {ai_walk(2);}; +void() knight_walk12 =[ $walk12, knight_walk13 ] {ai_walk(3);}; +void() knight_walk13 =[ $walk13, knight_walk14 ] {ai_walk(4);}; +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);}; +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);}; +void() knight_run5 =[ $runb5, knight_run6 ] {ai_run(16);}; +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_runatk2 =[ $runattack2, knight_runatk3 ] {ai_charge_side();}; +void() knight_runatk3 =[ $runattack3, knight_runatk4 ] {ai_charge_side();}; +void() knight_runatk4 =[ $runattack4, knight_runatk5 ] {ai_charge_side();}; +void() knight_runatk5 =[ $runattack5, knight_runatk6 ] {ai_melee_side();}; +void() knight_runatk6 =[ $runattack6, knight_runatk7 ] {ai_melee_side();}; +void() knight_runatk7 =[ $runattack7, knight_runatk8 ] {ai_melee_side();}; +void() knight_runatk8 =[ $runattack8, knight_runatk9 ] {ai_melee_side();}; +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_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_atk9 =[ $attackb9, knight_atk10] {ai_charge(1);}; +void() knight_atk10=[ $attackb10, knight_run1 ] {ai_charge(5);}; + +//void() knight_atk9 =[ $attack9, knight_atk10 ] {}; +//void() knight_atk10 =[ $attack10, knight_atk11 ] {}; +//void() knight_atk11 =[ $attack11, knight_run1 ] {}; + +//=========================================================================== + +void() knight_pain1 =[ $pain1, knight_pain2 ] {}; +void() knight_pain2 =[ $pain2, knight_pain3 ] {}; +void() knight_pain3 =[ $pain3, knight_run1 ] {}; + +void() knight_painb1 =[ $painb1, knight_painb2 ] {ai_painforward(0);}; +void() knight_painb2 =[ $painb2, knight_painb3 ] {ai_painforward(3);}; +void() knight_painb3 =[ $painb3, knight_painb4 ] {}; +void() knight_painb4 =[ $painb4, knight_painb5 ] {}; +void() knight_painb5 =[ $painb5, knight_painb6 ] {ai_painforward(2);}; +void() knight_painb6 =[ $painb6, knight_painb7 ] {ai_painforward(4);}; +void() knight_painb7 =[ $painb7, knight_painb8 ] {ai_painforward(2);}; +void() knight_painb8 =[ $painb8, knight_painb9 ] {ai_painforward(5);}; +void() knight_painb9 =[ $painb9, knight_painb10 ] {ai_painforward(5);}; +void() knight_painb10 =[ $painb10, knight_painb11 ] {ai_painforward(0);}; +void() knight_painb11 =[ $painb11, knight_run1 ] {}; + +void(entity attacker, float damage) knight_pain = +{ + local float r; + + if (self.pain_finished > time) + return; + + r = random(); + + sound (self, CHAN_VOICE, "knight/khurt.wav", 1, ATTN_NORM); + if (r < 0.85) + { + knight_pain1 (); + self.pain_finished = time + 1; + } + else + { + knight_painb1 (); + self.pain_finished = time + 1; + } + +}; + +//=========================================================================== + +void() knight_bow1 =[ $kneel1, knight_bow2 ] {ai_turn();}; +void() knight_bow2 =[ $kneel2, knight_bow3 ] {ai_turn();}; +void() knight_bow3 =[ $kneel3, knight_bow4 ] {ai_turn();}; +void() knight_bow4 =[ $kneel4, knight_bow5 ] {ai_turn();}; + +void() knight_bow5 =[ $kneel5, knight_bow5 ] {ai_turn();}; + +void() knight_bow6 =[ $kneel4, knight_bow7 ] {ai_turn();}; +void() knight_bow7 =[ $kneel3, knight_bow8 ] {ai_turn();}; +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_die4 =[ $death4, knight_die5 ] {}; +void() knight_die5 =[ $death5, knight_die6 ] {}; +void() knight_die6 =[ $death6, knight_die7 ] {}; +void() knight_die7 =[ $death7, knight_die8 ] {}; +void() knight_die8 =[ $death8, knight_die9 ] {}; +void() knight_die9 =[ $death9, knight_die10] {}; +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_dieb4 =[ $deathb4, knight_dieb5 ] {}; +void() knight_dieb5 =[ $deathb5, knight_dieb6 ] {}; +void() knight_dieb6 =[ $deathb6, knight_dieb7 ] {}; +void() knight_dieb7 =[ $deathb7, knight_dieb8 ] {}; +void() knight_dieb8 =[ $deathb8, knight_dieb9 ] {}; +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) + { + sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); + ThrowHead ("progs/h_knight.mdl", self.health); + ThrowGib ("progs/gib1.mdl", self.health); + ThrowGib ("progs/gib2.mdl", self.health); + ThrowGib ("progs/gib3.mdl", self.health); + return; + } + +// regular death + sound (self, CHAN_VOICE, "knight/kdeath.wav", 1, ATTN_NORM); + if (random() < 0.5) + knight_die1 (); + else + knight_dieb1 (); +}; + +void() monster_knight = +{ + if (deathmatch) + { + remove(self); + return; + } + precache_model ("progs/knight.mdl"); + precache_model ("progs/h_knight.mdl"); + + precache_sound ("knight/kdeath.wav"); + precache_sound ("knight/khurt.wav"); + precache_sound ("knight/ksight.wav"); + precache_sound ("knight/sword1.wav"); + precache_sound ("knight/sword2.wav"); + precache_sound ("knight/idle.wav"); + + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_STEP; + + setmodel (self, "progs/knight.mdl"); + + setsize (self, '-16 -16 -24', '16 16 40'); + self.health = 75; + + self.th_stand = knight_stand1; + self.th_walk = knight_walk1; + self.th_run = knight_run1; + self.th_melee = knight_atk1; + self.th_pain = knight_pain; + self.th_die = knight_die; + + walkmonster_start (); +}; diff --git a/quakec/fallout2/menus.qc b/quakec/fallout2/menus.qc new file mode 100644 index 000000000..ce034ba28 --- /dev/null +++ b/quakec/fallout2/menus.qc @@ -0,0 +1,179 @@ +/* + + return (" +weaponry\n\n +1 melee \n +2 thrown \n +3 pistols&smgs \n +4 shotguns \n +5 rifles \n +6 heavy guns \n +e leave +*/ + +/* +1 1911a1 .45 01 5$\n +2 d. eagle .44 02 7$\n +3 mk23 socom .45 02 9$\n +4 h&k mp7 4mm 03 14$\n +5 h&k mp5 9mm 03 17$\n +6 alien blaster 02 21$\n + +1 pipe rifle .44 02 4$\n +2 winchester 12g 03 8$\n +3 mossberg 12g 04 14$\n +4 citykiller 12g 05 35$\n + +1 rangemaster 7mm 03 11$\n +2 ak-112 5mm 04 21$\n +3 remington .308 05 24$\n +4 ak-74 5mm 04 27$\n +5 moonlight .223 05 36$\n +6 sa-80 5mm 05 23$\n +7 plasma rifle 07 41$\n +8 gauss rifle 2mm 08 51$\n +*/ + +string () ShopString = +{ + return ("--- S H O P -------\n\n1 traits \n2 perks \n3 body armour \n4 protection \n5 weapons \n6 equipment \n7 chems \n8 special \ne leave \n"); +}; + +string () WeaponString = +{ + return ("weaponry\n\n1 melee \n2 thrown \n3 pistols&smgs \n4 shotguns \n5 rifles \ne leave \n"); +}; + +string () TraitString = +{ + return ("traits\n\n1 one handed \n2 small frame \n3 bruiser \n4 heavy handed \n5 bloody mess \n6 bad luck \ne leave \n"); +}; + +string () ThrownString = +{ + return ("grenades\n GRENADE | COST \n\n1 smoke grenade 3$\n2 frag grenade 4$\n3 emp grenade 5$\n4 flashbang 7$\ne exit \n"); +}; + +string () BuildString = +{ + return ("BUILD A STRUCTURE\n NAME | UPGRADE | SCRAPS\n\n1 Mr. Ammo 4\n2 Barricade 6\n3 AutoDoc(tm) 10\n4 Robo-Fang 11\ne exit \n"); +}; + +string () HelmetString = +{ + return ("helmets\nprotect you from headshots so\nmake sure you use a decent one\n\n ABS% WT DEFLECT PRC\n1 combat helm -10% 01 5% 05\n2 combat helm 2 +0% 02 5% 20\n3 heavy-duty +20% 03 5% 20\n4 ceramic helm -20% ..."); +}; + +string () ArmorString = +{ + return ("body armour wt abs prc\n\n1 light kevlar 03 1/20% 03$\n2 leather armor 05 2/30% 08$\n3 kevlar armor 09 3/35% 10$\n4 metal armor 15 5/35% 12$\n5 combat armor 12 4/40% 25$\n6 brotherhood armor 17 5/45% 35$\n7 force armor 06 7/10% 45$\n8 metal armor mkii 20 8/50% 55$\n"); +}; + +string () PerkString = +{ + return ("perks\n ABILITY | FRAGS NEEDED \n\n1 bonus movement 2\n2 strong back 2\n3 quick pockets 2\n4 awareness 2\n5 silent running 3\n6 better criticals 3\n7 bonus ranged damage 3\n8 divine favor 3\n9 slayer 3\n0 sharpshooter 4\n"); +}; + +string () ProtectString = +{ + return ("++ high-tech protective devices ++ \n\n HARDWARE | SHIELDS VS | PRICE \n1 energy amulet |damage: 7% 15\n2 force field |front: 15% 20\n3 safety ring |absorb: 3 35\n4 smokescreen |obscures 40\n5 sentient cube |regenerate 45\n"); +}; + + +/*return ("++ high-tech protective devices ++ \n\n + HARDWARE | SHIELDS VS | PRICE \n +1 energy amulet |damage: 7% 15\n +2 force field |front: 15% 20\n +3 safety ring |absorb: 3 35\n +4 smokescreen |obscures 40\n +5 sentient cube |regenerate 45\n");*/ + + +string () OtherString = +{ + return ("++ miscellaneous items ++\n ITEM | CLASS | PRICE \n\n\n1 (25) bandages for medic 2$\n2 (5) metal scraps 5$\n"); +}; + + +string () MeleeString = +{ + return ("MELEE WEAPONS\nWEAPON | TYPE | WT | PRICE \n\n1 knife melee 01 01$\n2 hand axe melee 08 03$\n3 vibroblade melee 04 10$\n4 power axe melee 07 15$\ne exit \n"); +}; + +/* +6 h&k mp5 9mmP 03 17$\n +7 h&k mp7 4.60mm 03 14$\n +8 fn p90 5.57mm 03 22$\n +9 h&k mp10 10mm 03 24$\n +0 thompson .45 03 20$\n + + +6 h&k mp5 9mmP 03 17$\n7 h&k mp7 4.60mm 03 14$\n8 fn p90 5.57mm 03 22$\n9 h&k mp10 10mm 03 24$\n0 thompson .45 03 20$\n +*/ + +string () PistolString = +{ + return ("Pistols and Submachineguns\n WEAPON | CAL | WEIGHT | PRICE \n\n1 mk23 socom .45 01 5$\n2 d. eagle .44 02 7$\n3 needler pistol 02 9$\n4 h&k mp7 4mm 03 14$\n5 grease gun 9mm 03 17$\n6 alien blaster 02 21$\n"); +}; + +string () ShotgunString = +{ + return ("shotguns\n WEAPON | TYPE | WEIGHT | PRICE \n\n1 pipe rifle .44 02 4$\n2 winchester 12g 03 8$\n3 mossberg 12g 04 14$\n4 citykiller 12g 05 35$\n"); +}; + +/* +6 dks-1 .338 bolt 08 32$\n +7 moonlight .223 auto 06 54$\n +8 xl70e3 5mm auto 08 27$\n +9 fn-fal .308 auto 04 51$\n +0 sa-80 .223 auto 07 45$\n + +*/ +string () RifleString = +{ + return ("rifles\n RIFLE | TYPE | WEIGHT | PRICE \n\n1 rangemaster 7mm 03 11$\n2 ak-112 5mm 04 21$\n3 remington .308 05 24$\n4 ak-74 5mm 04 27$\n5 moonlight .223 05 36$\n6 xl-70 5mm 05 23$\n7 plasma rifle 07 41$\n8 gauss rifle 2mm 08 51$\n"); +}; + +string () ChemString = +{ + return ("drugs\n DRUG | EFFECTS | PRICE\n\n1 stimpack heals 05+20 3$\n2 medkit+ heals 10+50 5$\n3 adrenaline*+speed/jump 10$\n4 superstim* heals 20+60 12$\n5 jet* aim better 18$\ne exit \n\n+ requires medic \n* requires advanced medic \n"); +}; + +string () ChemString2 = +{ + return ("chems\n DRUG | EFFECTS | PRICE\n\n1 adrenaline +60 speed/jump 3$\n2 stimpack heals 40 5$\n3 psycho+ +60 hp/no pain 11$\n4 medkit* heals 20+50 12$\n5 berserk* adren+psycho 12$\n6 jet* aim better 15$\ne exit \n\n+ requires shaman \n* requires advanced shaman \n"); +}; + +string () EnergyWeaponsString = +{ + return ("high-tech weaponry\n WEAPON | TYPE | WEIGHT | PRICE \n\n1 [*] flash gun semi 03 21$\n2 [&] plasma rifle semi 08 34$\n3 [*] laser rifle semi 11 40$\n4 [*] laser carbine auto 06 57$\n5 [?] alien blaster semi 02 72$\n"); +}; + +//6 bozar 14 81$\n7 firestorm 12 97$ + +string () HeavyGunsString = +{ + return ("heavy guns\n WEAPON | TYPE | WEIGHT | PRICE \n\n1 light support weapon 15 55$\n2 rocket launcher 11 75$\n3 50oc flamethrower 16 35$\n4 steyr amr .50 flechette 17 72$\n5 m72 gauss rifle 2mm 12 81$\n6 bozar 14 81$\n7 firestorm 12 97$"); +}; + +string () de_dust = +{ + return (" DE_DUST \n (BOMB/DEFUSE MAP) \n\nrangers have obtained two ufos\nthat have crash landed in the \ndesert. raiders must blow them\nup with c4 before its too late\n\n(activate electronic tools and\nc4 by pressing 4) ..."); +}; + +/* +4 motion sensor 20c\n +5 extra magazines 20c\n +6 electronic tools mark ii 30c\n +7 climbing gear 30c\n +8 remote camera 40c\n +9 cooling module 50c\n +0 laser defense field 50c\n +*/ + + + +string () EquipmentString = +{ + return ("+ special equipment +\npress your c key to activate!\n\n1 stealth boy 20c\n2 displacer cloak 20c\n3 security alarm 20c\n4 motion sensor 20c\n5 extra magazines 20c\n6 electronic tools mark ii 30c\n7 climbing gear 30c\n8 remote camera 40c\n9 enhanced battery 50c\n0 laser defense field 50c\n"); +}; diff --git a/quakec/fallout2/misc.qc b/quakec/fallout2/misc.qc new file mode 100644 index 000000000..6ba82b57d --- /dev/null +++ b/quakec/fallout2/misc.qc @@ -0,0 +1,730 @@ + +/*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4) +Used as a positional target for spotlights, etc. +*/ +void() info_null = +{ + remove(self); +}; + +/*QUAKED info_notnull (0 0.5 0) (-4 -4 -4) (4 4 4) +Used as a positional target for lightning. +*/ +void() info_notnull = +{ +}; + +//============================================================================ + +float START_OFF = 1; + +void() light_use = +{ + if (self.spawnflags & START_OFF) + { + lightstyle(self.style, "m"); + self.spawnflags = self.spawnflags - START_OFF; + } + else + { + lightstyle(self.style, "a"); + self.spawnflags = self.spawnflags + START_OFF; + } +}; + +/*QUAKED light (0 1 0) (-8 -8 -8) (8 8 8) START_OFF +Non-displayed light. +Default light value is 300 +Default style is 0 +If targeted, it will toggle between on or off. +*/ +void() light = +{ + if (!self.targetname) + { // inert light + remove(self); + return; + } + + if (self.style >= 32) + { + self.use = light_use; + if (self.spawnflags & START_OFF) + lightstyle(self.style, "a"); + else + lightstyle(self.style, "m"); + } +}; + +/*QUAKED light_fluoro (0 1 0) (-8 -8 -8) (8 8 8) START_OFF +Non-displayed light. +Default light value is 300 +Default style is 0 +If targeted, it will toggle between on or off. +Makes steady fluorescent humming sound +*/ +void() light_fluoro = +{ + if (self.style >= 32) + { + self.use = light_use; + if (self.spawnflags & START_OFF) + lightstyle(self.style, "a"); + else + lightstyle(self.style, "m"); + } + + precache_sound ("ambience/fl_hum1.wav"); + ambientsound (self.origin, "ambience/fl_hum1.wav", 0.5, ATTN_STATIC); +}; + +/*QUAKED light_fluorospark (0 1 0) (-8 -8 -8) (8 8 8) +Non-displayed light. +Default light value is 300 +Default style is 10 +Makes sparking, broken fluorescent sound +*/ +void() light_fluorospark = +{ + if (!self.style) + self.style = 10; + + precache_sound ("ambience/buzz1.wav"); + ambientsound (self.origin, "ambience/buzz1.wav", 0.5, ATTN_STATIC); +}; + +/*QUAKED light_globe (0 1 0) (-8 -8 -8) (8 8 8) +Sphere globe light. +Default light value is 300 +Default style is 0 +*/ +void() light_globe = +{ + precache_model ("progs/s_light.spr"); + setmodel (self, "progs/s_light.spr"); + makestatic (self); +}; + +void() FireAmbient = +{ + precache_sound ("ambience/fire1.wav"); +// attenuate fast + ambientsound (self.origin, "ambience/fire1.wav", 0.5, ATTN_STATIC); +}; + +/*QUAKED light_torch_small_walltorch (0 .5 0) (-10 -10 -20) (10 10 20) +Short wall torch +Default light value is 200 +Default style is 0 +*/ +void() light_torch_small_walltorch = +{ + precache_model ("progs/flame.mdl"); + setmodel (self, "progs/flame.mdl"); + FireAmbient (); + makestatic (self); +}; + +/*QUAKED light_flame_large_yellow (0 1 0) (-10 -10 -12) (12 12 18) +Large yellow flame ball +*/ +void() light_flame_large_yellow = +{ + precache_model ("progs/flame2.mdl"); + setmodel (self, "progs/flame2.mdl"); + self.frame = 1; + FireAmbient (); + makestatic (self); +}; + +/*QUAKED light_flame_small_yellow (0 1 0) (-8 -8 -8) (8 8 8) START_OFF +Small yellow flame ball +*/ +void() light_flame_small_yellow = +{ + precache_model ("progs/flame2.mdl"); + setmodel (self, "progs/flame2.mdl"); + FireAmbient (); + makestatic (self); +}; + +/*QUAKED light_flame_small_white (0 1 0) (-10 -10 -40) (10 10 40) START_OFF +Small white flame ball +*/ +void() light_flame_small_white = +{ + precache_model ("progs/flame2.mdl"); + setmodel (self, "progs/flame2.mdl"); + FireAmbient (); + makestatic (self); +}; + +//============================================================================ + + +/*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.think = fire_fly; + if (!self.speed) + self.speed == 1000; +}; + +void() fire_fly = +{ +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.classname = "fireball"; + setmodel (fireball, "progs/lavaball.mdl"); + setsize (fireball, '0 0 0', '0 0 0'); + setorigin (fireball, self.origin); + fireball.nextthink = time + 5; + fireball.think = SUB_Remove; + fireball.touch = fire_touch; + + self.nextthink = time + (random() * 5) + 3; + self.think = fire_fly; +}; + + +void() fire_touch = +{ + T_Damage (other, self, self, 20); + remove(self); +}; + +//============================================================================ + + +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); + 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; + + self.solid = SOLID_BBOX; + self.movetype = MOVETYPE_NONE; + precache_model ("maps/b_explob.bsp"); + setmodel (self, "maps/b_explob.bsp"); + setsize (self, '0 0 0', '32 32 64'); + precache_sound ("weapons/r_exp3.wav"); + self.health = 20; + self.th_die = barrel_explode; + self.takedamage = DAMAGE_AIM; + + self.origin_z = self.origin_z + 2; + oldz = self.origin_z; + droptofloor(); + if (oldz - self.origin_z > 250) + { + dprint ("item fell out of level at "); + dprint (vtos(self.origin)); + dprint ("\n"); + 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; + + self.solid = SOLID_BBOX; + self.movetype = MOVETYPE_NONE; + precache_model2 ("maps/b_exbox2.bsp"); + setmodel (self, "maps/b_exbox2.bsp"); + setsize (self, '0 0 0', '32 32 32'); + precache_sound ("weapons/r_exp3.wav"); + self.health = 20; + self.th_die = barrel_explode; + self.takedamage = DAMAGE_AIM; + + self.origin_z = self.origin_z + 2; + oldz = self.origin_z; + droptofloor(); + if (oldz - self.origin_z > 250) + { + dprint ("item fell out of level at "); + dprint (vtos(self.origin)); + dprint ("\n"); + remove(self); + } +}; + +//============================================================================ + +float SPAWNFLAG_SUPERSPIKE = 1; +float SPAWNFLAG_LASER = 2; + +void() Laser_Touch = +{ + local vector org; + + if (other == self.owner) + return; // don't explode on owner + + 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) + { + 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); + multicast (org, MULTICAST_PVS); + } + + remove(self); +}; + +void(vector org, vector vec) LaunchLaser = +{ + local vector vec; + + if (self.classname == "monster_enforcer") + sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM); + + vec = normalize(vec); + + newmis = spawn(); + newmis.owner = self; + newmis.movetype = MOVETYPE_FLY; + newmis.solid = SOLID_BBOX; + newmis.effects = EF_DIMLIGHT; + + setmodel (newmis, "progs/laser.mdl"); + setsize (newmis, '0 0 0', '0 0 0'); + + setorigin (newmis, org); + + newmis.velocity = vec * 600; + newmis.angles = vectoangles(newmis.velocity); + + newmis.nextthink = time + 5; + newmis.think = SUB_Remove; + newmis.touch = Laser_Touch; +}; + +void() spikeshooter_use = +{ + if (self.spawnflags & SPAWNFLAG_LASER) + { + sound (self, CHAN_VOICE, "enforcer/enfire.wav", 1, ATTN_NORM); + LaunchLaser (self.origin, self.movedir); + } + else + { + sound (self, CHAN_VOICE, "weapons/spike2.wav", 1, ATTN_NORM); + launch_spike (self.origin, self.movedir); + newmis.velocity = self.movedir * 500; + if (self.spawnflags & SPAWNFLAG_SUPERSPIKE) + newmis.touch = superspike_touch; + } +}; + +void() shooter_think = +{ + spikeshooter_use (); + self.nextthink = time + self.wait; + 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) + { + precache_model2 ("progs/laser.mdl"); + + precache_sound2 ("enforcer/enfire.wav"); + precache_sound2 ("enforcer/enfstop.wav"); + } + else + 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) +"nextthink" delay before firing first spike, so multiple shooters can be stagered. +*/ +void() trap_shooter = +{ + trap_spikeshooter (); + + if (self.wait == 0) + self.wait = 1; + self.nextthink = self.nextthink + self.wait + self.ltime; + self.think = shooter_think; +}; + + + +/* +=============================================================================== + + +=============================================================================== +*/ + + +void() make_bubbles; +void() bubble_remove; +void() bubble_bob; + +/*QUAKED air_bubbles (0 .5 .8) (-8 -8 -8) (8 8 8) + +testing air bubbles +*/ + +void() air_bubbles = +{ + remove (self); +}; + +void() make_bubbles = +{ +local entity bubble; + + bubble = spawn(); + setmodel (bubble, "progs/s_bubble.spr"); + setorigin (bubble, self.origin); + bubble.movetype = MOVETYPE_NOCLIP; + bubble.solid = SOLID_NOT; + bubble.velocity = '0 0 15'; + bubble.nextthink = time + 0.5; + bubble.think = bubble_bob; + bubble.touch = bubble_remove; + bubble.classname = "bubble"; + bubble.frame = 0; + bubble.cnt = 0; + setsize (bubble, '-8 -8 -8', '8 8 8'); + self.nextthink = time + random() + 0.5; + self.think = make_bubbles; +}; + +void() bubble_split = +{ +local entity bubble; + bubble = spawn(); + setmodel (bubble, "progs/s_bubble.spr"); + setorigin (bubble, self.origin); + bubble.movetype = MOVETYPE_NOCLIP; + bubble.solid = SOLID_NOT; + bubble.velocity = self.velocity; + bubble.nextthink = time + 0.5; + bubble.think = bubble_bob; + bubble.touch = bubble_remove; + bubble.classname = "bubble"; + bubble.frame = 1; + bubble.cnt = 10; + setsize (bubble, '-8 -8 -8', '8 8 8'); + self.frame = 1; + self.cnt = 10; + if (self.waterlevel != 3) + remove (self); +}; + +void() bubble_remove = +{ + if (other.classname == self.classname) + { +// dprint ("bump"); + return; + } + remove(self); +}; + +void() bubble_bob = +{ +local float rnd1, rnd2, rnd3; +local vector vtmp1, modi; + + self.cnt = self.cnt + 1; + if (self.cnt == 4) + 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; + + if (rnd1 > 10) + rnd1 = 5; + if (rnd1 < -10) + rnd1 = -5; + + if (rnd2 > 10) + rnd2 = 5; + if (rnd2 < -10) + rnd2 = -5; + + if (rnd3 < 10) + rnd3 = 15; + if (rnd3 > 30) + rnd3 = 25; + + self.velocity_x = rnd1; + self.velocity_y = rnd2; + self.velocity_z = rnd3; + + self.nextthink = time + 0.5; + self.think = bubble_bob; +}; + +/*~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~> +~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~<~>~*/ + +/*QUAKED viewthing (0 .5 .8) (-8 -8 -8) (8 8 8) + +Just for the debugging level. Don't use +*/ + +void() viewthing = + +{ + self.movetype = MOVETYPE_NONE; + self.solid = SOLID_NOT; + precache_model ("progs/player.mdl"); + setmodel (self, "progs/player.mdl"); +}; + + +/* +============================================================================== + +SIMPLE BMODELS + +============================================================================== +*/ + +void() func_wall_use = +{ // change to alternate textures + self.frame = 1 - self.frame; +}; + +/*QUAKED func_wall (0 .5 .8) ? +This is just a solid wall if not inhibitted +*/ +void() func_wall = +{ + self.angles = '0 0 0'; + self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything + self.solid = SOLID_BSP; + self.use = func_wall_use; + 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; + self.solid = SOLID_NOT; + setmodel (self, self.model); + makestatic (); +}; + +/*QUAKED func_episodegate (0 .5 .8) ? E1 E2 E3 E4 +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 + + self.angles = '0 0 0'; + self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything + self.solid = SOLID_BSP; + self.use = func_wall_use; + setmodel (self, self.model); +}; + +/*QUAKED func_bossgate (0 .5 .8) ? +This bmodel appears unless players have all of the episode sigils. +*/ +void() func_bossgate = + +{ + if ( (serverflags & 15) == 15) + return; // all episodes completed + self.angles = '0 0 0'; + self.movetype = MOVETYPE_PUSH; // so it doesn't get pushed by anything + self.solid = SOLID_BSP; + self.use = func_wall_use; + setmodel (self, self.model); +}; + +//============================================================================ +/*QUAKED ambient_suck_wind (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_suck_wind = +{ + precache_sound ("ambience/suck1.wav"); + ambientsound (self.origin, "ambience/suck1.wav", 1, ATTN_STATIC); +}; + +/*QUAKED ambient_drone (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +void() ambient_drone = +{ + precache_sound ("ambience/drone6.wav"); + ambientsound (self.origin, "ambience/drone6.wav", 0.5, ATTN_STATIC); +}; + +/*QUAKED ambient_flouro_buzz (0.3 0.1 0.6) (-10 -10 -8) (10 10 8) +*/ +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 = +{ + 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 = +{ + 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 = +{ + 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 = +{ + 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 = +{ + 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 = +{ + precache_sound ("ambience/swamp2.wav"); + ambientsound (self.origin, "ambience/swamp2.wav", 0.5, ATTN_STATIC); +}; + +//============================================================================ + +void() noise_think = +{ + self.nextthink = time + 0.5; + sound (self, 1, "enforcer/enfire.wav", 1, ATTN_NORM); + sound (self, 2, "enforcer/enfstop.wav", 1, ATTN_NORM); + sound (self, 3, "enforcer/sight1.wav", 1, ATTN_NORM); + sound (self, 4, "enforcer/sight2.wav", 1, ATTN_NORM); + sound (self, 5, "enforcer/sight3.wav", 1, ATTN_NORM); + sound (self, 6, "enforcer/sight4.wav", 1, ATTN_NORM); + sound (self, 7, "enforcer/pain1.wav", 1, ATTN_NORM); +}; + +/*QUAKED misc_noisemaker (1 0.5 0) (-10 -10 -10) (10 10 10) + +For optimzation testing, starts a lot of sounds. +*/ + +void() misc_noisemaker = + +{ + precache_sound2 ("enforcer/enfire.wav"); + precache_sound2 ("enforcer/enfstop.wav"); + precache_sound2 ("enforcer/sight1.wav"); + precache_sound2 ("enforcer/sight2.wav"); + precache_sound2 ("enforcer/sight3.wav"); + precache_sound2 ("enforcer/sight4.wav"); + precache_sound2 ("enforcer/pain1.wav"); + precache_sound2 ("enforcer/pain2.wav"); + precache_sound2 ("enforcer/death1.wav"); + precache_sound2 ("enforcer/idle1.wav"); + + self.nextthink = time + 0.1 + random(); + self.think = noise_think; +}; diff --git a/quakec/fallout2/mod_buy.qc b/quakec/fallout2/mod_buy.qc new file mode 100644 index 000000000..2297ef998 --- /dev/null +++ b/quakec/fallout2/mod_buy.qc @@ -0,0 +1,1931 @@ + +float () weightx; + +void (float wt, float cost, string item) BuyWeapon = +{ + local float lbs; + local string qq; + local float curr; + local float c3; + local string c1; + local string c2; + + lbs = weightx (); + if (((self.team == SPAWNFLAG_LASER) && ((random () * SECRET_NO_SHOOT) < AS_MELEE))) + { + sprint (self, SPAWNFLAG_LASER, "markdown: from "); + c1 = ftos (cost); + sprint (self, SPAWNFLAG_LASER, c1); + sprint (self, SPAWNFLAG_LASER, " to "); + c3 = ceil ((cost * 0.66)); + c2 = ftos (c3); + sprint (self, SPAWNFLAG_LASER, c2); + sprint (self, SPAWNFLAG_LASER, "\n"); + cost = (cost * 0.66); + } + if ((self.current_slot == SPAWNFLAG_SUPERSPIKE)) + { + curr = self.slot1_weight; + if ((self.slot2 == "none")) + { + self.slot2 = self.slot1; + } + /*else + { + if ((self.slot1 != "none")) + { + DropWeapon (self.slot1, SPAWNFLAG_SUPERSPIKE, MULTICAST_ALL); + } + }*/ + //GetWeaponModel (); + } + if ((self.current_slot == SPAWNFLAG_LASER)) + { + curr = self.slot2_weight; + if ((self.slot1 == "none")) + { + self.slot1 = self.slot2; + } + /*else + { + if ((self.slot2 != MULTICAST_ALL)) + { + DropWeapon (self.slot2, SPAWNFLAG_SUPERSPIKE, MULTICAST_ALL); + } + }*/ + //GetWeaponModel (); + } + if ((((lbs + wt) - curr) > 30)) + { + //Weight (); + sprint (self, PRINT_HIGH, "you can't carry that much.\n"); + self.currentmenu = "none"; + //GetWeaponModel (); + return; + } + if ((cost > self.ammo_shells)) + { + sprint (self, PRINT_HIGH, "not enough money.\n"); + self.currentmenu = "none"; + //GetWeaponModel (); + return; + } + self.ammo_shells = (self.ammo_shells - cost); + if ((self.current_slot == SPAWNFLAG_SUPERSPIKE)) + { + GetWeaponWeight (self, self.current_slot); + stuffcmd (self, "impulse 1\n"); + self.slot1 = item; + self.items = (self.items | IT_SUPER_NAILGUN); + //GetWeaponModel (); + } + else + { + if ((self.current_slot == SPAWNFLAG_LASER)) + { + GetWeaponWeight (self, self.current_slot); + stuffcmd (self, "impulse 2\n"); + self.slot2 = item; + self.items = (self.items | IT_GRENADE_LAUNCHER); + //GetWeaponModel (); + } + } + //qq = GetWeaponName (self, self.current_slot); + sprint (self, PRINT_HIGH, qq); + sprint (self, PRINT_HIGH, " purchased.\n"); + self.currentmenu = "none"; + //WeaponAmmo (SPAWNFLAG_SUPERSPIKE); + //WeaponAmmo (SPAWNFLAG_LASER); + GetWeaponWeight (self, SPAWNFLAG_SUPERSPIKE); + GetWeaponWeight (self, SPAWNFLAG_LASER); + //GetWeaponModel (); + return; +}; + +void (float cost, string item) BuyPerk = +{ + if ((self.frags < cost)) + { + sprint (self, PRINT_HIGH, "not enough kills\n"); + self.currentmenu = "none"; + return; + } + sprint (self, PRINT_HIGH, "ok, ability gained.\n"); + self.perk = item; + self.currentmenu = "none"; + return; +}; + +void (float wt, float cost, string item) BuyArmor = +{ + local float curr; + local float lbs; + + lbs = weightx (); + + if ((cost > self.ammo_shells)) + { + sprint (self, PRINT_HIGH, "not enough money.\n"); + self.currentmenu = "none"; + return; + } + if ((((lbs + wt) - self.armor_weight) > 30)) + { + //Weight (); + sprint (self, PRINT_HIGH, "you can't carry that much.\n"); + self.currentmenu = "none"; + return; + } + sprint (self, PRINT_HIGH, "armor purchased.\n"); + self.ammo_shells = (self.ammo_shells - cost); + self.armor_weight = wt; + self.armor = item; + //Equip_Armor (); + return; +}; + +void (float cost, string item) BuyGadget = +{ + local float lbs; + + lbs = weightx (); + if ((cost > self.ammo_shells)) + { + sprint (self, PRINT_HIGH, "not enough money.\n"); + self.currentmenu = "none"; + return; + } + sprint (self, PRINT_HIGH, "gadget purchased.\n"); + self.ammo_shells = (self.ammo_shells - cost); + self.equipment = item; + return; +}; + +void (float cost, string item) Buyprotect = +{ + if ((self.armor == "brotherhood combat armor")) + { + sprint (self, PRINT_HIGH, "too many electronics in\nyour currently worn armor!"); + self.currentmenu = "none"; + return; + } + if ((cost > self.ammo_shells)) + { + sprint (self, PRINT_HIGH, "not enough money.\n"); + self.currentmenu = "none"; + return; + } + sprint (self, PRINT_HIGH, "protect purchased.\n"); + self.ammo_shells = (self.ammo_shells - cost); + self.protect = item; + return; +}; + +float (float input) overweight = +{ + local float var; + local float max; + + var = ((((input) + self.armor_weight) + self.slot1_weight) + self.slot2_weight); + max = 30; + if (self.class == 6) + max = 40; + + if (self.perk == "") + max = max + 10; + + if (var > max) + return (TRUE); + else + return (FALSE); +}; + +float () weightx = +{ + local float var; + + var = 0; + var = (self.slot1_weight + self.slot2_weight + self.armor_weight); + return (var); +}; + +void () W_GetClass = +{ + if ((self.currentmenu == "select_class")) + { + sound (self, CHAN_WEAPON, "buttons/switch02.wav", TRUE, ATTN_NORM); + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + if ((self.class == SPAWNFLAG_LASER)) + { + return; + } + self.currentmenu = "none"; + self.max_health = 80; + self.class = SPAWNFLAG_LASER; + self.override = SPAWNFLAG_SUPERSPIKE; + stuffcmd (self, "kill\n"); + self.ghost = MULTICAST_ALL; + return; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + if ((self.class == AS_MELEE)) + { + return; + } + self.currentmenu = "none"; + self.max_health = 70; + self.class = AS_MELEE; + self.override = SPAWNFLAG_SUPERSPIKE; + stuffcmd (self, "kill\n"); + self.ghost = MULTICAST_ALL; + return; + } + if ((self.impulse == AS_MELEE)) + { + if ((self.class == SECRET_1ST_DOWN)) + { + return; + } + self.currentmenu = "none"; + self.max_health = 100; + self.class = SECRET_1ST_DOWN; + self.override = SPAWNFLAG_SUPERSPIKE; + stuffcmd (self, "kill\n"); + self.ghost = MULTICAST_ALL; + return; + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + if ((self.class == MULTICAST_PVS_R)) + { + return; + } + self.max_health = 80; + self.currentmenu = "none"; + self.class = TE_LIGHTNING2; + self.override = SPAWNFLAG_SUPERSPIKE; + stuffcmd (self, "kill\n"); + self.ghost = MULTICAST_ALL; + return; + } + } + if ((self.impulse > SECRET_1ST_DOWN)) + { + return; + } +}; + +/* +void () W_PlayerMenu = +{ + local float type; + local float value; + local float bit; + local float r; + local entity spot; + local entity te; + local string ac; + local string menu; + local float ratio; + local float r1; + local float r2; + local float var; + local float soldout; + local float lbs; + local float b1; + + if ((self.currentmenu == "none")) + { + return; + } + else + { + if ((self.currentmenu == "help")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + self.currentmenu = "help1"; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + self.currentmenu = "help2"; + } + if ((self.impulse == AS_MELEE)) + { + self.currentmenu = "help3"; + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + self.currentmenu = "help4"; + } + if ((self.impulse == MULTICAST_PVS_R)) + { + self.currentmenu = "help5"; + } + if ((self.impulse == TE_LIGHTNING2)) + { + self.currentmenu = "help6"; + } + if ((self.impulse == TE_WIZSPIKE)) + { + self.currentmenu = "help7"; + } + return; + } + else + { + if ((self.currentmenu == "menu_votehs")) + { + spot = find (spot, classname, "voteboy"); + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + spot.vote1 = (spot.vote1 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + spot.vote2 = (spot.vote2 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + sprint (self, PRINT_HIGH, "Thank you for voting!\n"); + return; + } + else + { + if ((self.currentmenu == "menu_voters")) + { + spot = find (spot, classname, "voteboy"); + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + spot.vote1 = (spot.vote1 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + spot.vote2 = (spot.vote2 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + sprint (self, PRINT_HIGH, "Thank you for voting!\n"); + return; + } + else + { + if ((self.currentmenu == "menu_votemap")) + { + spot = find (spot, classname, "voteboy"); + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + spot.vote1 = (spot.vote1 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + spot.vote2 = (spot.vote2 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == AS_MELEE)) + { + spot.vote3 = (spot.vote3 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + spot.vote4 = (spot.vote4 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == MULTICAST_PVS_R)) + { + spot.vote5 = (spot.vote5 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == TE_LIGHTNING2)) + { + spot.vote6 = (spot.vote6 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == TE_WIZSPIKE)) + { + spot.vote7 = (spot.vote7 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse <= TE_WIZSPIKE)) + { + sprint (self, PRINT_HIGH, "Thank you for voting!\n"); + } + return; + } + else + { + if ((self.currentmenu == "menu_voteff")) + { + spot = find (spot, classname, "voteboy"); + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + spot.vote1 = (spot.vote1 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + spot.vote2 = (spot.vote2 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + sprint (self, PRINT_HIGH, "Thank you for voting!\n"); + return; + } + else + { + if ((self.currentmenu == "menu_votez")) + { + spot = find (spot, classname, "voteboy"); + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + spot.vote1 = (spot.vote1 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + spot.vote2 = (spot.vote2 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == AS_MELEE)) + { + spot.vote3 = (spot.vote3 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + spot.vote4 = (spot.vote4 + SPAWNFLAG_SUPERSPIKE); + self.currentmenu = "none"; + } + sprint (self, PRINT_HIGH, "Thank you for voting!\n"); + return; + } + else + { + if ((self.currentmenu == "menu_buy")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + menu = TraitString (); + centerprint (self, menu); + self.currentmenu = "menu_trait"; + return; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + menu = PlusString (); + centerprint (self, menu); + self.currentmenu = "menu_plus"; + return; + } + if ((self.impulse == AS_MELEE)) + { + menu = ArmorString1 (); + centerprint (self, menu); + self.currentmenu = "menu_armor"; + return; + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + if (((self.team == SPAWNFLAG_SUPERSPIKE) && (blue_gadget == MULTICAST_ALL))) + { + self.currentmenu = "none"; + sprint (self, SPAWNFLAG_LASER, "your team needs a proto-lab.\n"); + return; + } + if (((self.team == SPAWNFLAG_LASER) && (red_gadget == MULTICAST_ALL))) + { + self.currentmenu = "none"; + sprint (self, SPAWNFLAG_LASER, "your team needs a proto-lab.\n"); + return; + } + menu = HardwareString (); + centerprint (self, menu); + self.currentmenu = "menu_protect"; + return; + } + if ((self.impulse == MULTICAST_PVS_R)) + { + menu = WeaponString (); + centerprint (self, menu); + self.currentmenu = "menu_weapon"; + return; + } + if ((self.impulse == TE_LIGHTNING2)) + { + if (((self.team == SPAWNFLAG_SUPERSPIKE) && (blue_gadget == MULTICAST_ALL))) + { + self.currentmenu = "none"; + sprint (self, SPAWNFLAG_LASER, "your team needs a proto-lab.\n"); + return; + } + if (((self.team == SPAWNFLAG_LASER) && (red_gadget == MULTICAST_ALL))) + { + self.currentmenu = "none"; + sprint (self, SPAWNFLAG_LASER, "your team needs a proto-lab.\n"); + return; + } + menu = GadgetString (); + centerprint (self, menu); + self.currentmenu = "menu_gadget"; + return; + } + if ((self.impulse == TE_WIZSPIKE)) + { + if ((self.team == SPAWNFLAG_SUPERSPIKE)) + { + menu = DrugString1 (); + } + if ((self.team == SPAWNFLAG_LASER)) + { + menu = DrugString2 (); + } + centerprint (self, menu); + if ((self.team == SPAWNFLAG_SUPERSPIKE)) + { + self.currentmenu = "menu_drug1"; + } + if ((self.team == SPAWNFLAG_LASER)) + { + self.currentmenu = "menu_drug2"; + } + return; + } + } + else + { + if ((self.currentmenu == "menu_weapon")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + menu = MeleeString (); + centerprint (self, menu); + self.currentmenu = "menu_melee"; + return; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + menu = MiscString (); + centerprint (self, menu); + self.currentmenu = "menu_misc"; + return; + } + if ((self.impulse == AS_MELEE)) + { + menu = SmallArmString1 (); + centerprint (self, menu); + self.currentmenu = "menu_smallarm1"; + return; + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + menu = SmallArmString2 (); + centerprint (self, menu); + self.currentmenu = "menu_smallarm2"; + return; + } + if ((self.impulse == MULTICAST_PVS_R)) + { + menu = SmallArmString3 (); + centerprint (self, menu); + self.currentmenu = "menu_smallarm3"; + return; + } + + if ((self.impulse == TE_LIGHTNING2)) + { + if (((self.team == SPAWNFLAG_SUPERSPIKE) && (blue_weapon == MULTICAST_ALL))) + { + self.currentmenu = "none"; + sprint (self, SPAWNFLAG_LASER, "your team needs an arms lab.\n"); + return; + } + if (((self.team == SPAWNFLAG_LASER) && (red_weapon == MULTICAST_ALL))) + { + self.currentmenu = "none"; + sprint (self, SPAWNFLAG_LASER, "your team needs an arms lab.\n"); + return; + } + menu = HeavyGunsString (); + centerprint (self, menu); + self.currentmenu = "menu_heavy"; + return; + } + if ((self.impulse == TE_WIZSPIKE)) + { + if (((self.team == SPAWNFLAG_SUPERSPIKE) && (blue_weapon == MULTICAST_ALL))) + { + self.currentmenu = "none"; + sprint (self, SPAWNFLAG_LASER, "your team needs an arms lab.\n"); + return; + } + if (((self.team == SPAWNFLAG_LASER) && (red_weapon == MULTICAST_ALL))) + { + self.currentmenu = "none"; + sprint (self, SPAWNFLAG_LASER, "your team needs an arms lab.\n"); + return; + } + menu = EnergyWeaponsString (); + centerprint (self, menu); + self.currentmenu = "menu_energy"; + return; + } + + } + else + { + if ((self.currentmenu == "menu_build")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + spawn_station (self.origin, self, MULTICAST_ALL, SECRET_1ST_DOWN); + return; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + spawn_station (self.origin, self, SPAWNFLAG_SUPERSPIKE, TE_LIGHTNING2); + return; + } + if ((self.impulse == AS_MELEE)) + { + spawn_station (self.origin, self, SPAWNFLAG_LASER, TE_LAVASPLASH); + return; + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + spawn_station (self.origin, self, 3, 15); + return; + } + } + else + { + if ((self.currentmenu == "menu_misc")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + if ((self.ammo_shells >= TE_TELEPORT)) + { + if ((self.total_handgren >= SPAWNFLAG_SUPERSPIKE)) + { + sprint (self, SPAWNFLAG_LASER, "max of one grenade.\n"); + return; + } + self.ammo_shells = (self.ammo_shells - TE_TELEPORT); + self.handgren_plasma = (self.handgren_plasma + SPAWNFLAG_SUPERSPIKE); + self.total_handgren = (self.total_handgren + SPAWNFLAG_SUPERSPIKE); + sprint (self, SPAWNFLAG_LASER, "plasma grenade purchased.\n"); + return; + } + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + if ((self.ammo_shells >= MULTICAST_PVS_R)) + { + if ((self.total_handgren >= SPAWNFLAG_SUPERSPIKE)) + { + sprint (self, SPAWNFLAG_LASER, "max of one grenade.\n"); + return; + } + self.ammo_shells = (self.ammo_shells - MULTICAST_PVS_R); + self.handgren_frag = (self.handgren_frag + SPAWNFLAG_SUPERSPIKE); + self.total_handgren = (self.total_handgren + SPAWNFLAG_SUPERSPIKE); + sprint (self, SPAWNFLAG_LASER, "frag grenade purchased.\n"); + return; + } + } + if ((self.impulse == AS_MELEE)) + { + if ((self.ammo_shells >= AS_MELEE)) + { + if ((self.total_handgren >= SPAWNFLAG_SUPERSPIKE)) + { + sprint (self, SPAWNFLAG_LASER, "max of one grenade.\n"); + return; + } + self.ammo_shells = (self.ammo_shells - AS_MELEE); + self.handgren_emp = (self.handgren_emp + SPAWNFLAG_SUPERSPIKE); + self.total_handgren = (self.total_handgren + SPAWNFLAG_SUPERSPIKE); + sprint (self, SPAWNFLAG_LASER, "emp grenade purchased.\n"); + return; + } + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + if ((self.ammo_shells >= SPAWNFLAG_LASER)) + { + if ((self.total_handgren >= SPAWNFLAG_SUPERSPIKE)) + { + sprint (self, SPAWNFLAG_LASER, "max of one grenade.\n"); + return; + } + self.ammo_shells = (self.ammo_shells - SPAWNFLAG_LASER); + self.handgren_smoke = (self.handgren_smoke + SPAWNFLAG_SUPERSPIKE); + self.total_handgren = (self.total_handgren + SPAWNFLAG_SUPERSPIKE); + centerprint (self, "Smoke Grenade purchased."); + return; + } + } + if ((self.impulse == MULTICAST_PVS_R)) + { + if ((self.ammo_shells >= SPAWNFLAG_LASER)) + { + if ((self.total_handgren >= SPAWNFLAG_LASER)) + { + sprint (self, SPAWNFLAG_LASER, "max of two flashbangs.\n"); + return; + } + self.ammo_shells = (self.ammo_shells - SPAWNFLAG_LASER); + self.handgren_flash = (self.handgren_flash + SPAWNFLAG_SUPERSPIKE); + self.total_handgren = (self.total_handgren + SPAWNFLAG_SUPERSPIKE); + centerprint (self, "Flash Bang purchased."); + return; + } + } + } + else + { + + if ((self.currentmenu == "menu_armor")) + { + + if ((((self.impulse == MULTICAST_PVS_R) || (self.impulse == TE_LIGHTNING2)) || (self.impulse == SECRET_NO_SHOOT))) + { + if (((self.team == SPAWNFLAG_SUPERSPIKE) && (blue_armor == MULTICAST_ALL))) + { + self.currentmenu = "none"; + sprint (self, SPAWNFLAG_LASER, "your team needs an armory.\n"); + return; + } + if (((self.team == SPAWNFLAG_LASER) && (red_armor == MULTICAST_ALL))) + { + self.currentmenu = "none"; + sprint (self, SPAWNFLAG_LASER, "your team needs an armory.\n"); + return; + } + } + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + BuyArmor (AS_MELEE, AS_MELEE, "vault suit"); + } + else + { + if ((self.impulse == 2)) + { + BuyArmor (TE_WIZSPIKE, MULTICAST_PVS_R, "leather armor"); + } + else + { + if ((self.impulse == 3)) + { + BuyArmor (TE_LAVASPLASH, SECRET_NO_SHOOT, "kevlar body armor"); + } + else + { + if ((self.impulse == 4)) + { + BuyArmor (TE_LIGHTNINGBLOOD, TE_TELEPORT, "combat armor"); + } + else + { + if ((self.impulse == 5)) + { + BuyArmor (17, 15, "brotherhood combat armor"); + } + + + + + } + } + } + } + } + } + } + } + } + } + else + { + if ((self.currentmenu == "menu_drop")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + if ((self.current_slot == SPAWNFLAG_SUPERSPIKE)) + { + DropWeapon (self.slot1, SPAWNFLAG_SUPERSPIKE, MULTICAST_ALL); + self.slot1 = "none"; + self.slot1_weight = MULTICAST_ALL; + } + if ((self.current_slot == SPAWNFLAG_LASER)) + { + DropWeapon (self.slot2, SPAWNFLAG_SUPERSPIKE, MULTICAST_ALL); + self.slot2 = "none"; + self.slot2_weight = MULTICAST_ALL; + } + centerprint (self, "WEAPON REMOVED!"); + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + self.armor = "none"; + self.armor_weight = MULTICAST_ALL; + centerprint (self, "ARMOR REMOVED!"); + } + if ((self.impulse == AS_MELEE)) + { + centerprint (self, "HELMET REMOVED!"); + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + self.protect = MULTICAST_ALL; + centerprint (self, "protect REMOVED!"); + } + if ((self.impulse == 5)) + { + self.equipment = "none"; + self.runevar = MULTICAST_ALL; + centerprint (self, "GADGET REMOVED!"); + } + if ((self.impulse == TE_LIGHTNING2)) + { + self.perk = MULTICAST_ALL; + centerprint (self, "AUGMENT REMOVED!"); + } + } + else + { + if ((self.currentmenu == "menu_armor2")) + { + lbs = weightx (); + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + BuyArmor (SECRET_NO_SHOOT, 50, TE_LAVASPLASH); + } + else + { + if ((self.impulse == SPAWNFLAG_LASER)) + { + BuyArmor (TE_LIGHTNING3, 60, TE_TELEPORT); + } + else + { + if ((self.impulse == AS_MELEE)) + { + BuyArmor (TE_LIGHTNING3, 60, TE_BLOOD); + } + else + { + if ((self.impulse == SECRET_1ST_DOWN)) + { + BuyArmor (TE_LIGHTNING3, 70, TE_LIGHTNINGBLOOD); + } + else + { + if ((self.impulse == MULTICAST_PVS_R)) + { + BuyArmor (TE_WIZSPIKE, 70, IDLE2A); + } + else + { + if ((self.impulse == TE_LIGHTNING2)) + { + BuyArmor (TE_TELEPORT, 80, IDLE3A); + } + else + { + if ((self.impulse == TE_WIZSPIKE)) + { + BuyArmor (TE_BLOOD, 80, SECRET_YES_SHOOT); + } + else + { + if ((self.impulse == SECRET_NO_SHOOT)) + { + BuyArmor (IDLE2A, 90, IDLE5A); + } + else + { + if ((self.impulse == TE_LIGHTNING3)) + { + BuyArmor (SECRET_YES_SHOOT, 95, IDLE6A); + } + else + { + if ((self.impulse == TE_LAVASPLASH)) + { + if (((self.frags / self.dead) < 3.5)) + { + menu = ArmorString1 (); + centerprint (self, menu); + self.currentmenu = "menu_armor"; + return; + } + if (((self.frags / self.dead) >= 3.5)) + { + menu = ArmorString3 (); + centerprint (self, menu); + self.currentmenu = "menu_armor3"; + return; + } + } + } + } + } + } + } + } + } + } + } + } + else + { + if ((self.currentmenu == "menu_armor3")) + { + + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + BuyArmor (TE_WIZSPIKE, 95, IDLE7A); + } + else + { + if ((self.impulse == SPAWNFLAG_LASER)) + { + BuyArmor (SECRET_NO_SHOOT, 95, IDLE8A); + } + else + { + if ((self.impulse == AS_MELEE)) + { + BuyArmor (IDLE2A, 95, IDLE9A); + } + else + { + if ((self.impulse == TE_LAVASPLASH)) + { + menu = ArmorString1 (); + centerprint (self, menu); + self.currentmenu = "menu_armor"; + return; + } + } + } + } + } + else + { + if ((self.currentmenu == "menu_plus")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + BuyPerk (SECRET_NO_SHOOT, SPAWNFLAG_SUPERSPIKE); + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + BuyPerk (TE_BLOOD, SPAWNFLAG_LASER); + } + if ((self.impulse == AS_MELEE)) + { + BuyPerk (IDLE2A, AS_MELEE); + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + BuyPerk (IDLE3A, SECRET_1ST_DOWN); + } + if ((self.impulse == MULTICAST_PVS_R)) + { + BuyPerk (IDLE5A, MULTICAST_PVS_R); + } + if ((self.impulse == TE_LIGHTNING2)) + { + BuyPerk (SVC_TEMPENTITY, TE_LIGHTNING2); + } + if ((self.impulse == TE_WIZSPIKE)) + { + BuyPerk (DRAW4, TE_WIZSPIKE); + } + if ((self.impulse == SECRET_NO_SHOOT)) + { + BuyPerk (DOOR_TOGGLE, SECRET_NO_SHOOT); + } + if ((self.impulse == TE_LIGHTNING3)) + { + BuyPerk (RN_SHUB, TE_LIGHTNING3); + } + if ((self.impulse == TE_LAVASPLASH)) + { + BuyPerk (44, TE_LAVASPLASH); + } + } + else + { + if ((self.currentmenu == "menu_protect")) + { + if ((self.armor == "brotherhood combat armor")) + { + sprint (self, PRINT_HIGH, "too many electronics in\nyour currently worn armor!"); + self.currentmenu = "none"; + return; + } + if (((self.impulse == SPAWNFLAG_SUPERSPIKE) && (self.ammo_shells >= IDLE3A))) + { + self.protect = SPAWNFLAG_SUPERSPIKE; + self.ammo_shells = (self.ammo_shells - IDLE3A); + sprint (self, PRINT_HIGH, "pro cloak\n"); + self.currentmenu = "none"; + return; + } + if (((self.impulse == SPAWNFLAG_LASER) && (self.ammo_shells >= DRAW3))) + { + self.protect = SPAWNFLAG_LASER; + self.ammo_shells = (self.ammo_shells - DRAW3); + sprint (self, PRINT_HIGH, "emp shield\n"); + self.currentmenu = "none"; + return; + } + if ((self.armor == "brotherhood combat armor")) + { + sprint (self, PRINT_HIGH, "too many electronics in\nyour currently worn armor!"); + return; + } + if (((self.impulse == AS_MELEE) && (self.ammo_shells >= IDLE8A))) + { + self.protect = AS_MELEE; + self.ammo_shells = (self.ammo_shells - IDLE8A); + sprint (self, PRINT_HIGH, "force shield\n"); + self.currentmenu = "none"; + return; + } + if (((self.impulse == SECRET_1ST_DOWN) && (self.ammo_shells >= DRAW3))) + { + self.protect = SECRET_1ST_DOWN; + self.ammo_shells = (self.ammo_shells - DRAW3); + sprint (self, PRINT_HIGH, "force field\n"); + self.currentmenu = "none"; + return; + } + if (((self.impulse == MULTICAST_PVS_R) && (self.ammo_shells >= DRAW3))) + { + self.protect = MULTICAST_PVS_R; + self.ammo_shells = (self.ammo_shells - DRAW3); + sprint (self, PRINT_HIGH, "energy shield\nonly protects against energy\n"); + self.currentmenu = "none"; + return; + } + if (((self.impulse == TE_LIGHTNING2) && (self.ammo_shells >= 65))) + { + self.protect = TE_LIGHTNING2; + self.ammo_shells = (self.ammo_shells - 65); + sprint (self, PRINT_HIGH, "pro ring\n"); + self.currentmenu = "none"; + return; + } + if (((self.impulse == TE_WIZSPIKE) && (self.ammo_shells >= 75))) + { + self.protect = TE_WIZSPIKE; + self.ammo_shells = (self.ammo_shells - 75); + sprint (self, PRINT_HIGH, "dark force\n"); + self.currentmenu = "none"; + return; + } + if (((self.impulse == SECRET_NO_SHOOT) && (self.ammo_shells >= 85))) + { + self.protect = SECRET_NO_SHOOT; + self.ammo_shells = (self.ammo_shells - 85); + sprint (self, PRINT_HIGH, "efreet-9088 module\nprotects against fire\n"); + self.currentmenu = "none"; + return; + } + if (((self.impulse == TE_LIGHTNING3) && (self.ammo_shells >= 95))) + { + self.protect = TE_LIGHTNING3; + self.ammo_shells = (self.ammo_shells - 95); + sprint (self, PRINT_HIGH, "sentient cube\n"); + self.currentmenu = "none"; + return; + } + if (((self.impulse == TE_LAVASPLASH) && (self.ammo_shells >= 95))) + { + self.currentmenu = "none"; + self.protect = TE_LAVASPLASH; + self.ammo_shells = (self.ammo_shells - 95); + sprint (self, PRINT_HIGH, "xe+ vampire\n"); + self.currentmenu = "none"; + return; + } + } + else + { + if ((self.currentmenu == "menu_melee")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + BuyWeapon (SPAWNFLAG_SUPERSPIKE, SPAWNFLAG_SUPERSPIKE, SPAWNFLAG_SUPERSPIKE); + } + else + { + if ((self.impulse == SPAWNFLAG_LASER)) + { + BuyWeapon (SPAWNFLAG_LASER, AS_MELEE, SPAWNFLAG_LASER); + } + else + { + if ((self.impulse == AS_MELEE)) + { + BuyWeapon (SPAWNFLAG_LASER, TE_WIZSPIKE, AS_MELEE); + } + } + } + } + else + { + if ((self.currentmenu == "menu_trait")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + self.trait = SPAWNFLAG_SUPERSPIKE; + sprint (self, PRINT_HIGH, "trait acquired\n"); + } + else + { + if ((self.impulse == SPAWNFLAG_LASER)) + { + self.trait = SPAWNFLAG_LASER; + sprint (self, PRINT_HIGH, "trait acquired\n"); + } + else + { + if ((self.impulse == AS_MELEE)) + { + self.trait = AS_MELEE; + sprint (self, PRINT_HIGH, "trait acquired\n"); + } + else + { + if ((self.impulse == SECRET_1ST_DOWN)) + { + self.trait = SECRET_1ST_DOWN; + sprint (self, PRINT_HIGH, "trait acquired\n"); + } + else + { + if ((self.impulse == MULTICAST_PVS_R)) + { + self.trait = MULTICAST_PVS_R; + sprint (self, PRINT_HIGH, "trait acquired\n"); + } + else + { + if ((self.impulse == TE_LIGHTNING2)) + { + self.trait = TE_LIGHTNING2; + sprint (self, PRINT_HIGH, "trait acquired\n"); + } + } + } + } + } + } + } + else + { + if ((self.currentmenu == "menu_smallarm1")) + { + if (self.impulse == 1) + BuyWeapon (1, 5, TE_LAVASPLASH); + if (self.impulse == 2) + BuyWeapon (2, 7, TE_TELEPORT); + if (self.impulse == 3) + BuyWeapon (2, 9, TE_WIZSPIKE); + if (self.impulse == 4) + BuyWeapon (3, 14, TE_BLOOD); + if (self.impulse == 5) + BuyWeapon (3, 17, TE_LIGHTNINGBLOOD); + if (self.impulse == 6) + BuyWeapon (2, 21, 42); + } + else + { + if ((self.currentmenu == "menu_smallarm2")) + { + if (self.impulse == 1) + BuyWeapon (2, 3, IDLE8A); + if (self.impulse == 2) + BuyWeapon (3, 3, DRAW3); + if (self.impulse == 3) + BuyWeapon (4, IDLE2A, DRAW4); + if (self.impulse == 4) + BuyWeapon (5, 35, RN_HOLO); + } + else + { + if ((self.currentmenu == "menu_drug1")) + { + if ((self.regen > MULTICAST_ALL)) + { + return; + } + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + if ((self.ammo_shells < AS_MELEE)) + { + centerprint (self, "not enough money."); + self.currentmenu = "none"; + return; + } + self.drug = SPAWNFLAG_SUPERSPIKE; + if ((self.class == SPAWNFLAG_LASER)) + { + self.supplies = MULTICAST_PVS_R; + } + else + { + self.supplies = SPAWNFLAG_LASER; + } + self.ammo_shells = (self.ammo_shells - AS_MELEE); + centerprint (self, "stimpacks purchased."); + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + if ((self.ammo_shells < MULTICAST_PVS_R)) + { + centerprint (self, "not enough money."); + self.currentmenu = "none"; + return; + } + if ((self.class != SPAWNFLAG_LASER)) + { + centerprint (self, "not a medic."); + self.currentmenu = "none"; + return; + } + self.drug = SPAWNFLAG_LASER; + if ((self.class == SPAWNFLAG_LASER)) + { + self.supplies = MULTICAST_PVS_R; + } + else + { + self.supplies = SPAWNFLAG_LASER; + } + self.ammo_shells = (self.ammo_shells - MULTICAST_PVS_R); + centerprint (self, "medkit purchased."); + } + if ((self.impulse == AS_MELEE)) + { + if ((self.ammo_shells < TE_BLOOD)) + { + centerprint (self, "not enough money."); + self.currentmenu = "none"; + return; + } + if ((self.class != SPAWNFLAG_LASER)) + { + centerprint (self, "not a medic."); + self.currentmenu = "none"; + return; + } + if ((self.frags < TE_LAVASPLASH)) + { + centerprint (self, "not yet ready."); + self.currentmenu = "none"; + return; + } + self.drug = AS_MELEE; + if ((self.class == SPAWNFLAG_LASER)) + { + self.supplies = MULTICAST_PVS_R; + } + else + { + self.supplies = SPAWNFLAG_LASER; + } + self.ammo_shells = (self.ammo_shells - TE_BLOOD); + centerprint (self, "superstims purchased."); + } + } + else + { + if ((self.currentmenu == "menu_drug2")) + { + if ((self.regen > MULTICAST_ALL)) + { + return; + } + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + if ((self.ammo_shells < AS_MELEE)) + { + centerprint (self, "not enough money."); + self.currentmenu = "none"; + return; + } + self.drug = SPAWNFLAG_SUPERSPIKE; + if ((self.class == SPAWNFLAG_LASER)) + { + self.supplies = MULTICAST_PVS_R; + } + else + { + self.supplies = SPAWNFLAG_LASER; + } + self.ammo_shells = (self.ammo_shells - AS_MELEE); + centerprint (self, "stimpacks purchased."); + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + if ((self.ammo_shells < TE_WIZSPIKE)) + { + centerprint (self, "not enough money."); + self.currentmenu = "none"; + return; + } + self.drug = SECRET_1ST_DOWN; + if ((self.class == SPAWNFLAG_LASER)) + { + self.supplies = MULTICAST_PVS_R; + } + else + { + self.supplies = SPAWNFLAG_LASER; + } + self.ammo_shells = (self.ammo_shells - TE_WIZSPIKE); + centerprint (self, "adrenaline purchased."); + } + if ((self.impulse == AS_MELEE)) + { + if ((self.ammo_shells < IDLE3A)) + { + centerprint (self, "not enough money."); + self.currentmenu = "none"; + return; + } + if ((self.class != SPAWNFLAG_LASER)) + { + centerprint (self, "not a medic."); + self.currentmenu = "none"; + return; + } + self.drug = MULTICAST_PVS_R; + if ((self.class == SPAWNFLAG_LASER)) + { + self.supplies = MULTICAST_PVS_R; + } + else + { + self.supplies = SPAWNFLAG_LASER; + } + self.ammo_shells = (self.ammo_shells - IDLE3A); + centerprint (self, "psycho purchased."); + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + if ((self.ammo_shells < TE_BLOOD)) + { + centerprint (self, "not enough money."); + self.currentmenu = "none"; + return; + } + if ((self.class != SPAWNFLAG_LASER)) + { + centerprint (self, "not a medic."); + self.currentmenu = "none"; + return; + } + if ((self.frags < TE_LAVASPLASH)) + { + centerprint (self, "not yet ready."); + self.currentmenu = "none"; + return; + } + self.drug = SPAWNFLAG_LASER; + if ((self.class == SPAWNFLAG_LASER)) + { + self.supplies = MULTICAST_PVS_R; + } + else + { + self.supplies = SPAWNFLAG_LASER; + } + self.ammo_shells = (self.ammo_shells - TE_BLOOD); + centerprint (self, "medkit purchased."); + } + if ((self.impulse == MULTICAST_PVS_R)) + { + if ((self.ammo_shells < IDLE9A)) + { + centerprint (self, "not enough money."); + self.currentmenu = "none"; + return; + } + if ((self.class != SPAWNFLAG_LASER)) + { + centerprint (self, "not a medic."); + self.currentmenu = "none"; + return; + } + if ((self.frags < TE_LAVASPLASH)) + { + centerprint (self, "not yet ready."); + self.currentmenu = "none"; + return; + } + self.drug = TE_LIGHTNING2; + if ((self.class == SPAWNFLAG_LASER)) + { + self.supplies = MULTICAST_PVS_R; + } + else + { + self.supplies = SPAWNFLAG_LASER; + } + self.ammo_shells = (self.ammo_shells - IDLE9A); + centerprint (self, "berserk purchased."); + } + } + else + { + if (self.currentmenu == "menu_smallarm3") + { + if (self.impulse == 1) + BuyWeapon (3, 11, EF_FLAG1); + if (self.impulse == 2) + BuyWeapon (4, 21, IDLE9A); + if (self.impulse == 3) + BuyWeapon (6, 24, IDLE5A); + if (self.impulse == 4) + BuyWeapon (5, 27, IDLE7A); + if (self.impulse == 5) + BuyWeapon (6, 36, IDLE10A); + if (self.impulse == 6) + BuyWeapon (5, 23, SVC_SELLSCREEN); + if (self.impulse == 7) + BuyWeapon (7, 41, RN_ATTRACT); + if (self.impulse == 8) + BuyWeapon (8, 51, SVC_FINALE); + + } + else + { + if ((self.currentmenu == "menu_energy")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + BuyWeapon (AS_MELEE, IDLE9A, RN_FIELD); + } + else + { + if ((self.impulse == SPAWNFLAG_LASER)) + { + BuyWeapon (TE_WIZSPIKE, SVC_SMALLKICK, 43); + } + else + { + if ((self.impulse == AS_MELEE)) + { + BuyWeapon (TE_TELEPORT, RN_SHAMB, RN_CLOUD); + } + else + { + if ((self.impulse == SECRET_1ST_DOWN)) + { + BuyWeapon (TE_LIGHTNING2, 57, RN_ATTRACT); + } + else + { + if ((self.impulse == MULTICAST_PVS_R)) + { + BuyWeapon (SPAWNFLAG_LASER, 72, 42); + } + else + { + if ((self.impulse == TE_LIGHTNING2)) + { + BuyWeapon (TE_LIGHTNING2, 89, SVC_BIGKICK); + } + else + { + if ((self.impulse == TE_WIZSPIKE)) + { + BuyWeapon (TE_WIZSPIKE, 96, DOOR_TOGGLE); + } + } + } + } + } + } + } + } + else + { + if ((self.currentmenu == "menu_heavy")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + BuyWeapon (SECRET_YES_SHOOT, 55, 47); + } + else + { + if ((self.impulse == SPAWNFLAG_LASER)) + { + BuyWeapon (TE_TELEPORT, 75, 50); + } + else + { + if ((self.impulse == AS_MELEE)) + { + BuyWeapon (SECRET_YES_SHOOT, SVC_BIGKICK, RN_SHAMB); + } + else + { + if ((self.impulse == SECRET_1ST_DOWN)) + { + BuyWeapon (IDLE5A, 72, 49); + } + else + { + if ((self.impulse == MULTICAST_PVS_R)) + { + BuyWeapon (TE_BLOOD, 81, SVC_FINALE); + } + else + { + if ((self.impulse == TE_LIGHTNING2)) + { + BuyWeapon (IDLE2A, 81, 55); + } + else + { + if ((self.impulse == TE_WIZSPIKE)) + { + BuyWeapon (TE_LIGHTNINGBLOOD, 56, 54); + } + } + } + } + } + } + } + } + else + { + if ((self.currentmenu == "menu_gadget")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + BuyGadget (IDLE8A, SPAWNFLAG_SUPERSPIKE); + } + else + { + if ((self.impulse == SPAWNFLAG_LASER)) + { + BuyGadget (IDLE8A, SPAWNFLAG_LASER); + } + else + { + if ((self.impulse == AS_MELEE)) + { + BuyGadget (IDLE8A, AS_MELEE); + } + else + { + if ((self.impulse == SECRET_1ST_DOWN)) + { + BuyGadget (IDLE8A, SECRET_1ST_DOWN); + } + else + { + if ((self.impulse == MULTICAST_PVS_R)) + { + BuyGadget (IDLE8A, MULTICAST_PVS_R); + //WeaponAmmo (SPAWNFLAG_SUPERSPIKE); + //WeaponAmmo (SPAWNFLAG_LASER); + } + else + { + if ((self.impulse == TE_LIGHTNING2)) + { + BuyGadget (IDLE8A, TE_LIGHTNING2); + } + else + { + if ((self.impulse == TE_WIZSPIKE)) + { + BuyGadget (IDLE8A, TE_WIZSPIKE); + } + else + { + if ((self.impulse == SECRET_NO_SHOOT)) + { + BuyGadget (IDLE8A, SECRET_NO_SHOOT); + } + else + { + if ((self.impulse == TE_LIGHTNING3)) + { + BuyGadget (IDLE8A, TE_LIGHTNING3); + } + else + { + if ((self.impulse == TE_LAVASPLASH)) + { + BuyGadget (IDLE8A, TE_LAVASPLASH); + } + } + } + } + } + } + } + } + } + } + } + else + { + if ((self.currentmenu == "13")) + { + return; + } + else + { + if ((self.currentmenu == "menu_svote")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + stuffcmd (self, "votehs\n"); + self.currentmenu = "none"; + return; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + stuffcmd (self, "voters\n"); + self.currentmenu = "none"; + return; + } + if ((self.impulse == AS_MELEE)) + { + stuffcmd (self, "votemap\n"); + self.currentmenu = "none"; + return; + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + stuffcmd (self, "voteff\n"); + self.currentmenu = "none"; + return; + } + if ((self.impulse == MULTICAST_PVS_R)) + { + stuffcmd (self, "zombie\n"); + self.currentmenu = "none"; + return; + } + } + else + { + if ((self.currentmenu == "menu_menu")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + Garage (); + self.currentmenu = "none"; + return; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + self.currentmenu = "menu_drop"; + return; + } + if ((self.impulse == AS_MELEE)) + { + Score (); + return; + } + if ((self.impulse == SECRET_1ST_DOWN)) + { + self.currentmenu = "menu_svote"; + return; + } + if ((self.impulse == MULTICAST_PVS_R)) + { + self.currentmenu = "menu_website"; + return; + } + if ((self.impulse == TE_LIGHTNING2)) + { + self.currentmenu = "menu_contact"; + return; + } + if ((self.impulse == TE_WIZSPIKE)) + { + stuffcmd (self, "clear\n"); + stuffcmd (self, "cmd topten\n"); + stuffcmd (self, "toggleconsole\n"); + self.currentmenu = "none"; + return; + } + if ((self.impulse == SECRET_NO_SHOOT)) + { + stuffcmd (self, "clear\n"); + stuffcmd (self, "server\n"); + stuffcmd (self, "toggleconsole\n"); + self.currentmenu = "none"; + return; + } + if ((self.impulse == TE_LIGHTNING3)) + { + centerprint (self, "stats and equipment reset"); + BasicConfig (); + self.currentmenu = "none"; + return; + } + } + else + { + if ((self.currentmenu == "menu_special")) + { + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + Hack (); + self.currentmenu = "none"; + return; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + Shield (); + self.currentmenu = "none"; + return; + } + if ((self.impulse == AS_MELEE)) + { + LocalScan (); + self.currentmenu = "none"; + return; + } + } + else + { + if ((self.currentmenu == "775")) + { + return; + } + else + { + if ((self.currentmenu == "774")) + { + return; + } + else + { + if ((self.currentmenu == "motd")) + { + MOTD (); + } + else + { + if ((self.currentmenu == "select_team")) + { + sound (self, CHAN_WEAPON, "buttons/switch02.wav", TRUE, ATTN_NORM); + if ((self.impulse == SPAWNFLAG_SUPERSPIKE)) + { + self.ghost = MULTICAST_ALL; + stuffcmd (self, "team Good\n"); + self.team = SPAWNFLAG_SUPERSPIKE; + centerprint (self, "You now work for Vault 18."); + bprint (PRINT_HIGH, self.netname); + bprint (PRINT_HIGH, " has joined Vault 18\n"); + if ((self.class == MULTICAST_ALL)) + { + self.currentmenu = "select_class"; + } + if ((self.class != MULTICAST_ALL)) + { + self.currentmenu = "none"; + self.override = SPAWNFLAG_SUPERSPIKE; + stuffcmd (self, "kill\n"); + self.motd_count = MULTICAST_ALL; + if ((self.max_health == SPAWNFLAG_SUPERSPIKE)) + { + self.max_health = 90; + } + self.ghost = MULTICAST_ALL; + return; + } + self.motd_count = MULTICAST_ALL; + return; + } + if ((self.impulse == SPAWNFLAG_LASER)) + { + self.ghost = MULTICAST_ALL; + stuffcmd (self, "team Evil\n"); + self.team = SPAWNFLAG_LASER; + centerprint (self, "You now work for the Enclave."); + bprint (PRINT_HIGH, self.netname); + bprint (PRINT_HIGH, " has joined the Enclave\n"); + if ((self.class == MULTICAST_ALL)) + { + self.currentmenu = "select_class"; + } + if ((self.class != MULTICAST_ALL)) + { + self.currentmenu = "none"; + self.override = SPAWNFLAG_SUPERSPIKE; + stuffcmd (self, "kill\n"); + self.motd_count = MULTICAST_ALL; + if ((self.max_health == SPAWNFLAG_SUPERSPIKE)) + { + self.max_health = 90; + } + self.ghost = MULTICAST_ALL; + return; + } + self.motd_count = MULTICAST_ALL; + return; + } + if ((self.impulse == AS_MELEE)) + { + other = find (world, classname, "player"); + while ((other != world)) + { + if ((other.team == SPAWNFLAG_SUPERSPIKE)) + { + b1 = (b1 + other.frags); + } + if ((other.team == SPAWNFLAG_LASER)) + { + r1 = (r1 + other.frags); + } + other = find (other, classname, "player"); + } + if ((r1 > b1)) + { + self.impulse = SPAWNFLAG_SUPERSPIKE; + W_PlayerMenu (); + return; + } + if ((b1 > r1)) + { + self.impulse = SPAWNFLAG_LASER; + W_PlayerMenu (); + return; + } + if ((r1 == b1)) + { + if (((random () * SECRET_NO_SHOOT) <= SECRET_1ST_DOWN)) + { + self.impulse = SPAWNFLAG_SUPERSPIKE; + } + else + { + self.impulse = SPAWNFLAG_LASER; + } + W_PlayerMenu (); + return; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + if ((self.impulse > AS_MELEE)) + { + return; + } + self.currentmenu = "none"; + return; +};*/ diff --git a/quakec/fallout2/monsters.qc b/quakec/fallout2/monsters.qc new file mode 100644 index 000000000..c137d178a --- /dev/null +++ b/quakec/fallout2/monsters.qc @@ -0,0 +1,236 @@ +/* ALL MONSTERS SHOULD BE 1 0 0 IN COLOR */ + +// name =[framenum, nexttime, nextthink] {code} +// expands to: +// name () +// { +// self.frame=framenum; +// self.nextthink = time + nexttime; +// self.think = nextthink +// +// }; + + +/* +================ +monster_use + +Using a monster makes it angry at the current activator +================ +*/ +void() monster_use = +{ + if (self.enemy) + return; + if (self.health <= 0) + return; + if (activator.items & IT_INVISIBILITY) + return; + if (activator.flags & FL_NOTARGET) + return; + if (activator.classname != "player") + return; + +// delay reaction so if the monster is teleported, its sound is still +// heard + self.enemy = activator; + self.nextthink = time + 0.1; + self.think = FoundTarget; +}; + +/* +================ +monster_death_use + +When a mosnter dies, it fires all of its targets with the current +enemy as activator. +================ +*/ +void() monster_death_use = +{ + local entity ent, otemp, stemp; + +// fall to ground + if (self.flags & FL_FLY) + self.flags = self.flags - FL_FLY; + if (self.flags & FL_SWIM) + self.flags = self.flags - FL_SWIM; + + if (!self.target) + return; + + activator = self.enemy; + SUB_UseTargets (); +}; + + +//============================================================================ + +void() walkmonster_start_go = +{ +local string stemp; +local entity etemp; + + self.origin_z = self.origin_z + 1; // raise off floor a bit + droptofloor(); + + if (!walkmove(0,0)) + { + dprint ("walkmonster in wall at: "); + dprint (vtos(self.origin)); + dprint ("\n"); + } + + self.takedamage = DAMAGE_AIM; + + self.ideal_yaw = self.angles * '0 1 0'; + if (!self.yaw_speed) + self.yaw_speed = 20; + self.view_ofs = '0 0 25'; + self.use = monster_use; + + 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) + { + dprint ("Monster can't find target at "); + dprint (vtos(self.origin)); + dprint ("\n"); + } +// this used to be an objerror + if (self.movetarget.classname == "path_corner") + self.th_walk (); + else + self.pausetime = 99999999; + self.th_stand (); + } + 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; +}; + + +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; + self.think = walkmonster_start_go; + total_monsters = total_monsters + 1; +}; + + + +void() flymonster_start_go = +{ + self.takedamage = DAMAGE_AIM; + + self.ideal_yaw = self.angles * '0 1 0'; + if (!self.yaw_speed) + self.yaw_speed = 10; + self.view_ofs = '0 0 25'; + self.use = monster_use; + + self.flags = self.flags | FL_FLY; + self.flags = self.flags | FL_MONSTER; + + 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) + { + dprint ("Monster can't find target at "); + dprint (vtos(self.origin)); + dprint ("\n"); + } +// this used to be an objerror + if (self.movetarget.classname == "path_corner") + self.th_walk (); + else + self.pausetime = 99999999; + self.th_stand (); + } + else + { + self.pausetime = 99999999; + self.th_stand (); + } +}; + +void() flymonster_start = +{ +// spread think times so they don't all happen at same time + self.nextthink = self.nextthink + random()*0.5; + self.think = flymonster_start_go; + total_monsters = total_monsters + 1; +}; + + +void() swimmonster_start_go = +{ + if (deathmatch) + { + remove(self); + return; + } + + self.takedamage = DAMAGE_AIM; + total_monsters = total_monsters + 1; + + self.ideal_yaw = self.angles * '0 1 0'; + if (!self.yaw_speed) + self.yaw_speed = 10; + self.view_ofs = '0 0 10'; + self.use = monster_use; + + 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) + { + 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); + self.th_walk (); + } + 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; +}; + +void() swimmonster_start = +{ +// 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/quakec/fallout2/ogre.qc b/quakec/fallout2/ogre.qc new file mode 100644 index 000000000..b4230de50 --- /dev/null +++ b/quakec/fallout2/ogre.qc @@ -0,0 +1,897 @@ + +void () OgreGrenadeExplode = +{ + T_RadiusDamage (self, self.owner, (IDLE2A + (random () * TE_BLOOD)), world, ""); + sound (self, CHAN_VOICE, "weapons/r_exp3.wav", PLAT_LOW_TRIGGER, 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); + self.velocity = VEC_ORIGIN; + self.touch = SUB_Null; + self.solid = SOLID_NOT; + remove (self); +}; + +void (float side) chainsaw = +{ + local vector delta; + local float ldmg; + + if (!self.enemy) + { + return; + } + if (!CanDamage (self.enemy, self)) + { + return; + } + ai_charge (TE_LAVASPLASH); + delta = (self.enemy.origin - self.origin); + if ((vlen (delta) > 100)) + { + return; + } + ldmg = (TE_LIGHTNING3 + (random () * IDLE6A)); + T_Damage (self.enemy, self, self, ldmg); + if (side) + { + makevectors (self.angles); + if ((side == PLAT_LOW_TRIGGER)) + { + SpawnMeatSpray ((self.origin + (v_forward * SECRET_YES_SHOOT)), ((crandom () * 100) * v_right)); + } + else + { + SpawnMeatSpray ((self.origin + (v_forward * SECRET_YES_SHOOT)), (side * v_right)); + } + } +}; + +void () ogre_stand1 = [ 0, ogre_stand2 ] +{ + ai_stand (); +}; + +void () ogre_stand2 = [ 1, ogre_stand3 ] +{ + ai_stand (); +}; + +void () ogre_stand3 = [ 2, ogre_stand4 ] +{ + ai_stand (); +}; + +void () ogre_stand4 = [ 3, ogre_stand5 ] +{ + ai_stand (); +}; + +void () ogre_stand5 = [ 4, ogre_stand6 ] +{ + if ((random () < 0.2)) + { + sound (self, CHAN_VOICE, "ogre/ogidle.wav", PLAT_LOW_TRIGGER, ATTN_IDLE); + } + ai_stand (); +}; + +void () ogre_stand6 = [ 5, ogre_stand7 ] +{ + ai_stand (); +}; + +void () ogre_stand7 = [ 6, ogre_stand8 ] +{ + ai_stand (); +}; + +void () ogre_stand8 = [ 7, ogre_stand9 ] +{ + ai_stand (); +}; + +void () ogre_stand9 = [ 8, ogre_stand1 ] +{ + ai_stand (); +}; + +void () ogre_walk1 = [ 9, ogre_walk2 ] +{ + ai_walk (AS_MELEE); +}; + +void () ogre_walk2 = [ 10, ogre_walk3 ] +{ + ai_walk (SILENT); +}; + +void () ogre_walk3 = [ 11, ogre_walk4 ] +{ + ai_walk (SILENT); + if ((random () < 0.2)) + { + sound (self, CHAN_VOICE, "ogre/ogidle.wav", PLAT_LOW_TRIGGER, ATTN_IDLE); + } +}; + +void () ogre_walk4 = [ 12, ogre_walk5 ] +{ + ai_walk (SILENT); +}; + +void () ogre_walk5 = [ 13, ogre_walk6 ] +{ + ai_walk (SILENT); +}; + +void () ogre_walk6 = [ 14, ogre_walk7 ] +{ + ai_walk (MULTICAST_PVS_R); + if ((random () < 0.1)) + { + sound (self, CHAN_VOICE, "ogre/ogdrag.wav", PLAT_LOW_TRIGGER, ATTN_IDLE); + } +}; + +void () ogre_walk7 = [ 15, ogre_walk8 ] +{ + ai_walk (AS_MELEE); +}; + +void () ogre_walk8 = [ 16, ogre_walk9 ] +{ + ai_walk (SILENT); +}; + +void () ogre_walk9 = [ 17, ogre_walk10 ] +{ + ai_walk (AS_MELEE); +}; + +void () ogre_walk10 = [ 18, ogre_walk11 ] +{ + ai_walk (PLAT_LOW_TRIGGER); +}; + +void () ogre_walk11 = [ 19, ogre_walk12 ] +{ + ai_walk (SILENT); +}; + +void () ogre_walk12 = [ 20, ogre_walk13 ] +{ + ai_walk (AS_MELEE); +}; + +void () ogre_walk13 = [ 21, ogre_walk14 ] +{ + ai_walk (AS_MELEE); +}; + +void () ogre_walk14 = [ 22, ogre_walk15 ] +{ + ai_walk (AS_MELEE); +}; + +void () ogre_walk15 = [ 23, ogre_walk16 ] +{ + ai_walk (AS_MELEE); +}; + +void () ogre_walk16 = [ 24, ogre_walk1 ] +{ + ai_walk (SECRET_1ST_DOWN); +}; + +void () ogre_run1 = [ 25, ogre_run2 ] +{ + ai_run (TE_LIGHTNING3+2); + if ((random () < 0.2)) + { + sound (self, CHAN_VOICE, "ogre/ogidle2.wav", PLAT_LOW_TRIGGER, ATTN_IDLE); + } +}; + +void () ogre_run2 = [ 26, ogre_run3 ] +{ + ai_run (TE_BLOOD+2); +}; + +void () ogre_run3 = [ 27, ogre_run4 ] +{ + ai_run (SECRET_NO_SHOOT+2); +}; + +void () ogre_run4 = [ 28, ogre_run5 ] +{ + ai_run (IDLE10A); +}; + +void () ogre_run5 = [ 29, ogre_run6 ] +{ + ai_run (SECRET_YES_SHOOT+2); +}; + +void () ogre_run6 = [ 30, ogre_run7 ] +{ + ai_run (SECRET_1ST_DOWN+2); +}; + +void () ogre_run7 = [ 31, ogre_run8 ] +{ + ai_run (TE_LIGHTNINGBLOOD+2); +}; + +void () ogre_run8 = [ 32, ogre_run1 ] +{ + ai_run (DRAW2+2); +}; + +void () ogre_swing1 = [ 33, ogre_swing2 ] +{ + ai_charge (TE_TELEPORT); + sound (self, CHAN_WEAPON, "ogre/ogsawatk.wav", PLAT_LOW_TRIGGER, ATTN_NORM); +}; + +void () ogre_swing2 = [ 34, ogre_swing3 ] +{ + ai_charge (PLAT_LOW_TRIGGER); +}; + +void () ogre_swing3 = [ 35, ogre_swing4 ] +{ + ai_charge (SECRET_1ST_DOWN); +}; + +void () ogre_swing4 = [ 36, ogre_swing5 ] +{ + ai_charge (TE_LIGHTNINGBLOOD); +}; + +void () ogre_swing5 = [ 37, ogre_swing6 ] +{ + ai_charge (TE_LIGHTNING3); + chainsaw (MULTICAST_ALL); + self.angles_y = (self.angles_y + (random () * DRAW3)); +}; + +void () ogre_swing6 = [ 38, ogre_swing7 ] +{ +}; + +void () ogre_swing7 = [ 39, ogre_swing8 ] +{ +}; + +void () ogre_swing8 = [ 40, ogre_swing9 ] +{ + chainsaw (MULTICAST_ALL); + self.angles_y = (self.angles_y + (random () * DRAW3)); +}; + +void () ogre_swing9 = [ 41, ogre_swing10 ] +{ +}; + +void () ogre_swing10 = [ 42, ogre_swing11 ] +{ +}; + +void () ogre_swing11 = [ 43, ogre_swing12 ] +{ +}; + +void () ogre_swing12 = [ 44, ogre_swing13 ] +{ + ai_charge (AS_MELEE); +}; + +void () ogre_swing13 = [ 45, ogre_swing14 ] +{ + ai_charge (SECRET_NO_SHOOT); +}; + +void () ogre_swing14 = [ 46, ogre_run1 ] +{ + ai_charge (TE_LIGHTNING3); +}; + +void () ogre_smash1 = [ 47, ogre_smash2 ] +{ + ai_charge (TE_LIGHTNING2); + sound (self, CHAN_WEAPON, "ogre/ogsawatk.wav", PLAT_LOW_TRIGGER, ATTN_NORM); +}; + +void () ogre_smash2 = [ 48, ogre_smash3 ] +{ + ai_charge (MULTICAST_ALL); +}; + +void () ogre_smash3 = [ 49, ogre_smash4 ] +{ + ai_charge (MULTICAST_ALL); +}; + +void () ogre_smash4 = [ 50, ogre_smash5 ] +{ + ai_charge (PLAT_LOW_TRIGGER); +}; + +void () ogre_smash5 = [ 51, ogre_smash6 ] +{ + ai_charge (SECRET_1ST_DOWN); +}; + +void () ogre_smash6 = [ 52, ogre_smash7 ] +{ + ai_charge (SECRET_1ST_DOWN); + chainsaw (MULTICAST_ALL); +}; + +void () ogre_smash7 = [ 53, ogre_smash8 ] +{ + ai_charge (SECRET_1ST_DOWN); + chainsaw (MULTICAST_ALL); +}; + +void () ogre_smash8 = [ 54, ogre_smash9 ] +{ + ai_charge (TE_LAVASPLASH); + chainsaw (MULTICAST_ALL); +}; + +void () ogre_smash9 = [ 55, ogre_smash10 ] +{ + ai_charge (TE_LIGHTNINGBLOOD); + chainsaw (MULTICAST_ALL); +}; + +void () ogre_smash10 = [ 56, ogre_smash11 ] +{ + chainsaw (PLAT_LOW_TRIGGER); +}; + +void () ogre_smash11 = [ 57, ogre_smash12 ] +{ + ai_charge (SILENT); + chainsaw (MULTICAST_ALL); + self.nextthink = (self.nextthink + (random () * 0.2)); +}; + +void () ogre_smash12 = [ 58, ogre_smash13 ] +{ + ai_charge (); +}; + +void () ogre_smash13 = [ 59, ogre_smash14 ] +{ + ai_charge (SECRET_1ST_DOWN); +}; + +void () ogre_smash14 = [ 60, ogre_run1 ] +{ + ai_charge (TE_BLOOD); +}; + +void () ogre_nail1 = [ 61, ogre_nail2 ] +{ + ai_face (); +}; + +void () ogre_nail2 = [ 62, ogre_nail3 ] +{ + ai_face (); +}; + +void () ogre_nail3 = [ 62, ogre_nail4 ] +{ + ai_face (); +}; + +void () ogre_nail4 = [ 63, ogre_nail5 ] +{ + ai_face (); +}; + +void () ogre_nail5 = [ 64, ogre_nail6 ] +{ + ai_face (); +}; + +void () ogre_nail6 = [ 65, ogre_nail7 ] +{ + ai_face (); +}; + +void () ogre_nail7 = [ 66, ogre_run1 ] +{ + ai_face (); +}; + +void () ogre_naila = [ 61, ogre_nailb ] +{ + ai_face (); +}; + +void () ogre_nailb = [ 62, ogre_nailc ] +{ + ai_face (); +}; + +void () ogre_nailc = [ 62, ogre_naild ] +{ + ai_face (); +}; + +void () ogre_naild = [ 63, ogre_naile ] +{ + ai_face (); +}; + +void () ogre_naile = [ 64, ogre_nailf ] +{ + ai_face (); +}; + +void () ogre_nailf = [ 65, ogre_nailg ] +{ + ai_face (); +}; + +void () ogre_nailg = [ 66, ogre_run1 ] +{ + ai_face (); +}; + +void () ogre_pain1 = [ 67, ogre_pain2 ] +{ +}; + +void () ogre_pain2 = [ 68, ogre_pain3 ] +{ +}; + +void () ogre_pain3 = [ 69, ogre_pain4 ] +{ +}; + +void () ogre_pain4 = [ 70, ogre_pain5 ] +{ +}; + +void () ogre_pain5 = [ 71, ogre_run1 ] +{ +}; + +void () ogre_painb1 = [ 72, ogre_painb2 ] +{ +}; + +void () ogre_painb2 = [ 73, ogre_painb3 ] +{ +}; + +void () ogre_painb3 = [ 74, ogre_run1 ] +{ +}; + +void () ogre_painc1 = [ 75, ogre_painc2 ] +{ +}; + +void () ogre_painc2 = [ 76, ogre_painc3 ] +{ +}; + +void () ogre_painc3 = [ 77, ogre_painc4 ] +{ +}; + +void () ogre_painc4 = [ 78, ogre_painc5 ] +{ +}; + +void () ogre_painc5 = [ 79, ogre_painc6 ] +{ +}; + +void () ogre_painc6 = [ 80, ogre_run1 ] +{ +}; + +void () ogre_paind1 = [ 81, ogre_paind2 ] +{ +}; + +void () ogre_paind2 = [ 82, ogre_paind3 ] +{ + ai_pain (TE_LAVASPLASH); +}; + +void () ogre_paind3 = [ 83, ogre_paind4 ] +{ + ai_pain (TE_LIGHTNING3); +}; + +void () ogre_paind4 = [ 84, ogre_paind5 ] +{ + ai_pain (SECRET_1ST_DOWN); +}; + +void () ogre_paind5 = [ 85, ogre_paind6 ] +{ +}; + +void () ogre_paind6 = [ 86, ogre_paind7 ] +{ +}; + +void () ogre_paind7 = [ 87, ogre_paind8 ] +{ +}; + +void () ogre_paind8 = [ 88, ogre_paind9 ] +{ +}; + +void () ogre_paind9 = [ 89, ogre_paind10 ] +{ +}; + +void () ogre_paind10 = [ 90, ogre_paind11 ] +{ +}; + +void () ogre_paind11 = [ 91, ogre_paind12 ] +{ +}; + +void () ogre_paind12 = [ 92, ogre_paind13 ] +{ +}; + +void () ogre_paind13 = [ 93, ogre_paind14 ] +{ +}; + +void () ogre_paind14 = [ 94, ogre_paind15 ] +{ +}; + +void () ogre_paind15 = [ 95, ogre_paind16 ] +{ +}; + +void () ogre_paind16 = [ 96, ogre_run1 ] +{ +}; + +void () ogre_paine1 = [ 97, ogre_paine2 ] +{ +}; + +void () ogre_paine2 = [ 98, ogre_paine3 ] +{ + ai_pain (TE_LAVASPLASH); +}; + +void () ogre_paine3 = [ 99, ogre_paine4 ] +{ + ai_pain (TE_LIGHTNING3); +}; + +void () ogre_paine4 = [ 100, ogre_paine5 ] +{ + ai_pain (SECRET_1ST_DOWN); +}; + +void () ogre_paine5 = [ 101, ogre_paine6 ] +{ +}; + +void () ogre_paine6 = [ 102, ogre_paine7 ] +{ +}; + +void () ogre_paine7 = [ 103, ogre_paine8 ] +{ +}; + +void () ogre_paine8 = [ 104, ogre_paine9 ] +{ +}; + +void () ogre_paine9 = [ 105, ogre_paine10 ] +{ +}; + +void () ogre_paine10 = [ 106, ogre_paine11 ] +{ +}; + +void () ogre_paine11 = [ 107, ogre_paine12 ] +{ +}; + +void () ogre_paine12 = [ 108, ogre_paine13 ] +{ +}; + +void () ogre_paine13 = [ 109, ogre_paine14 ] +{ +}; + +void () ogre_paine14 = [ 110, ogre_paine15 ] +{ +}; + +void () ogre_paine15 = [ 111, ogre_run1 ] +{ +}; + +void (entity attacker, float damage) ogre_pain = +{ + local float r; + + if (self.pain_finished > time) + return; + + if (random()*8 <= 1) + { + ogre_paind1(); + self.pain_finished = time + 7; + sound (self, CHAN_VOICE, "ogre/ogpain1.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + return; + } +}; + +void () ogre_die1 = [ 112, ogre_die2 ] +{ + self.solid = SOLID_NOT; +}; + +void () ogre_die2 = [ 113, ogre_die3 ] +{ +}; + +void () ogre_die3 = [ 114, ogre_die4 ] +{ + DropBackpack (); + DropBackpack (); + DropBackpack (); +}; + +void () ogre_die4 = [ 115, ogre_die5 ] +{ +}; + +void () ogre_die5 = [ 116, ogre_die6 ] +{ +}; + +void () ogre_die6 = [ 117, ogre_die7 ] +{ +}; + +void () ogre_die7 = [ 118, ogre_die8 ] +{ +}; + +void () ogre_die8 = [ 119, ogre_die9 ] +{ +}; + +void () ogre_die9 = [ 120, ogre_die10 ] +{ +}; + +void () ogre_die10 = [ 121, ogre_die11 ] +{ +}; + +void () ogre_die11 = [ 122, ogre_die12 ] +{ +}; + +void () ogre_die12 = [ 123, ogre_die13 ] +{ +}; + +void () ogre_die13 = [ 124, ogre_die14 ] +{ +}; + +void () ogre_die14 = [ 125, ogre_die14 ] +{ +}; + +void () ogre_bdie1 = [ 126, ogre_bdie2 ] +{ +}; + +void () ogre_bdie2 = [ 127, ogre_bdie3 ] +{ + ai_forward (MULTICAST_PVS_R); +}; + +void () ogre_bdie3 = [ 128, ogre_bdie4 ] +{ + self.solid = SOLID_NOT; + self.ammo_rockets = SILENT; + DropBackpack (); +}; + +void () ogre_bdie4 = [ 129, ogre_bdie5 ] +{ + ai_forward (PLAT_LOW_TRIGGER); +}; + +void () ogre_bdie5 = [ 130, ogre_bdie6 ] +{ + ai_forward (AS_MELEE); +}; + +void () ogre_bdie6 = [ 131, ogre_bdie7 ] +{ + ai_forward (TE_WIZSPIKE); +}; + +void () ogre_bdie7 = [ 132, ogre_bdie8 ] +{ + ai_forward (DRAW3); +}; + +void () ogre_bdie8 = [ 133, ogre_bdie9 ] +{ +}; + +void () ogre_bdie9 = [ 134, ogre_bdie10 ] +{ +}; + +void () ogre_bdie10 = [ 135, ogre_bdie10 ] +{ +}; + + +void () mutant_pain = +{ + if (self.frame == 69) + { + self.frame = 70; + self.health = 180; + self.think = army_die1; + self.nextthink = time + 0.12; + self.think = ogre_die1; + } + else + { + ThrowGib ("progs/zom_gib.mdl", -40); + self.frame = 69; + self.health = 180; + self.think = ogre_die1; + self.nextthink = time + 0.12; + } + + self.attack = self.attack + 1; + + if (self.attack == 8) + { + if (random()*4 <= 2) + sound (self, CHAN_VOICE, "player/agdie1.wav", 1, ATTN_NORM); + else + sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); + } + if (self.attack >= 16) + { + self.solid = SOLID_NOT; + + self.think = ogre_bdie1; + ThrowGib ("progs/zom_gib.mdl", -35); + ThrowGib ("progs/zom_gib.mdl", -35); + ThrowGib ("progs/gib1.mdl", -35); + } +}; + + +void (vector stuff, vector ang) spawn_live_ogre = +{ + local entity ogre; + local entity te; + + ogre = spawn (); + ogre.origin = stuff; + ogre.enemy = world; + ogre.attack_finished = time + 10; + ogre.solid = SOLID_SLIDEBOX; + ogre.movetype = MOVETYPE_STEP; + ogre.takedamage = DAMAGE_YES; + setmodel (ogre, "progs/ogre.mdl"); + setsize (ogre, '-20 -20 -24', '20 20 36'); + ogre.classname = "body"; + ogre.netname = "dead"; + ogre.health = 180; + ogre.angles = ang; + ogre.max_health = ogre.health; + ogre.th_pain = mutant_pain; + ogre.think = mutant_pain; + ogre.nextthink = time + 0.05; +}; + +void () ogre_die = +{ + local string attack_total; + local string damage_total; + + if (self.enemy.classname == "player") + self.enemy.frags = self.enemy.frags + 1; + + if (self.health <= -35) + { + self.solid = SOLID_NOT; + sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); + ThrowGib ("progs/zom_gib.mdl", -30); + ThrowGib ("progs/zom_gib.mdl", -35); + ogre_bdie1 (); + } + else + { + self.solid = SOLID_NOT; + spawn_live_ogre(self.origin, self.angles); + remove(self); + } + + sound (self, CHAN_VOICE, "ogre/ogpain1.wav", 1, ATTN_NORM); +}; + +void () ogre_melee = +{ + if ((random () > 0.5)) + { + ogre_smash1 (); + } + else + { + ogre_swing1 (); + } +}; + +void () monster_ogre = +{ + precache_model ("progs/ogre.mdl"); + precache_model ("progs/h_ogre.mdl"); + precache_model ("progs/grenade.mdl"); + precache_sound ("ogre/ogdrag.wav"); + precache_sound ("ogre/ogdth.wav"); + precache_sound ("ogre/ogidle.wav"); + precache_sound ("ogre/ogidle2.wav"); + precache_sound ("ogre/ogpain1.wav"); + precache_sound ("ogre/ogsawatk.wav"); + precache_sound ("ogre/ogwake.wav"); + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_STEP; + setmodel (self, "progs/ogre.mdl"); + self.netname = "mutant"; + self.classname = "monster"; + setsize (self, '-24 -24 -24', '24 24 48'); + self.health = 280; + self.team = 3; + self.armorvalue = 0; + self.th_stand = ogre_stand1; + self.th_walk = ogre_walk1; + self.th_run = ogre_run1; + self.th_die = ogre_die; + self.th_melee = ogre_melee; + self.th_pain = ogre_pain; + self.armortype = 0; + walkmonster_start (); +}; + + +void () monster_ogre_marksman = +{ + monster_ogre (); +}; diff --git a/quakec/fallout2/plats.qc b/quakec/fallout2/plats.qc new file mode 100644 index 000000000..f60081e8a --- /dev/null +++ b/quakec/fallout2/plats.qc @@ -0,0 +1,367 @@ + + +void() plat_center_touch; +void() plat_outside_touch; +void() plat_trigger_use; +void() plat_go_up; +void() plat_go_down; +void() plat_crush; +float PLAT_LOW_TRIGGER = 1; + +void() plat_spawn_inside_trigger = +{ + local entity trigger; + local vector tmin, tmax; + +// +// middle trigger +// + trigger = spawn(); + trigger.touch = plat_center_touch; + trigger.movetype = MOVETYPE_NONE; + trigger.solid = SOLID_TRIGGER; + trigger.enemy = self; + + tmin = self.mins + '25 25 0'; + tmax = self.maxs - '25 25 -8'; + tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8); + if (self.spawnflags & PLAT_LOW_TRIGGER) + tmax_z = tmin_z + 8; + + if (self.size_x <= 50) + { + tmin_x = (self.mins_x + self.maxs_x) / 2; + tmax_x = tmin_x + 1; + } + if (self.size_y <= 50) + { + tmin_y = (self.mins_y + self.maxs_y) / 2; + tmax_y = tmin_y + 1; + } + + setsize (trigger, tmin, tmax); +}; + +void() plat_hit_top = +{ + sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self.noise1, 1, ATTN_NORM); + self.state = STATE_TOP; + self.think = plat_go_down; + self.nextthink = self.ltime + 3; +}; + +void() plat_hit_bottom = +{ + sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self.noise1, 1, ATTN_NORM); + self.state = STATE_BOTTOM; +}; + +void() plat_go_down = +{ + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); + self.state = STATE_DOWN; + SUB_CalcMove (self.pos2, self.speed, plat_hit_bottom); +}; + +void() plat_go_up = +{ + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); + self.state = STATE_UP; + SUB_CalcMove (self.pos1, self.speed, plat_hit_top); +}; + +void() plat_center_touch = +{ + if (other.classname != "player") + return; + + if (other.health <= 0) + return; + + self = self.enemy; + if (self.state == STATE_BOTTOM) + plat_go_up (); + else if (self.state == STATE_TOP) + self.nextthink = self.ltime + 1; // delay going down +}; + +void() plat_outside_touch = +{ + if (other.classname != "player") + return; + + if (other.health <= 0) + return; + +//dprint ("plat_outside_touch\n"); + self = self.enemy; + if (self.state == STATE_TOP) + plat_go_down (); +}; + +void() plat_trigger_use = +{ + if (self.think) + return; // allready activated + plat_go_down(); +}; + + +void() plat_crush = +{ +//dprint ("plat_crush\n"); + + other.deathtype = "squish"; + T_Damage (other, self, self, 1); + + if (self.state == STATE_UP) + plat_go_down (); + else if (self.state == STATE_DOWN) + plat_go_up (); + else + objerror ("plat_crush: bad self.state\n"); +}; + +void() plat_use = +{ + self.use = SUB_Null; + if (self.state != STATE_UP) + objerror ("plat_use: not in up state"); + plat_go_down(); +}; + + +/*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER +speed default 150 + +Plats are always drawn in the extended position, so they will light correctly. + +If the plat is the target of another trigger or button, it will start out disabled in the extended position until it is trigger, when it will lower and become a normal plat. + +If the "height" key is set, that will determine the amount the plat moves, instead of being implicitly determined by the model's height. +Set "sounds" to one of the following: +1) base fast +2) chain slow +*/ + + +void() func_plat = + +{ +local entity t; + + if (!self.t_length) + self.t_length = 80; + if (!self.t_width) + self.t_width = 10; + + if (self.sounds == 0) + self.sounds = 2; +// 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) + { + 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'; + + self.classname = "plat"; + self.solid = SOLID_BSP; + self.movetype = MOVETYPE_PUSH; + setorigin (self, self.origin); + setmodel (self, self.model); + setsize (self, self.mins , self.maxs); + + self.blocked = plat_crush; + if (!self.speed) + self.speed = 150; + +// pos1 is the top position, pos2 is the bottom + self.pos1 = self.origin; + self.pos2 = self.origin; + if (self.height) + self.pos2_z = self.origin_z - self.height; + else + self.pos2_z = self.origin_z - self.size_z + 8; + + self.use = plat_trigger_use; + + plat_spawn_inside_trigger (); // the "start moving" trigger + + if (self.targetname) + { + self.state = STATE_UP; + self.use = plat_use; + } + else + { + setorigin (self, self.pos2); + self.state = STATE_BOTTOM; + } +}; + +//============================================================================ + +void() train_next; +void() func_train_find; + +void() train_blocked = +{ + if (time < self.attack_finished) + return; + self.attack_finished = time + 0.5; + other.deathtype = "squish"; + T_Damage (other, self, self, self.dmg); +}; + +void() train_use = +{ + if (self.think != func_train_find) + return; // already activated + train_next(); +}; + +void() train_wait = +{ + if (self.wait) + { + self.nextthink = self.ltime + self.wait; + sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self.noise, 1, ATTN_NORM); + } + else + self.nextthink = self.ltime + 0.1; + + self.think = train_next; +}; + +void() train_next = +{ + local entity targ; + + targ = find (world, targetname, self.target); + self.target = targ.target; + if (!self.target) + objerror ("train_next: no next target"); + if (targ.wait) + self.wait = targ.wait; + else + self.wait = 0; + sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM); + SUB_CalcMove (targ.origin - self.mins, self.speed, train_wait); +}; + +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 + self.nextthink = self.ltime + 0.1; + self.think = train_next; + } +}; + +/*QUAKED func_train (0 .5 .8) ? +Trains are moving platforms that players can ride. +The targets origin specifies the min point of the train at each corner. +The train spawns at the first target it is pointing at. +If the train is the target of a button or trigger, it will not begin moving until activated. +speed default 100 +dmg default 2 +sounds +1) ratchet metal + +*/ +void() func_train = +{ + if (!self.speed) + self.speed = 100; + if (!self.target) + objerror ("func_train without a target"); + if (!self.dmg) + self.dmg = 2; + + 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) + { + self.noise = ("plats/train2.wav"); + precache_sound ("plats/train2.wav"); + self.noise1 = ("plats/train1.wav"); + precache_sound ("plats/train1.wav"); + } + + self.cnt = 1; + self.solid = SOLID_BSP; + self.movetype = MOVETYPE_PUSH; + self.blocked = train_blocked; + self.use = train_use; + self.classname = "train"; + + setmodel (self, self.model); + 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 + self.nextthink = self.ltime + 0.1; + self.think = func_train_find; +}; + +/*QUAKED misc_teleporttrain (0 .5 .8) (-8 -8 -8) (8 8 8) +This is used for the final bos +*/ +void() misc_teleporttrain = +{ + if (!self.speed) + self.speed = 100; + if (!self.target) + objerror ("func_train without a target"); + + self.cnt = 1; + self.solid = SOLID_NOT; + self.movetype = MOVETYPE_PUSH; + self.blocked = train_blocked; + self.use = train_use; + self.avelocity = '100 200 300'; + + self.noise = ("misc/null.wav"); + precache_sound ("misc/null.wav"); + self.noise1 = ("misc/null.wav"); + precache_sound ("misc/null.wav"); + + precache_model2 ("progs/teleport.mdl"); + setmodel (self, "progs/teleport.mdl"); + 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 + self.nextthink = self.ltime + 0.1; + self.think = func_train_find; +}; + diff --git a/quakec/fallout2/player.qc b/quakec/fallout2/player.qc new file mode 100644 index 000000000..586606c64 --- /dev/null +++ b/quakec/fallout2/player.qc @@ -0,0 +1,1420 @@ +void () bubble_bob; +void () make_bubbles; +void () bubble_remove; +void () PlayerDead; +void () player_diea1; + +void () player_duck = [ 45, player_run ] +{ +}; + +void () player_lay = [ 45, player_run ] +{ +}; + +void () Footstep = +{ + local float rand; + local float r; + + rand = random (); + if (self.perk == 5) + r = 0.4; + else + r = 0.8; + if ((rand < 0.25)) + sound (self, CHAN_ITEM, "player/step1.wav", r, ATTN_NORM); + else + { + if ((rand < 0.5)) + { + sound (self, CHAN_ITEM, "player/step2.wav", r, ATTN_NORM); + } + else + { + if ((rand < 0.75)) + { + sound (self, CHAN_ITEM, "player/step3.wav", r, ATTN_NORM); + } + else + { + sound (self, CHAN_ITEM, "player/step4.wav", r, ATTN_NORM); + } + } + } +}; + +void () player_crouch; + +void () player_stand1 = [ 149, player_stand1 ] +{ + if (self.rtime == 0) + self.weaponframe = 0; + + if ((self.position == WEAPON_SHOTGUN)) + { + player_crouch (); + return; + } + else + { + if ((self.position == WEAPON_SHOTGUN)) + { + player_lay (); + return; + } + } + if ((self.velocity_x || self.velocity_y)) + { + self.walkframe = 0; + player_run (); + return; + } + if ((self.walkframe >= MULTICAST_PVS_R)) + { + self.walkframe = 0; + } + self.frame = (149 + self.walkframe); + self.walkframe = (self.walkframe + WEAPON_SHOTGUN); +}; + +void () player_crouch = [ 45, player_run ] +{ + if (self.rtime == 0) + self.weaponframe = 0; + + if ((!self.velocity_x && !self.velocity_y)) + { + self.frame = 45; + return; + } + else + { + if ((self.position == WEAPON_SHOTGUN)) + { + player_lay (); + return; + } + } + self.frame = (36 + self.walkframe); + if (self.walkframe >= TE_TELEPORT) + self.walkframe = 0; + self.walkframe = (self.walkframe + 1); +}; + +void () player_climb = [ 20, player_run ] +{ + self.weaponframe = 0; + if (((!self.velocity_x && !self.velocity_y) && !self.velocity_z)) + { + self.frame = 25; + return; + } + self.frame = (SVC_TEMPENTITY + self.walkframe); + if ((self.walkframe >= TE_LIGHTNINGBLOOD)) + { + self.walkframe = 0; + } + self.walkframe = (self.walkframe + WEAPON_SHOTGUN); +}; + +void () player_run = [ 137, player_run ] +{ + local float crap; + + if (self.rtime == 0) + self.weaponframe = 0; + + if (((((self.equipment == 7) && (self.equipment_state == WEAPON_SHOTGUN)) && (self.grab == WEAPON_SHOTGUN)) && !(self.flags & FL_ONGROUND))) + { + player_climb (); + return; + } + if ((!self.velocity_x && !self.velocity_y)) + { + player_stand1 (); + return; + } + if ((self.position == WEAPON_SHOTGUN)) + { + player_crouch (); + return; + } + else + { + if (self.position == 1) + { + player_lay (); + return; + } + } + if ((((((self.walkframe == AS_MELEE) && (self.ghost == 0)) && (self.position == 0)) && (self.velocity_z == 0)) && (self.vehicle == 0))) + { + Footstep (); + } + if ((((((self.walkframe == 6) && (self.ghost == 0)) && (self.position == 0)) && (self.velocity_z == 0)) && (self.vehicle == 0))) + { + Footstep (); + } + if ((((((self.walkframe == TE_LIGHTNING3) && (self.ghost == 0)) && (self.position == 0)) && (self.velocity_z == 0)) && (self.vehicle == 0))) + { + Footstep (); + } + self.frame = (137 + self.walkframe); + if ((self.walkframe >= TE_LIGHTNING3)) + { + self.walkframe = 0; + } + self.walkframe = (self.walkframe + WEAPON_SHOTGUN); +}; + +void () player_reload1 = [ 123, player_reload2 ] +{ + sound (self, CHAN_WEAPON, "weapons/reload.wav", WEAPON_SHOTGUN, ATTN_NORM); +}; + +void () player_reload2 = [ 124, player_reload3 ] +{ + +}; + +void () player_reload3 = [ 125, player_reload4 ] +{ +}; + +void () player_reload4 = [ 126, player_reload5 ] +{ +}; + +void () player_reload5 = [ 127, player_reload6 ] +{ +}; + +void () player_reload6 = [ 128, player_reload7 ] +{ +}; + +void () player_reload7 = [ 129, player_reload8 ] +{ +}; + +void () player_reload8 = [ 130, player_reload9 ] +{ +}; + +void () player_reload9 = [ 131, player_reload10 ] +{ +}; + +void () player_reload10 = [ 132, player_reload11 ] +{ +}; + +void () player_reload11 = [ 133, player_reload12 ] +{ +}; + +void () player_reload12 = [ 134, player_reload13 ] +{ +}; + +void () player_reload13 = [ 135, player_reload14 ] +{ +}; + +void () player_reload14 = [ 136, player_run ] +{ +}; + +void () player_creload1 = [ 74, player_creload2 ] +{ + sound (self, CHAN_WEAPON, "weapons/reload.wav", WEAPON_SHOTGUN, ATTN_NORM); +}; + +void () player_creload2 = [ 75, player_creload3 ] +{ +}; + +void () player_creload3 = [ 76, player_creload4 ] +{ +}; + +void () player_creload4 = [ 77, player_creload5 ] +{ +}; + +void () player_creload5 = [ 78, player_creload6 ] +{ +}; + +void () player_creload6 = [ 79, player_creload7 ] +{ +}; + +void () player_creload7 = [ 80, player_creload8 ] +{ +}; + +void () player_creload8 = [ 81, player_creload9 ] +{ +}; + +void () player_creload9 = [ 82, player_creload10 ] +{ +}; + +void () player_creload10 = [ 83, player_creload11 ] +{ +}; + +void () player_creload11 = [ 84, player_creload12 ] +{ +}; + +void () player_creload12 = [ 85, player_creload13 ] +{ +}; + +void () player_creload13 = [ 86, player_creload14 ] +{ +}; + +void () player_creload14 = [ 87, player_run ] +{ +}; + +void () player_use1 = [ 155, player_use2 ] +{ +}; + +void () player_use2 = [ 156, player_use3 ] +{ +}; + +void () player_use3 = [ 157, player_use4 ] +{ +}; + +void () player_use4 = [ 158, player_use5 ] +{ +}; + +void () player_use5 = [ 159, player_use6 ] +{ +}; + +void () player_use6 = [ 160, player_use7 ] +{ +}; + +void () player_use7 = [ 161, player_use8 ] +{ +}; + +void () player_use8 = [ 162, player_use9 ] +{ +}; + +void () player_use9 = [ 163, player_use10 ] +{ +}; + +void () player_use10 = [ 164, player_use11 ] +{ +}; + +void () player_use11 = [ 165, player_use12 ] +{ +}; + +void () player_use12 = [ 166, player_use13 ] +{ +}; + +void () player_use13 = [ 167, player_use14 ] +{ +}; + +void () player_use14 = [ 168, player_use15 ] +{ +}; + +void () player_use15 = [ 169, player_use16 ] +{ +}; + +void () player_use16 = [ 170, player_run ] +{ +}; + +void () player_holster1 = [ 107, player_holster2 ] +{ + self.attack_finished = (time + 0.25); +}; + +void () player_holster2 = [ 109, player_holster3 ] +{ +}; + +void () player_holster3 = [ 111, player_holster4 ] +{ +}; + +void () player_holster4 = [ 112, player_holster5 ] +{ +}; + +void () player_holster5 = [ 113, player_holster6 ] +{ +}; + +void () player_holster6 = [ 114, player_holster7 ] +{ +}; + +void () player_holster7 = [ 115, player_holster8 ] +{ +}; + +void () player_holster8 = [ 116, player_holster9 ] +{ +}; + +void () player_holster9 = [ 117, player_holster10 ] +{ +}; + +void () player_holster10 = [ 119, player_holster11 ] +{ +}; + +void () player_holster11 = [ 121, player_holster12 ] +{ +}; + +void () player_holster12 = [ 122, player_run ] +{ +}; + +void () player_jump1 = [ 48, player_jump2 ] +{ +}; + +void () player_jump2 = [ 49, player_jump3 ] +{ +}; + +void () player_jump3 = [ 50, player_jump4 ] +{ +}; + +void () player_jump4 = [ 52, player_jump5 ] +{ +}; + +void () player_jump5 = [ 54, player_jump6 ] +{ +}; + +void () player_jump6 = [ 53, player_jump7 ] +{ +}; + +void () player_jump7 = [ 51, player_jump8 ] +{ +}; + +void () player_jump8 = [ 49, player_jump9 ] +{ +}; + +void () player_jump9 = [ 48, player_run ] +{ +}; + + +void () player_singlea = [ 88, player_run ] +{ + self.weaponframe = WEAPON_SHOTGUN; + muzzleflash (); +}; + +void () player_singleaz = [ 183, player_run ] +{ + self.weaponframe = WEAPON_SHOTGUN; + muzzleflash (); +}; + +void () player_singlea2 = [ 89, player_run ] +{ + self.weaponframe = WEAPON_SHOTGUN; + muzzleflash (); +}; + +void () player_singleb = [ 89, player_run ] +{ + self.weaponframe = WEAPON_ROCKET; + muzzleflash (); +}; + +void () player_singleb2 = [ 89, player_run ] +{ + self.weaponframe = WEAPON_ROCKET; + muzzleflash (); +}; + +void () player_singlebz = [ 184, player_run ] +{ + self.weaponframe = WEAPON_ROCKET; + muzzleflash (); +}; + +void () player_shotty1 = [ 88, player_shotty2 ] +{ + self.weaponframe = WEAPON_SHOTGUN; +}; + +void () player_shotty2 = [ 89, player_shotty3 ] +{ + self.weaponframe = WEAPON_ROCKET; +}; + +void () player_shotty3 = [ 90, player_shotty4 ] +{ + self.weaponframe = AS_MELEE; +}; + +void () player_shotty4 = [ 91, player_run ] +{ + self.weaponframe = WEAPON_ROCKET; +}; + +void () player_pull1 = [ 155, player_pull2 ] +{ + self.weaponframe = WEAPON_SHOTGUN; +}; + +void () player_pull2 = [ 156, player_pull3 ] +{ + self.weaponframe = WEAPON_ROCKET; +}; + +void () player_pull3 = [ 157, player_pull4 ] +{ + self.weaponframe = AS_MELEE; +}; + +void () player_pull4 = [ 158, player_pull5 ] +{ + self.weaponframe = WEAPON_SPIKES; +}; + +void () player_pull5 = [ 157, player_pull6 ] +{ + self.weaponframe = MULTICAST_PVS_R; +}; + +void () player_pull6 = [ 156, player_pull7 ] +{ + self.weaponframe = 6; + sound (self, CHAN_WEAPON, "weapons/gpull.wav", WEAPON_SHOTGUN, ATTN_IDLE); +}; + +void () player_pull7 = [ 155, player_pull8 ] +{ + self.weaponframe = 7; +}; + +void () player_pull8 = [ 155, player_pull9 ] +{ + self.weaponframe = WEAPON_BIG; + self.grenade_hold = WEAPON_SHOTGUN; +}; + +void () player_pull9 = [ 155, player_pull10 ] +{ + self.weaponframe = TE_LIGHTNING3; +}; + +void () player_pull10 = [ 155, player_pull11 ] +{ + self.weaponframe = TE_LAVASPLASH; +}; + +void () player_pull11 = [ 155, player_run ] +{ + self.weaponframe = TE_TELEPORT; +}; + +void () player_throw1 = [ 155, player_throw2 ] +{ + self.weaponframe = TE_BLOOD; + if (((random () * WEAPON_BIG) <= WEAPON_SPIKES)) + { + sound (self, CHAN_VOICE, "radio/grenade.wav", 0.7, ATTN_NORM); + } + else + { + sound (self, CHAN_VOICE, "radio/lookout.wav", 0.7, ATTN_NORM); + } +}; + +void () player_throw2 = [ 156, player_throw3 ] +{ + self.weaponframe = TE_LIGHTNINGBLOOD; + FireHandGrenade (); +}; + +void () player_throw3 = [ 157, player_throw4 ] +{ + self.weaponframe = 14; +}; + +void () player_throw4 = [ 158, player_throw5 ] +{ + self.weaponframe = 15; +}; + +void () player_throw5 = [ 157, player_throw6 ] +{ + self.weaponframe = 16; +}; + +void () player_throw6 = [ 156, player_throw7 ] +{ + self.weaponframe = 17; +}; + +void () player_throw7 = [ 155, player_throw8 ] +{ + self.weaponframe = 18; + if (self.handgrenade <= 0) + stuffcmd (self, "impulse 1\n"); + else + stuffcmd (self, "impulse 3\n"); +}; + +void () player_throw8 = [ 159, player_throw9 ] +{ + self.weaponframe = 19; +}; + +void () player_throw9 = [ 160, player_throw10 ] +{ + self.weaponframe = 20; +}; + +void () player_throw10 = [ 161, player_throw11 ] +{ + self.weaponframe = 21; +}; + +void () player_throw11 = [ 162, player_run ] +{ + self.weaponframe = 22; +}; + +void () player_shotty1b = [ 183, player_shotty2b ] +{ + self.weaponframe = 1; +}; + +void () player_shotty2b = [ 183, player_shotty3b ] +{ + self.weaponframe = 2; +}; + +void () player_shotty3b = [ 184, player_shotty4b ] +{ + self.weaponframe = 3; +}; + +void () player_shotty4b = [ 184, player_run ] +{ + self.weaponframe = 4; +}; + +void () player_knife1 = [ 155, player_knife2 ] +{ + self.weaponframe = 1; +}; + +void () player_knife2 = [ 156, player_knife3 ] +{ + self.weaponframe = 2; +}; + +void () player_knife3 = [ 157, player_run ] +{ + self.weaponframe = 3; +}; + +void () player_knifea = [ 155, player_knifeb ] +{ + self.weaponframe = 4; +}; + +void () player_knifeb = [ 156, player_knifec ] +{ + self.weaponframe = 5; +}; + +void () player_knifec = [ 157, player_run ] +{ + self.weaponframe = 6; +}; + +void () player_nail1 = [ 88, player_nail2 ] +{ + muzzleflash (); + if (((!self.button0 || intermission_running) || self.impulse)) + { + player_run (); + return; + } + self.weaponframe = (self.weaponframe + WEAPON_SHOTGUN); + if ((self.weaponframe == AS_MELEE)) + { + self.weaponframe = WEAPON_SHOTGUN; + } +}; + +void () player_nail2 = [ 89, player_nail1 ] +{ + muzzleflash (); + if (((!self.button0 || intermission_running) || self.impulse)) + { + player_run (); + return; + } + self.weaponframe = (self.weaponframe + WEAPON_SHOTGUN); + if ((self.weaponframe == AS_MELEE)) + { + self.weaponframe = WEAPON_SHOTGUN; + } +}; + +void () player_auto1 = [ 88, player_auto2 ] +{ + muzzleflash (); + if (((!self.button0 || intermission_running) || self.impulse)) + { + player_run (); + return; + } + self.weaponframe = (self.weaponframe + WEAPON_SHOTGUN); + if ((self.weaponframe == WEAPON_ROCKET)) + { + self.weaponframe = WEAPON_SHOTGUN; + } +}; + +void () player_auto2 = [ 89, player_auto1 ] +{ + muzzleflash (); + if (((!self.button0 || intermission_running) || self.impulse)) + { + player_run (); + return; + } + self.weaponframe = (self.weaponframe + WEAPON_SHOTGUN); + if ((self.weaponframe == WEAPON_ROCKET)) + { + self.weaponframe = WEAPON_SHOTGUN; + } +}; + +void () player_auto3 = [ 88, player_auto4 ] +{ + muzzleflash (); + if (((!self.button0 || intermission_running) || self.impulse)) + { + player_run (); + return; + } + self.weaponframe = WEAPON_SHOTGUN; +}; + +void () player_auto4 = [ 89, player_auto3 ] +{ + muzzleflash (); + if (((!self.button0 || intermission_running) || self.impulse)) + { + player_run (); + return; + } + self.weaponframe = 0; +}; +void (float num_bubbles) DeathBubbles; + +void () PainSound = +{ + local float rs; + + if (self.health <= 0) + return; + + if ((damage_attacker.classname == "teledeath")) + { + sound (self, CHAN_VOICE, "player/teledth1.wav", WEAPON_SHOTGUN, ATTN_NONE); + return; + } + if (((self.watertype == CONTENT_WATER) && (self.waterlevel == AS_MELEE))) + { + DeathBubbles (WEAPON_SHOTGUN); + sound (self, CHAN_VOICE, "player/pain1.wav", WEAPON_SHOTGUN, ATTN_NORM); + return; + } + if ((self.watertype == CONTENT_SLIME)) + { + if ((random () > 0.5)) + { + sound (self, CHAN_VOICE, "player/slimbrn2.wav", WEAPON_SHOTGUN, ATTN_NORM); + } + else + { + sound (self, CHAN_VOICE, "player/lburn2.wav", WEAPON_SHOTGUN, ATTN_NORM); + } + return; + } + if ((self.watertype == CONTENT_LAVA)) + { + if ((random () > 0.5)) + { + sound (self, CHAN_VOICE, "player/lburn1.wav", WEAPON_SHOTGUN, ATTN_NORM); + } + else + { + sound (self, CHAN_VOICE, "player/lburn2.wav", WEAPON_SHOTGUN, ATTN_NORM); + } + return; + } + if ((self.pain_finished > time)) + { + self.axhitme = 0; + return; + } + self.pain_finished = (time + 1.5); + if ((self.axhitme == WEAPON_SHOTGUN)) + { + self.axhitme = 0; + sound (self, CHAN_VOICE, "player/pain1.wav", WEAPON_SHOTGUN, ATTN_NORM); + return; + } + self.noise = "player/pain2.wav"; + sound (self, CHAN_VOICE, self.noise, WEAPON_SHOTGUN, ATTN_NORM); + return; +}; + +void () player_pain1 = [ 14, player_pain2 ] +{ +}; + +void () player_pain2 = [ 15, player_pain3 ] +{ +}; + +void () player_pain3 = [ 16, player_pain4 ] +{ +}; + +void () player_pain4 = [ 17, player_pain5 ] +{ +}; + +void () player_pain5 = [ 18, player_pain6 ] +{ +}; + +void () player_pain6 = [ 19, player_run ] +{ +}; + +void () player_pain = +{ + if (self.weaponframe) + { + return; + } + if (((random () * WEAPON_BIG) < WEAPON_SPIKES)) + { + sound (self, CHAN_VOICE, "player/paina.wav", WEAPON_SHOTGUN, ATTN_NORM); + } + else + { + sound (self, CHAN_VOICE, "player/painb.wav", WEAPON_SHOTGUN, ATTN_NORM); + } + if (((random () * WEAPON_BIG) < 6)) + { + sound (self, CHAN_BODY, "player/hit1.wav", WEAPON_SHOTGUN, ATTN_NORM); + } + if ((self.invisible_finished > time)) + { + return; + } + player_pain1 (); +}; +void () player_dieb1; +void () player_diec1; + +void () DeathBubblesSpawn = +{ + local entity bubble; + + if ((self.owner.waterlevel != AS_MELEE)) + { + return; + } + bubble = spawn (); + setmodel (bubble, "progs/s_bubble.spr"); + setorigin (bubble, (self.owner.origin + '0 0 24')); + bubble.movetype = MOVETYPE_NOCLIP; + bubble.solid = SOLID_NOT; + bubble.velocity = '0 0 15'; + bubble.nextthink = (time + 0.5); + bubble.think = bubble_bob; + bubble.classname = "bubble"; + bubble.frame = 0; + bubble.cnt = 0; + setsize (bubble, '-8 -8 -8', '8 8 8'); + self.nextthink = (time + 0.1); + self.think = DeathBubblesSpawn; + self.air_finished = (self.air_finished + WEAPON_SHOTGUN); + if ((self.air_finished >= self.bubble_count)) + { + remove (self); + } +}; + +void (float num_bubbles) DeathBubbles = +{ + local entity bubble_spawner; + + bubble_spawner = spawn (); + setorigin (bubble_spawner, self.origin); + bubble_spawner.movetype = MOVETYPE_NONE; + bubble_spawner.solid = SOLID_NOT; + bubble_spawner.nextthink = (time + 0.1); + bubble_spawner.think = DeathBubblesSpawn; + bubble_spawner.air_finished = 0; + bubble_spawner.owner = self; + bubble_spawner.bubble_count = num_bubbles; + return; +}; + +void () DeathSound = +{ + local float rs; + local float r; + + if ((self.waterlevel == AS_MELEE)) + { + sound (self, CHAN_VOICE, "player/drown2.wav", WEAPON_SHOTGUN, ATTN_NONE); + return; + } + r = random (); + self.noise = "player/agdie4.wav"; + if ((self.deathsound == "")) + { + if ((r < 0.3)) + { + self.noise = "player/agdie1.wav"; + } + else + { + if ((r < 0.6)) + { + self.noise = "player/agdie3.wav"; + } + else + { + self.noise = "player/agdie4.wav"; + } + } + } + if ((self.deathsound == "")) + { + if ((r < 0.5)) + { + self.noise = "player/teledth1.wav"; + } + else + { + self.noise = "player/agdie4.wav"; + } + } + if ((self.deathsound =="")) + { + if ((r < 0.3)) + { + self.noise = "player/udeath.wav"; + } + else + { + if ((r < 0.6)) + { + self.noise = "player/agdie3.wav"; + } + else + { + self.noise = "player/gib1.wav"; + } + } + } + sound (self, CHAN_VOICE, self.noise, 0.9, ATTN_NORM); + return; +}; + +void () PlayerDead = +{ + self.nextthink = CONTENT_EMPTY; + self.deadflag = DEAD_DEAD; +}; + +vector(float dm) VelocityForDamage = +{ + local vector v; + + v_x = 100 * crandom(); + v_y = 100 * crandom(); + v_z = 200 + 100 * random(); + + if (dm > -50) + { +// dprint ("level 1\n"); + v = v * 0.7; + } + else if (dm > -200) + { +// dprint ("level 3\n"); + v = v * 2; + } + else + v = v * 10; + + return v; +}; + +void(string gibname, float dm) ThrowGib = +{ + local entity new; + + new = spawn(); + new.origin = self.origin; + setmodel (new, gibname); + setsize (new, '0 0 0', '0 0 0'); + 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.think = SUB_Remove; + new.ltime = time; + new.nextthink = time + 10 + random()*10; + new.frame = 0; + new.flags = 0; +}; + +void(string gibname, float dm) ThrowHead = +{ + setmodel (self, gibname); + self.frame = 0; + self.nextthink = -1; + self.movetype = MOVETYPE_BOUNCE; + self.takedamage = DAMAGE_NO; + self.solid = SOLID_NOT; + self.view_ofs = '0 0 8'; + setsize (self, '-16 -16 0', '16 16 56'); + 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'; +}; + +void (string gibname, float dm) ThrowGib2 = +{ + local entity new; + + new = spawn(); + new.origin = self.origin; + setmodel (new, gibname); + setsize (new, '0 0 0', '0 0 0'); + new.velocity = VelocityForDamage (dm); + new.velocity_z = new.velocity_z + 40; + new.movetype = MOVETYPE_BOUNCE; + new.solid = SOLID_NOT; +// 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.frame = 0; + new.flags = 0; +}; + + +void () SmokeBob2 = +{ + local float rnd1; + local float rnd2; + local float rnd3; + local vector vtmp1; + local vector modi; + + self.cnt = (self.cnt + WEAPON_SHOTGUN); + if ((self.cnt >= (WEAPON_ROCKET + (random () * AS_MELEE)))) + { + remove (self); + } + rnd1 = (self.velocity_x + (-10 + (random () * 20))); + rnd2 = (self.velocity_y + (-10 + (random () * 20))); + rnd3 = ((self.velocity_z + TE_LAVASPLASH) + (random () * TE_LAVASPLASH)); + if ((rnd1 > MULTICAST_PVS_R)) + { + rnd1 = MULTICAST_PVS_R; + } + if ((rnd1 < CONTENT_LAVA)) + { + rnd1 = CONTENT_LAVA; + } + if ((rnd2 > MULTICAST_PVS_R)) + { + rnd2 = MULTICAST_PVS_R; + } + if ((rnd2 < CONTENT_LAVA)) + { + rnd2 = CONTENT_LAVA; + } + if ((rnd3 < TE_LAVASPLASH)) + { + rnd3 = 15; + } + if ((rnd3 > SVC_INTERMISSION)) + { + rnd3 = 25; + } + self.velocity_x = rnd1; + self.velocity_y = rnd2; + self.velocity_z = rnd3; + self.nextthink = (time + 0.5); + self.think = SmokeBob2; +}; + +void (string gibname, float dm) ThrowPlayerHead = +{ + setmodel (self, gibname); + self.frame = 0; + if ((self.team == WEAPON_ROCKET)) + { + self.skin = 0; + } + if ((self.team == WEAPON_SHOTGUN)) + { + self.skin = WEAPON_SHOTGUN; + } + self.nextthink = (time + WEAPON_SHOTGUN); + self.think = SUB_Null; + self.movetype = MOVETYPE_BOUNCE; + self.takedamage = DAMAGE_NO; + self.view_ofs = '0 0 8'; + setsize (self, '-8 -8 -8', '8 8 8'); + 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'); +}; + +void () GibPlayer = +{ + self.solid = SOLID_NOT; + self.deadflag = DEAD_DYING; + setmodel (self, ""); + self.skin = self.team; + ThrowGib ("progs/gib1.mdl", self.health); + ThrowGib ("progs/gib1.mdl", self.health); + ThrowGib ("progs/gib3.mdl", self.health); + SpawnMeatSpray (self.origin, (self.origin + VEC_ORIGIN)); + SpawnMeatSpray (self.origin, (self.origin + VEC_ORIGIN)); + SpawnMeatSpray (self.origin, (self.origin + VEC_ORIGIN)); + self.deadflag = DEAD_DEAD; +}; + +void () PlayerDie = +{ + local float i; + local float r; + + self.solid = 0; + + if ((self.deathtype == "fall")) + { + sound (self, CHAN_VOICE, "player/agdie4.wav", WEAPON_SHOTGUN, ATTN_NONE); + self.deathsound = ""; + self.deathtype = ""; + } + if ((self.waterlevel == AS_MELEE)) + { + DeathBubbles (20); + sound (self, CHAN_VOICE, "player/drown2.wav", WEAPON_SHOTGUN, ATTN_NONE); + self.deathsound = ""; + } + r = random (); + self.noise = "player/agdie2.wav"; + if ((self.deathsound == "")) + { + if ((r < 0.3)) + { + self.noise = "player/agdie1.wav"; + } + else + { + if ((r < 0.6)) + { + self.noise = "player/agdie3.wav"; + } + else + { + self.noise = "player/agdie4.wav"; + } + } + } + if ((self.deathsound == "")) + { + if ((r < 0.5)) + { + self.noise = "player/teledth1.wav"; + } + else + { + self.noise = "player/agdie4.wav"; + } + } + if ((self.deathsound == "")) + { + if ((r < 0.3)) + { + self.noise = "player/udeath.wav"; + } + else + { + if ((r < 0.6)) + { + self.noise = "player/agdie3.wav"; + } + else + { + self.noise = "player/teledth1.wav"; + } + } + } + if ((self.deathsound == "")) + { + self.noise = "player/vaporized.wav"; + } + sound (self, CHAN_VOICE, self.noise, WEAPON_SHOTGUN, ATTN_NORM); + self.items = (self.items - (self.items & IT_INVISIBILITY)); + self.invisible_finished = 0; + self.invincible_finished = 0; + self.super_damage_finished = 0; + self.radsuit_finished = 0; + self.modelindex = modelindex_player; + self.weaponmodel = ""; + self.view_ofs = '0 0 -8'; + self.deadflag = DEAD_DYING; + self.flags = (self.flags - (self.flags & FL_ONGROUND)); + self.movetype = MOVETYPE_TOSS; + if ((self.velocity_z < TE_LAVASPLASH)) + { + self.velocity_z = (self.velocity_z + (random () * 300)); + } + self.angles_x = 0; + self.angles_y = 0; + self.angles_z = 0; + i = (WEAPON_SHOTGUN + floor ((random () * WEAPON_ROCKET))); + self.angles_z = 0; + if (((self.position == WEAPON_SHOTGUN) || (self.position == WEAPON_SHOTGUN))) + { + player_diec1 (); + } + else + { + if ((self.health <= -40)) + { + player_dieb1 (); + } + else + { + player_diea1 (); + } + } +}; + +void () set_suicide_frame = +{ + self.frame = TE_LAVASPLASH; + self.solid = SOLID_NOT; + self.movetype = MOVETYPE_TOSS; + self.deadflag = DEAD_DEAD; + self.nextthink = CONTENT_EMPTY; +}; + +void () player_diea1 = [ 1, player_diea2 ] +{ +}; + +void () player_diea2 = [ 2, player_diea3 ] +{ +}; + +void () player_diea3 = [ 3, player_diea4 ] +{ +}; + +void () player_diea4 = [ 4, player_diea5 ] +{ +}; + +void () player_diea5 = [ 5, player_diea6 ] +{ +}; + +void () player_diea6 = [ 6, player_diea7 ] +{ +}; + +void () player_diea7 = [ 7, player_diea8 ] +{ +}; + +void () player_diea8 = [ 8, player_diea9 ] +{ +}; + +void () player_diea9 = [ 9, player_diea10 ] +{ +}; + +void () player_diea10 = [ 10, player_diea11 ] +{ +}; + +void () player_diea11 = [ 11, player_diea12 ] +{ +}; + +void () player_diea12 = [ 12, player_diea13 ] +{ +}; + +void () player_diea13 = [ 13, player_diea13 ] +{ + PlayerDead (); +}; + +void () player_dieb1 = [ 94, player_dieb2 ] +{ +}; + +void () player_dieb2 = [ 95, player_dieb3 ] +{ +}; + +void () player_dieb3 = [ 96, player_dieb4 ] +{ +}; + +void () player_dieb4 = [ 97, player_dieb5 ] +{ +}; + +void () player_dieb5 = [ 98, player_dieb6 ] +{ +}; + +void () player_dieb6 = [ 99, player_dieb7 ] +{ +}; + +void () player_dieb7 = [ 100, player_dieb8 ] +{ +}; + +void () player_dieb8 = [ 101, player_dieb9 ] +{ +}; + +void () player_dieb9 = [ 102, player_dieb10 ] +{ +}; + +void () player_dieb10 = [ 103, player_dieb11 ] +{ +}; + +void () player_dieb11 = [ 104, player_dieb12 ] +{ +}; + +void () player_dieb12 = [ 105, player_dieb13 ] +{ +}; + +void () player_dieb13 = [ 106, player_dieb13 ] +{ + PlayerDead (); +}; + +void () player_diec1 = [ 55, player_diec2 ] +{ +}; + +void () player_diec2 = [ 56, player_diec3 ] +{ +}; + +void () player_diec3 = [ 57, player_diec4 ] +{ +}; + +void () player_diec4 = [ 58, player_diec5 ] +{ +}; + +void () player_diec5 = [ 59, player_diec6 ] +{ +}; + +void () player_diec6 = [ 60, player_diec7 ] +{ +}; + +void () player_diec7 = [ 61, player_diec8 ] +{ +}; + +void () player_diec8 = [ 62, player_diec9 ] +{ +}; + +void () player_diec9 = [ 63, player_diec10 ] +{ +}; + +void () player_diec10 = [ 64, player_diec11 ] +{ +}; + +void () player_diec11 = [ 65, player_diec12 ] +{ +}; + +void () player_diec12 = [ 66, player_diec13 ] +{ +}; + +void () player_diec13 = [ 67, player_diec13 ] +{ + PlayerDead (); +}; diff --git a/quakec/fallout2/progs.src b/quakec/fallout2/progs.src new file mode 100644 index 000000000..39d4c5606 --- /dev/null +++ b/quakec/fallout2/progs.src @@ -0,0 +1,32 @@ +../qwprogs.dat + +defs.qc +subs.qc +fight.qc + +ai.qc +combat.qc +items.qc +menus.qc +weapons.qc +world.qc +client.qc +server.qc +player.qc +monsters.qc +doors.qc +buttons.qc +triggers.qc +plats.qc +hos.qc +zombie.qc +enforcer.qc +soldier.qc +demon.qc +boss.qc +knight.qc +wizard.qc +dog.qc +ogre.qc +misc.qc +modbuy.qc diff --git a/quakec/fallout2/server.qc b/quakec/fallout2/server.qc new file mode 100644 index 000000000..465bf4e8b --- /dev/null +++ b/quakec/fallout2/server.qc @@ -0,0 +1,84 @@ + +void() monster_tarbaby = {remove(self);}; +void() monster_oldone = {remove(self);}; +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. + +targetname +must be present. The name of this movetarget. + +target +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 + +============================================================================== +*/ + +/* +============= +t_movetarget + +Something has bumped into a movetarget. If it is a monster +moving towards it, change the next destination and continue. +============== + +void() t_movetarget = +{ +local entity temp; + + if (other.movetarget != self) + return; + + if (other.enemy) + return; // fighting, not following a path + + temp = self; + self = other; + other = temp; + + if (self.classname == "monster_ogre") + sound (self, CHAN_VOICE, "ogre/ogdrag.wav", 1, ATTN_IDLE);// play chainsaw drag sound + +//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.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) +Monsters will continue walking towards the next target corner. + +void() path_corner = +{ + movetarget_f (); +};*/ + + + +//============================================================================ diff --git a/quakec/fallout2/soldier.qc b/quakec/fallout2/soldier.qc new file mode 100644 index 000000000..8b0d9e5e8 --- /dev/null +++ b/quakec/fallout2/soldier.qc @@ -0,0 +1,1408 @@ +void () army_load1; + +//PISTOL +void (float var, float dam) army_fire = +{ + local vector src; + local vector dir; + local vector direction; + local entity en; + local float var; + local float r; + local vector targ; + local vector org; + local vector org2; + local float zdif; + local float ydif; + local float xdif; + local float true; + local float zdif; + + if (self.enemy.sneak == 1) + var = var * 2; + + if (self.mag1 == 0) + { + sound (self, CHAN_WEAPON, "misc/greload.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + army_load1(); + self.mag1 = self.maxmag1; + return; + } + + self.mag1 = self.mag1 - 1; + + + makevectors (self.angles); + + sound (self, CHAN_WEAPON, "weapons/1911.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + + src = self.origin + v_forward*10; + src_z = self.absmin_z + self.size_z * 0.7; + + en = self.enemy; + + dir = en.origin - en.velocity*0.2; + dir = normalize (dir - self.origin); + + direction = dir; + + traceline (src, src + direction*2048 + v_right*crandom()*var + v_up*crandom()*var, FALSE, self); + + if (trace_fraction == PLAT_LOW_TRIGGER) + return; + + if (trace_ent.takedamage) + { + dam = 1 + random()*dam + random()*dam; + dam = dam * (1 - (trace_fraction/2)); + SpawnBlood (org, PLAT_LOW_TRIGGER); + T_Damage (trace_ent, self, self, dam); + } + else + { + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SPIKE); + WriteCoord (MSG_MULTICAST, trace_endpos_x); + WriteCoord (MSG_MULTICAST, trace_endpos_y); + WriteCoord (MSG_MULTICAST, trace_endpos_z); + multicast (trace_endpos, MULTICAST_PVS); + } +}; + + +//RIFLE +void (float var, float dam) army_fire1 = +{ + local vector src; + local vector dir; + local vector direction; + local entity en; + local float var; + local float r; + local vector targ; + local vector org; + local vector org2; + local float zdif; + local float ydif; + local float xdif; + local float true; + local float zdif; + + if (self.enemy.sneak == 1) + var = var * 2; + + if (self.mag1 == 0) + { + sound (self, CHAN_WEAPON, "misc/greload.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + army_load1(); + self.mag1 = self.maxmag1; + return; + } + + self.mag1 = self.mag1 - 1; + + makevectors (self.angles); + + sound (self, CHAN_WEAPON, "weapons/rangem.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + + src = self.origin + v_forward*10; + src_z = self.absmin_z + self.size_z * 0.7; + + en = self.enemy; + + dir = en.origin - en.velocity*0.2; + dir = normalize (dir - self.origin); + + direction = dir; + + traceline (src, src + direction*2048 + v_right*crandom()*100 + v_up*crandom()*100, FALSE, self); + + if (trace_fraction == PLAT_LOW_TRIGGER) + return; + + if (trace_ent.takedamage) + { + SpawnBlood (org, PLAT_LOW_TRIGGER); + dam = 10 + random()*dam + random()*dam; + dam = dam * (1 - (trace_fraction/2)); + T_Damage (trace_ent, self, self, dam); + } + else + { + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SPIKE); + WriteCoord (MSG_MULTICAST, trace_endpos_x); + WriteCoord (MSG_MULTICAST, trace_endpos_y); + WriteCoord (MSG_MULTICAST, trace_endpos_z); + multicast (trace_endpos, MULTICAST_PVS); + } +}; + + +//SHOTGUN +void (float var, float dam) army_fire2 = +{ + local vector src; + local vector dir; + local vector direction; + local entity en; + local float var; + local float r; + local vector targ; + local vector org; + local vector org2; + local float var_u, var_r, var_o; + local float shot; + local float dif; + + if (self.enemy.sneak == 1) + var = var * 2; + + if (self.mag1 == 0) + { + sound (self, CHAN_WEAPON, "misc/greload.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + army_load1(); + self.mag1 = self.maxmag1; + return; + } + + self.mag1 = self.mag1 - 1; + + makevectors (self.angles); + + sound (self, CHAN_WEAPON, "weapons/shotgun2.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + + src = self.origin + v_forward*10; + src_z = self.absmin_z + self.size_z * 0.7; + + en = self.enemy; + + dir = en.origin - en.velocity*0.2; + dir = normalize (dir - self.origin); + + direction = dir; + + shot = 5; + var_o = crandom()*50; + + while (shot > 0) + { + if (shot == 5) + { + var_r = 30; + var_u = 30; + } + if (shot == 4) + { + var_r = -30; + var_u = 30; + } + if (shot == 3) + { + var_r = 30; + var_u = -30; + } + if (shot == 2) + { + var_r = -30; + var_u = -30; + } + if (shot == 1) + { + var_r = 0; + var_u = 0; + } + + traceline (src, src + direction*2048 + v_right*(var_o+var_r) + v_up*(var_o+var_u), FALSE, self); + + shot = (shot - 1); + + if (trace_fraction == PLAT_LOW_TRIGGER) + return; + + if (trace_ent.takedamage) + { + SpawnBlood (org, PLAT_LOW_TRIGGER); + dam = 1 + random()*dam + random()*dam; + dam = dam * (1 - (trace_fraction/2)); + T_Damage (trace_ent, self, self, dam); + } + else + { + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SPIKE); + WriteCoord (MSG_MULTICAST, trace_endpos_x); + WriteCoord (MSG_MULTICAST, trace_endpos_y); + WriteCoord (MSG_MULTICAST, trace_endpos_z); + multicast (trace_endpos, MULTICAST_PVS); + } + } +}; + +//SMG +void (float var, float dam) army_fire3 = +{ + local vector src; + local vector dir; + local vector direction; + local entity en; + local float var; + local float r; + local vector targ; + local vector org; + local vector org2; + local float zdif; + local float ydif; + local float xdif; + local float true; + local float zdif; + + if (self.mag1 == 0) + { + sound (self, CHAN_WEAPON, "misc/greload.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + army_load1(); + self.mag1 = self.maxmag1; + return; + } + + if (self.enemy.sneak == 1) + var = var * 2; + + self.mag1 = self.mag1 - 1; + + makevectors (self.angles); + + src = self.origin + v_forward*10; + src_z = self.absmin_z + self.size_z * 0.7; + + en = self.enemy; + + dir = en.origin - en.velocity*0.2; + dir = normalize (dir - self.origin); + + direction = dir; + + traceline (src, src + direction*1024 + v_right*crandom()*var + v_up*crandom()*var, FALSE, self); + + if (trace_fraction == PLAT_LOW_TRIGGER) + return; + + if (trace_ent.takedamage) + { + SpawnBlood (org, PLAT_LOW_TRIGGER); + dam = 1 + random()*dam + random()*dam; + dam = dam * (1 - (trace_fraction/2)); + T_Damage (trace_ent, self, self, dam); + } + else + { + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SPIKE); + WriteCoord (MSG_MULTICAST, trace_endpos_x); + WriteCoord (MSG_MULTICAST, trace_endpos_y); + WriteCoord (MSG_MULTICAST, trace_endpos_z); + multicast (trace_endpos, MULTICAST_PVS); + } +}; + +//Assault Rifle +void (float var, float dam) army_fire4 = +{ + local vector src; + local vector dir; + local vector direction; + local entity en; + local float var; + local float r; + local vector targ; + local vector org; + local vector org2; + local float zdif; + local float ydif; + local float xdif; + local float true; + local float shot_num; + + if (self.mag1 == 0) + { + sound (self, CHAN_WEAPON, "misc/greload.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + army_load1(); + self.mag1 = self.maxmag1; + return; + } + + if (self.enemy.sneak == 1) + var = var * 2; + + self.mag1 = self.mag1 - 1; + + makevectors (self.angles); + + src = self.origin + v_forward*10; + src_z = self.absmin_z + self.size_z * 0.7; + + en = self.enemy; + + dir = en.origin - en.velocity*0.2; + dir = normalize (dir - self.origin); + + direction = dir; + + traceline (src, src + direction*2048 + v_right*crandom()*var + v_up*crandom()*var, FALSE, self); + + if (trace_fraction == PLAT_LOW_TRIGGER) + return; + + if (trace_ent.takedamage) + { + SpawnBlood (org, PLAT_LOW_TRIGGER); + dam = 1 + random()*dam + random()*dam; + dam = dam * (1 - (trace_fraction/2)); + T_Damage (trace_ent, self, self, dam); + } + else + { + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SPIKE); + WriteCoord (MSG_MULTICAST, trace_endpos_x); + WriteCoord (MSG_MULTICAST, trace_endpos_y); + WriteCoord (MSG_MULTICAST, trace_endpos_z); + multicast (trace_endpos, MULTICAST_PVS); + } +}; + + +void () army_load1 = [ 29, army_load2 ] +{ + ai_stand (); +}; +void () army_load2 = [ 29, army_load3 ] +{ + ai_stand (); +}; +void () army_load3 = [ 30, army_load4 ] +{ + ai_stand (); +}; +void () army_load4 = [ 30, army_load5 ] +{ + ai_stand (); +}; +void () army_load5 = [ 31, army_load6 ] +{ + ai_stand (); +}; +void () army_load6 = [ 31, army_load7 ] +{ + ai_stand (); +}; +void () army_load7 = [ 32, army_load8 ] +{ + ai_stand (); +}; +void () army_load8 = [ 32, army_load9 ] +{ + ai_stand (); +}; +void () army_load9 = [ 33, army_load10 ] +{ + ai_stand (); +}; +void () army_load10 = [ 33, army_load11 ] +{ + ai_stand (); +}; +void () army_load11 = [ 34, army_load12 ] +{ + ai_stand (); +}; + +void () army_load12 = [ 34, army_load13 ] +{ + ai_stand (); +}; +void () army_load13 = [ 35, army_load14 ] +{ + ai_stand (); +}; +void () army_load14 = [ 35, army_load15 ] +{ + ai_stand (); +}; +void () army_load15 = [ 36, army_load16 ] +{ + ai_stand (); +}; +void () army_load16 = [ 36, army_load17 ] +{ + ai_stand (); +}; +void () army_load17 = [ 37, army_load18 ] +{ + ai_stand (); +}; +void () army_load18 = [ 37, army_load19 ] +{ + ai_stand (); +}; +void () army_load19 = [ 38, army_load20 ] +{ + ai_stand (); +}; +void () army_load20 = [ 38, army_load21 ] +{ + ai_stand (); +}; +void () army_load21 = [ 39, army_load22 ] +{ + ai_stand (); +}; +void () army_load22 = [ 39, army_run1 ] +{ + ai_stand (); +}; + +void () army_stand1 = [ 0, army_stand2 ] +{ + ai_stand (); +}; + +void () army_stand2 = [ 1, army_stand3 ] +{ + ai_stand (); +}; + +void () army_stand3 = [ 2, army_stand4 ] +{ + ai_stand (); +}; + +void () army_stand4 = [ 3, army_stand5 ] +{ + ai_stand (); +}; + +void () army_stand5 = [ 4, army_stand6 ] +{ + ai_stand (); +}; + +void () army_stand6 = [ 5, army_stand7 ] +{ + ai_stand (); +}; + +void () army_stand7 = [ 6, army_stand8 ] +{ + ai_stand (); +}; + +void () army_stand8 = [ 7, army_stand1 ] +{ + ai_stand (); +}; + +void () army_walk1 = [ 73, army_walk2 ] +{ + ai_walk (TE_TELEPORT); +}; + +void () army_walk2 = [ 74, army_walk3 ] +{ + ai_walk (15); +}; + +void () army_walk3 = [ 75, army_walk4 ] +{ + ai_walk (TE_LAVASPLASH); +}; + +void () army_walk4 = [ 76, army_walk5 ] +{ + ai_walk (TE_LAVASPLASH); +}; + +void () army_walk5 = [ 77, army_walk6 ] +{ + ai_walk (SECRET_NO_SHOOT); +}; + +void () army_walk6 = [ 78, army_walk7 ] +{ + ai_walk (15); +}; + +void () army_walk7 = [ 79, army_walk8 ] +{ + ai_walk (TE_LAVASPLASH); +}; + +void () army_walk8 = [ 80, army_walk1 ] +{ + ai_walk (SECRET_NO_SHOOT); +}; + +void () army_run1 = [ 73, army_run2 ] +{ + + ai_run (TE_TELEPORT); +}; + +void () army_run2 = [ 74, army_run3 ] +{ + ai_run (15); +}; + +void () army_run3 = [ 75, army_run4 ] +{ + if (self.active == 1) + self.action_points = self.action_points - 1; + + ai_run (TE_LAVASPLASH); +}; + +void () army_run4 = [ 76, army_run5 ] +{ + ai_run (TE_LAVASPLASH); +}; + +void () army_run5 = [ 77, army_run6 ] +{ + ai_run (SECRET_NO_SHOOT); +}; + +void () army_run6 = [ 78, army_run7 ] +{ + ai_run (15); +}; + +void () army_run7 = [ 79, army_run8 ] +{ + ai_run (TE_LAVASPLASH); +}; + +void () army_run8 = [ 80, army_run1 ] +{ + ai_run (SECRET_NO_SHOOT); +}; + +void () army_atk1 = [ 81, army_atk2 ] +{ + ai_face (); +}; + +void () army_atk2 = [ 82, army_atk3 ] +{ + ai_face (); +}; + +void () army_atk3 = [ 83, army_atk4 ] +{ + ai_face (); +}; + +void () army_atk4 = [ 84, army_atk5 ] +{ + ai_face (); +}; + +void () army_atk5 = [ 85, army_atk6 ] +{ + ai_face (); +}; + +void () army_atk6 = [ 86, army_atk7 ] +{ + ai_face (); +}; + +void () army_atk7 = [ 87, army_atk8 ] +{ + ai_face (); + army_fire (120, 14); +}; + +void () army_atk8 = [ 88, army_atk9 ] +{ + ai_face (); +}; + +void () army_atk9 = [ 89, army_run1 ] +{ + ai_face (); +}; + +void () army_atka1 = [ 81, army_atka2 ] +{ + ai_face (); +}; + +void () army_atka2 = [ 82, army_atka3 ] +{ + ai_face (); +}; + +void () army_atka3 = [ 83, army_atka4 ] +{ + ai_face (); +}; + +void () army_atka4 = [ 84, army_atka5 ] +{ + ai_face (); +}; + +void () army_atka5 = [ 85, army_atka6 ] +{ + ai_face (); + army_fire2 (200, 4); +}; + +void () army_atka6 = [ 86, army_atka7 ] +{ + ai_face (); +}; + +void () army_atka7 = [ 87, army_atka8 ] +{ + ai_face (); +}; + +void () army_atka8 = [ 88, army_atka9 ] +{ + ai_face (); +}; + +void () army_atka9 = [ 89, army_run1 ] +{ + ai_face (); +}; + +void () army_atkb1 = [ 81, army_atkb2 ] +{ + ai_face (); +}; + +void () army_atkb2 = [ 82, army_atkb4 ] +{ + ai_face (); +}; + +void () army_atkb3 = [ 83, army_atkb4 ] +{ + ai_face (); +}; + +void () army_atkb4 = [ 84, army_atkb5 ] +{ + ai_face (); +}; + +void () army_atkb5 = [ 85, army_atkb6 ] +{ + local float r; + + ai_face (); + r = range (self.enemy); + + self.recoil = 0; + + if (r == RANGE_NEAR || r == RANGE_MELEE) + self.recoil = 1; + + if (self.recoil == 1) + sound (self, CHAN_WEAPON, "weapons/burst.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + else + sound (self, CHAN_WEAPON, "weapons/mp7.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + + army_fire3 (150, 13); +}; + +void () army_atkb6 = [ 86, army_atkb7 ] +{ + ai_face (); + if (self.recoil == 1) + { + army_fire3 (170, 11); + army_fire3 (190, 9); + } +}; + +void () army_atkb7 = [ 87, army_atkb8 ] +{ + ai_face (); + if (self.recoil == 1) + army_fire3 (210, 11); +}; + +void () army_atkb8 = [ 88, army_atkb9 ] +{ + ai_face (); + if (self.recoil == 1) + { + army_fire3 (230, 11); + army_fire3 (250, 9); + } +}; + +void () army_atkb9 = [ 89, army_run1 ] +{ + ai_face (); + if (self.recoil == 1) + { + army_fire3 (270, 11); + army_fire3 (290, 9); + } +}; + +void () army_atkcs1 = [ 81, army_atkcs2 ] +{ + ai_face (); +}; + +void () army_atkcs2 = [ 82, army_atkcs3 ] +{ + ai_face (); +}; + +void () army_atkcs3 = [ 83, army_atkcs4 ] +{ + ai_face (); +}; + +void () army_atkcs4 = [ 84, army_atkcs5 ] +{ + ai_face (); +}; + +void () army_atkcs5 = [ 85, army_atkcs6 ] +{ + local float r; + + ai_face (); + sound (self, CHAN_WEAPON, "weapons/ak112.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + army_fire4 (100, 16); +}; + +void () army_atkcs6 = [ 85, army_atkcs7 ] +{ + + ai_face (); +}; + +void () army_atkcs7 = [ 87, army_atkcs8 ] +{ + + ai_face (); +}; + +void () army_atkcs8 = [ 88, army_atkcs9 ] +{ + + ai_face (); +}; + +void () army_atkcs9 = [ 89, army_run1 ] +{ + ai_face (); +}; + +void () army_atkc1 = [ 81, army_atkc2 ] +{ + ai_face (); +}; + +void () army_atkc2 = [ 82, army_atkc3 ] +{ + ai_face (); +}; + +void () army_atkc3 = [ 83, army_atkc4 ] +{ + ai_face (); +}; + +void () army_atkc4 = [ 84, army_atkc5 ] +{ + ai_face (); +}; + +void () army_assault_rifle = +{ + local float r; + + r = range (self.enemy); + + if (r == RANGE_FAR || r == RANGE_MID)//single shot at range + army_atkcs1(); + if (r == RANGE_NEAR || r == RANGE_MELEE)//open up when close + army_atkc1(); +}; + +void () army_atkc5 = [ 85, army_atkc6 ] +{ + ai_face (); + + sound (self, CHAN_WEAPON, "weapons/auto.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + army_fire4 (100, 16); +}; + +void () army_atkc6 = [ 84, army_atkc7 ] +{ + ai_face (); + army_fire4 (140, 16); +}; + +void () army_atkc7 = [ 85, army_atkc8 ] +{ + ai_face (); + army_fire4 (180, 16); +}; + +void () army_atkc8 = [ 84, army_atkc9 ] +{ + ai_face (); + army_fire4 (220, 16); +}; + +void () army_atkc9 = [ 85, army_atkc10 ] +{ + ai_face (); + army_fire4 (260, 16); +}; + +void () army_atkc10 = [ 84, army_atkc11 ] +{ + ai_face (); + army_fire4 (300, 16); +}; + +void () army_atkc11 = [ 85, army_atkc12 ] +{ + ai_face (); + army_fire4 (340, 16); +}; + +void () army_atkc12 = [ 84, army_atkc13 ] +{ + ai_face (); + army_fire4 (380, 16); +}; + +void () army_atkc13 = [ 86, army_atkc14 ] +{ + ai_face (); +}; + +void () army_atkc14 = [ 87, army_atkc15 ] +{ + ai_face (); +}; + +void () army_atkc15 = [ 88, army_atkc16 ] +{ + ai_face (); +}; + +void () army_atkc16 = [ 89, army_run1 ] +{ + ai_face (); +}; + +void () army_atkp1 = [ 81, army_atkp2 ] +{ + ai_face (); +}; + +void () army_atkp2 = [ 82, army_atkp3 ] +{ + ai_face (); +}; + +void () army_atkp3 = [ 83, army_atkp4 ] +{ + ai_face (); +}; + +void () army_atkp4 = [ 84, army_atkp5 ] +{ + ai_face (); +}; + +void () army_atkp5 = [ 85, army_atkp6 ] +{ + ai_face (); + army_fire1 (200, 15); +}; + +void () army_atkp6 = [ 86, army_atkp7 ] +{ + ai_face (); +}; + +void () army_atkp7 = [ 87, army_atkp8 ] +{ + ai_face (); +}; + +void () army_atkp8 = [ 88, army_atkp9 ] +{ + ai_face (); +}; + +void () army_atkp9 = [ 89, army_run1 ] +{ + ai_face (); +}; + +void () army_pain1 = [ 40, army_pain2 ] +{ +}; + +void () army_pain2 = [ 41, army_pain3 ] +{ +}; + +void () army_pain3 = [ 42, army_pain4 ] +{ +}; + +void () army_pain4 = [ 43, army_pain5 ] +{ +}; + +void () army_pain5 = [ 44, army_pain6 ] +{ +}; + +void () army_pain6 = [ 45, army_run1 ] +{ + ai_pain (PLAT_LOW_TRIGGER); +}; + +void () army_painb1 = [ 46, army_painb2 ] +{ +}; + +void () army_painb2 = [ 47, army_painb3 ] +{ + ai_painforward (TE_LIGHTNINGBLOOD); +}; + +void () army_painb3 = [ 48, army_painb4 ] +{ + ai_painforward (TE_LIGHTNING3); +}; + +void () army_painb4 = [ 49, army_painb5 ] +{ +}; + +void () army_painb5 = [ 50, army_painb6 ] +{ +}; + +void () army_painb6 = [ 51, army_painb7 ] +{ +}; + +void () army_painb7 = [ 52, army_painb8 ] +{ +}; + +void () army_painb8 = [ 53, army_painb9 ] +{ +}; + +void () army_painb9 = [ 54, army_painb10 ] +{ +}; + +void () army_painb10 = [ 55, army_painb11 ] +{ +}; + +void () army_painb11 = [ 56, army_painb12 ] +{ +}; + +void () army_painb12 = [ 57, army_painb13 ] +{ + ai_pain (SILENT); +}; + +void () army_painb13 = [ 58, army_painb14 ] +{ +}; + +void () army_painb14 = [ 59, army_run1 ] +{ +}; + +void () army_painc1 = [ 60, army_painc2 ] +{ +}; + +void () army_painc2 = [ 61, army_painc3 ] +{ + ai_pain (PLAT_LOW_TRIGGER); +}; + +void () army_painc3 = [ 62, army_painc4 ] +{ +}; + +void () army_painc4 = [ 63, army_painc5 ] +{ +}; + +void () army_painc5 = [ 64, army_painc6 ] +{ + ai_painforward (PLAT_LOW_TRIGGER); +}; + +void () army_painc6 = [ 65, army_painc7 ] +{ + ai_painforward (PLAT_LOW_TRIGGER); +}; + +void () army_painc7 = [ 66, army_painc8 ] +{ +}; + +void () army_painc8 = [ 67, army_painc9 ] +{ + ai_pain (PLAT_LOW_TRIGGER); +}; + +void () army_painc9 = [ 68, army_painc10 ] +{ + ai_painforward (SECRET_1ST_DOWN); +}; + +void () army_painc10 = [ 69, army_painc11 ] +{ + ai_painforward (AS_MELEE); +}; + +void () army_painc11 = [ 70, army_painc12 ] +{ + ai_painforward (TE_LIGHTNING2); +}; + +void () army_painc12 = [ 71, army_painc13 ] +{ + ai_painforward (SECRET_NO_SHOOT); +}; + +void () army_painc13 = [ 72, army_run1 ] +{ +}; + +void (entity attacker, float damage) army_pain = +{ + local float r; + + if ((self.pain_finished > time)) + { + return; + } + r = random (); + if ((r < 0.05)) + { + self.pain_finished = (time + 0.6); + army_pain1 (); + sound (self, CHAN_VOICE, "player/paina.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + } + else + { + if ((r < 0.1)) + { + self.pain_finished = (time + 1.1); + army_painb1 (); + sound (self, CHAN_VOICE, "player/painb.wav", PLAT_LOW_TRIGGER, ATTN_NORM); + } + } +}; + +void () army_die1 = [ 8, army_die2 ] +{ + + if (random()*4 <= 2) + sound (self, CHAN_VOICE, "player/agdie2.wav", 1, ATTN_NORM); + else + sound (self, CHAN_VOICE, "player/agdie3.wav", 1, ATTN_NORM); + +}; + +void () army_die2 = [ 9, army_die3 ] +{ + self.solid = SOLID_NOT; +}; + +void () army_die3 = [ 10, army_die4 ] +{ +}; + +void () army_die4 = [ 11, army_die5 ] +{ +}; + +void () army_die5 = [ 12, army_die6 ] +{ +}; + +void () army_die6 = [ 13, army_die7 ] +{ +}; + +void () army_die7 = [ 14, army_die8 ] +{ +}; + +void () army_die8 = [ 15, army_die9 ] +{ +}; + +void () army_die9 = [ 16, army_die10 ] +{ +}; + +void () army_die10 = [ 17, army_die10 ] +{ +}; + +void () army_cdie1 = [ 18, army_cdie2 ] +{ +}; + +void () army_cdie2 = [ 19, army_cdie3 ] +{ + self.solid = SOLID_NOT; + ai_back (MULTICAST_PVS_R); +}; + +void () army_cdie3 = [ 20, army_cdie4 ] +{ + ai_back (SECRET_1ST_DOWN); +}; + +void () army_cdie4 = [ 21, army_cdie5 ] +{ + ai_back (TE_LIGHTNINGBLOOD); +}; + +void () army_cdie5 = [ 22, army_cdie6 ] +{ + ai_back (AS_MELEE); +}; + +void () army_cdie6 = [ 23, army_cdie7 ] +{ + ai_back (SECRET_1ST_DOWN); +}; + +void () army_cdie7 = [ 24, army_cdie8 ] +{ +}; + +void () army_cdie8 = [ 25, army_cdie9 ] +{ +}; + +void () army_cdie9 = [ 26, army_cdie10 ] +{ +}; + +void () army_cdie10 = [ 27, army_cdie11 ] +{ +}; + +void () army_cdie11 = [ 28, army_cdie11 ] +{ +}; + + +void () grunt_pain = +{ + if (self.frame == 41) + { + self.frame = 42; + self.health = 180; + self.think = army_die1; + self.nextthink = time + 0.12; + } + else + { + ThrowGib ("progs/zom_gib.mdl", -40); + self.frame = 41; + self.health = 180; + self.think = army_cdie1; + self.nextthink = time + 0.12; + } + + self.attack = self.attack + 1; + + if (self.attack == 8) + { + if (random()*4 <= 2) + sound (self, CHAN_VOICE, "player/agdie1.wav", 1, ATTN_NORM); + else + sound (self, CHAN_VOICE, "player/agdie5.wav", 1, ATTN_NORM); + } + if (self.attack >= 16) + { + self.solid = SOLID_NOT; + + army_cdie1(); + ThrowGib ("progs/zom_gib.mdl", -35); + ThrowGib ("progs/zom_gib.mdl", -35); + ThrowGib ("progs/gib1.mdl", -35); + } +}; + +void (vector stuff, vector ang) spawn_live_grunt = +{ + local entity grunt; + local entity te; + + grunt = spawn (); + grunt.origin = stuff; + grunt.enemy = world; + grunt.attack_finished = time + 10; + grunt.solid = SOLID_SLIDEBOX; + grunt.movetype = MOVETYPE_STEP; + grunt.takedamage = DAMAGE_YES; + setmodel (grunt, "progs/soldier.mdl"); + setsize (grunt, VEC_HULL_MIN, '16 16 40'); + grunt.classname = "body"; + grunt.netname = "dead"; + grunt.health = 180; + grunt.angles = ang; + grunt.max_health = grunt.health; + grunt.th_pain = grunt_pain; + grunt.think = grunt_pain; + grunt.nextthink = time + 0.05; +}; + +void () army_die = +{ + DropBackpack (); + + if (self.health <= -35) + { + self.solid = SOLID_NOT; + sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); + army_die1 (); + } + else + { + self.solid = SOLID_NOT; + spawn_live_grunt(self.origin, self.angles); + remove(self); + } +}; + +void () monster_army = +{ + if (random()*10 <= 2) + { + precache_model2 ("progs/enforcer.mdl"); + precache_model2 ("progs/h_mega.mdl"); + precache_model2 ("progs/laser.mdl"); + + precache_sound2 ("enforcer/death1.wav"); + precache_sound2 ("enforcer/enfire.wav"); + precache_sound2 ("enforcer/enfstop.wav"); + precache_sound2 ("enforcer/idle1.wav"); + precache_sound2 ("enforcer/pain1.wav"); + precache_sound2 ("enforcer/pain2.wav"); + precache_sound2 ("enforcer/sight1.wav"); + precache_sound2 ("enforcer/sight2.wav"); + precache_sound2 ("enforcer/sight3.wav"); + precache_sound2 ("enforcer/sight4.wav"); + + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_STEP; + self.team = 3; + + setmodel (self, "progs/enforcer.mdl"); + self.classname = "monster"; + self.netname = "enforcer"; + + setsize (self, '-12 -12 -24', '12 12 32'); + self.health = 120; + self.armor = 5; + self.armortype = 35; + self.th_stand = enf_stand1; + self.th_walk = enf_walk1; + self.th_run = enf_run1; + self.th_pain = enf_pain; + self.th_die = enf_die; + self.th_missile = enf_atk1; + + walkmonster_start(); + if (random()*4 <= 2) + self.weapon = 5; + else + self.weapon = 6; + self.th_missile = enf_atk1; + self.mag1 = 24; + self.maxmag1 = self.mag1; + return; + } + + precache_model ("progs/soldier.mdl"); + precache_model ("progs/h_guard.mdl"); + precache_model ("progs/gib1.mdl"); + precache_model ("progs/gib2.mdl"); + precache_model ("progs/gib3.mdl"); + precache_sound ("soldier/death1.wav"); + precache_sound ("soldier/idle.wav"); + precache_sound ("soldier/pain1.wav"); + precache_sound ("soldier/pain2.wav"); + precache_sound ("soldier/sattck1.wav"); + precache_sound ("soldier/sight1.wav"); + precache_sound ("player/udeath.wav"); + + self.solid = SOLID_SLIDEBOX; + self.classname = "monster"; + self.netname = "raider"; + self.movetype = MOVETYPE_STEP; + setmodel (self, "progs/soldier.mdl"); + setsize (self, '-16 -16 -24', '16 16 32'); + self.health = 90; + self.team = 3; + self.armor = 2; + self.armortype = 0.2; + self.th_stand = army_stand1; + self.th_walk = army_walk1; + self.th_run = army_run1; + self.th_missile = army_atk1; + self.th_pain = army_pain; + self.th_die = army_die; + walkmonster_start (); + + self.weapon = ceil(random()*4); + + if (self.weapon == 1) + self.th_missile = army_atkp1; //pistol + if (self.weapon == 2) + self.th_missile = army_atk1; //rifle + if (self.weapon == 3) + self.th_missile = army_atka1; //shotgun + if (self.weapon == 4) + self.th_missile = army_atkb1; //smg + + if (self.weapon == 1) + self.mag1 = 12; + if (self.weapon == 2) + self.mag1 = 10; + if (self.weapon == 3) + self.mag1 = 6; + if (self.weapon == 4) + self.mag1 = 30; + + self.maxmag1 = self.mag1; +}; + diff --git a/quakec/fallout2/subs.qc b/quakec/fallout2/subs.qc new file mode 100644 index 000000000..3346c0dc4 --- /dev/null +++ b/quakec/fallout2/subs.qc @@ -0,0 +1,290 @@ + + +void() SUB_Null = {}; + +void() SUB_Remove = {remove(self);}; + + +void(float normal) SUB_AttackFinished = +{ + self.cnt = 0; // refire count for nightmare + self.attack_finished = time + normal; +}; + +/* +QuakeEd only writes a single float for angles (bad idea), so up and down are +just constant angles. +*/ +vector() SetMovedir = +{ + if (self.angles == '0 -1 0') + self.movedir = '0 0 1'; + else if (self.angles == '0 -2 0') + self.movedir = '0 0 -1'; + else + { + makevectors (self.angles); + self.movedir = v_forward; + } + + self.angles = '0 0 0'; +}; + +/* +================ +InitTrigger +================ +*/ +void() InitTrigger = +{ +// trigger angles are used for one-way touches. An angle of 0 is assumed +// to mean no restrictions, so use a yaw of 360 instead. + if (self.angles != '0 0 0') + SetMovedir (); + self.solid = SOLID_TRIGGER; + setmodel (self, self.model); // set size and link into world + self.movetype = MOVETYPE_NONE; + self.modelindex = 0; + self.model = ""; +}; + +/* +============= +SUB_CalcMove + +calculate self.velocity and self.nextthink to reach dest from +self.origin traveling at speed +=============== +*/ +void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt = +{ +local entity stemp; + stemp = self; + self = ent; + + SUB_CalcMove (tdest, tspeed, func); + self = stemp; +}; + +void(vector tdest, float tspeed, void() func) SUB_CalcMove = +{ +local vector vdestdelta; +local float len, traveltime; + + if (!tspeed) + objerror("No speed is defined!"); + + self.think1 = func; + self.finaldest = tdest; + self.think = SUB_CalcMoveDone; + + if (tdest == self.origin) + { + self.velocity = '0 0 0'; + self.nextthink = self.ltime + 0.1; + return; + } + +// set destdelta to the vector needed to move + vdestdelta = tdest - self.origin; + +// calculate length of vector + len = vlen (vdestdelta); + +// 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 + 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 +}; + +/* +============ +After moving, set origin to exact final destination +============ +*/ +void() SUB_CalcMoveDone = +{ + setorigin(self, self.finaldest); + self.velocity = '0 0 0'; + self.nextthink = -1; + if (self.think1) + self.think1(); +}; + + +/* +============= +SUB_CalcAngleMove + +calculate self.avelocity and self.nextthink to reach destangle from +self.angles rotating + +The calling function should make sure self.think is valid +=============== +*/ +void(entity ent, vector destangle, float tspeed, void() func) SUB_CalcAngleMoveEnt = +{ +local entity stemp; + stemp = self; + self = ent; + SUB_CalcAngleMove (destangle, tspeed, func); + self = stemp; +}; + +void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove = +{ +local vector destdelta; +local float len, traveltime; + + if (!tspeed) + objerror("No speed is defined!"); + +// set destdelta to the vector needed to move + destdelta = destangle - self.angles; + +// calculate length of vector + len = vlen (destdelta); + +// divide by speed to get time to reach dest + traveltime = len / tspeed; + +// 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.avelocity = destdelta * (1 / traveltime); + + self.think1 = func; + self.finalangle = destangle; + self.think = SUB_CalcAngleMoveDone; +}; + +/* +============ +After rotating, set angle to exact final angle +============ +*/ +void() SUB_CalcAngleMoveDone = +{ + self.angles = self.finalangle; + self.avelocity = '0 0 0'; + self.nextthink = -1; + if (self.think1) + self.think1(); +}; + + +//============================================================================= + +void() DelayThink = +{ + activator = self.enemy; + SUB_UseTargets (); + remove(self); +}; + +/* +============================== +SUB_UseTargets + +the global "activator" should be set to the entity that initiated the firing. + +If self.delay is set, a DelayedUse entity will be created that will actually +do the SUB_UseTargets after that many seconds have passed. + +Centerprints any self.message to the activator. + +Removes all entities with a targetname that match self.killtarget, +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(); + t.classname = "DelayedUse"; + t.nextthink = time + self.delay; + t.think = DelayThink; + t.enemy = activator; + t.message = self.message; + t.killtarget = self.killtarget; + t.target = self.target; + return; + } + + +// +// 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) + { + t = world; + do + { + t = find (t, targetname, self.killtarget); + if (!t) + return; + remove (t); + } while ( 1 ); + } + +// +// fire targets +// + if (self.target) + { + act = activator; + t = world; + 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) + self.use (); + } + self = stemp; + other = otemp; + activator = act; + } while ( 1 ); + } + + +}; + diff --git a/quakec/fallout2/triggers.qc b/quakec/fallout2/triggers.qc new file mode 100644 index 000000000..b428ca8dd --- /dev/null +++ b/quakec/fallout2/triggers.qc @@ -0,0 +1,646 @@ + +entity stemp, otemp, s, old; + + +void() trigger_reactivate = +{ + self.solid = SOLID_TRIGGER; +}; + +//============================================================================= + +float SPAWNFLAG_NOMESSAGE = 1; +float SPAWNFLAG_NOTOUCH = 1; + +// the wait time has passed, so set back up for another activation +void() multi_wait = +{ + if (self.max_health) + { + self.health = self.max_health; + self.takedamage = DAMAGE_YES; + self.solid = SOLID_BBOX; + } +}; + + +// the trigger was just touched/killed/used +// self.enemy should be set to the activator so it can be held through a delay +// so wait for the delay time before firing +void() multi_trigger = +{ + if (self.nextthink > time) + { + return; // allready been triggered + } + + if (self.classname == "trigger_secret") + { + if (self.enemy.classname != "player") + return; + found_secrets = found_secrets + 1; + WriteByte (MSG_ALL, SVC_FOUNDSECRET); + } + + if (self.noise) + sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM); + +// don't trigger again until reset + self.takedamage = DAMAGE_NO; + + activator = self.enemy; + + SUB_UseTargets(); + + if (self.wait > 0) + { + self.think = multi_wait; + self.nextthink = time + self.wait; + } + else + { // we can't just remove (self) here, because this is a touch function + // called wheil C code is looping through area links... + self.touch = SUB_Null; + self.nextthink = time + 0.1; + self.think = SUB_Remove; + } +}; + +void() multi_killed = +{ + self.enemy = damage_attacker; + multi_trigger(); +}; + +void() multi_use = +{ + self.enemy = activator; + multi_trigger(); +}; + +void() multi_touch = +{ + if (other.classname != "player") + return; + +// if the trigger has an angles field, check player's facing direction + if (self.movedir != '0 0 0') + { + makevectors (other.angles); + if (v_forward * self.movedir < 0) + return; // not facing the right way + } + + self.enemy = other; + multi_trigger (); +}; + +/*QUAKED trigger_multiple (.5 .5 .5) ? notouch +Variable sized repeatable trigger. Must be targeted at one or more entities. If "health" is set, the trigger must be killed to activate each time. +If "delay" is set, the trigger waits some time after activating before firing. +"wait" : Seconds between triggerings. (.2 default) +If notouch is set, the trigger is only fired by other entities, not by touching. +NOTOUCH has been obsoleted by trigger_relay! +sounds +1) secret +2) beep beep +3) large switch +4) +set "message" to text string +*/ +void() trigger_multiple = +{ + if (self.sounds == 1) + { + precache_sound ("misc/secret.wav"); + self.noise = "misc/secret.wav"; + } + else if (self.sounds == 2) + { + precache_sound ("misc/talk.wav"); + self.noise = "misc/talk.wav"; + } + else if (self.sounds == 3) + { + precache_sound ("misc/trigger1.wav"); + self.noise = "misc/trigger1.wav"; + } + + if (!self.wait) + self.wait = 0.2; + self.use = multi_use; + + InitTrigger (); + + if (self.health) + { + if (self.spawnflags & SPAWNFLAG_NOTOUCH) + objerror ("health and notouch don't make sense\n"); + self.max_health = self.health; + self.th_die = multi_killed; + self.takedamage = DAMAGE_YES; + self.solid = SOLID_BBOX; + setorigin (self, self.origin); // make sure it links into the world + } + else + { + if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) ) + { + self.touch = multi_touch; + } + } +}; + + +/*QUAKED trigger_once (.5 .5 .5) ? notouch +Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching +"targetname". If "health" is set, the trigger must be killed to activate. +If notouch is set, the trigger is only fired by other entities, not by touching. +if "killtarget" is set, any objects that have a matching "target" will be removed when the trigger is fired. +if "angle" is set, the trigger will only fire when someone is facing the direction of the angle. Use "360" for an angle of 0. +sounds +1) secret +2) beep beep +3) large switch +4) +set "message" to text string +*/ +void() trigger_once = +{ + self.wait = -1; + trigger_multiple(); +}; + +//============================================================================= + +/*QUAKED trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8) +This fixed size trigger cannot be touched, it can only be fired by other events. It can contain killtargets, targets, delays, and messages. +*/ +void() trigger_relay = +{ + self.use = SUB_UseTargets; +}; + + +//============================================================================= + +/*QUAKED trigger_secret (.5 .5 .5) ? +secret counter trigger +sounds +1) secret +2) beep beep +3) +4) +set "message" to text string +*/ +void() trigger_secret = +{ + total_secrets = total_secrets + 1; + self.wait = -1; + if (!self.message) + self.message = "You found a secret area!"; + if (!self.sounds) + self.sounds = 1; + + if (self.sounds == 1) + { + precache_sound ("misc/secret.wav"); + self.noise = "misc/secret.wav"; + } + else if (self.sounds == 2) + { + precache_sound ("misc/talk.wav"); + self.noise = "misc/talk.wav"; + } + + trigger_multiple (); +}; + +//============================================================================= + + +void() counter_use = +{ + local string junk; + + self.count = self.count - 1; + if (self.count < 0) + return; + + if (self.count != 0) + { + if (activator.classname == "player" + && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0) + { + if (self.count >= 4) + centerprint (activator, "There are more to go..."); + else if (self.count == 3) + centerprint (activator, "Only 3 more to go..."); + else if (self.count == 2) + centerprint (activator, "Only 2 more to go..."); + else + centerprint (activator, "Only 1 more to go..."); + } + return; + } + + if (activator.classname == "player" + && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0) + centerprint(activator, "Sequence completed!"); + self.enemy = activator; + multi_trigger (); +}; + +/*QUAKED trigger_counter (.5 .5 .5) ? nomessage +Acts as an intermediary for an action that takes multiple inputs. + +If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished. + +After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself. +*/ +void() trigger_counter = +{ + self.wait = -1; + if (!self.count) + self.count = 2; + + self.use = counter_use; +}; + + +/* +============================================================================== + +TELEPORT TRIGGERS + +============================================================================== +*/ + +float PLAYER_ONLY = 1; +float SILENT = 2; + +void() play_teleport = +{ + local float v; + local string tmpstr; + + v = random() * 5; + if (v < 1) + tmpstr = "misc/r_tele1.wav"; + else if (v < 2) + tmpstr = "misc/r_tele2.wav"; + else if (v < 3) + tmpstr = "misc/r_tele3.wav"; + else if (v < 4) + tmpstr = "misc/r_tele4.wav"; + else + tmpstr = "misc/r_tele5.wav"; + + sound (self, CHAN_VOICE, tmpstr, 1, ATTN_NORM); + remove (self); +}; + +void(vector org) spawn_tfog = +{ + s = spawn (); + s.origin = org; + 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); + multicast (org, MULTICAST_PHS); +}; + + +void() tdeath_touch = +{ + local entity other2; + + if (other == self.owner) + return; + +// frag anyone who teleports in on top of an invincible player + if (other.classname == "player") + { + if (other.invincible_finished > time && + self.owner.invincible_finished > time) { + self.classname = "teledeath3"; + other.invincible_finished = 0; + self.owner.invincible_finished = 0; + T_Damage (other, self, self, 50000); + other2 = self.owner; + self.owner = other; + T_Damage (other2, self, self, 50000); + } + + if (other.invincible_finished > time) + { + self.classname = "teledeath2"; + T_Damage (self.owner, self, self, 50000); + return; + } + + } + + if (other.health) + { + T_Damage (other, self, self, 50000); + } +}; + + +void(vector org, entity death_owner) spawn_tdeath = +{ +local entity death; + + death = spawn(); + death.classname = "teledeath"; + death.movetype = MOVETYPE_NONE; + death.solid = SOLID_TRIGGER; + death.angles = '0 0 0'; + setsize (death, death_owner.mins - '1 1 1', death_owner.maxs + '1 1 1'); + setorigin (death, org); + death.touch = tdeath_touch; + death.nextthink = time + 0.2; + death.think = SUB_Remove; + death.owner = death_owner; + + force_retouch = 2; // make sure even still objects get hit +}; + +void() teleport_touch = +{ +local entity t; +local vector org; + + if (self.targetname) + { + if (self.nextthink < time) + { + return; // not fired yet + } + } + + if (self.spawnflags & PLAYER_ONLY) + { + if (other.classname != "player") + return; + } + +// only teleport living creatures + if (other.health <= 0 || other.solid != SOLID_SLIDEBOX) + return; + + SUB_UseTargets (); + +// put a tfog where the player was + spawn_tfog (other.origin); + + t = find (world, targetname, self.target); + if (!t) + objerror ("couldn't find target"); + +// spawn a tfog flash in front of the destination + makevectors (t.mangle); + org = t.origin + 32 * v_forward; + + spawn_tfog (org); + spawn_tdeath(t.origin, other); + +// move the player and lock him down for a little while + if (!other.health) + { + other.origin = t.origin; + other.velocity = (v_forward * other.velocity_x) + (v_forward * other.velocity_y); + return; + } + + setorigin (other, t.origin); + other.angles = t.mangle; + if (other.classname == "player") + { + other.fixangle = 1; // turn this way immediately + other.teleport_time = time + 0.7; + if (other.flags & FL_ONGROUND) + other.flags = other.flags - FL_ONGROUND; + other.velocity = v_forward * 300; + } + other.flags = other.flags - other.flags & FL_ONGROUND; +}; + +/*QUAKED info_teleport_destination (.5 .5 .5) (-8 -8 -8) (8 8 32) +This is the destination marker for a teleporter. It should have a "targetname" field with the same value as a teleporter's "target" field. +*/ +void() info_teleport_destination = +{ +// this does nothing, just serves as a target spot + self.mangle = self.angles; + self.angles = '0 0 0'; + self.model = ""; + self.origin = self.origin + '0 0 27'; + if (!self.targetname) + objerror ("no targetname"); +}; + +void() teleport_use = +{ + self.nextthink = time + 0.2; + force_retouch = 2; // make sure even still objects get hit + self.think = SUB_Null; +}; + +/*QUAKED trigger_teleport (.5 .5 .5) ? PLAYER_ONLY SILENT +Any object touching this will be transported to the corresponding info_teleport_destination entity. You must set the "target" field, and create an object with a "targetname" field that matches. + +If the trigger_teleport has a targetname, it will only teleport entities when it has been fired. +*/ +void() trigger_teleport = +{ + local vector o; + + InitTrigger (); + self.touch = teleport_touch; + // find the destination + if (!self.target) + objerror ("no target"); + self.use = teleport_use; + + if (!(self.spawnflags & SILENT)) + { + precache_sound ("ambience/hum1.wav"); + o = (self.mins + self.maxs)*0.5; + ambientsound (o, "ambience/hum1.wav",0.5 , ATTN_STATIC); + } +}; + +/* +============================================================================== + +trigger_setskill + +============================================================================== +*/ + +/*QUAKED trigger_setskill (.5 .5 .5) ? +sets skill level to the value of "message". +Only used on start map. +*/ +void() trigger_setskill = +{ + remove (self); +}; + + +/* +============================================================================== + +ONLY REGISTERED TRIGGERS + +============================================================================== +*/ + +void() trigger_onlyregistered_touch = +{ + if (other.classname != "player") + return; + if (self.attack_finished > time) + return; + + self.attack_finished = time + 2; + if (cvar("registered")) + { + self.message = ""; + SUB_UseTargets (); + remove (self); + } + else + { + if (self.message != "") + { + centerprint (other, self.message); + sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM); + } + } +}; + +/*QUAKED trigger_onlyregistered (.5 .5 .5) ? +Only fires if playing the registered version, otherwise prints the message +*/ +void() trigger_onlyregistered = +{ + precache_sound ("misc/talk.wav"); + InitTrigger (); + self.touch = trigger_onlyregistered_touch; +}; + +//============================================================================ + +void() hurt_on = +{ + self.solid = SOLID_TRIGGER; + self.nextthink = -1; +}; + +void() hurt_touch = +{ + if (other.takedamage) + { + self.solid = SOLID_NOT; + T_Damage (other, self, self, self.dmg); + self.think = hurt_on; + self.nextthink = time + 1; + } + + return; +}; + +/*QUAKED trigger_hurt (.5 .5 .5) ? +Any object touching this will be hurt +set dmg to damage amount +defalt dmg = 5 +*/ +void() trigger_hurt = +{ + InitTrigger (); + self.touch = hurt_touch; + if (!self.dmg) + self.dmg = 5; +}; + +//============================================================================ + +float PUSH_ONCE = 1; + +void() trigger_push_touch = +{ + if (other.classname == "grenade") + other.velocity = self.speed * self.movedir * 10; + else if (other.health > 0) + { + other.velocity = self.speed * self.movedir * 10; + if (other.classname == "player") + { + if (other.fly_sound < time) + { + other.fly_sound = time + 1.5; + sound (other, CHAN_AUTO, "ambience/windfly.wav", 1, ATTN_NORM); + } + } + } + if (self.spawnflags & PUSH_ONCE) + remove(self); +}; + + +/*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE +Pushes the player +*/ +void() trigger_push = +{ + InitTrigger (); + precache_sound ("ambience/windfly.wav"); + self.touch = trigger_push_touch; + if (!self.speed) + self.speed = 1000; +}; + +//============================================================================ + +void() trigger_monsterjump_touch = +{ + if ( other.flags & (FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER ) + return; + +// set XY even if not on ground, so the jump will clear lips + other.velocity_x = self.movedir_x * self.speed; + other.velocity_y = self.movedir_y * self.speed; + + if ( !(other.flags & FL_ONGROUND) ) + return; + + other.flags = other.flags - FL_ONGROUND; + + other.velocity_z = self.height; +}; + +/*QUAKED trigger_monsterjump (.5 .5 .5) ? +Walking monsters that touch this will jump in the direction of the trigger's angle +"speed" default to 200, the speed thrown forward +"height" default to 200, the speed thrown upwards +*/ +void() trigger_monsterjump = +{ + if (!self.speed) + self.speed = 200; + if (!self.height) + self.height = 200; + if (self.angles == '0 0 0') + self.angles = '0 360 0'; + InitTrigger (); + self.touch = trigger_monsterjump_touch; +}; + diff --git a/quakec/fallout2/weapons.qc b/quakec/fallout2/weapons.qc new file mode 100644 index 000000000..ee35b935b --- /dev/null +++ b/quakec/fallout2/weapons.qc @@ -0,0 +1,3538 @@ +/* +*/ +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 (float dam, float rec, string snd, float rng, float rate) FireAssaultRifle; +void (float dam, float rec, string snd, float rng, float rate) FirePistol; +void (float dam, float rec, string snd, float rng, float rate) FireSMG; +void () W_PlayerMenu; +void() Sneak; +void() Bandage; +void() Shield; + +float () weightx; +void (entity guy, float slot) GetWeaponWeight; +string (entity guy, float slot) GetWeaponName; + + +// called by worldspawn +void() W_Precache = +{ + precache_sound ("weapons/r_exp3.wav"); // new rocket explosion + precache_sound ("weapons/rocket1i.wav"); // spike gun + precache_sound ("weapons/sgun1.wav"); + precache_sound ("weapons/guncock.wav"); // player shotgun + precache_sound ("weapons/ric1.wav"); // ricochet (used in c code) + precache_sound ("weapons/ric2.wav"); // ricochet (used in c code) + precache_sound ("weapons/ric3.wav"); // ricochet (used in c code) + precache_sound ("weapons/ric4.wav"); // ricochet (used in c code) + precache_sound ("weapons/ric5.wav"); // ricochet (used in c code) + precache_sound ("weapons/spike2.wav"); // super spikes + precache_sound ("weapons/tink1.wav"); // spikes tink (used in c code) + precache_sound ("weapons/grenade.wav"); // grenade launcher + precache_sound ("weapons/bounce.wav"); // grenade bounce + precache_sound ("weapons/shotgn2.wav"); // super shotgun +}; + +float() crandom = +{ + return 2*(random() - 0.5); +}; + +/* +================ +W_FireMelee +================ +*/ +void(float damage, float dist, float rate) FireMelee = +{ + local vector source; + local vector org; + + makevectors (self.v_angle); + source = self.origin + '0 0 16'; + traceline (source, source + v_forward*dist, FALSE, self); + if (trace_fraction == 1.0) + return; + + org = trace_endpos - v_forward*4; + + if (trace_ent.takedamage) + { + trace_ent.axhitme = 1; + SpawnBlood (org, 20); + T_Damage (trace_ent, self, self, damage+random()*damage); + } + else + { // hit wall + sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM); + + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SPIKE); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (self.origin, MULTICAST_PHS); + } +}; + + +//============================================================================ + +vector() wall_velocity = +{ + local vector vel; + + vel = normalize (self.velocity); + vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5)); + vel = vel + 2*trace_plane_normal; + vel = vel * 200; + + return vel; +}; + + +/* +================ +SpawnMeatSpray +================ +*/ +void(vector org, vector vel) SpawnMeatSpray = +{ + local entity missile; + local vector org; + + missile = spawn (); + missile.owner = self; + missile.movetype = MOVETYPE_BOUNCE; + missile.solid = SOLID_NOT; + + makevectors (self.angles); + + missile.velocity = vel; + missile.velocity_z = missile.velocity_z + 250 + 50*random(); + + missile.avelocity = '3000 1000 2000'; + +// set missile duration + missile.nextthink = time + 1; + missile.think = SUB_Remove; + + setmodel (missile, "progs/zom_gib.mdl"); + setsize (missile, '0 0 0', '0 0 0'); + setorigin (missile, org); +}; + +/* +================ +SpawnBlood +================ +*/ +void(vector org, 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); + multicast (org, MULTICAST_PVS); +}; + +/* +================ +spawn_touchblood +================ +*/ +void(float damage) spawn_touchblood = +{ + local vector vel; + + vel = wall_velocity () * 0.2; + 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; + multi_damage = 0; + blood_count = 0; + puff_count = 0; +}; + +void() ApplyMultiDamage = +{ + if (!multi_ent) + return; + T_Damage (multi_ent, self, self, multi_damage); +}; + +void(entity hit, float damage) AddMultiDamage = +{ + if (!hit) + return; + + if (hit != multi_ent) + { + ApplyMultiDamage (); + multi_damage = damage; + multi_ent = hit; + } + else + multi_damage = multi_damage + damage; +}; + +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); + 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); + multicast (puff_org, MULTICAST_PVS); + } +}; + +/* +============================================================================== +BULLETS +============================================================================== +*/ + +/* +================ +TraceAttack +================ +*/ +void(float damage, vector dir) TraceAttack = +{ + local vector vel, org; + + vel = normalize(dir + v_up*crandom() + v_right*crandom()); + vel = vel + 2*trace_plane_normal; + vel = vel * 200; + + org = trace_endpos - dir*4; + + if (trace_ent.takedamage) + { + blood_count = blood_count + 1; + blood_org = org; + AddMultiDamage (trace_ent, damage); + } + else + { + puff_count = puff_count + 1; + } +}; + +/* +================ +FireBullets + +Used by shotgun, super shotgun, and enemy soldier firing +Go to the trouble of combining multiple pellets into a single damage call. +================ +*/ + + +/* +============================================================================== + +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"); +// 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) { + return; + } + self.voided = 1; + + if (pointcontents(self.origin) == CONTENT_SKY) + { + remove(self); + return; + } + + damg = 100 + random()*20; + + if (other.health) + { + other.deathtype = "rocket"; + 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); + 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); + 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; + WriteByte (MSG_ONE, SVC_SMALLKICK); + + newmis = spawn (); + newmis.owner = self; + newmis.movetype = MOVETYPE_FLYMISSILE; + newmis.solid = SOLID_BBOX; + +// set newmis speed + + makevectors (self.v_angle); + newmis.velocity = aim(self, 1000); + newmis.velocity = newmis.velocity * 1000; + newmis.angles = vectoangles(newmis.velocity); + + newmis.touch = T_MissileTouch; + newmis.voided = 0; + +// set newmis duration + newmis.nextthink = time + 5; + newmis.think = SUB_Remove; + newmis.classname = "rocket"; + + setmodel (newmis, "progs/missile.mdl"); + setsize (newmis, '0 0 0', '0 0 0'); + setorigin (newmis, self.origin + v_forward*8 + '0 0 16'); +}; + +/* +=============================================================================== +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); + 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; + + f = p2 - p1; + normalize (f); + f_x = 0 - f_y; + f_y = f_x; + f_z = 0; + f = f*16; + + e1 = e2 = world; + + traceline (p1, p2, FALSE, self); + + if (trace_ent.takedamage) + { + LightningHit (from, damage); + if (self.classname == "player") + { + if (other.classname == "player") + trace_ent.velocity_z = trace_ent.velocity_z + 400; + } + } + e1 = trace_ent; + + traceline (p1 + f, p2 + f, FALSE, self); + if (trace_ent != e1 && trace_ent.takedamage) + { + 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; + + 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) + { + self.deathtype = "selfwater"; + 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, ""); + return; + } + } + else + { + cells = self.ammo_cells; + self.ammo_cells = 0; + W_SetCurrentAmmo (); + T_RadiusDamage (self, self, 35*cells, world,""); + return; + } + } + + if (self.t_width < time) + { + sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM); + self.t_width = time + 0.6; + } + msg_entity = self; + WriteByte (MSG_ONE, SVC_SMALLKICK); + + if (deathmatch != 4) + self.currentammo = self.ammo_cells = self.ammo_cells - 1; + + org = self.origin + '0 0 16'; + + traceline (org, org + v_forward*600, TRUE, self); + + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, 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); + multicast (org, MULTICAST_PHS); + + LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30); +}; + + +//============================================================================= + + +void() GrenadeExplode = +{ + 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); + multicast (self.origin, MULTICAST_PHS); + + remove (self); +}; + +void() GrenadeTouch = +{ + if (other == self.owner) + return; // don't explode on owner + if (other.takedamage == DAMAGE_AIM) + { + GrenadeExplode(); + return; + } + sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound + if (self.velocity == '0 0 0') + self.avelocity = '0 0 0'; +}; + +/* +================ +W_FireGrenade +================ +*/ +void() W_FireGrenade = +{ + if (deathmatch != 4) + self.currentammo = self.ammo_rockets = self.ammo_rockets - 1; + + sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM); + + msg_entity = self; + WriteByte (MSG_ONE, SVC_SMALLKICK); + + newmis = spawn (); + newmis.voided=0; + newmis.owner = self; + newmis.movetype = MOVETYPE_BOUNCE; + newmis.solid = SOLID_BBOX; + newmis.classname = "grenade"; + +// 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 = newmis.velocity * 600; + newmis.velocity_z = 200; + } + + newmis.avelocity = '300 300 300'; + + newmis.angles = vectoangles(newmis.velocity); + + newmis.touch = GrenadeTouch; + +// 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 + newmis.nextthink = time + 2.5; + + newmis.think = GrenadeExplode; + + setmodel (newmis, "progs/grenade.mdl"); + setsize (newmis, '0 0 0', '0 0 0'); + setorigin (newmis, self.origin); +}; + + +//============================================================================= + +void() spike_touch; +void() superspike_touch; + + +/* +=============== +launch_spike + +Used for both the player and the ogre +=============== +*/ +void(vector org, vector dir) launch_spike = +{ + newmis = spawn (); + newmis.voided=0; + newmis.owner = self; + newmis.movetype = MOVETYPE_FLYMISSILE; + newmis.solid = SOLID_BBOX; + + newmis.angles = vectoangles(dir); + + newmis.touch = spike_touch; + newmis.classname = "spike"; + newmis.think = SUB_Remove; + newmis.nextthink = time + 6; + setmodel (newmis, "progs/spike.mdl"); + setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); + setorigin (newmis, org); + + newmis.velocity = dir * 1000; +}; + +void() W_FireSuperSpikes = +{ + local vector dir; + local entity old; + + sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM); + self.attack_finished = time + 0.2; + if (deathmatch != 4) + self.currentammo = self.ammo_nails = self.ammo_nails - 2; + dir = aim (self, 1000); + launch_spike (self.origin + '0 0 16', dir); + newmis.touch = superspike_touch; + setmodel (newmis, "progs/s_spike.mdl"); + setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); + msg_entity = self; + WriteByte (MSG_ONE, SVC_SMALLKICK); +}; + +void(float ox) W_FireSpikes = +{ + local vector dir; + local entity old; + + makevectors (self.v_angle); + + if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN) + { + W_FireSuperSpikes (); + return; + } + + if (self.ammo_nails < 1) + { + self.weapon = W_BestWeapon (); + W_SetCurrentAmmo (); + return; + } + + sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM); + self.attack_finished = time + 0.2; + 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); + + msg_entity = self; + WriteByte (MSG_ONE, SVC_SMALLKICK); +}; + + + +.float hit_z; +void() spike_touch = +{ +local float rand; + if (other == self.owner) + return; + + if (self.voided) { + return; + } + self.voided = 1; + + if (other.solid == SOLID_TRIGGER) + return; // trigger field, do nothing + + if (pointcontents(self.origin) == CONTENT_SKY) + { + remove(self); + return; + } + +// hit something that bleeds + if (other.takedamage) + { + spawn_touchblood (9); + 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); + multicast (self.origin, MULTICAST_PHS); + } + + remove(self); + +}; + +void() superspike_touch = +{ +local float rand; + if (other == self.owner) + return; + + if (self.voided) { + return; + } + self.voided = 1; + + + if (other.solid == SOLID_TRIGGER) + return; // trigger field, do nothing + + if (pointcontents(self.origin) == CONTENT_SKY) + { + remove(self); + return; + } + +// hit something that bleeds + if (other.takedamage) + { + spawn_touchblood (18); + 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); + multicast (self.origin, MULTICAST_PHS); + } + + remove(self); + +}; + + +/* +=============================================================================== + +PLAYER WEAPON USE + +=============================================================================== +*/ + +void(float temp_weapon) GetWeaponModel = +{ + if (temp_weapon == 0) + self.weaponmodel = "progs/v_fist.mdl"; + else if (temp_weapon == 1) + self.weaponmodel = "progs/v_knife.mdl"; + else if (temp_weapon == 2) + self.weaponmodel = "progs/v_axe.mdl"; + else if (temp_weapon == 3) + self.weaponmodel = "progs/v_knife.mdl"; + else if (temp_weapon == 4) + self.weaponmodel = "progs/v_axe.mdl"; + else if (temp_weapon == 5) + self.weaponmodel = "progs/v_1911.mdl"; + else if (temp_weapon == 12) + self.weaponmodel = "progs/v_jackhammer.mdl"; + else if (temp_weapon == 13) + self.weaponmodel = "progs/v_mp9.mdl"; + else if (temp_weapon == 14) + self.weaponmodel = "progs/v_mp7.mdl"; + else if (temp_weapon == 17) + self.weaponmodel = "progs/v_ak47.mdl"; + else if (temp_weapon == 19) + self.weaponmodel = "progs/v_night.mdl"; + +}; + +void() W_SetCurrentAmmo = +{ + local float temp_weapon; + local string x; + + player_run (); // get out of any weapon firing states + + self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) ); + + + if (self.current_slot == 1) + self.currentammo = self.mag1; + else if (self.current_slot == 2) + self.currentammo = self.mag2; + else if (self.current_slot == 3 && self.handgrenade > 0) + self.currentammo = self.handgrenade; + else if (self.current_slot == 4) + { + if (self.team == 1) + { + sound (self, CHAN_WEAPON, "misc/tools.wav", 1, ATTN_NORM); + self.items = (self.items | IT_LIGHTNING); + self.currentammo = 0; + self.weaponmodel = ""; + } + else + sound (self, CHAN_WEAPON, "misc/menu3.wav", 1, ATTN_NORM); + } + else + sound (self, CHAN_WEAPON, "misc/menu3.wav", 1, ATTN_NORM); + + if (self.current_slot == 1) + x = GetWeaponName(self, self.slot1); + if (self.current_slot == 2) + x = GetWeaponName(self, self.slot2); + if (self.current_slot == 3) + x = "grenade"; + if (self.current_slot == 4) + x = "tools"; + + sprint(self, 2, x); + sprint (self, PRINT_HIGH, " selected.\n"); + sound (self, CHAN_WEAPON, "misc/weapon.wav", 1, ATTN_NORM); + if (self.current_slot == 1) + GetWeaponModel(self.slot1); + if (self.current_slot == 2) + GetWeaponModel(self.slot2); + + if (self.current_slot == 1) + self.currentammo = self.mag1; + if (self.current_slot == 2) + self.currentammo = self.mag2; +}; + +float() W_BestWeapon = +{ + local float it; + + it = self.items; + + if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & IT_LIGHTNING) ) + return IT_LIGHTNING; + else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) ) + return IT_SUPER_NAILGUN; + else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) ) + return IT_SUPER_SHOTGUN; + else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) ) + return IT_NAILGUN; + else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) ) + return IT_SHOTGUN; + +/* + if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) ) + return IT_ROCKET_LAUNCHER; + else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) ) + return IT_GRENADE_LAUNCHER; + +*/ + + return IT_AXE; +}; + +void () ReloadWeapon = +{ + local float x; + + sound (self, CHAN_WEAPON, "weapons/reload.wav", TRUE, ATTN_NORM); + sprint(self, 2, "reloading...\n"); + + if (self.current_slot == 1) + { + x = (self.maxmag1 - self.mag1); + self.mag1 = self.mag1 + x; + self.ammo1 = self.ammo1 - x; + } + if (self.current_slot == 2) + { + x = (self.maxmag2 - self.mag2); + self.mag2 = self.mag2 + x; + self.ammo2 = self.ammo2 - x; + } +}; + +float() W_CheckNoAmmo = +{ + if (self.current_slot == 1) + { + if (self.slot1 == 0) + return FALSE; + + if (self.mag1 < 1 && self.ammo1 < 1) + { + self.attack_finished = (time + 0.2); + stuffcmd (self, "-attack\n"); + sound (self, CHAN_WEAPON, "weapons/click.wav", TRUE, ATTN_NORM); + return TRUE; + } + if (self.mag1 <= 0) + { + stuffcmd (self, "-attack\n"); + ReloadWeapon (); + return TRUE; + } + } + if (self.current_slot == 2) + { + if (self.slot2 == 0) + return FALSE; + + if (self.mag1 < 2 && self.ammo1 < 2) + { + self.attack_finished = (time + 0.2); + stuffcmd (self, "-attack\n"); + sound (self, CHAN_WEAPON, "weapons/click.wav", TRUE, ATTN_NORM); + return TRUE; + } + if (self.mag2 <= 0) + { + stuffcmd (self, "-attack\n"); + ReloadWeapon (); + return TRUE; + } + } + + return FALSE; +}; + +/* +============ +W_Attack + +An attack impulse can be triggered now +============ +*/ + +void() W_Attack = +{ + local float weap, r; + + makevectors (self.v_angle); // calculate forward angle for velocity + self.show_hostile = time + 1; // wake monsters up + + if (W_CheckNoAmmo()) + return; + + if (self.current_slot == 1) + weap = self.slot1; + if (self.current_slot == 2) + weap = self.slot2; + + + if (weap == 0) + { + self.attack_finished = time + 0.1; + FireMelee(10, 64, 0.5); + } + if (weap == 5) + { + self.attack_finished = time + 0.1; + FirePistol(10, 2, "weapons/1911.wav", 2000, 0.1); + } + if (weap == 17) + { + self.attack_finished = time + 0.1; + FireAssaultRifle(18, 2, "weapons/ak47.wav", 6000, 0.1); + } + if (weap == 19) + { + self.attack_finished = time + 0.1; + FireAssaultRifle(18, 2, "weapons/m4a1.wav", 6000, 0.1); + } +}; + +/* +============ +W_ChangeWeapon + +============ +*/ +void() W_ChangeWeapon = +{ + local float it, am, fl, r; + + it = self.items; + am = 0; + + if (self.impulse == 1) + { + fl = IT_NAILGUN; + self.current_slot = 1; + } + if (self.impulse == 2) + { + fl = IT_SUPER_NAILGUN; + self.current_slot = 2; + } + if (self.impulse == 3) + { + if (self.handgrenade == 0) + { + sprint (self, PRINT_HIGH, "no grenade.\n"); + sound (self, CHAN_AUTO, "misc/noweapon.wav", 1, ATTN_STATIC); + return; + } + else + self.current_slot = 3; + } + + self.weapon = fl; + W_SetCurrentAmmo (); +}; + +/* +============ +CheatCommand +============ +*/ +void() CheatCommand = +{ +// if (deathmatch || coop) + return; + + self.ammo_rockets = 100; + self.ammo_nails = 200; + self.ammo_shells = 100; + self.items = self.items | + IT_AXE | + IT_SHOTGUN | + IT_SUPER_SHOTGUN | + IT_NAILGUN | + IT_SUPER_NAILGUN | + IT_GRENADE_LAUNCHER | + IT_ROCKET_LAUNCHER | + IT_KEY1 | IT_KEY2; + + self.ammo_cells = 200; + self.items = self.items | IT_LIGHTNING; + + self.weapon = IT_ROCKET_LAUNCHER; + self.impulse = 0; + W_SetCurrentAmmo (); +}; + +/* +============ +CycleWeaponCommand + +Go to the next weapon with ammo +============ +*/ +void() CycleWeaponCommand = +{ + local float it, am; + + it = self.items; + self.impulse = 0; + + while (1) + { + am = 0; + + if (self.weapon == IT_LIGHTNING) + { + self.weapon = IT_AXE; + } + else if (self.weapon == IT_AXE) + { + self.weapon = IT_SHOTGUN; + if (self.ammo_shells < 1) + am = 1; + } + else if (self.weapon == IT_SHOTGUN) + { + self.weapon = IT_SUPER_SHOTGUN; + if (self.ammo_shells < 2) + am = 1; + } + else if (self.weapon == IT_SUPER_SHOTGUN) + { + self.weapon = IT_NAILGUN; + if (self.ammo_nails < 1) + am = 1; + } + else if (self.weapon == IT_NAILGUN) + { + self.weapon = IT_SUPER_NAILGUN; + if (self.ammo_nails < 2) + am = 1; + } + else if (self.weapon == IT_SUPER_NAILGUN) + { + self.weapon = IT_GRENADE_LAUNCHER; + if (self.ammo_rockets < 1) + am = 1; + } + else if (self.weapon == IT_GRENADE_LAUNCHER) + { + self.weapon = IT_ROCKET_LAUNCHER; + if (self.ammo_rockets < 1) + am = 1; + } + else if (self.weapon == IT_ROCKET_LAUNCHER) + { + self.weapon = IT_LIGHTNING; + if (self.ammo_cells < 1) + am = 1; + } + + if ( (self.items & self.weapon) && am == 0) + { + W_SetCurrentAmmo (); + return; + } + } + +}; + + + + +void () ProneOff = +{ + sprint (self, 2, "position: stand.\n"); + self.position = 0; + player_run (); +}; + +void () ProneOn = +{ + local string x; + + if (self.velocity_z != 0) + return; + + if (self.position == 2) + { + ProneOff(); + return; + } + + self.maxspeed = (self.maxspeed * 0.25); + self.position = 2; + self.view_ofs = '0 0 -10'; + sprint (self, 2, "position: prone.\n"); +}; + + +void () DuckOff = +{ + sprint (self, 2, "position: stand.\n"); + self.position = 0; + player_run (); +}; + + +void () DuckOn = +{ + if (self.velocity_z != 0) + return; + + if (self.position == 1) + { + DuckOff(); + return; + } + + self.maxspeed = (self.maxspeed * 0.50); + self.position = 1; + self.view_ofs = '0 0 12'; + sprint (self, 2, "position: duck.\n"); +}; + + +/* +============ +CycleWeaponReverseCommand + +Go to the prev weapon with ammo +============ +*/ +void() CycleWeaponReverseCommand = +{ + local float it, am; + + it = self.items; + self.impulse = 0; + + while (1) + { + am = 0; + + if (self.weapon == IT_LIGHTNING) + { + self.weapon = IT_ROCKET_LAUNCHER; + if (self.ammo_rockets < 1) + am = 1; + } + else if (self.weapon == IT_ROCKET_LAUNCHER) + { + self.weapon = IT_GRENADE_LAUNCHER; + if (self.ammo_rockets < 1) + am = 1; + } + else if (self.weapon == IT_GRENADE_LAUNCHER) + { + self.weapon = IT_SUPER_NAILGUN; + if (self.ammo_nails < 2) + am = 1; + } + else if (self.weapon == IT_SUPER_NAILGUN) + { + self.weapon = IT_NAILGUN; + if (self.ammo_nails < 1) + am = 1; + } + else if (self.weapon == IT_NAILGUN) + { + self.weapon = IT_SUPER_SHOTGUN; + if (self.ammo_shells < 2) + am = 1; + } + else if (self.weapon == IT_SUPER_SHOTGUN) + { + self.weapon = IT_SHOTGUN; + if (self.ammo_shells < 1) + am = 1; + } + else if (self.weapon == IT_SHOTGUN) + { + self.weapon = IT_AXE; + } + else if (self.weapon == IT_AXE) + { + self.weapon = IT_LIGHTNING; + if (self.ammo_cells < 1) + am = 1; + } + + if ( (it & self.weapon) && am == 0) + { + W_SetCurrentAmmo (); + return; + } + } + +}; + + + +/* +============ +ServerflagsCommand + +Just for development +============ +*/ +void() ServerflagsCommand = +{ + serverflags = serverflags * 2 + 1; +}; + + +/* +============ +ImpulseCommands + +============ +*/ +void() ImpulseCommands = +{ + if (self.impulse >= 1 && self.impulse <= 4 && self.currentmenu == "none") + W_ChangeWeapon (); + + if (self.impulse >= 1 && self.impulse <= 10 && self.currentmenu != "none") + W_PlayerMenu (); + + if (self.impulse == 11) + ServerflagsCommand (); + if (self.impulse == 12) + CycleWeaponReverseCommand (); + if (self.impulse == 200) + DuckOn (); + if (self.impulse == 201) + ProneOn (); + self.impulse = 0; +}; + +/* +============ +W_WeaponFrame + +Called every frame so impulse events can be handled as well as possible +============ +*/ +void() W_WeaponFrame = +{ + if (time < self.attack_finished) + return; + + ImpulseCommands (); + +// check for attack + if (self.button0) + { + SuperDamageSound (); + W_Attack (); + } +}; + +/* +======== +SuperDamageSound + +Plays sound if needed +======== +*/ +void() SuperDamageSound = +{ + if (self.super_damage_finished > time) + { + if (self.super_sound < time) + { + self.super_sound = time + 1; + sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM); + } + } + return; +}; + + +void () DropAmmo = +{ + if (self.current_slot == 1) + { + self.currentammo = (self.mag1 - 1); + self.mag1 = (self.mag1 - 1); + self.ammo_nails = self.ammo1; + } + if (self.current_slot == 2) + { + self.currentammo = (self.mag2 - 1); + self.mag2 = (self.mag2 - 1); + self.ammo_nails = self.ammo2; + } +}; + +void()muzzleflash = +{ + WriteByte (MSG_MULTICAST, SVC_MUZZLEFLASH); + WriteEntity (MSG_MULTICAST, self); + multicast (self.origin, MULTICAST_PVS); +}; + +void () autofire = +{ + if (self.frame == 88) + self.frame = 89; + else + self.frame = 88; + + + if (self.weaponframe == 1) + self.weaponframe == 2; + else if (self.weaponframe == 2) + self.weaponframe == 1; + + muzzleflash (); +}; + +void () autofire_s = +{ + if (self.frame == 88) + self.frame = 89; + else + self.frame = 88; + + if (self.weaponframe == 1) + self.weaponframe == 2; + else if (self.weaponframe == 2) + self.weaponframe == 1; + + muzzleflash (); +}; + + +void () player_single1 = [ 88, player_single2 ] +{ + self.weaponframe = 1; + muzzleflash (); +}; + +void () player_single2 = [ 89, player_run ] +{ + self.weaponframe = 2; +}; + +void () player_single1_s = [ 183, player_single2_s ] +{ + self.weaponframe = 1; + muzzleflash (); +}; + +void () player_single2_s = [ 184, player_run ] +{ + self.weaponframe = 2; +}; + +void (vector org) bullet_hole = +{ + local float r; + local entity ric; + + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SPIKE); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (self.origin, MULTICAST_PHS); + + r = random(); + ric = spawn(); + setorigin(ric, org); + + if (r <= 0.20) + sound (ric, CHAN_WEAPON, "weapons/ric1.wav", TRUE, ATTN_NORM); + else if (r <= 0.40) + sound (ric, CHAN_WEAPON, "weapons/ric2.wav", TRUE, ATTN_NORM); + else if (r <= 0.60) + sound (ric, CHAN_WEAPON, "weapons/ric3.wav", TRUE, ATTN_NORM); + else if (r <= 0.80) + sound (ric, CHAN_WEAPON, "weapons/ric4.wav", TRUE, ATTN_NORM); + else + sound (ric, CHAN_WEAPON, "weapons/ric5.wav", TRUE, ATTN_NORM); + + remove(ric); +}; + +void (vector test, float length, float dam) penetrate = +{ + local vector org; + local vector org2; + local vector start; + local vector end; + local vector end2; + local float zdif; + local float ydif; + local float xdif; + local float true; + local float go; + local float tl; + + + go = 0; + tl = 8; + + length = 32 + dam; + + while (tl < length) + { + makevectors (self.v_angle); + start = (test + v_forward*tl); + + if (pointcontents (start) != CONTENT_SOLID && go == 0) //object penetrated + { + makevectors (self.v_angle); + end = (test + (v_forward * 8 * length)); + traceline (start, end, FALSE, self); + if (trace_fraction == 1) //nothing behind object + return; + + if (trace_fraction > 0) + { + go = 1; + + if (trace_ent.takedamage) + { + + if (trace_ent.solid != SOLID_BSP) + SpawnBlood (org, 1); + + T_Damage (trace_ent, self, self, dam); + } + else + { + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SPIKE); + WriteCoord (MSG_MULTICAST, trace_endpos_x); + WriteCoord (MSG_MULTICAST, trace_endpos_y); + WriteCoord (MSG_MULTICAST, trace_endpos_z); + multicast (trace_endpos, MULTICAST_PHS); + } + } + } + tl = tl + 4; +} +}; + +void (entity temp, vector org, float damage) SpawnWood = +{ + + if (random()*6 <= 3) + sound (temp, CHAN_WEAPON, "misc/woodhit.wav", TRUE, ATTN_NORM); + else + sound (temp, CHAN_WEAPON, "misc/woodhit2.wav", TRUE, ATTN_NORM); + + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_SUPERSPIKE); + WriteCoord (MSG_MULTICAST, org_x); + WriteCoord (MSG_MULTICAST, org_y); + WriteCoord (MSG_MULTICAST, org_z); + multicast (self.origin, MULTICAST_PHS); +}; + +void () EMPExplode = +{ + local entity te; + + self.velocity = VEC_ORIGIN; + 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); + sound (self, CHAN_BODY, "misc/flash.wav", 1, ATTN_NORM); + sound (self, CHAN_BODY, "misc/flash.wav", 0.2, ATTN_NONE); + te = findradius (self.origin, 300); + while (te) + { + if ((((te.classname == "camera") || (te.classname == "alarm")) && (te.owner.pcamera == 0))) + { + te.owner.pcamera = 0; + te.owner.pcamera2 = 0; + te.owner.equipment_state = 0; + sprint (self.owner, 2, te.owner.netname); + sprint (self.owner, 2, "'s "); + sprint (self.owner, 2, te.classname); + sprint (self.owner, 2, " was wiped out!\n"); + remove (te); + } + te = te.chain; + } + T_RadiusDamage (self, self.owner, 45+random()*45, other, ""); + remove (self); +}; + +void (vector org) CreateSmoke = +{ + newmis = spawn (); + setmodel (newmis, "progs/smoke.mdl"); + setorigin (newmis, org); + newmis.movetype = MOVETYPE_NONE; + newmis.solid = SOLID_NOT; + newmis.velocity = VEC_ORIGIN; + newmis.nextthink = (time + SVC_BIGKICK); + newmis.think = SUB_Remove; + newmis.touch = SUB_Null; + newmis.classname = "smoke"; + newmis.frame = 0; + newmis.cnt = 0; + newmis.avelocity_x = (random () * 100); + newmis.avelocity_y = (random () * 100); + setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); +}; + + +void () SmokeThink = +{ + local entity te; + local float ct; + + self.cnt = (self.cnt + 1); + + WriteByte (MSG_MULTICAST, SVC_TEMPENTITY); + WriteByte (MSG_MULTICAST, TE_GUNSHOT); + WriteByte (MSG_MULTICAST, 2); + WriteCoord (MSG_MULTICAST, self.origin_x); + WriteCoord (MSG_MULTICAST, self.origin_y); + WriteCoord (MSG_MULTICAST, self.origin_z); + multicast (self.origin, MULTICAST_PVS); + + self.nextthink = (time + 0.33); + if (self.cnt >= 90) + remove (self); +}; + +void () FragExplode = +{ + local float r; + + sound (self, CHAN_VOICE, "ambience/gunfire7.wav", 1, ATTN_NONE); + self.origin = (self.origin + '0 0 16'); + 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); + r = random (); + if ((r < 0.3)) + { + sound (self, CHAN_BODY, "misc/exp1.wav", 1, ATTN_NORM); + } + if ((r < 0.65)) + { + sound (self, CHAN_BODY, "misc/exp2.wav", 1, ATTN_NORM); + } + else + { + sound (self, CHAN_BODY, "misc/exp3.wav", 1, ATTN_NORM); + } + T_RadiusDamage (self, self.owner, 50+random()*50, other, ""); + remove (self); +}; + + +void () PlasmaExplode = +{ + local float r; + + sound (self, CHAN_VOICE, "ambience/gunfire7.wav", 1, ATTN_NONE); + self.origin = (self.origin + '0 0 16'); + self.velocity = VEC_ORIGIN; + 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); + sound (self, CHAN_BODY, "misc/flash.wav", 1, ATTN_NORM); + T_RadiusDamage (self, self.owner, 80+random()*80, other, ""); + remove (self); +}; + +void () FlashExplode = +{ + local entity te; + local float dot; + local float dot2; + local vector vec; + + self.velocity = VEC_ORIGIN; + setmodel (self, "progs/blast.mdl"); + WriteByte (0, SVC_TEMPENTITY); + WriteByte (0, WEAPON_SPIKES); + WriteCoord (0, self.origin_x); + WriteCoord (0, self.origin_y); + WriteCoord (0, self.origin_z); + sound (self, CHAN_BODY, "misc/flash.wav", 1, ATTN_NORM); + te = findradius (self.origin, 1200); + while (te) + { + if (te.classname == "raider") + te.attack_finished = time + 6; + if (te.classname == "radwolf") + te.attack_finished = time + 6; + + if ((te.classname == "player")) + { + makevectors (te.angles); + vec = normalize ((self.origin - te.origin)); + dot = (vec * v_forward); + if (((te.equipment == 7) && (te.equipment_state == 1))) + { + dot2 = 1; + } + if ((((dot > 0.3) && CanDamage (self, te)) && (dot2 == 0))) + { + stuffcmd (te, "v_cshift 255 255 255 255\n"); + stuffcmd (te, "v_idlescale 10\n"); + te.flash = 6; + } + } + te = te.chain; + } + remove (self); +}; + +void () HandGrenExplode = +{ + if ((self.cnt == 0)) + { + FragExplode (); + } + else + { + if ((self.cnt == 1)) + { + EMPExplode (); + } + else + { + if ((self.cnt == 2)) + { + self.nextthink = (time + 0.5); + self.think = SmokeThink; + } + else + { + if ((self.cnt == AS_MELEE)) + { + FlashExplode (); + } + else + { + if ((self.cnt == WEAPON_SPIKES)) + { + PlasmaExplode (); + } + } + } + } + } +}; + +void () HandGrenBounce = +{ + local float r; + + r = (random () * TE_LIGHTNING3); + + self.velocity = self.velocity * 0.75; + + if ((r < AS_MELEE)) + { + sound (self, CHAN_VOICE, "misc/bounce_1.wav", 0.9, ATTN_NORM); + } + else + { + if ((r < TE_LIGHTNING2)) + { + sound (self, CHAN_VOICE, "misc/bounce_2.wav", 0.9, ATTN_NORM); + } + else + { + sound (self, CHAN_VOICE, "misc/bounce_3.wav", 0.9, ATTN_NORM); + } + } +}; + + +void () FireHandGrenade = +{ + local float type; + + if (self.handgrenade <= 0) + return; + + type = self.grenadetype; + + + self.handgrenade = self.handgrenade - 1; + self.grenadetype = 0; + self.currentammo = 0; + + msg_entity = self; + WriteByte (MSG_ONE, SVC_SMALLKICK); + newmis = spawn (); + newmis.owner = self; + newmis.movetype = MOVETYPE_BOUNCE; + newmis.solid = SOLID_BBOX; + newmis.classname = "grenade"; + + newmis.skin = 0; + makevectors (self.v_angle); + newmis.velocity = aim (self, 800); + newmis.velocity = (newmis.velocity * 800); + newmis.velocity_z = (newmis.velocity_z + 200); + newmis.angles = vectoangles (newmis.velocity); + newmis.avelocity_x = (random () * 300); + newmis.avelocity_y = (random () * 300); + newmis.avelocity_z = (random () * 300); + newmis.touch = HandGrenBounce; + newmis.nextthink = (time + 2.5); + + if (type == 1) + newmis.think = FragExplode; + if (type == 2) + newmis.think = EMPExplode; + if (type == 3) + newmis.think = SmokeThink; + if (type == 4) + newmis.think = FlashExplode; + + newmis.frame = 1; + setmodel (newmis, "progs/handgren.mdl"); + setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); + setorigin (newmis, ((self.origin + (v_right * TE_BLOOD)) + (v_up * TE_BLOOD))); +}; + + + +void(float slot, float magazine) GiveAmmo = +{ + if (slot == 1) + { + self.maxmag1 = magazine; + self.ammo1 = magazine * 4; + self.mag1 = magazine; + } + if (slot == 2) + { + self.maxmag2 = magazine; + self.ammo2 = magazine * 4; + self.mag2 = magazine; + } +}; + + +void (float dam, float rec, string snd, float rng, float rate) FirePistol = +{ + local float var, var1, var2, zdif, xdif, ydif, true; + local vector dir, source, targ, org, org2, adjust; + local string x; + + + stuffcmd(self, "-attack\n"); + sound (self, CHAN_WEAPON, snd, 1, ATTN_NORM); + self.attack_finished = (time + rate); + + + if (self.attack == 0 && self.position == POS_STAND) + player_single1 (); + if (self.attack == 0 && self.position >= POS_DUCK) + player_single1_s (); + + if (self.position == 0) + adjust = '0 0 0'; + if (self.position == 1) + adjust = '0 0 -16'; + if (self.position == 2) + adjust = '0 0 -32'; + + + DropAmmo (); + makevectors (self.v_angle); + if (self.recoil >= 15) + self.recoil = 15; + + if (self.attack >= 1) + { + if (self.position == 0) + player_single1 (); + if (self.position == 1) + player_single1_s (); + if (self.position == 2) + player_single1 (); + } + if (self.attack >= 1) + { + if (self.position == 0) + autofire (); + if (self.position == 1) + autofire_s (); + if (self.position == 2) + player_single1 (); + } + + var = 50; + + if (self.velocity != '0 0 0') + var = 400; + + var = var + (40 * self.recoil); + + if (self.attack <= 3 && self.position == 1 && self.velocity_z == 0) + var = (var * 0.75); + + if (self.attack <= 3 && self.position == 2 && self.velocity_z == 0) + var = (var * 0.5); + + self.attack = self.attack + 1; + self.recoil = self.recoil + 4; + + source = self.origin + '0 0 22'; + + targ = self.origin + '0 0 22' + v_right*crandom()* var + v_up*crandom()*var; + + traceline (source+adjust, targ+adjust+v_forward*4000, FALSE, self); + if (trace_fraction == 1) + return; + + org = trace_endpos - v_forward * 2; + org2 = trace_endpos + (v_forward * ((trace_ent.size_y / 2) + (trace_ent.size_x / 2))); + if (trace_ent.takedamage) + { + org2 = (trace_endpos + (v_forward * ((trace_ent.size_y / 2) + (trace_ent.size_x / 2)))); + zdif = org_z - trace_ent.origin_z; + ydif = org2_y - trace_ent.origin_y; + xdif = org2_x - trace_ent.origin_x; + true = 0; + if (((ydif >= CONTENT_SKY) && (ydif <= TE_LIGHTNING2))) + true = 1; + if (((xdif >= CONTENT_SKY) && (xdif <= TE_LIGHTNING2))) + true = 1; + if (self.attack <= 5 && true == 1 && zdif >= (trace_ent.size_z / 2 * 0.8)) + self.critical = 3; + + dam = (dam * (1 - trace_fraction)); + if (trace_ent.solid != SOLID_BSP) + SpawnBlood (org, 1); + + if (trace_ent.solid == SOLID_BSP) + SpawnWood (trace_ent, org, 1); + + T_Damage (trace_ent, self, self, dam); + + if (trace_ent.solid == SOLID_BSP) + penetrate (org, (dam / 2), (dam / 2)); + } + else + { + bullet_hole (org); + dir = vectoangles (source - targ); + penetrate (org, (dam / 2), (dam / 2)); + return; + } +}; + +void (float dam, float rec, string snd, float rng, float rate) FireSMG = +{ + local float var, var1, var2, zdif, xdif, ydif, true; + local vector dir, source, targ, org, org2, adjust; + local string x; + + + sound (self, CHAN_WEAPON, snd, 1, ATTN_NORM); + self.attack_finished = (time + rate); + + + if (self.attack == 0 && self.position == POS_STAND) + player_single1 (); + if (self.attack == 0 && self.position >= POS_DUCK) + player_single1_s (); + + if (self.position == 0) + adjust = '0 0 0'; + if (self.position == 1) + adjust = '0 0 -16'; + if (self.position == 2) + adjust = '0 0 -32'; + + + DropAmmo (); + makevectors (self.v_angle); + if (self.recoil >= 15) + self.recoil = 15; + + if (self.attack >= 1) + { + if (self.position == 0) + player_single1 (); + if (self.position == 1) + player_single1_s (); + if (self.position == 2) + player_single1 (); + } + if (self.attack >= 1) + { + if (self.position == 0) + autofire (); + if (self.position == 1) + autofire_s (); + if (self.position == 2) + player_single1 (); + } + + var = 200; + + if (self.velocity != '0 0 0') + var = 200; + + var = var + (40 * self.recoil); + + if (self.attack <= 3 && self.position == 1 && self.velocity_z == 0) + var = (var * 0.75); + + if (self.attack <= 3 && self.position == 2 && self.velocity_z == 0) + var = (var * 0.5); + + self.attack = self.attack + 1; + self.recoil = self.recoil + 3; + + source = self.origin + '0 0 22'; + + targ = self.origin + '0 0 22' + v_right*crandom()* var + v_up*crandom()*var; + + traceline (source+adjust, targ+adjust+v_forward*4000, FALSE, self); + if (trace_fraction == 1) + return; + + org = trace_endpos - v_forward * 2; + org2 = trace_endpos + (v_forward * ((trace_ent.size_y / 2) + (trace_ent.size_x / 2))); + if (trace_ent.takedamage) + { + org2 = (trace_endpos + (v_forward * ((trace_ent.size_y / 2) + (trace_ent.size_x / 2)))); + zdif = org_z - trace_ent.origin_z; + ydif = org2_y - trace_ent.origin_y; + xdif = org2_x - trace_ent.origin_x; + true = 0; + if (((ydif >= CONTENT_SKY) && (ydif <= TE_LIGHTNING2))) + true = 1; + if (((xdif >= CONTENT_SKY) && (xdif <= TE_LIGHTNING2))) + true = 1; + if (self.attack <= 5 && true == 1 && zdif >= (trace_ent.size_z / 2 * 0.8)) + self.critical = 3; + + dam = (dam * (1 - trace_fraction)); + if (trace_ent.solid != SOLID_BSP) + SpawnBlood (org, 1); + + if (trace_ent.solid == SOLID_BSP) + SpawnWood (trace_ent, org, 1); + + T_Damage (trace_ent, self, self, dam); + + if (trace_ent.solid == SOLID_BSP) + penetrate (org, (dam / 2), (dam / 2)); + } + else + { + bullet_hole (org); + dir = vectoangles (source - targ); + penetrate (org, (dam / 2), (dam / 2)); + return; + } +}; + +void (float dam, float rec, string snd, float rng, float rate) FireAssaultRifle = +{ + local float var, var1, var2, zdif, xdif, ydif, true; + local vector dir, source, targ, org, org2, adjust; + local string x; + + sound (self, CHAN_WEAPON, snd, 1, ATTN_NORM); + self.attack_finished = (time + rate); + + + if (self.attack == 0 && self.position == POS_STAND) + player_single1 (); + if (self.attack == 0 && self.position >= POS_DUCK) + player_single1_s (); + if (self.attack >= 1 && self.position == POS_STAND) + autofire (); + if (self.attack >= 1 && self.position >= POS_DUCK) + autofire_s (); + + if (self.position == 0) + adjust = '0 0 0'; + if (self.position == 1) + adjust = '0 0 -16'; + if (self.position == 2) + adjust = '0 0 -32'; + + + DropAmmo (); + makevectors (self.v_angle); + if (self.recoil >= 15) + self.recoil = 15; + + if (self.attack >= 1) + { + if (self.position == 0) + player_single1 (); + if (self.position == 1) + player_single1_s (); + if (self.position == 2) + player_single1 (); + } + if (self.attack >= 1) + { + if (self.position == 0) + autofire (); + if (self.position == 1) + autofire_s (); + if (self.position == 2) + player_single1 (); + } + + var = 50; + + if (self.velocity != '0 0 0') + var = 400; + + var = var + (40 * self.recoil); + + if (self.attack <= 3 && self.position == 1 && self.velocity_z == 0) + var = (var * 0.75); + + if (self.attack <= 3 && self.position == 2 && self.velocity_z == 0) + var = (var * 0.5); + + self.attack = self.attack + 1; + self.recoil = self.recoil + 5; + + source = self.origin + '0 0 22'; + + targ = self.origin + '0 0 22' + v_right*crandom()* var + v_up*crandom()*var; + + traceline (source+adjust, targ+adjust+v_forward*4000, FALSE, self); + if (trace_fraction == 1) + return; + + org = trace_endpos - v_forward * 2; + org2 = trace_endpos + (v_forward * ((trace_ent.size_y / 2) + (trace_ent.size_x / 2))); + if (trace_ent.takedamage) + { + org2 = (trace_endpos + (v_forward * ((trace_ent.size_y / 2) + (trace_ent.size_x / 2)))); + zdif = org_z - trace_ent.origin_z; + ydif = org2_y - trace_ent.origin_y; + xdif = org2_x - trace_ent.origin_x; + true = 0; + if (((ydif >= CONTENT_SKY) && (ydif <= TE_LIGHTNING2))) + true = 1; + if (((xdif >= CONTENT_SKY) && (xdif <= TE_LIGHTNING2))) + true = 1; + if (self.attack <= 5 && true == 1 && zdif >= (trace_ent.size_z / 2 * 0.8)) + self.critical = 3; + + dam = (dam * (1 - trace_fraction)); + if (trace_ent.solid != SOLID_BSP) + SpawnBlood (org, 1); + + if (trace_ent.solid == SOLID_BSP) + SpawnWood (trace_ent, org, 1); + + T_Damage (trace_ent, self, self, dam); + + if (trace_ent.solid == SOLID_BSP) + penetrate (org, (dam / 2), (dam / 2)); + } + else + { + bullet_hole (org); + dir = vectoangles (source - targ); + penetrate (org, (dam / 2), (dam / 2)); + return; + } +}; + + +void () Screenshake = +{ + local entity te; + + te = findradius (self.origin, 700); + while (te) + { + if (((te.classname == "player") && (te.ghost == 0))) + { + stuffcmd (te, "v_iyaw_level 2\n"); + stuffcmd (te, "v_iyaw_cycle 32\n"); + stuffcmd (te, "v_ipitch_level 2\n"); + stuffcmd (te, "v_ipitch_cycle 32\n"); + stuffcmd (te, "v_iroll_level 2\n"); + stuffcmd (te, "v_iroll_cycle 32\n"); + stuffcmd (te, "v_idlescale 1\n"); + } + te = te.chain; + } +}; + +void () ScreenshakeSingle = +{ + stuffcmd (self, "v_iyaw_level 2\n"); + stuffcmd (self, "v_iyaw_cycle 32\n"); + stuffcmd (self, "v_ipitch_level 2\n"); + stuffcmd (self, "v_ipitch_cycle 32\n"); + stuffcmd (self, "v_iroll_level 2\n"); + stuffcmd (self, "v_iroll_cycle 32\n"); + stuffcmd (self, "v_idlescale 1\n"); +}; + +void () ExplosionFrames = +{ + self.avelocity = '300 300 250'; + self.nextthink = (time + 0.02); + self.frame = (self.frame + 1); + if (self.frame == 16) + remove (self); +}; + +void (float input) Explosion = +{ + local float r; + + self.effects = EF_DIMLIGHT; + self.touch = SUB_Null; + setmodel (self, "progs/blast.mdl"); + r = random (); + if ((r < 0.3)) + sound (self, CHAN_BODY, "misc/exp1.wav", 1, ATTN_NORM); + if ((r < 0.65)) + sound (self, CHAN_BODY, "misc/exp2.wav", 1, ATTN_NORM); + else + sound (self, CHAN_BODY, "misc/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); + Screenshake (); + self.frame = AS_MELEE; + self.velocity = VEC_ORIGIN; + self.avelocity = '300 300 250'; + self.think = ExplosionFrames; + self.nextthink = (time + 0.02); +}; + + +void () WeaponTouch = +{ + if (other.classname != "player") + return; + + if (other.ghost != 0) + return; + + if (other.current_slot == WEAPON_SPIKES) + { + return; + } + if (other.current_slot == AS_MELEE) + return; + + if (self.handgrenade == 1) + { + if (other.handgrenade > 0) + { + sprint(other, 2, "already have a grenade.\n"); + return; + } + + sound (other, CHAN_BODY, "misc/item1.wav", 1, ATTN_NORM); + other.handgrenade = self.handgrenade; + other.grenadetype = self.grenadetype; + sprint(other, 2, "picked up a grenade.\n"); + remove(self); + return; + } + + if (((other.current_slot == 1) && (other.slot1 != 0))) + return; + + if (((other.current_slot == 2) && (other.slot2 != 0))) + return; + + sound (other, CHAN_BODY, "misc/item1.wav", 1, ATTN_NORM); + + if ((other.current_slot == 1)) + { + GetWeaponWeight (other, self.cnt); + other.slot1 = self.cnt; + stuffcmd (other, "impulse 1\n"); + other.ammo1 = self.slot1; + other.maxmag1 = self.slot2; + other.mag1 = self.class; + GetWeaponModel (); + remove (self); + } + if ((other.current_slot == 2)) + { + GetWeaponWeight (other, self.cnt); + other.slot2 = self.cnt; + stuffcmd (other, "impulse 2\n"); + other.ammo2 = self.slot1; + other.maxmag2 = self.slot2; + other.mag2 = self.class; + GetWeaponModel (); + remove (self); + } +}; + +void (float weap, float snd, float drop) DropWeapon = +{ + local string mdel; + + if (((self.attack_finished > time) && (drop == 0))) + return; + if (self.current_slot == 3 && self.handgrenade == 0) + return; + + if (((self.current_slot == WEAPON_SPIKES) && (self.c4 == 0))) + { + return; + } + if ((weap == 0)) + { + return; + } + if ((snd == 1)) + { + sound (self, CHAN_WEAPON, "weapons/lock4.wav", 1, ATTN_NORM); + } + makevectors (self.v_angle); + newmis = spawn (); + newmis.owner = self; + newmis.classname = "dropped_weapon"; + newmis.movetype = MOVETYPE_TOSS; + newmis.solid = SOLID_TRIGGER; + newmis.velocity = aim (self, 500); + newmis.velocity = (newmis.velocity * 500); + newmis.angles_y = (random () * 360); + mdel = "progs/w_m4a1.mdl"; + + + mdel = "progs/w_1911.mdl"; + + if (weap == 1) + mdel = "progs/w_knife.mdl"; + if (weap == 2) + mdel = "progs/w_knife.mdl"; + if (weap == 3) + mdel = "progs/w_axe.mdl"; + if (weap == 4) + mdel = "progs/w_axe.mdl"; + + if (weap == 5) + mdel = "progs/w_1911.mdl"; + if (weap == 6) + mdel = "progs/w_deagle.mdl"; + if (weap == 7) + mdel = "progs/w_1911.mdl"; + if (weap == 8) + mdel = "progs/w_alien.mdl"; + + if (weap == 9) + mdel = "progs/w_pipe.mdl"; + if (weap == 10) + mdel = "progs/w_shotgun.mdl"; + if (weap == 11) + mdel = "progs/w_pipe.mdl"; + if (weap == 12) + mdel = "progs/w_jackhammer.mdl"; + + if (weap == 13) + mdel = "progs/w_mp9.mdl"; + if (weap == 14) + mdel = "progs/w_mp7.mdl"; + + if (weap == 15) + mdel = "progs/w_rangem.mdl"; + if (weap == 16) + mdel = "progs/w_ak47.mdl"; + if (weap == 17) + mdel = "progs/w_ak47.mdl"; + if (weap == 18) + mdel = "progs/w_srifle.mdl"; + if (weap == 19) + mdel = "progs/w_night.mdl"; + if (weap == 20) + mdel = "progs/w_sa80.mdl"; + if (weap == 21) + mdel = "progs/w_gauss.mdl"; + if (weap == 22) + mdel = "progs/w_carbine.mdl"; + if (self.current_slot == 3) + mdel = "progs/grenade2.mdl"; + + if (self.current_slot == 4 && self.c4 == 1) + mdel = "progs/c4.mdl"; + + setmodel (newmis, mdel); + setsize (newmis, '-2 -2 0', '2 2 1'); + makevectors (self.v_angle); + traceline (self.origin, ((self.origin + (v_forward * IT_LIGHTNING)) + '0 0 32'), FALSE, self); + trace_endpos = (trace_endpos - (v_forward * WEAPON_SPIKES)); + setorigin (newmis, trace_endpos); + newmis.origin_z = self.origin_z; + newmis.nextthink = (time + 180); + newmis.think = SUB_Remove; + newmis.touch = WeaponTouch; + newmis.cnt = weap; + if ((self.current_slot == 1)) + { + self.attack_finished = time; + self.slot1_weight = 0; + self.slot1 = 0; + newmis.slot1 = self.ammo1; + newmis.slot2 = self.maxmag1; + newmis.class = self.mag1; + self.mag1 = 0; + self.maxmag1 = 0; + GetWeaponModel (); + } + if ((self.current_slot == 2)) + { + self.attack_finished = time; + self.slot2_weight = 0; + self.slot2 = 0; + newmis.slot1 = self.ammo2; + newmis.slot2 = self.maxmag2; + newmis.class = self.mag2; + self.mag2 = 0; + self.maxmag2 = 0; + GetWeaponModel (); + } + if ((self.current_slot == 3)) + { + self.attack_finished = time; + newmis.handgrenade = self.handgrenade; + newmis.grenadetype = self.grenadetype; + + stuffcmd(self, "impulse 1\n"); + } +}; + +void (entity guy, float slot) GetWeaponWeight = +{ + local float wt; + + if (slot == 1) + wt = 1; + else if (slot == 2) + wt = 2; + else if (slot == 3) + wt = 8; + else if (slot == 4) + wt = 6; + else if (slot == 5) + wt = 1; + else if (slot == 6) + wt = 2; + else if (slot == 7) + wt = 2; + else if (slot == 8) + wt = 2; + else if (slot == 9) + wt = 3; + else if (slot == 10) + wt = 4; + else if (slot == 11) + wt = 5; + else if (slot == 12) + wt = 6; + else if (slot == 13) + wt = 3; + else if (slot == 14) + wt = 3; + else if (slot == 15) + wt = 5; + else if (slot == 16) + wt = 5; + else if (slot == 17) + wt = 5; + else if (slot == 18) + wt = 7; + else if (slot == 19) + wt = 5; + else if (slot == 20) + wt = 5; + else if (slot == 21) + wt = 9; + else if (slot == 22) + wt = 10; + else if (slot == 23) + wt = 1; + + if (self.current_slot == 1) + self.slot1_weight = wt; + if (self.current_slot == 2) + self.slot2_weight = wt; +}; + +string (entity guy, float slot) GetWeaponName = +{ + local string name; + + if (slot == 1) + name = "knife"; + else if (slot == 2) + name = "axe"; + else if (slot == 3) + name = "ripper"; + else if (slot == 4) + name = "power axe"; + else if (slot == 5) + name = "1911"; + else if (slot == 6) + name = "desert eagle"; + else if (slot == 7) + name = "needler"; + else if (slot == 8) + name = "alien blaster"; + else if (slot == 9) + name = "pipe rifle"; + else if (slot == 10) + name = "winchester"; + else if (slot == 11) + name = "mossberg"; + else if (slot == 12) + name = "citykiller"; + else if (slot == 13) + name = "mp9"; + else if (slot == 14) + name = "grease gun"; + else if (slot == 15) + name = "rangemaster"; + else if (slot == 16) + name = "ak-112"; + else if (slot == 17) + name = "ak-74"; + else if (slot == 18) + name = "dks-1"; + else if (slot == 19) + name = "moonlight"; + else if (slot == 20) + name = "sa-80"; + else if (slot == 21) + name = "gauss rifle"; + else if (slot == 22) + name = "laser carbine"; + + return name; +}; + +string (float slot) GetArmorName = +{ + local string name; + + if (slot == 0) + name = "nothing"; + if (slot == 1) + name = "bulletproof shirt"; + else if (slot == 2) + name = "leather armor"; + else if (slot == 3) + name = "kevlar armor"; + else if (slot == 4) + name = "metal armor"; + else if (slot == 5) + name = "combat armor"; + else if (slot == 6) + name = "brotherhood armor"; + else if (slot == 7) + name = "force armor"; + else if (slot == 8) + name = "light power armor"; + + return name; +}; + + +void (float slot) WeaponAmmo = +{ + local float weap, amount; + + if (slot == 1) + weap = self.slot1; + if (slot == 2) + weap = self.slot2; + + if (weap <= 4) + amount = 0; + else if (weap == 5) + amount = 12; + else if (weap == 6) + amount = 7; + else if (weap == 7) + amount = 15; + else if (weap == 8) + amount = 6; + else if (weap == 9) + amount = 1; + else if (weap == 10) + amount = 2; + else if (weap == 11) + amount = 6; + else if (weap == 12) + amount = 10; + else if (weap == 13) + amount = 30; + else if (weap == 14) + amount = 30; + else if (weap == 15) + amount = 10; + else if (weap == 16) + amount = 24; + else if (weap == 17) + amount = 30; + else if (weap == 18) + amount = 8; + else if (weap == 19) + amount = 30; + else if (weap == 20) + amount = 30; + else if (weap == 21) + amount = 10; + else if (weap == 22) + amount = 40; + + if (slot == 1) + GiveAmmo (1, amount); + if (slot == 2) + GiveAmmo (2, amount); +}; + +void() Crosshair = +{ + local float r; + local string new; + + r = 32 + (self.recoil*8); + if (r > 256) + r = 256; + if (r < 0) + r = 0; + + new = ftos(r); + stuffcmd(self, "crosshairsize "); + stuffcmd(self, new); + stuffcmd(self, "\n"); + r = 0.75 - (self.recoil*0.03); + if (r <= 0.25) + r = 0.25; + + new = ftos(r); + stuffcmd(self, "crosshairalpha "); + stuffcmd(self, new); + stuffcmd(self, "\n"); +}; + + +string () GetChemName = +{ + if (self.chem == 1) + return "stimpack"; + if (self.chem == 2) + return "medical bag"; + if (self.chem == 3) + return "superstim"; + if (self.chem == 4) + return "adrenaline"; + if (self.chem == 5) + return "psycho"; + if (self.chem == 6) + return "berserk"; +}; + +void (entity healer, entity saved) RevivePlayer = +{ + local entity oself; + + saved.deadflag = DEAD_NO; + saved.takedamage = DAMAGE_AIM; + saved.movetype = MOVETYPE_WALK; + saved.solid = SOLID_SLIDEBOX; + saved.ghost = 0; + saved.health = 2; + saved.air_finished = time + 10; + saved.view_ofs = '0 0 22'; + oself = self; + self = saved; + player_run(); + self = oself; + stuffcmd(saved, "impulse 1\n"); + sprint (healer, PRINT_HIGH, "you revive "); + sprint (healer, PRINT_HIGH, trace_ent.netname); + sprint (healer, PRINT_HIGH, ".\n "); + sprint (saved, PRINT_HIGH, healer.netname); + sprint (saved, PRINT_HIGH, " saves you from death.\n"); + saved.view2 = world; +}; + +void(float type) UseBoostingChem = +{ + local vector source; + local vector org; + local string x; + + x = GetChemName(); + + if (self.attack_finished > time) + return; + + self.attack_finished = time + 1; + + makevectors (self.v_angle); + source = self.origin + '0 0 0'; + traceline (source, source + v_forward*64, FALSE, self); + if (trace_fraction == 1.0) + { + if (self.health < self.max_health && self.rage == 0) + { + sound (self, CHAN_BODY, "player/berserk.wav", 1, ATTN_NORM); + self.rage = type; + self.ragetime = (20+type)+random()*30; + return; + } + } + if (trace_ent.classname == "player" && trace_ent.team == self.team) + { + if (trace_ent.health <= 0) + return; + + if (trace_ent.rage >= 1) + { + sprint (self, 2, trace_ent.netname); + sprint (self, PRINT_HIGH, " is already affected.\n"); + return; + } + sprint (trace_ent, 2, self.netname); + sprint (trace_ent, PRINT_HIGH, " used a "); + sprint (trace_ent, PRINT_HIGH, x); + sprint (trace_ent, PRINT_HIGH, " on you.\n"); + sound (trace_ent, CHAN_BODY, "player/berserk.wav", 1, ATTN_NORM); + trace_ent.rage = type; + trace_ent.ragetime = (20+type)+random()*30; + } +}; + +void(float type) UseHealingChem = +{ + local vector source; + local vector org; + local float heal; + local string x; + + x = GetChemName(); + if (type == 1) + x = "bandage"; + + if (self.attack_finished > time) + return; + + heal = type*5; + + self.attack_finished = time + 1; + + makevectors (self.v_angle); + source = self.origin + '0 0 0'; + traceline (source, source + v_forward*64, FALSE, self); + if (trace_fraction == 1.0) + { + if (self.health < self.max_health && self.regen == 0) + { + sound (self, CHAN_BODY, "items/r_item2.wav", 1, ATTN_NORM); + self.health = self.health + heal; + self.regen = heal; + return; + } + } + if (trace_ent.classname == "player" && trace_ent.team == self.team) + { + if (trace_ent.health <= 0 && coop == 1) + { + RevivePlayer(self, trace_ent); + return; + } + if (trace_ent.health <= 0 && coop == 0) + return; + + if (trace_ent.regen >= 1) + { + sprint (self, 2, trace_ent.netname); + sprint (self, PRINT_HIGH, " IS ALREADY HEALING.\n"); + return; + } + sprint (trace_ent, 2, self.netname); + sprint (trace_ent, PRINT_HIGH, " used a "); + sprint (trace_ent, PRINT_HIGH, x); + sprint (trace_ent, PRINT_HIGH, " to heal you.\n"); + + trace_ent.regen = heal; + trace_ent.health = trace_ent.health + heal; + stuffcmd (trace_ent, "v_cshift 0 0 0 0\n"); + sound (self, CHAN_BODY, "items/r_item2.wav", 1, ATTN_NORM); + + } +}; + +void() UseChem = +{ + if (self.chemcount <= 0 || self.chem == 0) + { + self.chem = 0; + self.chemcount = 0; + sound (self, CHAN_BODY, "misc/menu3.wav", 1, ATTN_IDLE); + sprint(self, 2, "you are out of chems!\n"); + return; + } + + if (self.chem == 1)//stimpack + UseHealingChem(2); + if (self.chem == 2)//medical bag + UseHealingChem(3); + if (self.chem == 3)//super-stim + UseHealingChem(4); + if (self.chem == 4)//adrenaline + UseBoostingChem(1); + if (self.chem == 5)//jet + UseBoostingChem(2); + if (self.chem == 6)//psycho + UseBoostingChem(3); + if (self.chem == 7)//mentats + UseBoostingChem(3); + + self.chemcount = self.chemcount - 1; + if (self.chemcount == 0) + self.chem = 0; +}; + +void() Bandage = +{ + if (self.bandages <= 0) + { + self.bandages = 0; + sound (self, CHAN_BODY, "misc/menu3.wav", 1, ATTN_IDLE); + sprint(self, 2, "you are out of bandages!\n"); + return; + } + + UseHealingChem(1); + + self.chemcount = self.chemcount - 1; + if (self.chemcount == 0) + self.chem = 0; +}; + +void () DisplayMenu = +{ + local entity spot; + local string menu; + local entity te; + local string qq; + + if (self.currentmenu == "none") + return; + + if (self.currentmenu == "shop_list") + { + menu = ShopString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_trait") + { + menu = TraitString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_perks") + { + menu = PerkString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_armor") + { + menu = ArmorString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_protect") + { + menu = ProtectString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_melee") + { + menu = MeleeString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_thrown") + { + menu = ThrownString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_pistols") + { + menu = PistolString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_shotguns") + { + menu = ShotgunString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_rifles") + { + menu = RifleString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_chems") + { + menu = ChemString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_other") + { + menu = OtherString (); + centerprint (self, menu); + } + if (self.currentmenu == "shop_equipment") + { + menu = EquipmentString (); + centerprint (self, menu); + } + + if (((self.currentmenu == "select_skill") && (self.team == 1))) + { + centerprint (self, "CHOOSE SKILL SET\n\n1 Medic \n2 Assassin \n3 Soldier \n4 Scientist\n"); + } + if (((self.currentmenu == "select_skill") && (self.team == 2))) + { + centerprint (self, "CHOOSE SKILL SET\n\n1 Medic \n2 Assassin \n3 Soldier \n4 Scientist\n"); + } + if ((self.currentmenu == "select_team")) + { + if (self.class == 0) + centerprint (self, "CHOOSE YOUR TEAM\n\n1 Rangers (good)\n2 Raiders (evil)\n3 Auto-Assign \n"); + if (self.class >= 0 && self.oldteam == 0) + centerprint (self, "CHOOSE YOUR TEAM\n\n1 Rangers (good)\n2 Raiders (evil)\n3 Auto-Assign \n"); + if (self.class > 0 && self.oldteam > 0) + centerprint (self, "CHOOSE YOUR TEAM\n\n1 Rangers (good)\n2 Raiders (evil)\n3 Auto-Assign \n4 Keep Previous \n"); + + + } + if (self.currentmenu == "confirm_team") + { + sound (self, CHAN_BODY, "player/yourturn.wav", 1, ATTN_NORM); + + if (self.team == 1) + centerprint (self, "you will respawn as\n\nRanger - OK?\n1 Yes \n2 No \n"); + if (self.team == 2) + centerprint (self, "you will respawn as\n\nRaider - OK?\n1 Yes \n2 No \n"); + } + if (self.currentmenu == "confirm_skill") + { + sound (self, CHAN_BODY, "player/yourturn.wav", 1, ATTN_NORM); + + if (self.class == 2) + centerprint (self, "your class will be\n\nMedic - OK?\n1 Yes \n2 No \n"); + if (self.class == 3) + centerprint (self, "your class will be\n\nAssassin - OK?\n1 Yes \n2 No \n"); + if (self.class == 4) + centerprint (self, "your class will be\n\nSoldiier - OK?\n1 Yes \n2 No \n"); + if (self.class == 6) + centerprint (self, "your class will be\n\nScientist - OK?\n1 Yes \n2 No \n"); + } +}; + + +void () Special = +{ + if (self.class == 2) + Bandage (); + if (self.class == 3) + Sneak (); + if (self.class == 6) + Shield (); + +}; + +void () hos_run1; +void () hos_stand1; +void (vector org, entity guy, float input, float cost) spawn_station; + +void () ExitScreen = +{ + local float car; + local float q; + local entity te; + local string x; + + + if (self.class == 0) + return; + + if (self.ghost == 1) + return; + + if (self.team == 0) + return; + + if (self.attack_finished > time) + return; + + if (trace_ent.classname == "hostage" && trace_ent.health > 0 && trace_fraction < 1) + { + if (self.team != 1) + return; + + if (self.currentmenu == "menu_build") + return; + + if (trace_ent.cnt == 0) + { + sprint (self, 2, "hostage is now following you.\n"); + trace_ent.nextthink = (time + 0.1); + trace_ent.think = hos_run1; + trace_ent.cnt = 1; + trace_ent.friend = self; + return; + } + else + { + if (trace_ent.cnt == 1) + { + sprint (self, 2, "hostage stopped following you.\n"); + trace_ent.nextthink = (time + 0.1); + trace_ent.think = hos_stand1; + trace_ent.cnt = 0; + trace_ent.friend = trace_ent; + return; + } + } + return; + } + + if ((self.currentmenu != "none")) + { + centerprint (self, "\n"); + self.currentmenu = "none"; + } + else if (self.class == 4) + self.currentmenu = "menu_build"; +}; + +void () Sneak = +{ + local float w; + + w = weightx(); + + if (self.class != 3) + { + sprint (self, PRINT_HIGH, "no stealth-boy.\n"); + return; + } + if (self.sneak == 1) + { + sound (self, CHAN_BODY, "items/inv1.wav", 1, ATTN_NORM); + centerprint (self, " Uncloaked \n"); + setmodel (self, "progs/guy.mdl"); + self.sneak = 0; + return; + } + if (self.ammo_cells < 20) + { + sprint (self, PRINT_HIGH, "wait for stealth-boy to recharge.\n"); + return; + } + if (self.sneak == 0 && w <= 10) + { + sound (self, CHAN_BODY, "items/inv1.wav", 1, ATTN_NORM); + centerprint (self, " Cloaked \n(3% detection chance)"); + self.sneak = 1; + return; + } + else if (self.sneak == 0 && w <= 20) + { + sound (self, CHAN_BODY, "items/inv1.wav", 1, ATTN_NORM); + centerprint (self, " Cloaked \n(10% detection chance)"); + self.sneak = 3; + return; + } + else if (self.sneak == 0 && w > 20) + { + sound (self, CHAN_BODY, "items/inv1.wav", 1, ATTN_NORM); + centerprint (self, " Too Much Gear \n"); + setmodel (self, "progs/guy.mdl"); + self.sneak = 0; + return; + } +}; + +void () Shield = +{ + if (self.class != 6) + { + centerprint (self, "You can't shield yourself!\n"); + return; + } + if (self.sneak == 2) + { + centerprint (self, " Unshielded \n"); + self.sneak = 0; + sound (self, CHAN_BODY, "items/protect2.wav", 1, ATTN_NORM); + return; + } + if (self.ammo_cells < 10) + { + centerprint (self, "wait for your shield to recharge.\n"); + return; + } + if (self.sneak == 0) + { + centerprint (self, " Energy Shield \n"); + self.sneak = 2; + sound (self, CHAN_BODY, "items/protect.wav", 1, ATTN_NORM); + return; + } + +}; + +void () station_die = +{ + if ((self.buildtype == 1)) + { + if ((self.team == 1)) + { + blue_weapon = 0; + } + else + { + if ((self.team == 2)) + { + red_weapon = 0; + } + } + } + if ((self.buildtype == 2)) + { + if ((self.team == 1)) + { + blue_armor = 0; + } + else + { + if ((self.team == 2)) + { + red_armor = 0; + } + } + } + if ((self.buildtype == AS_MELEE)) + { + if ((self.team == 1)) + { + blue_gadget = 0; + } + else + { + if ((self.team == 2)) + { + red_gadget = 0; + } + } + } + Explosion (2); +}; + +void () station_think = +{ + local entity dog; + local entity te; + local string qq; + local float zz, x; + + self.nextthink = time + 2; + self.frame = self.buildtype; + + if (self.track.team != self.team) + { + station_die (); + return; + } + + if (self.chemcount <= 0) + { + station_die (); + return; + } + + if (self.buildtype == 1)//barricade + { + sound (self, CHAN_BODY, "items/protect2.wav", 1, ATTN_NORM); + + te = findradius (self.origin, 256); + while (te) + { + if (te.classname == "player" && te.team == self.team) + { + if (self.chemcount <= 0) + { + sound (self, CHAN_BODY, "misc/menu2.wav", TRUE, ATTN_NORM); + sprint (te, 2, "the shield generator is out of power.\n"); + return; + } + if (te.classname == "player") + { + te.protect = 3; + self.chemcount = self.chemcount - 1; + stuffcmd(te, "v_cshift 0 100 100 100\n"); + } + } + te = te.chain; + } + } + if (self.buildtype == 2)//autodoc + { + te = findradius (self.origin, 70); + while (te) + { + if (te.classname == "player" && te.team == self.team) + { + if (self.chemcount <= 0) + { + sound (self, CHAN_BODY, "misc/item1.wav", TRUE, ATTN_NORM); + sprint (te, 2, "the autodoc is out of medical supplies.\n"); + return; + } + if (te.health < te.max_health) + { + sound (self, CHAN_BODY, "items/r_item2.wav", 1, ATTN_NORM); + sprint (te, 2, "the auto-doc heals you for 3 health.\n"); + te.health = te.health + 3; + self.chemcount = self.chemcount - 1; + if (te.health > te.max_health) + te.health = te.max_health; + } + } + te = te.chain; + } + } + + if (self.buildtype == 0)//mr. ammo + { + te = findradius (self.origin, 60); + while (te) + { + if (te.classname == "player" && te.team == self.team) + { + if (self.chemcount <= 0) + { + sound (self, CHAN_BODY, "misc/item1.wav", TRUE, ATTN_NORM); + sprint (te, 2, "this mr.ammo is out of ammunition.\n"); + return; + } + + x = 300; + + if (te.current_slot == 1 && te.ammo2 < (x)) + { + sound (self, CHAN_BODY, "misc/item1.wav", TRUE, ATTN_NORM); + zz = (te.maxmag1 / 2); + zz = ceil (zz); + qq = ftos (zz); + sprint (te, 2, qq); + sprint (te, 2, " ammo was received from the mr.ammo.\n"); + te.ammo1 = (te.ammo1 + zz); + te.ammo1 = ceil (te.ammo1); + self.chemcount = self.chemcount - 1; + } + else + { + if (te.current_slot == 2 && te.ammo2 < (x)) + { + sound (self, CHAN_BODY, "misc/item1.wav", TRUE, ATTN_NORM); + zz = (te.maxmag2 / 2); + zz = ceil (zz); + qq = ftos (zz); + sprint (te, 2, qq); + sprint (te, 2, " ammo was received from the mr.ammo.\n"); + te.ammo2 = (te.ammo2 + zz); + te.ammo2 = ceil (te.ammo2); + self.chemcount = self.chemcount - 1; + } + } + } + te = te.chain; + } + } +}; + +void () Bar_Think = +{ + local float var; + local float dot1; + + if ((self.owner.health < WEAPON_SHOTGUN)) + { + remove (self); + return; + } + if ((self.owner.health >= self.owner.max_health)) + { + remove (self); + return; + } + self.flags = self.flags; + if ((((self.owner.equipment >= WEAPON_SHOTGUN) && (self.owner.equipment <= AS_MELEE)) && (self.owner.equipment_state == WEAPON_SHOTGUN))) + { + dot1 = WEAPON_SHOTGUN; + } + if ((self.owner.position == WEAPON_SHOTGUN)) + { + dot1 = WEAPON_SHOTGUN; + } + if ((dot1 == WEAPON_SHOTGUN)) + { + self.frame = MULTICAST_ALL; + setmodel (self, ""); + self.nextthink = (time + 0.01); + return; + } + if (((self.owner.health >= WEAPON_SHOTGUN) && (dot1 == MULTICAST_ALL))) + { + self.frame = floor (((self.owner.health / self.owner.max_health) * TE_WIZSPIKE)); + setorigin (self, (self.owner.origin + '0 0 48')); + self.nextthink = (time + 0.01); + setmodel (self, "progs/hbar.spr"); + } +}; + +void (entity guy) spawn_dot = +{ + local entity hologram; + + hologram = spawn (); + hologram.movetype = MOVETYPE_NONE; + hologram.solid = SOLID_NOT; + hologram.owner = self; + setmodel (hologram, "progs/hbar.spr"); + hologram.skin = self.skin; + setorigin (hologram, self.origin); + setsize (hologram, VEC_ORIGIN, VEC_ORIGIN); + hologram.angles = self.angles; + hologram.colormap = self.colormap; + hologram.cnt = MULTICAST_ALL; + hologram.think = Bar_Think; + hologram.nextthink = (time + 0.01); +}; + + +void (vector org, entity guy, float input, float cost) spawn_station = +{ + local entity dog; + local entity te; + + if (input == 3) + { + te = find (world, classname, "robofang"); + while (te) + { + if (te.track == self && te.buildtype == 3) + { + makevectors (self.v_angle); + setorigin(te, self.origin + v_forward*32); + return; + } + te = find (te, classname, "robofang"); + } + } + + if (self.scraps < cost) + { + sprint (self, 2, "not enough metal.\n"); + return; + } + + if (input == 4) + { + if (self.handgrenade == 0) + { + sprint (self, 2, "need a grenade.\n"); + return; + } + if (self.handgrenade == 1) + { + self.grenadetype = 0; + self.handgrenade = 0; + } + + } + + self = guy; + te = find (world, classname, "station"); + while (te) + { + if (te.track == self && te.buildtype == input) + { + sprint (self, 2, "already have one.\n"); + return; + } + te = find (te, classname, "station"); + } + if (input == 3) + { + te = findradius (self.origin, 128); + while (te) + { + if (te != self && te.classname == "player" && te.health > 0) + { + sprint(self, PRINT_HIGH, "not with other players nearby.\n"); + return; + } + te = te.chain; + } + } + + makevectors (self.v_angle); + org = ((org + (v_forward * IT_LIGHTNING)) + (v_up * EF_FLAG2)); + if ((pointcontents ((org + '0 20 0')) != CONTENT_EMPTY)) + { + sprint (self, 2, "can't build there.\n"); + return; + } + if ((pointcontents ((org + '0 -20 0')) != CONTENT_EMPTY)) + { + sprint (self, 2, "can't build there.\n"); + return; + } + if ((pointcontents ((org + '20 0 0')) != CONTENT_EMPTY)) + { + sprint (self, 2, "can't build there.\n"); + return; + } + if ((pointcontents ((org + '-20 0 0')) != CONTENT_EMPTY)) + { + sprint (self, 2, "can't build there.\n"); + return; + } + if ((pointcontents ((org + '0 0 50')) != CONTENT_EMPTY)) + { + sprint (self, 2, "can't build there.\n"); + return; + } + if ((pointcontents ((org + '0 0 -10')) != CONTENT_EMPTY)) + { + sprint (self, 2, "can't build there.\n"); + return; + } + self.impulse = 0; + te = findradius (org, 40); + while (te) + { + if (te.classname == "spawn1") + { + sprint (self, 2, "can't build at spawn.\n"); + return; + } + if (te.classname == "spawn2") + { + sprint (self, 2, "can't build at spawn.\n"); + return; + } + if (te.classname == "ghoul") + { + sprint (self, 2, "somethings in the way.\n"); + return; + } + if (((te.classname == "player") && (te.health > 0))) + { + sprint (self, 2, "can't build on players.\n"); + return; + } + if (((te.classname == "station") && (te.health > 0))) + { + sprint (self, 2, "can't build on other stations.\n"); + return; + } + te = te.chain; + } + self.scraps = (self.scraps - cost); + dog = spawn (); + dog.team = self.team; + dog.track = self; + self = dog; + spawn_dot (dog); + self.origin = org; + self.takedamage = DAMAGE_YES; + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_TOSS; + setsize (self, '-16 -16 0', '16 16 40'); + self.health = SVC_INTERMISSION; + self.max_health = (300 + (input * 50)); + self.th_die = station_die; + setmodel (self, "progs/station.mdl"); + self.classname = "station"; + self.think = station_think; + self.helmet = 2; + self.buildtype = input; + if (self.buildtype == 0) + self.netname = "mr. ammo"; + if (self.buildtype == 1) + self.netname = "shield generator"; + if (self.buildtype == 2) + self.netname = "autodoc"; + if (self.buildtype == 3) + { + setsize(self, '-24 -24 -24', '24 24 24'); + self.netname = "robofang"; + setmodel (self, "progs/dog.mdl"); + } + if (self.buildtype == 4) + { + setsize(self, '-4 -4 -4', '4 4 4'); + self.netname = "grenade"; + setmodel (self, "progs/grenade2.mdl"); + } + self.frame = 4; +}; diff --git a/quakec/fallout2/wizard.qc b/quakec/fallout2/wizard.qc new file mode 100644 index 000000000..6f443bbf2 --- /dev/null +++ b/quakec/fallout2/wizard.qc @@ -0,0 +1,403 @@ +/* +============================================================================== + +WIZARD + +============================================================================== +*/ + +$cd id1/models/a_wizard +$origin 0 0 24 +$base wizbase +$skin wizbase + +$frame hover1 hover2 hover3 hover4 hover5 hover6 hover7 hover8 +$frame hover9 hover10 hover11 hover12 hover13 hover14 hover15 + +$frame fly1 fly2 fly3 fly4 fly5 fly6 fly7 fly8 fly9 fly10 +$frame fly11 fly12 fly13 fly14 + +$frame magatt1 magatt2 magatt3 magatt4 magatt5 magatt6 magatt7 +$frame magatt8 magatt9 magatt10 magatt11 magatt12 magatt13 + +$frame pain1 pain2 pain3 pain4 + +$frame death1 death2 death3 death4 death5 death6 death7 death8 + +/* +============================================================================== + +WIZARD + +If the player moves behind cover before the missile is launched, launch it +at the last visible spot with no velocity leading, in hopes that the player +will duck back out and catch it. +============================================================================== +*/ + +/* +============= +LaunchMissile + +Sets the given entities velocity and angles so that it will hit self.enemy +if self.enemy maintains it's current velocity +0.1 is moderately accurate, 0.0 is totally accurate +============= +*/ +void(entity missile, float mspeed, float accuracy) LaunchMissile = +{ + local vector vec, move; + local float fly; + + 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 + fly = vlen (vec) / mspeed; + +// get the entities xy velocity + move = self.enemy.velocity; + move_z = 0; + +// 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); + + missile.velocity = vec * mspeed; + + missile.angles = '0 0 0'; + missile.angles_y = vectoyaw(missile.velocity); + +// 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; + + if (time < self.attack_finished) + return FALSE; + if (!enemy_vis) + return FALSE; + + if (enemy_range == RANGE_FAR) + { + if (self.attack_state != AS_STRAIGHT) + { + self.attack_state = AS_STRAIGHT; + wiz_run1 (); + } + return FALSE; + } + + targ = self.enemy; + +// 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) + { + self.attack_state = AS_STRAIGHT; + wiz_run1 (); + } + return FALSE; + } + + if (enemy_range == RANGE_MELEE) + chance = 0.9; + else if (enemy_range == RANGE_NEAR) + chance = 0.6; + else if (enemy_range == RANGE_MID) + chance = 0.2; + else + chance = 0; + + if (random () < chance) + { + self.attack_state = AS_MISSILE; + return TRUE; + } + + 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) + { + self.attack_state = AS_SLIDING; + wiz_side1 (); + } + } + + return FALSE; +}; + +/* +================= +WizardAttackFinished +================= +*/ +void() WizardAttackFinished = +{ + if (enemy_range >= RANGE_MID || !enemy_vis) + { + self.attack_state = AS_STRAIGHT; + self.think = wiz_run1; + } + else + { + self.attack_state = AS_SLIDING; + self.think = wiz_side1; + } +}; + +/* +============================================================================== + +FAST ATTACKS + +============================================================================== +*/ + +void() Wiz_FastFire = +{ + local vector vec; + local vector dst; + + if (self.owner.health > 0) + { + makevectors (self.enemy.angles); + dst = self.enemy.origin - 13*self.movedir; + + 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.owner = self.owner; + newmis.classname = "wizspike"; + setmodel (newmis, "progs/w_spike.mdl"); + setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); + } + + remove (self); +}; + + +void() Wiz_StartFast = +{ + local entity missile; + + sound (self, CHAN_WEAPON, "wizard/wattack.wav", 1, ATTN_NORM); + self.v_angle = self.angles; + makevectors (self.angles); + + 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); + missile.enemy = self.enemy; + missile.nextthink = time + 0.8; + missile.think = Wiz_FastFire; + missile.movedir = v_right; + + missile = spawn (); + 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); + 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; + + if (self.waitmin < time) + { + self.waitmin = time + 2; + if (wr > 4.5) + sound (self, CHAN_VOICE, "wizard/widle1.wav", 1, ATTN_IDLE); + if (wr < 1.5) + sound (self, CHAN_VOICE, "wizard/widle2.wav", 1, ATTN_IDLE); + } + return; +}; + +void() wiz_stand1 =[ $hover1, wiz_stand2 ] {ai_stand();}; +void() wiz_stand2 =[ $hover2, wiz_stand3 ] {ai_stand();}; +void() wiz_stand3 =[ $hover3, wiz_stand4 ] {ai_stand();}; +void() wiz_stand4 =[ $hover4, wiz_stand5 ] {ai_stand();}; +void() wiz_stand5 =[ $hover5, wiz_stand6 ] {ai_stand();}; +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_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);}; +void() wiz_walk5 =[ $hover5, wiz_walk6 ] {ai_walk(8);}; +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_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);}; +void() wiz_side5 =[ $hover5, wiz_side6 ] {ai_run(8);}; +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_run2 =[ $fly2, wiz_run3 ] {ai_run(16);}; +void() wiz_run3 =[ $fly3, wiz_run4 ] {ai_run(16);}; +void() wiz_run4 =[ $fly4, wiz_run5 ] {ai_run(16);}; +void() wiz_run5 =[ $fly5, wiz_run6 ] {ai_run(16);}; +void() wiz_run6 =[ $fly6, wiz_run7 ] {ai_run(16);}; +void() wiz_run7 =[ $fly7, wiz_run8 ] {ai_run(16);}; +void() wiz_run8 =[ $fly8, wiz_run9 ] {ai_run(16);}; +void() wiz_run9 =[ $fly9, wiz_run10 ] {ai_run(16);}; +void() wiz_run10 =[ $fly10, wiz_run11 ] {ai_run(16);}; +void() wiz_run11 =[ $fly11, wiz_run12 ] {ai_run(16);}; +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_fast2 =[ $magatt2, wiz_fast3 ] {ai_face();}; +void() wiz_fast3 =[ $magatt3, wiz_fast4 ] {ai_face();}; +void() wiz_fast4 =[ $magatt4, wiz_fast5 ] {ai_face();}; +void() wiz_fast5 =[ $magatt5, wiz_fast6 ] {ai_face();}; +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_pain1 =[ $pain1, wiz_pain2 ] {}; +void() wiz_pain2 =[ $pain2, wiz_pain3 ] {}; +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); +}; +void() wiz_death2 =[ $death2, wiz_death3 ] {}; +void() wiz_death3 =[ $death3, wiz_death4 ]{self.solid = SOLID_NOT;}; +void() wiz_death4 =[ $death4, wiz_death5 ] {}; +void() wiz_death5 =[ $death5, wiz_death6 ] {}; +void() wiz_death6 =[ $death6, wiz_death7 ] {}; +void() wiz_death7 =[ $death7, wiz_death8 ] {}; +void() wiz_death8 =[ $death8, wiz_death8 ] {}; + +void() wiz_die = +{ +// check for gib + if (self.health < -40) + { + sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); + ThrowHead ("progs/h_wizard.mdl", -10); + ThrowGib ("progs/gib2.mdl", -10); + ThrowGib ("progs/gib2.mdl", -10); + ThrowGib ("progs/gib2.mdl", -10); + return; + } + + wiz_death1 (); +}; + + +void(entity attacker, float damage) Wiz_Pain = +{ + sound (self, CHAN_VOICE, "wizard/wpain.wav", 1, ATTN_NORM); + if (random()*70 > damage) + return; // didn't flinch + + wiz_pain1 (); +}; + + +void() Wiz_Missile = +{ + wiz_fast1(); +}; + +void() monster_wizard = +{ + precache_model ("progs/wizard.mdl"); + precache_model ("progs/h_wizard.mdl"); + precache_model ("progs/w_spike.mdl"); + + precache_sound ("wizard/hit.wav"); // used by c code + precache_sound ("wizard/wattack.wav"); + precache_sound ("wizard/wdeath.wav"); + precache_sound ("wizard/widle1.wav"); + precache_sound ("wizard/widle2.wav"); + precache_sound ("wizard/wpain.wav"); + precache_sound ("wizard/wsight.wav"); + + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_STEP; + + setmodel (self, "progs/wizard.mdl"); + + setsize (self, '-16 -16 -24', '16 16 40'); + self.health = 150; + self.team = 3; + self.classname = "monster"; + self.netname = "floater"; + self.th_stand = wiz_stand1; + self.th_walk = wiz_walk1; + self.th_run = wiz_run1; + self.th_missile = Wiz_Missile; + self.th_pain = Wiz_Pain; + self.th_die = wiz_die; + + flymonster_start (); +}; diff --git a/quakec/fallout2/world.qc b/quakec/fallout2/world.qc new file mode 100644 index 000000000..262d18b70 --- /dev/null +++ b/quakec/fallout2/world.qc @@ -0,0 +1,523 @@ + +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 () GameTimer = +{ + local entity te, ze; + local float switch; + local float c, z; + + + switch = 0; + + te = findradius(self.origin, 25000); + while (c < 300 && switch == 0) + { + if (te.classname == "raider" && te.enemy != world && te.processed == 0 && te.active == 0 && switch == 0) + { + te.active = 1; + te.processed = 1; + bprint(2, "it is now "); + bprint(2, te.netname); + bprint(2, "'s turn.\n"); + te.maxspeed = 300; + switch = 1; + + ze = findradius(self.origin, 25000); + z = 0; + while (z < 300) + { + if ((ze.classname == "player" || ze.classname == "raider") && ze != te) + { + ze.active = 0; + ze.maxspeed = 0; + } + z = z + 1; + ze = ze.chain; + } + } + if (te.classname == "player" && te.processed == 0 && te.active == 0 && switch == 0) + { + te.active = 1; + te.processed = 1; + bprint(2, "it is now "); + bprint(2, te.netname); + bprint(2, "'s turn.\n"); + te.maxspeed = 300; + switch = 1; + + ze = findradius(self.origin, 25000); + z = 0; + while (z < 300) + { + if ((ze.classname == "player" || ze.classname == "raider") && ze != te) + { + ze.active = 0; + ze.maxspeed = 0; + } + z = z + 1; + ze = ze.chain; + } + } + c = c + 1; + te = te.chain; + } + + c = 0; + if (switch == 0) // no entities left, turn is over + { + bprint(2, "round is now over.\n"); + + te = findradius(self.origin, 25000); + while (c < 300) + { + if (te.classname == "player" || te.classname == "raider") + { + te.active = 0; + te.processed = 0; + te.maxspeed = 0; + } + + c = c + 1; + te = te.chain; + } + } + + self.think = GameTimer; + self.nextthink = time + 1; +}; + +void () create_timer = +{ + newmis = spawn (); + newmis.owner = self; + newmis.movetype = MOVETYPE_NONE; + setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); + newmis.solid = SOLID_BBOX; + newmis.velocity = VEC_ORIGIN; + newmis.touch = SUB_Null; + setorigin (newmis, '0 0 -300'); + newmis.nextthink = (time + 1); + newmis.think = GameTimer; + newmis.classname = "referee"; +}; + +entity lastspawn; + +//======================= +/*QUAKED worldspawn (0 0 0) ? +Only used for the world entity. +Set message to the level name. +Set sounds to the cd track to play. + +World Types: +0: medieval +1: metal +2: base +*/ +//======================= +void() worldspawn = +{ + lastspawn = world; + InitBodyQue (); + coop = 1; + +// 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 + +// player precaches + W_Precache (); // get weapon precaches + +// sounds used from C physics code + precache_sound ("demon/dland2.wav"); // landing thud + precache_sound ("misc/h2ohit1.wav"); // landing splash + +// 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/land2.wav"); // player hurt landing + precache_sound ("player/drown1.wav"); // drowning pain + precache_sound ("player/drown2.wav"); // drowning pain + precache_sound ("player/gasp1.wav"); // gasping for air + precache_sound ("player/gasp2.wav"); // taking breath + precache_sound ("player/h2odeath.wav"); // drowning death + + 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"); + precache_sound ("misc/r_tele3.wav"); + precache_sound ("misc/r_tele4.wav"); + precache_sound ("misc/r_tele5.wav"); + precache_sound ("weapons/lock4.wav"); // ammo pick up + precache_sound ("weapons/pkup.wav"); // weapon up + precache_sound ("items/armor1.wav"); // armor up + precache_sound ("weapons/lhit.wav"); //lightning + precache_sound ("weapons/lstart.wav"); //lightning start + precache_sound ("items/damage3.wav"); + + precache_sound ("misc/power.wav"); //lightning for boss + +// player gib sounds + precache_sound ("player/gib.wav"); // player gib sound + precache_sound ("player/udeath.wav"); // player gib sound + precache_sound ("player/tornoff2.wav"); // gib sound + +// player pain sounds + + precache_sound ("player/pain1.wav"); + precache_sound ("player/pain2.wav"); + precache_sound ("player/pain3.wav"); + precache_sound ("player/pain4.wav"); + precache_sound ("player/pain5.wav"); + precache_sound ("player/pain6.wav"); + +// player death sounds + precache_sound ("player/death1.wav"); + precache_sound ("player/death2.wav"); + precache_sound ("player/death3.wav"); + precache_sound ("player/death4.wav"); + precache_sound ("player/death5.wav"); + + precache_sound ("boss1/sight1.wav"); + +// 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 + + precache_sound ("player/h2ojump.wav"); // player jumping into water + precache_sound ("player/slimbrn2.wav"); // player enter slime + precache_sound ("player/inh2o.wav"); // player enter water + precache_sound ("player/inlava.wav"); // player enter lava + precache_sound ("misc/outwater.wav"); // leaving water sound + + 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 + +// Invulnerability sounds + precache_sound ("items/protect.wav"); + precache_sound ("items/protect2.wav"); + precache_sound ("items/protect3.wav"); + + precache_model ("progs/player.mdl"); + precache_model ("progs/guy.mdl"); + precache_model ("progs/lay.mdl"); + precache_model ("progs/eyes.mdl"); + precache_model ("progs/h_player.mdl"); + precache_model ("progs/gib1.mdl"); + precache_model ("progs/gib2.mdl"); + precache_model ("progs/gib3.mdl"); + + precache_model ("progs/s_bubble.spr"); // drowning bubbles + precache_model ("progs/s_explod.spr"); // sprite explosion + + precache_model ("progs/v_axe.mdl"); + precache_model ("progs/v_shot.mdl"); + precache_model ("progs/v_nail.mdl"); + precache_model ("progs/v_rock.mdl"); + precache_model ("progs/v_shot2.mdl"); + precache_model ("progs/v_nail2.mdl"); + precache_model ("progs/v_rock2.mdl"); + precache_model ("progs/v_fist.mdl"); + precache_model ("progs/v_knife.mdl"); + precache_model ("progs/v_1911.mdl"); + precache_model ("progs/v_mp5.mdl"); + precache_model ("progs/v_ak47.mdl"); + precache_model ("progs/v_night.mdl"); + precache_model ("progs/sneak.mdl"); + precache_model ("progs/dead.mdl"); + + precache_sound ("weapons/1911.wav"); + precache_sound ("weapons/ak47.wav"); + precache_sound ("weapons/reload.wav"); + precache_sound ("weapons/click.wav"); + + 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/missile.mdl"); + precache_model ("progs/grenade.mdl"); + precache_model ("progs/spike.mdl"); + precache_model ("progs/s_spike.mdl"); + + precache_model ("progs/backpack.mdl"); + + precache_model ("progs/zom_gib.mdl"); + + precache_model ("progs/v_light.mdl"); + + + +// +// Setup light animation tables. 'a' is total darkness, 'z' is maxbright. +// + + // 0 normal + lightstyle(0, "m"); + + // 1 FLICKER (first variety) + lightstyle(1, "mmnmmommommnonmmonqnmmo"); + + // 2 SLOW STRONG PULSE + lightstyle(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"); + + // 3 CANDLE (first variety) + lightstyle(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"); + + // 4 FAST STROBE + lightstyle(4, "mamamamamama"); + + // 5 GENTLE PULSE 1 + lightstyle(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj"); + + // 6 FLICKER (second variety) + lightstyle(6, "nmonqnmomnmomomno"); + + // 7 CANDLE (second variety) + lightstyle(7, "mmmaaaabcdefgmmmmaaaammmaamm"); + + // 8 CANDLE (third variety) + lightstyle(8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"); + + // 9 SLOW STROBE (fourth variety) + lightstyle(9, "aaaaaaaazzzzzzzz"); + + // 10 FLUORESCENT FLICKER + lightstyle(10, "mmamammmmammamamaaamammma"); + + // 11 SLOW PULSE NOT FADE TO BLACK + lightstyle(11, "abcdefghijklmnopqrrqponmlkjihgfedcba"); + + // styles 32-62 are assigned by the light program for switchable lights + + // 63 testing + lightstyle(63, "a"); +}; + +void() StartFrame = +{ + timelimit = cvar("timelimit") * 60; + fraglimit = cvar("fraglimit"); + teamplay = cvar("teamplay"); + deathmatch = cvar("deathmatch"); + + framecount = framecount + 1; +}; + +/* +============================================================================== + +BODY QUE + +============================================================================== +*/ + +entity bodyque_head; + +void() bodyque = +{ // just here so spawn functions don't complain after the world + // creates bodyques +}; + +void() InitBodyQue = +{ + local entity e; + + 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; +}; + + +// make a body que entry for the given ent so the ent can be +// respawned elsewhere +void(entity ent) CopyToBodyQue = +{ + 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; +}; + + diff --git a/quakec/fallout2/zombie.qc b/quakec/fallout2/zombie.qc new file mode 100644 index 000000000..bf9f2a9da --- /dev/null +++ b/quakec/fallout2/zombie.qc @@ -0,0 +1,505 @@ +/* +============================================================================== + +ZOMBIE + +============================================================================== +*/ +$cd id1/models/zombie + +$origin 0 0 24 + +$base base +$skin skin + +$frame stand1 stand2 stand3 stand4 stand5 stand6 stand7 stand8 +$frame stand9 stand10 stand11 stand12 stand13 stand14 stand15 + +$frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8 walk9 walk10 walk11 +$frame walk12 walk13 walk14 walk15 walk16 walk17 walk18 walk19 + +$frame run1 run2 run3 run4 run5 run6 run7 run8 run9 run10 run11 run12 +$frame run13 run14 run15 run16 run17 run18 + +$frame atta1 atta2 atta3 atta4 atta5 atta6 atta7 atta8 atta9 atta10 atta11 +$frame atta12 atta13 + +$frame attb1 attb2 attb3 attb4 attb5 attb6 attb7 attb8 attb9 attb10 attb11 +$frame attb12 attb13 attb14 + +$frame attc1 attc2 attc3 attc4 attc5 attc6 attc7 attc8 attc9 attc10 attc11 +$frame attc12 + +$frame paina1 paina2 paina3 paina4 paina5 paina6 paina7 paina8 paina9 paina10 +$frame paina11 paina12 + +$frame painb1 painb2 painb3 painb4 painb5 painb6 painb7 painb8 painb9 painb10 +$frame painb11 painb12 painb13 painb14 painb15 painb16 painb17 painb18 painb19 +$frame painb20 painb21 painb22 painb23 painb24 painb25 painb26 painb27 painb28 + +$frame painc1 painc2 painc3 painc4 painc5 painc6 painc7 painc8 painc9 painc10 +$frame painc11 painc12 painc13 painc14 painc15 painc16 painc17 painc18 + +$frame paind1 paind2 paind3 paind4 paind5 paind6 paind7 paind8 paind9 paind10 +$frame paind11 paind12 paind13 + +$frame paine1 paine2 paine3 paine4 paine5 paine6 paine7 paine8 paine9 paine10 +$frame paine11 paine12 paine13 paine14 paine15 paine16 paine17 paine18 paine19 +$frame paine20 paine21 paine22 paine23 paine24 paine25 paine26 paine27 paine28 +$frame paine29 paine30 + +$frame cruc_1 cruc_2 cruc_3 cruc_4 cruc_5 cruc_6 + +float SPAWN_CRUCIFIED = 1; + +//============================================================================= + +.float inpain; + +void() zombie_stand1 =[ $stand1, zombie_stand2 ] {ai_stand();}; +void() zombie_stand2 =[ $stand2, zombie_stand3 ] {ai_stand();}; +void() zombie_stand3 =[ $stand3, zombie_stand4 ] {ai_stand();}; +void() zombie_stand4 =[ $stand4, zombie_stand5 ] {ai_stand();}; +void() zombie_stand5 =[ $stand5, zombie_stand6 ] {ai_stand();}; +void() zombie_stand6 =[ $stand6, zombie_stand7 ] {ai_stand();}; +void() zombie_stand7 =[ $stand7, zombie_stand8 ] {ai_stand();}; +void() zombie_stand8 =[ $stand8, zombie_stand9 ] {ai_stand();}; +void() zombie_stand9 =[ $stand9, zombie_stand10 ] {ai_stand();}; +void() zombie_stand10 =[ $stand10, zombie_stand11 ] {ai_stand();}; +void() zombie_stand11 =[ $stand11, zombie_stand12 ] {ai_stand();}; +void() zombie_stand12 =[ $stand12, zombie_stand13 ] {ai_stand();}; +void() zombie_stand13 =[ $stand13, zombie_stand14 ] {ai_stand();}; +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;}; + +void() zombie_walk1 =[ $walk1, zombie_walk2 ] {ai_walk(0);}; +void() zombie_walk2 =[ $walk2, zombie_walk3 ] {ai_walk(2);}; +void() zombie_walk3 =[ $walk3, zombie_walk4 ] {ai_walk(3);}; +void() zombie_walk4 =[ $walk4, zombie_walk5 ] {ai_walk(2);}; +void() zombie_walk5 =[ $walk5, zombie_walk6 ] {ai_walk(1);}; +void() zombie_walk6 =[ $walk6, zombie_walk7 ] {ai_walk(0);}; +void() zombie_walk7 =[ $walk7, zombie_walk8 ] {ai_walk(0);}; +void() zombie_walk8 =[ $walk8, zombie_walk9 ] {ai_walk(0);}; +void() zombie_walk9 =[ $walk9, zombie_walk10 ] {ai_walk(0);}; +void() zombie_walk10 =[ $walk10, zombie_walk11 ] {ai_walk(0);}; +void() zombie_walk11 =[ $walk11, zombie_walk12 ] {ai_walk(2);}; +void() zombie_walk12 =[ $walk12, zombie_walk13 ] {ai_walk(2);}; +void() zombie_walk13 =[ $walk13, zombie_walk14 ] {ai_walk(1);}; +void() zombie_walk14 =[ $walk14, zombie_walk15 ] {ai_walk(0);}; +void() zombie_walk15 =[ $walk15, zombie_walk16 ] {ai_walk(0);}; +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);}; + +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);}; +void() zombie_run5 =[ $run5, zombie_run6 ] {ai_run(2);}; +void() zombie_run6 =[ $run6, zombie_run7 ] {ai_run(3);}; +void() zombie_run7 =[ $run7, zombie_run8 ] {ai_run(4);}; +void() zombie_run8 =[ $run8, zombie_run9 ] {ai_run(4);}; +void() zombie_run9 =[ $run9, zombie_run10 ] {ai_run(2);}; +void() zombie_run10 =[ $run10, zombie_run11 ] {ai_run(0);}; +void() zombie_run11 =[ $run11, zombie_run12 ] {ai_run(0);}; +void() zombie_run12 =[ $run12, zombie_run13 ] {ai_run(0);}; +void() zombie_run13 =[ $run13, zombie_run14 ] {ai_run(2);}; +void() zombie_run14 =[ $run14, zombie_run15 ] {ai_run(4);}; +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); +}; + +/* +============================================================================= + +ATTACKS + +============================================================================= +*/ + +void() ZombieGrenadeTouch = +{ + if (other == self.owner) + return; // don't explode on owner + 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 + self.velocity = '0 0 0'; + self.avelocity = '0 0 0'; + self.touch = SUB_Remove; +}; + +/* +================ +ZombieFireGrenade +================ +*/ +void(vector st) ZombieFireGrenade = +{ + local entity missile, mpuff; + local vector org; + + sound (self, CHAN_WEAPON, "zombie/z_shot1.wav", 1, ATTN_NORM); + + missile = spawn (); + missile.owner = self; + missile.movetype = MOVETYPE_BOUNCE; + missile.solid = SOLID_BBOX; + +// calc org + org = self.origin + st_x * v_forward + st_y * v_right + (st_z - 24) * v_up; + +// 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 + missile.nextthink = time + 2.5; + missile.think = SUB_Remove; + + setmodel (missile, "progs/zom_gib.mdl"); + setsize (missile, '0 0 0', '0 0 0'); + 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();}; +void() zombie_atta4 =[ $atta4, zombie_atta5 ] {ai_face();}; +void() zombie_atta5 =[ $atta5, zombie_atta6 ] {ai_face();}; +void() zombie_atta6 =[ $atta6, zombie_atta7 ] {ai_face();}; +void() zombie_atta7 =[ $atta7, zombie_atta8 ] {ai_face();}; +void() zombie_atta8 =[ $atta8, zombie_atta9 ] {ai_face();}; +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_attb1 =[ $attb1, zombie_attb2 ] {ai_face();}; +void() zombie_attb2 =[ $attb2, zombie_attb3 ] {ai_face();}; +void() zombie_attb3 =[ $attb3, zombie_attb4 ] {ai_face();}; +void() zombie_attb4 =[ $attb4, zombie_attb5 ] {ai_face();}; +void() zombie_attb5 =[ $attb5, zombie_attb6 ] {ai_face();}; +void() zombie_attb6 =[ $attb6, zombie_attb7 ] {ai_face();}; +void() zombie_attb7 =[ $attb7, zombie_attb8 ] {ai_face();}; +void() zombie_attb8 =[ $attb8, zombie_attb9 ] {ai_face();}; +void() zombie_attb9 =[ $attb9, zombie_attb10 ] {ai_face();}; +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_attc1 =[ $attc1, zombie_attc2 ] {ai_face();}; +void() zombie_attc2 =[ $attc2, zombie_attc3 ] {ai_face();}; +void() zombie_attc3 =[ $attc3, zombie_attc4 ] {ai_face();}; +void() zombie_attc4 =[ $attc4, zombie_attc5 ] {ai_face();}; +void() zombie_attc5 =[ $attc5, zombie_attc6 ] {ai_face();}; +void() zombie_attc6 =[ $attc6, zombie_attc7 ] {ai_face();}; +void() zombie_attc7 =[ $attc7, zombie_attc8 ] {ai_face();}; +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_missile = +{ + local float r; + + r = random(); + + if (r < 0.3) + zombie_atta1 (); + else if (r < 0.6) + zombie_attb1 (); + else + zombie_attc1 (); +}; + + +/* +============================================================================= + +PAIN + +============================================================================= +*/ + +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);}; +void() zombie_paina5 =[ $paina5, zombie_paina6 ] {ai_pain(3);}; +void() zombie_paina6 =[ $paina6, zombie_paina7 ] {ai_pain(1);}; +void() zombie_paina7 =[ $paina7, zombie_paina8 ] {}; +void() zombie_paina8 =[ $paina8, zombie_paina9 ] {}; +void() zombie_paina9 =[ $paina9, zombie_paina10 ] {}; +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_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);}; +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_painb10 =[ $painb10, zombie_painb11 ] {}; +void() zombie_painb11 =[ $painb11, zombie_painb12 ] {}; +void() zombie_painb12 =[ $painb12, zombie_painb13 ] {}; +void() zombie_painb13 =[ $painb13, zombie_painb14 ] {}; +void() zombie_painb14 =[ $painb14, zombie_painb15 ] {}; +void() zombie_painb15 =[ $painb15, zombie_painb16 ] {}; +void() zombie_painb16 =[ $painb16, zombie_painb17 ] {}; +void() zombie_painb17 =[ $painb17, zombie_painb18 ] {}; +void() zombie_painb18 =[ $painb18, zombie_painb19 ] {}; +void() zombie_painb19 =[ $painb19, zombie_painb20 ] {}; +void() zombie_painb20 =[ $painb20, zombie_painb21 ] {}; +void() zombie_painb21 =[ $painb21, zombie_painb22 ] {}; +void() zombie_painb22 =[ $painb22, zombie_painb23 ] {}; +void() zombie_painb23 =[ $painb23, zombie_painb24 ] {}; +void() zombie_painb24 =[ $painb24, zombie_painb25 ] {}; +void() zombie_painb25 =[ $painb25, zombie_painb26 ] {ai_painforward(1);}; +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_painc2 =[ $painc2, zombie_painc3 ] {}; +void() zombie_painc3 =[ $painc3, zombie_painc4 ] {ai_pain(3);}; +void() zombie_painc4 =[ $painc4, zombie_painc5 ] {ai_pain(1);}; +void() zombie_painc5 =[ $painc5, zombie_painc6 ] {}; +void() zombie_painc6 =[ $painc6, zombie_painc7 ] {}; +void() zombie_painc7 =[ $painc7, zombie_painc8 ] {}; +void() zombie_painc8 =[ $painc8, zombie_painc9 ] {}; +void() zombie_painc9 =[ $painc9, zombie_painc10 ] {}; +void() zombie_painc10 =[ $painc10, zombie_painc11 ] {}; +void() zombie_painc11 =[ $painc11, zombie_painc12 ] {ai_painforward(1);}; +void() zombie_painc12 =[ $painc12, zombie_painc13 ] {ai_painforward(1);}; +void() zombie_painc13 =[ $painc13, zombie_painc14 ] {}; +void() zombie_painc14 =[ $painc14, zombie_painc15 ] {}; +void() zombie_painc15 =[ $painc15, zombie_painc16 ] {}; +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_paind2 =[ $paind2, zombie_paind3 ] {}; +void() zombie_paind3 =[ $paind3, zombie_paind4 ] {}; +void() zombie_paind4 =[ $paind4, zombie_paind5 ] {}; +void() zombie_paind5 =[ $paind5, zombie_paind6 ] {}; +void() zombie_paind6 =[ $paind6, zombie_paind7 ] {}; +void() zombie_paind7 =[ $paind7, zombie_paind8 ] {}; +void() zombie_paind8 =[ $paind8, zombie_paind9 ] {}; +void() zombie_paind9 =[ $paind9, zombie_paind10 ] {ai_pain(1);}; +void() zombie_paind10 =[ $paind10, zombie_paind11 ] {}; +void() zombie_paind11 =[ $paind11, zombie_paind12 ] {}; +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; +}; +void() zombie_paine2 =[ $paine2, zombie_paine3 ] {ai_pain(8);}; +void() zombie_paine3 =[ $paine3, zombie_paine4 ] {ai_pain(5);}; +void() zombie_paine4 =[ $paine4, zombie_paine5 ] {ai_pain(3);}; +void() zombie_paine5 =[ $paine5, zombie_paine6 ] {ai_pain(1);}; +void() zombie_paine6 =[ $paine6, zombie_paine7 ] {ai_pain(2);}; +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; + self.solid = SOLID_NOT; + return; +} +}; +void() zombie_paine13 =[ $paine13, zombie_paine14 ] {}; +void() zombie_paine14 =[ $paine14, zombie_paine15 ] {}; +void() zombie_paine15 =[ $paine15, zombie_paine16 ] {}; +void() zombie_paine16 =[ $paine16, zombie_paine17 ] {}; +void() zombie_paine17 =[ $paine17, zombie_paine18 ] {}; +void() zombie_paine18 =[ $paine18, zombie_paine19 ] {}; +void() zombie_paine19 =[ $paine19, zombie_paine20 ] {}; +void() zombie_paine20 =[ $paine20, zombie_paine21 ] {}; +void() zombie_paine21 =[ $paine21, zombie_paine22 ] {}; +void() zombie_paine22 =[ $paine22, zombie_paine23 ] {}; +void() zombie_paine23 =[ $paine23, zombie_paine24 ] {}; +void() zombie_paine24 =[ $paine24, zombie_paine25 ] {}; +void() zombie_paine25 =[ $paine25, zombie_paine26 ] {ai_painforward(5);}; +void() zombie_paine26 =[ $paine26, zombie_paine27 ] {ai_painforward(3);}; +void() zombie_paine27 =[ $paine27, zombie_paine28 ] {ai_painforward(1);}; +void() zombie_paine28 =[ $paine28, zombie_paine29 ] {ai_pain(1);}; +void() zombie_paine29 =[ $paine29, zombie_paine30 ] {}; +void() zombie_paine30 =[ $paine30, zombie_run1 ] {}; + +void() zombie_die = +{ + sound (self, CHAN_VOICE, "zombie/z_gib.wav", 1, ATTN_NORM); + ThrowHead ("progs/h_zombie.mdl", self.health); + ThrowGib ("progs/gib1.mdl", self.health); + ThrowGib ("progs/gib2.mdl", self.health); + ThrowGib ("progs/gib3.mdl", self.health); +}; + +/* +================= +zombie_pain + +Zombies can only be killed (gibbed) by doing 60 hit points of damage +in a single frame (rockets, grenades, quad shotgun, quad nailgun). + +A hit of 25 points or more (super shotgun, quad nailgun) will allways put it +down to the ground. + +A hit of from 10 to 40 points in one frame will cause it to go down if it +has been twice in two seconds, otherwise it goes into one of the four +fast pain frames. + +A hit of less than 10 points of damage (winged by a shotgun) will be ignored. + +FIXME: don't use pain_finished because of nightmare hack +================= +*/ +void(entity attacker, float take) zombie_pain = +{ + local float r; + + self.health = 60; // allways reset health + + if (take < 9) + return; // totally ignore + + 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) + { + self.inpain = 2; + zombie_paine1 (); + return; + } + + 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 + self.inpain = 2; + zombie_paine1 (); + return; + } + +// gp into one of the fast pain animations + self.inpain = 1; + + r = random(); + if (r < 0.25) + zombie_paina1 (); + else if (r < 0.5) + zombie_painb1 (); + else if (r < 0.75) + zombie_painc1 (); + else + zombie_paind1 (); +}; + +//============================================================================ + +void() monster_zombie = +{ + precache_model ("progs/zombie.mdl"); + precache_model ("progs/h_zombie.mdl"); + precache_model ("progs/zom_gib.mdl"); + + precache_sound ("zombie/z_idle.wav"); + precache_sound ("zombie/z_idle1.wav"); + precache_sound ("zombie/z_shot1.wav"); + precache_sound ("zombie/z_gib.wav"); + precache_sound ("zombie/z_pain.wav"); + precache_sound ("zombie/z_pain1.wav"); + precache_sound ("zombie/z_fall.wav"); + precache_sound ("zombie/z_miss.wav"); + precache_sound ("zombie/z_hit.wav"); + precache_sound ("zombie/idle_w2.wav"); + + self.solid = SOLID_SLIDEBOX; + self.movetype = MOVETYPE_STEP; + + setmodel (self, "progs/zombie.mdl"); + + setsize (self, '-16 -16 -24', '16 16 40'); + self.health = 60; + + self.th_stand = zombie_stand1; + self.th_walk = zombie_walk1; + self.th_run = zombie_run1; + self.th_pain = zombie_pain; + self.th_die = zombie_die; + self.th_missile = zombie_missile; + + if (self.spawnflags & SPAWN_CRUCIFIED) + { + self.movetype = MOVETYPE_NONE; + zombie_cruc1 (); + } + else + walkmonster_start(); +};