home *** CD-ROM | disk | FTP | other *** search
- /*
- ==============================================================================
-
- BOT AI
-
- ==============================================================================
- */
-
- // Prototypes
-
- float () BotFindTarget;
- float () BotFindStuff;
- void () bot_ai_stand;
- void (entity attacker, float damage) bot_pain;
- void () bot_die;
- void () BotSightSound;
- void () BotFoundTarget;
- void () BotHuntTarget;
- void () BotFoundStuff;
- void () BotHuntStuff;
- void () bot_ai_turn;
- void (float dist) bot_ai_run;
- void (float dist) bot_ai_stuff;
- void (void () thinkst) BotCheckRefire;
- void () BotSelfDeActivate;
- void () bot_fire;
- void () bot_fire2;
- void (vector org, vector dir) launch_spike;
- void () spike_touch;
-
- // Frame macros
-
- $cd /raid/quake/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() bot_stand1 =[ $stand1, bot_stand2 ] {bot_ai_stand();};
- void() bot_stand2 =[ $stand2, bot_stand3 ] {bot_ai_stand();};
- void() bot_stand3 =[ $stand3, bot_stand4 ] {bot_ai_stand();};
- void() bot_stand4 =[ $stand4, bot_stand5 ] {bot_ai_stand();};
- void() bot_stand5 =[ $stand5, bot_stand6 ] {bot_ai_stand();};
- void() bot_stand6 =[ $stand6, bot_stand7 ] {bot_ai_stand();};
- void() bot_stand7 =[ $stand7, bot_stand1 ] {bot_ai_stand();};
-
- void() bot_walk1 =[ $walk1 , bot_walk2 ]
- {
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_ai_roam(4);
- };
- void() bot_walk2 =[ $walk2 , bot_walk3 ] {bot_ai_roam(8);};
- void() bot_walk3 =[ $walk3 , bot_walk4 ] {bot_ai_roam(8);};
- void() bot_walk4 =[ $walk4 , bot_walk5 ] {bot_ai_roam(6);};
- void() bot_walk5 =[ $walk5 , bot_walk6 ] {bot_ai_roam(8);};
- void() bot_walk6 =[ $walk6 , bot_walk7 ] {bot_ai_roam(8);};
- void() bot_walk7 =[ $walk7 , bot_walk8 ] {bot_ai_roam(4);};
- void() bot_walk8 =[ $walk8 , bot_walk9 ] {bot_ai_roam(2);};
- void() bot_walk9 =[ $walk9 , bot_walk10 ] {bot_ai_roam(4);};
- void() bot_walk10 =[ $walk10, bot_walk11 ] {bot_ai_roam(6);};
- void() bot_walk11 =[ $walk11, bot_walk12 ] {bot_ai_roam(4);};
- void() bot_walk12 =[ $walk12, bot_walk13 ] {bot_ai_roam(2);};
- void() bot_walk13 =[ $walk13, bot_walk14 ] {bot_ai_roam(4);};
- void() bot_walk14 =[ $walk14, bot_walk15 ] {bot_ai_roam(2);};
- void() bot_walk15 =[ $walk15, bot_walk16 ] {bot_ai_roam(8);};
- void() bot_walk16 =[ $walk16, bot_walk1 ] {bot_ai_roam(4);};
-
- void() bot_run1 =[ $run1 , bot_run2 ]
- {
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_ai_run(18);
- };
- void() bot_run2 =[ $run2 , bot_run3 ] {bot_ai_run(14);};
- void() bot_run3 =[ $run3 , bot_run4 ] {bot_ai_run(7);};
- void() bot_run4 =[ $run4 , bot_run5 ] {bot_ai_run(12);};
- void() bot_run5 =[ $run5 , bot_run6 ] {bot_ai_run(14);};
- void() bot_run6 =[ $run6 , bot_run7 ] {bot_ai_run(14);};
- void() bot_run7 =[ $run7 , bot_run8 ] {bot_ai_run(7);};
- void() bot_run8 =[ $run8 , bot_run1 ] {bot_ai_run(11);};
-
- //***********
- void() bot_runa1 =[ $run1 , bot_runa2 ]
- {
- if (random() < 0.1)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_ai_roam(18);
- };
- void() bot_runa2 =[ $run2 , bot_runa3 ] {bot_ai_roam(14);};
- void() bot_runa3 =[ $run3 , bot_runa4 ] {bot_ai_roam(7);};
- void() bot_runa4 =[ $run4 , bot_runa5 ] {bot_ai_roam(12);};
- void() bot_runa5 =[ $run5 , bot_runa6 ] {bot_ai_roam(14);};
- void() bot_runa6 =[ $run6 , bot_runa7 ] {bot_ai_roam(14);};
- void() bot_runa7 =[ $run7 , bot_runa8 ] {bot_ai_roam(7);};
- void() bot_runa8 =[ $run8 , bot_runa1 ] {bot_ai_roam(11);};
- //***********
-
- void() bot_stuff1 =[ $run1 , bot_stuff2 ]
- {
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_ai_stuff(18);
- };
- void() bot_stuff2 =[ $run2 , bot_stuff3 ] {bot_ai_stuff(14);};
- void() bot_stuff3 =[ $run3 , bot_stuff4 ] {bot_ai_stuff(7);};
- void() bot_stuff4 =[ $run4 , bot_stuff5 ] {bot_ai_stuff(12);};
- void() bot_stuff5 =[ $run5 , bot_stuff6 ] {bot_ai_stuff(14);};
- void() bot_stuff6 =[ $run6 , bot_stuff7 ] {bot_ai_stuff(14);};
- void() bot_stuff7 =[ $run7 , bot_stuff8 ] {bot_ai_stuff(7);};
- void() bot_stuff8 =[ $run8 , bot_runa1 ] {bot_ai_stuff(11);};
-
- void() bot_atk1 =[ $attack1, bot_atk2 ] {ai_face();};
- void() bot_atk2 =[ $attack2, bot_atk3 ] {ai_face();};
- void() bot_atk3 =[ $attack3, bot_atk4 ] {bot_attack();};
- void() bot_atk4 =[ $attack4, bot_atk5 ] {ai_face();};
- void() bot_atk5 =[ $attack5, bot_atk6 ] {ai_face();};
- void() bot_atk6 =[ $attack6, bot_atk7 ] {bot_attack();};
- void() bot_atk7 =[ $attack6, bot_atk8 ] {ai_face();};
- void() bot_atk8 =[ $attack5, bot_atk9 ] {ai_face();};
- void() bot_atk9 =[ $attack6, bot_atk10 ] {ai_face();};
- void() bot_atk10 =[ $attack5, bot_atk11 ] {bot_attack();};
- void() bot_atk11 =[ $attack6, bot_atk12 ] {ai_face();};
- void() bot_atk12 =[ $attack5, bot_atk13 ] {ai_face();};
- void() bot_atk13 =[ $attack6, bot_atk14 ] {bot_attack();};
- void() bot_atk14 =[ $attack5, bot_atk15 ] {ai_face();};
- void() bot_atk15 =[ $attack6, bot_atk16 ] {ai_face();};
- void() bot_atk16 =[ $attack5, bot_atk17 ] {ai_face();};
- void() bot_atk17 =[ $attack6, bot_atk18 ] {bot_attack();};
- void() bot_atk18 =[ $attack7, bot_atk19 ] {ai_face();};
- void() bot_atk19 =[ $attack8, bot_atk20 ] {ai_face();};
- void() bot_atk20 =[ $attack9, bot_atk21 ] {ai_face();};
- void() bot_atk21 =[ $attack10,bot_run1 ]
- {
- ai_face();
- BotCheckRefire (bot_atk1);
- };
-
- void() bot_paina1 =[ $paina1, bot_paina2 ] {};
- void() bot_paina2 =[ $paina2, bot_paina3 ] {};
- void() bot_paina3 =[ $paina3, bot_paina4 ] {};
- void() bot_paina4 =[ $paina4, bot_run1 ] {};
-
- void() bot_painb1 =[ $painb1, bot_painb2 ] {};
- void() bot_painb2 =[ $painb2, bot_painb3 ] {};
- void() bot_painb3 =[ $painb3, bot_painb4 ] {};
- void() bot_painb4 =[ $painb4, bot_painb5 ] {};
- void() bot_painb5 =[ $painb5, bot_run1 ] {};
-
- void() bot_painc1 =[ $painc1, bot_painc2 ] {};
- void() bot_painc2 =[ $painc2, bot_painc3 ] {};
- void() bot_painc3 =[ $painc3, bot_painc4 ] {};
- void() bot_painc4 =[ $painc4, bot_painc5 ] {};
- void() bot_painc5 =[ $painc5, bot_painc6 ] {};
- void() bot_painc6 =[ $painc6, bot_painc7 ] {};
- void() bot_painc7 =[ $painc7, bot_painc8 ] {};
- void() bot_painc8 =[ $painc8, bot_run1 ] {};
-
- void() bot_paind1 =[ $paind1, bot_paind2 ] {};
- void() bot_paind2 =[ $paind2, bot_paind3 ] {};
- void() bot_paind3 =[ $paind3, bot_paind4 ] {};
- void() bot_paind4 =[ $paind4, bot_paind5 ] {ai_painforward(2);};
- void() bot_paind5 =[ $paind5, bot_paind6 ] {ai_painforward(1);};
- void() bot_paind6 =[ $paind6, bot_paind7 ] {};
- void() bot_paind7 =[ $paind7, bot_paind8 ] {};
- void() bot_paind8 =[ $paind8, bot_paind9 ] {};
- void() bot_paind9 =[ $paind9, bot_paind10 ] {};
- void() bot_paind10 =[ $paind10, bot_paind11 ] {};
- void() bot_paind11 =[ $paind11, bot_paind12 ] {ai_painforward(1);};
- void() bot_paind12 =[ $paind12, bot_paind13 ] {ai_painforward(1);};
- void() bot_paind13 =[ $paind13, bot_paind14 ] {ai_painforward(1);};
- void() bot_paind14 =[ $paind14, bot_paind15 ] {};
- void() bot_paind15 =[ $paind15, bot_paind16 ] {};
- void() bot_paind16 =[ $paind16, bot_paind17 ] {ai_pain(1);};
- void() bot_paind17 =[ $paind17, bot_paind18 ] {ai_pain(1);};
- void() bot_paind18 =[ $paind18, bot_paind19 ] {};
- void() bot_paind19 =[ $paind19, bot_run1 ] {};
-
- void() bot_die1 =[ $death1, bot_die2 ] {};
- void() bot_die2 =[ $death2, bot_die3 ] {};
- void() bot_die3 =[ $death3, bot_die4 ]
- {
- self.solid = SOLID_NOT;
- self.ammo_cells = 5;
- DropBackpack();
- };
- void() bot_die4 =[ $death4, bot_die5 ] {ai_forward(14);};
- void() bot_die5 =[ $death5, bot_die6 ] {ai_forward(2);};
- void() bot_die6 =[ $death6, bot_die7 ] {};
- void() bot_die7 =[ $death7, bot_die8 ] {};
- void() bot_die8 =[ $death8, bot_die9 ] {};
- void() bot_die9 =[ $death9, bot_die10 ] {ai_forward(3);};
- void() bot_die10 =[ $death10, bot_die11 ] {ai_forward(5);};
- void() bot_die11 =[ $death11, bot_die12 ] {ai_forward(5);};
- void() bot_die12 =[ $death12, bot_die13 ] {ai_forward(5);};
- void() bot_die13 =[ $death13, bot_die14 ] {};
- void() bot_die14 =[ $death14, bot_die14 ] {BotSelfDeActivate();};
-
- void() bot_fdie1 =[ $fdeath1, bot_fdie2 ] {};
- void() bot_fdie2 =[ $fdeath2, bot_fdie3 ] {};
- void() bot_fdie3 =[ $fdeath3, bot_fdie4 ]
- {
- self.solid = SOLID_NOT;
- self.ammo_cells = 5;
- DropBackpack();
- };
- void() bot_fdie4 =[ $fdeath4, bot_fdie5 ] {};
- void() bot_fdie5 =[ $fdeath5, bot_fdie6 ] {};
- void() bot_fdie6 =[ $fdeath6, bot_fdie7 ] {};
- void() bot_fdie7 =[ $fdeath7, bot_fdie8 ] {};
- void() bot_fdie8 =[ $fdeath8, bot_fdie9 ] {};
- void() bot_fdie9 =[ $fdeath9, bot_fdie10 ] {};
- void() bot_fdie10 =[ $fdeath10, bot_fdie11 ] {};
- void() bot_fdie11 =[ $fdeath11, bot_fdie11 ] {BotSelfDeActivate();};
-
- //===============================================================================
-
- float() BotFindTarget =
- {
- local entity head, selected;
- local float dist;
- dist = 1200; // awareness radius of bot, increasing it slows down game
- selected = world;
-
- head = findradius(self.origin, dist);
- head = findradius(self.origin, 1500);
- while(head)
- {
- if(!(head.flags & FL_NOTARGET) && ((head.flags & FL_CLIENT) || (head.flags & FL_MONSTER) || (head.classname == "bot")))
- if (((teamplay) && (head.team != self.owner.team)) || (!teamplay))
- if ((head.health > 1) && (head != self))
- if (visible(head))
- if (trace_plane_dist < dist)
- if ((head.health > 0) && (head !=self))
- {
- selected = head;
- dist = trace_plane_dist;
- }
- head = head.chain;
- }
- self.enemy = selected;
-
- if (self.enemy == world)
- return FALSE;
- else
- {
- BotFoundTarget();
- return TRUE;
- }
- };
-
- float() BotFindStuff =
- {
- local entity head, selected;
- local float dist,stuff_vis;
- dist = 300;
- selected = world;
-
- head = findradius(self.origin, 200);
- while(head)
- {
- if ((head.classname == "weapon_supernailgun") ||
- (head.classname == "weapon_supershotgun") ||
- (head.classname == "weapon_rocketlauncher") ||
- (head.classname == "weapon_nailgun") ||
- (head.classname == "backpack") ||
- (head.classname == "botammo") ||
- (head.classname == "item_armor1") ||
- (head.classname == "item_armor2") ||
- (head.classname == "item_armorInv") ||
- ((head.healtype == 1) && (self.health < 100)) ||
- ((head.healtype == 2) && (self.health < 100)))
- {
- selected = head;
- dist = trace_plane_dist;
- }
- head = head.chain;
- }
- self.stuff = selected;
-
- //***********
- stuff_vis = visible(self.stuff);
- if ((self.stuff == world) || !(stuff_vis))
- {
- // if (!(stuff_vis)) bprint("Item not visible...\n");
- //***********
- return FALSE;
- }
- else
- {
- BotFoundStuff();
- return TRUE;
- }
- };
-
- //=============================================================
- // bot_ai_stand - bot stands in place until target acquired,
- // and starts to walk if pausetime has expired
- //=============================================================
- void() bot_ai_stand =
- {
- if (BotFindTarget ())
- return;
-
- if (BotFindStuff ())
- return;
-
- if (time > self.pausetime)
- {
- self.th_walk ();
- return;
- }
- };
-
-
- //=============================================================
- // bot_pain
- //=============================================================
- void(entity attacker, float damage) bot_pain =
- {
- local float r;
- local entity oldself;
-
- r = random ();
- if (self.pain_finished > time)
- 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.2)
- {
- self.pain_finished = time + 0.5;
- bot_paina1 ();
- }
- else if (r < 0.4)
- {
- self.pain_finished = time + 0.5;
- bot_painb1 ();
- }
- else if (r < 0.7)
- {
- self.pain_finished = time + 0.5;
- bot_painc1 ();
- }
- else
- {
- self.pain_finished = time + 1;
- bot_paind1 ();
- }
-
- };
-
- //=============================================================
- // bot_die
- //=============================================================
- void() bot_die =
- {
- sound (self, CHAN_VOICE, "enforcer/death1.wav", 1, ATTN_NORM);
-
- //***********
- self.fl_lead = FALSE;
- //***********
-
- if (random() > 0.5)
- bot_die1 ();
- else
- bot_fdie1 ();
-
- // death frame sequence includes bot deactivation
- };
-
-
- //=============================================================
- // BotSightSound
- //=============================================================
- void() BotSightSound =
- {
- local float rsnd;
-
- 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);
- };
-
-
- //=============================================================
- // BotHuntTarget
- //=============================================================
- void() BotHuntTarget =
- {
- 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 (0.1); // wait a while before first attack
- };
-
- //=============================================================
- // BotHuntStuff
- //=============================================================
- void() BotHuntStuff =
- {
- self.goalentity = self.stuff;
- self.think = self.th_stuff;
- self.ideal_yaw = vectoyaw(self.stuff.origin - self.origin);
- self.nextthink = time + 0.1;
- };
-
- //=============================================================
- // BotFoundTarget
- //=============================================================
- void() BotFoundTarget =
- {
- local float f_dist;
- local string s_dist;
- f_dist = vlen (self.enemy.origin - self.origin);
- s_dist = ftos (f_dist);
-
- self.show_hostile = time + 1; // wake up other monsters
-
- BotSightSound ();
- BotHuntTarget ();
- };
-
- //=============================================================
- // BotFoundStuff - Items
- //=============================================================
- void() BotFoundStuff =
- {
- local float f_dist;
- local string s_dist;
- f_dist = vlen (self.stuff.origin - self.origin);
- s_dist = ftos (f_dist);
-
- BotHuntStuff ();
- };
-
- //=============================================================
- // bot_ai_turn - turn towards ideal_yaw if no enemy sighted
- //=============================================================
- void() bot_ai_turn =
- {
- if (BotFindTarget ())
- return;
-
- if (BotFindStuff ())
- return;
-
- ChangeYaw ();
- };
-
-
- //=============================================================
- // bot_ai_run - still needs a little work
- //=============================================================
- void(float dist) bot_ai_run =
- {
- local vector delta;
- local float axis;
- local float direct, ang_rint, ang_floor, ang_ceil;
-
- movedist = dist;
-
- //***********
- enemy_vis = visible(self.enemy);
- if (enemy_vis)
- self.search_time = time + 5;
-
- if ((self.enemy.health) <= 0 || (self.search_time < time))
- //***********
- {
- self.enemy = world;
- if (self.oldenemy.health > 0)
- {
- self.enemy = self.oldenemy;
- BotHuntTarget();
- }
- else
- {
- if (BotFindTarget())
- return;
- else
- {
- self.th_walk ();
- return;
- }
- }
- }
-
- self.show_hostile = time + 1; // wake up other monsters
-
- enemy_infront = infront(self.enemy);
- enemy_range = range(self.enemy);
- enemy_yaw = vectoyaw(self.enemy.origin - self.origin);
-
- if (self.attack_state == AS_MISSILE)
- {
- ai_run_missile ();
- return;
- }
- if (self.attack_state == AS_MELEE)
- {
- ai_run_melee ();
- return;
- }
-
- if (CheckAnyAttack ())
- return; // beginning an attack
-
- if (self.attack_state == AS_SLIDING)
- {
- ai_run_slide ();
- return;
- }
-
- movetogoal (dist);
- };
-
- //=============================================================
- // bot_ai_stuff
- //=============================================================
- void(float dist) bot_ai_stuff =
- {
- local vector delta;
- local float axis;
- local float direct, ang_rint, ang_floor, ang_ceil;
-
- movedist = dist;
-
- enemy_vis = visible(self.stuff);
- if (enemy_vis)
- self.search_time = time + 3;
-
- enemy_infront = infront(self.stuff);
- enemy_range = range(self.stuff);
- enemy_yaw = vectoyaw(self.stuff.origin - self.origin);
-
- movetogoal (dist);
- };
-
-
- //=============================================================
- // BotCheckRefire
- //=============================================================
- void (void () thinkst) BotCheckRefire =
- {
- if (!visible (self.enemy) || (self.enemy.health <= 0))
- return;
- self.think = thinkst;
- };
-
- //=============================================================
- // BotSelfDeActivate - Bot deactivates itself
- //=============================================================
- void () BotSelfDeActivate =
- {
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_TELEPORT);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
- remove (self);
- };
-
- //=============================================================
- // Bot Weapons
- //=============================================================
- void() bot_FireShotgun =
- {
- local vector dir;
-
- sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
-
- self.currentammo = self.ammo_shells = self.ammo_shells - 1;
- dir = self.enemy.origin - self.origin;
- dir = normalize(dir);
- FireBullets (6, dir, '0.04 0.04 0');
- eject_shell (self.origin + '0 0 16' + v_forward*3,dir); //eject shell
- };
-
- void() bot_FireSuperShotgun =
- {
- local vector dir;
-
- if (self.currentammo == 1)
- {
- bot_FireShotgun ();
- return;
- }
-
- sound (self, CHAN_AUTO, "weapons/shotgn2.wav", 1, ATTN_NORM);
-
- self.currentammo = self.ammo_shells = self.ammo_shells - 2;
- dir = self.enemy.origin - self.origin;
- dir = normalize(dir);
- FireBullets (14, dir, '0.14 0.08 0');
- eject_shell (self.origin + '0 0 16' + v_forward*3,dir); //eject shell
- eject_shell (self.origin + '0 0 16' + v_forward*3,dir); //eject shell
- };
-
- void() bot_FireRocket =
- {
- local entity missile, mpuff;
-
- self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
-
- sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
-
- missile = spawn ();
- missile.owner = self;
- missile.movetype = MOVETYPE_FLYMISSILE;
- missile.solid = SOLID_BBOX;
- makevectors (self.angles);
- missile.velocity = self.enemy.origin - self.origin;
- missile.velocity = normalize(missile.velocity);
- missile.velocity = missile.velocity * 1000;
- missile.angles = vectoangles(missile.velocity);
- missile.touch = T_MissileTouch;
- missile.nextthink = time + 5;
- missile.think = SUB_Remove;
- setmodel (missile, "progs/missile.mdl");
- setsize (missile, '0 0 0', '0 0 0');
- setorigin (missile, self.origin + '0 0 16');
- };
-
- void () bot_fire =
- {
- local vector org;
- local vector dir;
- local float ox;
-
- ox = 4;
-
- self.effects = self.effects | EF_MUZZLEFLASH;
- makevectors (self.angles);
- sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
- self.currentammo = self.ammo_nails = self.ammo_nails - 1;
- org = self.origin + v_forward * 30 + v_right*ox + '0 0 16';
- dir = self.enemy.origin - self.origin;
- dir = normalize(dir);
- launch_spike(org, dir);
- };
-
- void () bot_fire2 =
- {
- local vector dir;
- local vector org;
-
- self.effects = self.effects | EF_MUZZLEFLASH;
- makevectors (self.angles);
- sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
- self.currentammo = self.ammo_nails = self.ammo_nails - 2;
- org = self.origin + '0 0 16';
- dir = self.enemy.origin - self.origin;
- dir = normalize(dir);
- launch_spike (org, dir);
- newmis.touch = superspike_touch;
- setmodel (newmis, "progs/s_spike.mdl");
- setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
- };
-
- /* OLD TM BOT CODE
- void(vector offset) benforcer_fire =
- {
- local vector org;
- local vector dir;
- local float ox;
-
- ox = 4;
-
- self.effects = self.effects | EF_MUZZLEFLASH;
- makevectors (self.angles);
- sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
-
- org = self.origin + v_forward * 30 + v_right*ox + '0 0 16';
- dir = self.enemy.origin - self.origin;
- dir = normalize(dir);
- launch_spike(org, dir);
- org = org + offset;
- launch_spike(org, dir);
- }; */
- /*
- ====================================================
- bot_SetCurrentAmmo
- ====================================================
- */
- void() bot_SetCurrentAmmo =
- {
- self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
-
- if (self.weapon == IT_SHOTGUN)
- {
- self.currentammo = self.ammo_shells;
- self.items = self.items | IT_SHELLS;
- }
- else if (self.weapon == IT_SUPER_SHOTGUN)
- {
- self.currentammo = self.ammo_shells;
- self.items = self.items | IT_SHELLS;
- }
- else if (self.weapon == IT_NAILGUN)
- {
- self.currentammo = self.ammo_nails;
- self.items = self.items | IT_NAILS;
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- self.currentammo = self.ammo_nails;
- self.items = self.items | IT_NAILS;
- }
- else if (self.weapon == IT_ROCKET_LAUNCHER)
- {
- self.currentammo = self.ammo_rockets;
- self.items = self.items | IT_ROCKETS;
- }
- else
- {
- self.currentammo = 0;
- self.weaponmodel = "";
- self.weaponframe = 0;
- }
- };
- /*
- ====================================================
- bot_bestweapon - AI to choose which weapon is best
- ====================================================
- */
- float () bot_bestweapon =
- {
- local float it;
-
- it = self.items;
-
- if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) )
- return IT_ROCKET_LAUNCHER;
- 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;
-
- return IT_SHOTGUN;
-
- };
- /*
- ===============================================
- bot_CheckNoAmmo - checks to see if he has ammo
- ===============================================
- */
- float() bot_CheckNoAmmo =
- {
- if (self.currentammo > 0)
- return TRUE;
-
- self.weapon = bot_bestweapon ();
-
- bot_SetCurrentAmmo ();
-
- return FALSE;
- };
- /*
- ==========================
- bot_attack - fires weapon
- ==========================
- */
- void() bot_attack =
- {
- local float r;
-
- if (!visible (self.enemy) || (self.enemy.health <= 0))
- return;
-
- if (!bot_CheckNoAmmo ())
- return;
-
- makevectors (self.angles);
- self.show_hostile = time + 1; // wake monsters up
-
- if (self.weapon == IT_SHOTGUN)
- {
- bot_FireShotgun ();
- }
- else if (self.weapon == IT_SUPER_SHOTGUN)
- {
- bot_FireSuperShotgun ();
- }
- else if (self.weapon == IT_NAILGUN)
- {
- bot_fire ();
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- bot_fire2 ();
- }
- else if (self.weapon == IT_ROCKET_LAUNCHER)
- {
- bot_FireRocket();
- }
- };
-