home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-01 | 66.3 KB | 1,905 lines |
- /*
- ==============================================================================
-
- BOT AI
-
- ==============================================================================
- */
-
- // Prototypes
- void(float shotcount, vector dir, vector spread) FireBullets;
- void () bot_upabit;
- float() check_dodge;
- void () bot_start_dodge;
- void () bot_run_mdodge;
- void () bot_end_dodge;
- void () bot_start_circle;
- void () bot_end_circle;
- void () bot_enemy_image;
- void () bot_remove_enemy_image;
- void () bot_ai_face;
- float(entity targ, entity targ2) infrontr;
- void() bot_firebullets;
- void () BotFoundRocket;
- void () BotStartDM;
- void (float frgs,entity tmp) BotReStartDM;
- void () bot_run_dodge;
- float () BotFindTarget;
- void () bot_run_circle;
- void () bot_ai_stand;
- void () bot_die;
- void () BotSightSound;
- void () BotFoundTarget;
- void () BotHuntTarget;
- void (float dist) bot_ai_walk;
- void () bot_ai_turn;
- void (float dist) bot_ai_run;
- void (void () thinkst) BotCheckRefire;
- void () BotSelfDeActivate;
- void () bot_attack;
- void () bot_shoot;
- void () bot_fire;
- void () bot_nail;
- void () bot_nail2;
- void () enforcer_fire;
- void (vector offset) benforcer_fire;
- void (vector org, vector dir) launch_spike;
- void () spike_touch;
- void () superspike_touch;
- void (entity oldself) Bot_PostThink;
- void (entity oldself) Bot_PreThink;
- //void () bot_remove_controller;
- void () bot_think;
- void () Bot_PostThinkb;
- void () Bot_PreThinkb;
- void () bot_thinkb;
- void() BotCheckPowerupsb;
- float modelindex_eyes, modelindex_bot;
- void () BotFoundItem;
- float () BotFindItem;
- void () BOTFireGrenade;
- void () BOTGrenadeTouch;
- void () BOTGrenadeExplode;
- void () s_explode1;
- void (float dist) bot_ai_stuff;
- void () BotFoundStuff;
- void () BotHuntStuff;
- float () BotFindStuff;
-
- //void () set_ai_think;
-
- $cd /raid/quake/id1/models/player_4
- $origin 0 -6 24
- $base base
- $skin skin
-
- //
- // running
- //
- $frame axrun1 axrun2 axrun3 axrun4 axrun5 axrun6
-
- $frame rockrun1 rockrun2 rockrun3 rockrun4 rockrun5 rockrun6
-
- //
- // standing
- //
- $frame stand1 stand2 stand3 stand4 stand5
-
- $frame axstnd1 axstnd2 axstnd3 axstnd4 axstnd5 axstnd6
- $frame axstnd7 axstnd8 axstnd9 axstnd10 axstnd11 axstnd12
-
-
- //
- // pain
- //
- $frame axpain1 axpain2 axpain3 axpain4 axpain5 axpain6
-
- $frame pain1 pain2 pain3 pain4 pain5 pain6
-
-
- //
- // death
- //
-
- $frame axdeth1 axdeth2 axdeth3 axdeth4 axdeth5 axdeth6
- $frame axdeth7 axdeth8 axdeth9
-
- $frame deatha1 deatha2 deatha3 deatha4 deatha5 deatha6 deatha7 deatha8
- $frame deatha9 deatha10 deatha11
-
- $frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8
- $frame deathb9
-
- $frame deathc1 deathc2 deathc3 deathc4 deathc5 deathc6 deathc7 deathc8
- $frame deathc9 deathc10 deathc11 deathc12 deathc13 deathc14 deathc15
-
- $frame deathd1 deathd2 deathd3 deathd4 deathd5 deathd6 deathd7
- $frame deathd8 deathd9
-
- $frame deathe1 deathe2 deathe3 deathe4 deathe5 deathe6 deathe7
- $frame deathe8 deathe9
-
- //
- // attacks
- //
- $frame nailatt1 nailatt2
-
- $frame light1 light2
-
- $frame rockatt1 rockatt2 rockatt3 rockatt4 rockatt5 rockatt6
-
- $frame shotatt1 shotatt2 shotatt3 shotatt4 shotatt5 shotatt6
-
- $frame axatt1 axatt2 axatt3 axatt4 axatt5 axatt6
-
- $frame axattb1 axattb2 axattb3 axattb4 axattb5 axattb6
-
- $frame axattc1 axattc2 axattc3 axattc4 axattc5 axattc6
-
- $frame axattd1 axattd2 axattd3 axattd4 axattd5 axattd6
-
-
- 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_stand1 ] {bot_ai_stand();};
-
- void() bot_walk1 =[ $rockrun1 , bot_walk2 ]
- {
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_ai_walk(6);
- };
- void() bot_walk2 =[ $rockrun1 , bot_walk3 ] {bot_ai_walk(10);};
- void() bot_walk3 =[ $rockrun2 , bot_walk4 ] {bot_ai_walk(10);};
- void() bot_walk4 =[ $rockrun2 , bot_walk5 ] {bot_ai_walk(8);};
- void() bot_walk5 =[ $rockrun3 , bot_walk6 ] {bot_ai_walk(4);};
- void() bot_walk6 =[ $rockrun3 , bot_walk7 ] {bot_ai_walk(6);bot_upabit();};
- void() bot_walk7 =[ $rockrun4 , bot_walk8 ] {bot_ai_walk(10);};
- void() bot_walk8 =[ $rockrun4 , bot_walk9 ] {bot_ai_walk(10);};
- void() bot_walk9 =[ $rockrun5 , bot_walk10 ] {bot_ai_walk(8);};
- void() bot_walk10 =[ $rockrun5 , bot_walk11 ] {bot_ai_walk(4);};
- void() bot_walk11 =[ $rockrun6 , bot_walk12 ] {bot_ai_walk(6);};
- void() bot_walk12 =[ $rockrun6 , bot_walk1 ] {bot_ai_walk(8);bot_upabit();};
-
- void() bot_run1 =[ $rockrun1 , bot_run2 ]
- {
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_ai_run(30);//18
- };
- void() bot_run2 =[ $rockrun2 , bot_run3 ] {bot_ai_run(30);};//14
- void() bot_run3 =[ $rockrun3 , bot_run4 ] {bot_ai_run(30);bot_upabit();};//7
- void() bot_run4 =[ $rockrun4 , bot_run5 ] {bot_ai_run(30);};//12
- void() bot_run5 =[ $rockrun5 , bot_run6 ] {bot_ai_run(30);};//14
- void() bot_run6 =[ $rockrun6 , bot_run1 ] {bot_ai_run(30);bot_upabit();};//14
-
- void() bot_dodge1 =[ $shotatt1, bot_dodge2 ] {bot_ai_face();bot_start_dodge();bot_run_dodge();};
- void() bot_dodge2 =[ $shotatt2, bot_dodge3 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodge3 =[ $shotatt3, bot_dodge4 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge4 =[ $shotatt4, bot_dodge5 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge5 =[ $shotatt5, bot_dodge6 ] {bot_ai_face();bot_run_dodge();};
-
- void() bot_dodge6 =[ $rockrun1 , bot_dodge7 ]
- {bot_ai_face();
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_run_dodge();
- };
- void() bot_dodge7 =[ $rockrun2 , bot_dodge8 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge8 =[ $rockrun3 , bot_dodge9 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge9 =[ $rockrun4 , bot_dodge10 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge10 =[ $rockrun5 , bot_dodge11 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge11 =[ $shotatt1, bot_dodge12 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge12 =[ $shotatt2, bot_dodge13 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodge13 =[ $shotatt3, bot_dodge14 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge14 =[ $shotatt4, bot_dodge15 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge15 =[ $shotatt5, bot_dodge16 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge16 =[ $shotatt6, bot_dodge17 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge17 =[ $rockrun3 , bot_dodge18 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge18 =[ $rockrun4 , bot_dodge19 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge19 =[ $rockrun5 , bot_dodge20 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodge20 =[ $rockrun6 , bot_run1 ] {bot_ai_face();bot_run_dodge();bot_end_dodge();};
-
- void() bot_dodgen1 =[ $nailatt2, bot_dodgen2 ] {bot_ai_face();bot_start_dodge();bot_run_dodge();};
- void() bot_dodgen2 =[ $nailatt1, bot_dodgen3 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgen3 =[ $nailatt2, bot_dodgen4 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen4 =[ $nailatt1, bot_dodgen5 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgen5 =[ $nailatt2, bot_dodgen6 ] {bot_ai_face();bot_run_dodge();};
-
- void() bot_dodgen6 =[ $rockrun1 , bot_dodgen7 ]
- {bot_ai_face();
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_run_dodge();
- };
- void() bot_dodgen7 =[ $rockrun2 , bot_dodgen8 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen8 =[ $rockrun3 , bot_dodgen9 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen9 =[ $rockrun4 , bot_dodgen10 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen10 =[ $rockrun5 , bot_dodgen11 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen11 =[ $nailatt2, bot_dodgen12 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen12 =[ $nailatt1, bot_dodgen13 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgen13 =[ $nailatt2, bot_dodgen14 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen14 =[ $nailatt1, bot_dodgen15 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgen15 =[ $nailatt2, bot_dodgen16 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen16 =[ $nailatt1, bot_dodgen17 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgen17 =[ $rockrun3 , bot_dodgen18 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen18 =[ $rockrun4 , bot_dodgen19 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen19 =[ $rockrun5 , bot_dodgen20 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgen20 =[ $rockrun6 , bot_run1 ] {bot_ai_face();bot_run_dodge();bot_end_dodge();};
-
- void() bot_dodgesn1 =[ $nailatt2, bot_dodgesn2 ] {bot_ai_face();bot_start_dodge();bot_run_dodge();};
- void() bot_dodgesn2 =[ $nailatt1, bot_dodgesn3 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgesn3 =[ $nailatt1, bot_dodgesn4 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgesn4 =[ $nailatt2, bot_dodgesn5 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgesn5 =[ $nailatt1, bot_dodgesn6 ] {bot_ai_face();bot_attack();bot_run_dodge();};
-
- void() bot_dodgesn6 =[ $rockrun1 , bot_dodgesn7 ]
- {bot_ai_face();
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_run_dodge();
- };
- void() bot_dodgesn7 =[ $rockrun2 , bot_dodgesn8 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgesn8 =[ $rockrun3 , bot_dodgesn9 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgesn9 =[ $rockrun4 , bot_dodgesn10 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgesn10 =[ $rockrun5 , bot_dodgesn11 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgesn11 =[ $nailatt2, bot_dodgesn12 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgesn12 =[ $nailatt1, bot_dodgesn13 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgesn13 =[ $nailatt1, bot_dodgesn14 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgesn14 =[ $nailatt2, bot_dodgesn15 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgesn15 =[ $nailatt1, bot_dodgesn16 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgesn16 =[ $nailatt1, bot_dodgesn17 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodgesn17 =[ $rockrun3 , bot_dodgesn18 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgesn18 =[ $rockrun4 , bot_dodgesn19 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgesn19 =[ $rockrun5 , bot_dodgesn20 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgesn20 =[ $rockrun6 , bot_run1 ] {bot_ai_face();bot_run_dodge();bot_end_dodge();};
-
- void() bot_dodger1 =[ $rockatt1, bot_dodger2 ] {bot_ai_face();bot_start_dodge();bot_attack();bot_run_dodge();};
- void() bot_dodger2 =[ $rockatt2, bot_dodger3 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger3 =[ $rockatt3, bot_dodger4 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger4 =[ $rockatt4, bot_dodger5 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger5 =[ $rockatt5, bot_dodger6 ] {bot_ai_face();bot_run_dodge();};
-
- void() bot_dodger6 =[ $rockrun1 , bot_dodger7 ]
- {bot_ai_face();
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_run_dodge();
- };
- void() bot_dodger7 =[ $rockrun2 , bot_dodger8 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger8 =[ $rockrun3 , bot_dodger9 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger9 =[ $rockrun4 , bot_dodger10 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger10 =[ $rockrun5 , bot_dodger11 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger11 =[ $rockatt1, bot_dodger12 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_dodger12 =[ $rockatt2, bot_dodger13 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger13 =[ $rockatt3, bot_dodger14 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger14 =[ $rockatt4, bot_dodger15 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger15 =[ $rockatt5, bot_dodger16 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger16 =[ $rockatt6, bot_dodger17 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger17 =[ $rockrun3 , bot_dodger18 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger18 =[ $rockrun4 , bot_dodger19 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger19 =[ $rockrun5 , bot_dodger20 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodger20 =[ $rockrun6 , bot_run1 ] {bot_ai_face();bot_run_dodge();bot_end_dodge();};
-
- void() bot_circle1 =[ $shotatt1, bot_circle2 ] {bot_ai_face();bot_start_circle();bot_run_circle();};
- void() bot_circle2 =[ $shotatt2, bot_circle3 ] {bot_ai_face();bot_attack();bot_run_circle();};
- void() bot_circle3 =[ $shotatt3, bot_circle4 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle4 =[ $shotatt4, bot_circle5 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle5 =[ $shotatt5, bot_circle6 ] {bot_ai_face();bot_run_circle();};
-
- void() bot_circle6 =[ $rockrun1 , bot_circle7 ]
- {bot_ai_face();
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_run_circle();
- };
- void() bot_circle7 =[ $rockrun2 , bot_circle8 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle8 =[ $rockrun3 , bot_circle9 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle9 =[ $rockrun4 , bot_circle10 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle10 =[ $rockrun5 , bot_circle11 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle11 =[ $shotatt1, bot_circle12 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle12 =[ $shotatt2, bot_circle13 ] {bot_ai_face();bot_attack();bot_run_circle();};
- void() bot_circle13 =[ $shotatt3, bot_circle14 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle14 =[ $shotatt4, bot_circle15 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle15 =[ $shotatt5, bot_circle16 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle16 =[ $shotatt6, bot_circle17 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle17 =[ $rockrun3 , bot_circle18 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle18 =[ $rockrun4 , bot_circle19 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle19 =[ $rockrun5 , bot_circle20 ] {bot_ai_face();bot_run_circle();};
- void() bot_circle20 =[ $rockrun6 , bot_circle1 ] {bot_ai_face();bot_run_circle();bot_end_circle();};
-
-
-
- void() bot_atk1 =[ $shotatt1, bot_atk2 ] {bot_ai_face();};
- void() bot_atk2 =[ $shotatt2, bot_atk3 ] {bot_ai_face();bot_attack();};
- void() bot_atk3 =[ $shotatt3, bot_atk4 ] {bot_ai_face();};
- void() bot_atk4 =[ $shotatt4, bot_atk5 ] {bot_ai_face();};
- void() bot_atk5 =[ $shotatt5, bot_atk6 ] {bot_ai_face();};
- void() bot_atk6 =[ $shotatt6, bot_run1 ] {bot_ai_face();
- bot_ai_face();
- BotCheckRefire (bot_atk1);
- };
- void() bot_atkn1 =[ $nailatt2, bot_atkn2 ] {bot_ai_face();};
- void() bot_atkn2 =[ $nailatt1, bot_atkn3 ] {bot_ai_face();bot_attack();};
- void() bot_atkn3 =[ $nailatt2, bot_atkn4 ] {bot_ai_face();};
- void() bot_atkn4 =[ $nailatt1, bot_atkn5 ] {bot_ai_face();bot_attack();};
- void() bot_atkn5 =[ $nailatt2, bot_atkn6 ] {bot_ai_face();};
- void() bot_atkn6 =[ $nailatt1, bot_run1 ] {bot_ai_face();bot_attack();
- bot_ai_face();
- BotCheckRefire (bot_atkn1);
- };
- void() bot_atksn1 =[ $nailatt2, bot_atksn2 ] {bot_ai_face();};
- void() bot_atksn2 =[ $nailatt1, bot_atksn3 ] {bot_ai_face();bot_attack();};
- void() bot_atksn3 =[ $nailatt1, bot_atksn4 ] {bot_ai_face();bot_attack();};
- void() bot_atksn4 =[ $nailatt2, bot_atksn5 ] {bot_ai_face();};
- void() bot_atksn5 =[ $nailatt1, bot_atksn6 ] {bot_ai_face();bot_attack();};
- void() bot_atksn6 =[ $nailatt1, bot_run1 ] {bot_ai_face();bot_attack();
- bot_ai_face();
- BotCheckRefire (bot_atksn1);
- };
-
- void() bot_atkr1 =[ $rockatt1, bot_atkr2 ] {bot_ai_face();bot_attack();};
- void() bot_atkr2 =[ $rockatt2, bot_atkr3 ] {bot_ai_face();};
- void() bot_atkr3 =[ $rockatt3, bot_atkr4 ] {bot_ai_face();};
- void() bot_atkr4 =[ $rockatt4, bot_atkr5 ] {bot_ai_face();};
- void() bot_atkr5 =[ $rockatt5, bot_atkr6 ] {bot_ai_face();};
- void() bot_atkr6 =[ $rockatt6, bot_run1 ] {bot_ai_face();
- bot_ai_face();
- BotCheckRefire (bot_atkr1);
- };
-
- void() bot_stuff1 =[ $rockrun1 , bot_stuff2 ]
- {
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_ai_stuff(18);
- };
- void() bot_stuff2 =[ $rockrun2 , bot_stuff3 ] {bot_ai_stuff(14);};
- void() bot_stuff3 =[ $rockrun3 , bot_stuff4 ] {bot_ai_stuff(7);bot_upabit();};
- void() bot_stuff4 =[ $rockrun4 , bot_stuff5 ] {bot_ai_stuff(12);};
- void() bot_stuff5 =[ $rockrun5 , bot_stuff6 ] {bot_ai_stuff(14);};
- void() bot_stuff6 =[ $rockrun6 , bot_walk1 ] {bot_ai_stuff(14);bot_upabit();};
-
-
- void() bot_diea1 = [ $deatha1, bot_diea2 ] {};
- void() bot_diea2 = [ $deatha2, bot_diea3 ] {};
- void() bot_diea3 = [ $deatha3, bot_diea4 ]
- {
- self.solid = SOLID_NOT;
- DropBackpack();
- };
-
- void() bot_diea4 = [ $deatha4, bot_diea5 ] {};
- void() bot_diea5 = [ $deatha5, bot_diea6 ] {};
- void() bot_diea6 = [ $deatha6, bot_diea7 ] {};
- void() bot_diea7 = [ $deatha7, bot_diea8 ] {};
- void() bot_diea8 = [ $deatha8, bot_diea9 ] {};
- void() bot_diea9 = [ $deatha9, bot_diea10 ] {};
- void() bot_diea10 = [ $deatha10, bot_diea11 ] {};
- void() bot_diea11 = [ $deatha11, bot_diea11 ] {BotSelfDeActivate();};
-
- void() bot_dieb1 = [ $deathb1, bot_dieb2 ] {};
- void() bot_dieb2 = [ $deathb2, bot_dieb3 ] {};
- void() bot_dieb3 = [ $deathb3, bot_dieb4 ]
- {
- self.solid = SOLID_NOT;
- DropBackpack();
- };
-
- void() bot_dieb4 = [ $deathb4, bot_dieb5 ] {};
- void() bot_dieb5 = [ $deathb5, bot_dieb6 ] {};
- void() bot_dieb6 = [ $deathb6, bot_dieb7 ] {};
- void() bot_dieb7 = [ $deathb7, bot_dieb8 ] {};
- void() bot_dieb8 = [ $deathb8, bot_dieb9 ] {};
- void() bot_dieb9 = [ $deathb9, bot_dieb9 ] {BotSelfDeActivate();};
-
- void() bot_diec1 = [ $deathc1, bot_diec2 ] {};
- void() bot_diec2 = [ $deathc2, bot_diec3 ] {};
- void() bot_diec3 = [ $deathc3, bot_diec4 ]
- {
- self.solid = SOLID_NOT;
- DropBackpack();
- };
-
- void() bot_diec4 = [ $deathc4, bot_diec5 ] {};
- void() bot_diec5 = [ $deathc5, bot_diec6 ] {};
- void() bot_diec6 = [ $deathc6, bot_diec7 ] {};
- void() bot_diec7 = [ $deathc7, bot_diec8 ] {};
- void() bot_diec8 = [ $deathc8, bot_diec9 ] {};
- void() bot_diec9 = [ $deathc9, bot_diec10 ] {};
- void() bot_diec10 = [ $deathc10, bot_diec11 ] {};
- void() bot_diec11 = [ $deathc11, bot_diec12 ] {};
- void() bot_diec12 = [ $deathc12, bot_diec13 ] {};
- void() bot_diec13 = [ $deathc13, bot_diec14 ] {};
- void() bot_diec14 = [ $deathc14, bot_diec15 ] {};
- void() bot_diec15 = [ $deathc15, bot_diec15 ] {BotSelfDeActivate();};
-
- void() bot_died1 = [ $deathd1, bot_died2 ] {};
- void() bot_died2 = [ $deathd2, bot_died3 ] {};
- void() bot_died3 = [ $deathd3, bot_died4 ]
- {
- self.solid = SOLID_NOT;
- DropBackpack();
- };
-
- void() bot_died4 = [ $deathd4, bot_died5 ] {};
- void() bot_died5 = [ $deathd5, bot_died6 ] {};
- void() bot_died6 = [ $deathd6, bot_died7 ] {};
- void() bot_died7 = [ $deathd7, bot_died8 ] {};
- void() bot_died8 = [ $deathd8, bot_died9 ] {};
- void() bot_died9 = [ $deathd9, bot_died9 ] {BotSelfDeActivate();};
-
- void() bot_diee1 = [ $deathe1, bot_diee2 ] {};
- void() bot_diee2 = [ $deathe2, bot_diee3 ] {};
- void() bot_diee3 = [ $deathe3, bot_diee4 ]
- {
- self.solid = SOLID_NOT;
- DropBackpack();
- };
-
- void() bot_diee4 = [ $deathe4, bot_diee5 ] {};
- void() bot_diee5 = [ $deathe5, bot_diee6 ] {};
- void() bot_diee6 = [ $deathe6, bot_diee7 ] {};
- void() bot_diee7 = [ $deathe7, bot_diee8 ] {};
- void() bot_diee8 = [ $deathe8, bot_diee9 ] {};
- void() bot_diee9 = [ $deathe9, bot_diee9 ] {BotSelfDeActivate();};
-
-
- void() bot_qatk1 =[ $shotatt1, bot_qatk2 ] {bot_ai_face();bot_run_dodge();};
- void() bot_qatk2 =[ $shotatt2, bot_qatk3 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_qatk3 =[ $shotatt3, bot_qatk4 ] {bot_ai_face();bot_run_dodge();};
- void() bot_qatk4 =[ $shotatt4, bot_qatk5 ] {bot_ai_face();bot_run_dodge();};
- void() bot_qatk5 =[ $shotatt5, bot_atk1 ] {bot_ai_face();bot_run_dodge();};
-
- void() bot_qatkn1 =[ $nailatt2, bot_qatkn2 ] {bot_ai_face();bot_run_dodge();};
- void() bot_qatkn2 =[ $nailatt1, bot_qatkn3 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_qatkn3 =[ $nailatt2, bot_qatkn4 ] {bot_ai_face();bot_run_dodge();};
- void() bot_qatkn4 =[ $nailatt1, bot_qatkn5 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_qatkn5 =[ $nailatt2, bot_atkn1 ] {bot_ai_face();bot_run_dodge();};
-
- void() bot_qatksn1 =[ $nailatt2, bot_qatksn2 ] {bot_ai_face();bot_run_dodge();};
- void() bot_qatksn2 =[ $nailatt1, bot_qatksn3 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_qatksn3 =[ $nailatt1, bot_qatksn4 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_qatksn4 =[ $nailatt2, bot_qatksn5 ] {bot_ai_face();bot_run_dodge();};
- void() bot_qatksn5 =[ $nailatt1, bot_atksn1 ] {bot_ai_face();bot_attack();bot_run_dodge();};
-
- void() bot_qatkr1 =[ $rockatt1, bot_qatkr2 ] {bot_ai_face();bot_attack();bot_run_dodge();};
- void() bot_qatkr2 =[ $rockatt2, bot_qatkr3 ] {bot_ai_face();bot_run_dodge();};
- void() bot_qatkr3 =[ $rockatt3, bot_qatkr4 ] {bot_ai_face();bot_run_dodge();};
- void() bot_qatkr4 =[ $rockatt4, bot_qatkr5 ] {bot_ai_face();bot_run_dodge();};
- void() bot_qatkr5 =[ $rockatt5, bot_atkr1 ] {bot_ai_face();bot_run_dodge();};
-
- void() bot_dodgern1 =[ $rockrun1 , bot_dodgern2 ]
- {bot_ai_face();
- if (random() < 0.2)
- sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
- bot_start_dodge();
- bot_run_dodge();
- };
- void() bot_dodgern2 =[ $rockrun2 , bot_dodgern3 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgern3 =[ $rockrun3 , bot_dodgern4 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgern4 =[ $rockrun4 , bot_dodgern5 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgern5 =[ $rockrun5 , bot_dodgern6 ] {bot_ai_face();bot_run_dodge();};
- void() bot_dodgern6 =[ $rockrun6 , bot_run1 ] {bot_ai_face();bot_run_dodge();bot_end_dodge();};
-
-
- //=============================================================
- // BotFindTarget
- // Self is currently not attacking anything, so try to find a target
- // Sets self.enemy and returns TRUE if an enemy was sighted
- // Sets self.enemy to world and returns FALSE if no enemy sighted
- //=============================================================
- float() BotFindTarget =
- {
- local entity head, selected;
- local float dist;
-
- dist = 1500; // awareness radius of bot, increasing it slows down game
- selected = world;
-
- head = findradius(self.origin, 1500);
- while(head)
- {
- if(!(head.flags & FL_NOTARGET))// && (head.flags & FL_MONSTER))
- 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;
- }
- };
- //=============================================================
- // BotFinditem
- // Self is currently not attacking anything, so try to find an item
- // Sets self.movetarget and returns TRUE if an item was sighted
- // Sets self.movetarget to world and returns FALSE if no enemy sighted
- //=============================================================
- float() BotFindItem =
- {
- local entity head, selected;
- local float dist;
-
- dist = 1500; // awareness radius of bot, increasing it slows down game
- selected = world;
-
- head = findradius(self.origin, 1500);
- while(head)
- {
- if (head.flags == FL_ITEM)
- if (visible(head))
- if (trace_plane_dist < dist)
- {
- selected = head;
- dist = trace_plane_dist;
- }
- head = head.chain;
- }
- self.goalentity = selected;
- self.movetarget = selected;
-
- if (self.movetarget == world)
- return FALSE;
- else
- {
- BotFoundItem();
- return TRUE;
- }
- };
-
- float() BotFindRocket =
- {
- local entity head, selected;
- local float dist;
-
- dist = 1500; // awareness radius of bot, increasing it slows down game
- selected = world;
-
- head = findradius(self.origin, 1500);
- while(head)
- {
- if((head.movetype == MOVETYPE_FLYMISSILE))// && (head.flags & FL_MONSTER))
- if (visible(head))
- if (infrontr(self,head))
- if (trace_plane_dist < dist)
- if ((head !=self))
-
- {
- selected = head;
- dist = trace_plane_dist;
- }
- head = head.chain;
- }
-
- self.rcktdtct = selected;
-
- if (self.rcktdtct == world)
- return FALSE;
- else
- {
- BotFoundRocket();
- return TRUE;
- }
- };
-
-
- //=============================================================
- // bot_ai_stand - bot stands in place until target acquired,
- // and starts to walk if pausetime has expired
- //=============================================================
- void() bot_ai_stand =
- {
- // set_ai_think();
- if (BotFindTarget ())
- return;
-
- if ((BotFindStuff ()) && (visible(self.stuff)))
- 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 (self.enemy != attacker)
- {
- self.oldenemy = self.enemy;
- self.enemy = attacker;
- }
- 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 (range(self.enemy) >= RANGE_NEAR)
- self.th_dodge();
- else if (range(self.enemy) == RANGE_MELEE)
- self.th_qatk();
- };
-
- //=============================================================
- // bot_die
- //=============================================================
- float() zrandom =
- {
- return 2*(random());
- };
-
- void() bot_die =
- {
-
- sound (self, CHAN_VOICE, "enforcer/death1.wav", 1, ATTN_NORM);
-
- if (zrandom() > 1.6)
- bot_diea1 ();
- else if (zrandom() > 1.2)
- bot_dieb1 ();
- else if (zrandom() > 0.8)
- bot_diec1 ();
- else if (zrandom() > 0.4)
- bot_died1 ();
- else bot_diee1 ();
-
-
-
- // 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.5); // wait a while before first attack
- self.th_run();
- };
-
-
- //=============================================================
- // BotFoundTarget
- //=============================================================
- void() BotFoundTarget =
- {
- local float f_dist;
- local string s_dist;
- local string frgs;
- f_dist = vlen (self.enemy.origin - self.origin);
- s_dist = ftos (f_dist);
- frgs = ftos (self.frags);
- self.show_hostile = time + 1; // wake up other monsters
-
- //sprints changed to sprint to enemy for purpose of debugging
- sprint (self.enemy, "targetting: ");
- sprint (self.enemy, self.enemy.classname);
- sprint (self.enemy, "\n");
- sprint (self.enemy, "Frags: ");
- sprint (self.enemy, frgs);
- sprint (self.enemy, "\n");
- BotSightSound ();
- BotHuntTarget ();
- };
- //=============================================================
- // BotFoundItem
- //=============================================================
- void() BotFoundItem =
- {
- local float f_dist;
- local string s_dist;
- f_dist = vlen (self.movetarget.origin - self.origin);
- s_dist = ftos (f_dist);
- movetogoal(20);
- };
-
- void() BotFoundRocket =
- {
- local float f_dist;
- local string s_dist;
- f_dist = vlen (self.rcktdtct.origin - self.origin);
- s_dist = ftos (f_dist);
-
- self.show_hostile = time + 1; // wake up other monsters
-
- sprint (self.rcktdtct.owner, "evading: ");
- sprint (self.rcktdtct.owner, self.rcktdtct.classname);
- sprint (self.rcktdtct.owner, "\n");
- sprint (self.rcktdtct.owner, " distance: ");
- sprint (self.rcktdtct.owner, s_dist);
- sprint (self.rcktdtct.owner, "\n");
- BotSightSound ();
- bot_run_dodge ();
-
-
- };
-
-
- //=============================================================
- // bot_ai_walk - bot is walking, looking for enemies
- //=============================================================
- void(float dist) bot_ai_walk =
- {
- // set_ai_think();
- if (BotFindTarget ())
- return;
- if ((BotFindStuff ()) && (visible(self.stuff)))
- return;
-
- bot_upabit();
- movetogoal (dist);
- };
-
- void() bot_run_dodge =
- {
- local float ofs;
- // set_ai_think();
- if (self.enemy.attack_state == AS_MELEE)
- bot_run_mdodge();
- // if (range(self.enemy) == RANGE_MELEE)
- // bot_circle1();
-
- movedist = 18;
- bot_enemy_image();
-
- self.ideal_yaw = enemy_yaw;
- ChangeYaw ();
- if (self.lefty == 1)
- ofs = 45;
- else
- ofs = -45;
-
- if (walkmove (self.ideal_yaw + ofs, movedist))
- return;
-
- self.lefty = 1 - self.lefty;
- walkmove (self.ideal_yaw - ofs, movedist);
- bot_ai_face();
- };
-
- void() bot_run_circle =
- {
- local float ofs;
-
- // set_ai_think();
-
- movedist = 15;
- self.ideal_yaw = enemy_yaw;
- ChangeYaw ();
- if (self.lefty == 1)
- ofs = 90;
- else
- ofs = -90;
-
- if (walkmove (self.ideal_yaw + ofs, movedist))
- return;
-
- if (infrontr(self.enemy, self))
- self.lefty = 1 - self.lefty;
- walkmove (self.ideal_yaw - ofs, movedist);
- };
-
- void() bot_run_mdodge =
- {
- local float ofs;
-
- // set_ai_think();
-
- movedist = 20;
- self.ideal_yaw = enemy_yaw;
- ChangeYaw ();
- if (self.lefty == 1)
- ofs = 135;
- else
- ofs = -135;
-
- if (walkmove (self.ideal_yaw + ofs, movedist))
- return;
-
- self.lefty = 1 - self.lefty;
- walkmove (self.ideal_yaw - ofs, movedist);
- };
-
- //=============================================================
- // bot_ai_turn - turn towards ideal_yaw if no enemy sighted
- //=============================================================
- void() bot_ai_turn =
- {
- // set_ai_think();
-
- if (BotFindTarget ())
- return;
-
- if ((BotFindStuff ()) && (visible(self.stuff)))
- 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;
- // set_ai_think();
- bot_enemy_image();
-
-
- if (BotFindRocket())
- {
- if (check_dodge() == FALSE)
- bot_dodgern1();
- }
-
-
- if (self.enemy.health <= 0)
- {
- self.enemy = world;
- if (self.oldenemy.health > 0)
- {
- self.enemy = self.oldenemy;
- bot_enemy_image();
- BotHuntTarget ();
- }
- else
- {
- bot_enemy_image();
-
- if (BotFindTarget())
- {
- if ((visible(self.enemy)) == (FALSE))
- movetogoal(dist);
- else if ((visible(self.enemy)) == (TRUE))
- // sprint (self.enemy, "tracing: ");
- bot_enemy_image();
-
- return;
- }
- else
- {
- self.movetarget = self.owner;
- self.th_walk ();
- return;
- }
- }
- }
-
- self.show_hostile = time + 1; // wake up other monsters
- bot_enemy_image();
- enemy_vis = visible(self.enemy);
- if (enemy_vis)
- self.search_time = time + 5;
-
- enemy_infront = infront(self.enemy);
- enemy_range = range(self.enemy);
- enemy_yaw = vectoyaw(self.enemy.origin - self.origin);
-
- if (BotFindRocket())
- {
- if (check_dodge() == FALSE)
- bot_dodgern1();
- }
- if (random() <= 0.25)
- self.th_dodge();
-
- 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;
- }
- bot_upabit();
- movetogoal (dist); // done in C code...
- };
-
-
- //=============================================================
- // 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);
- sound (self, CHAN_BODY, "misc/r_tele1.wav", 1, ATTN_NORM);
- remove (self);
- BotReStartDM(self.frags, self.attackr);
- };
-
- //=============================================================
- // bot_fire
- //=============================================================
- void () bot_fire =
- {
- // in future, adjust frame sequence to not show firing if auto_fire off
-
- if (BotFindRocket())
- {
- if (check_dodge() == FALSE)
- bot_dodgern1();
- }
-
- if (self.enemy.health <= 0)
- {
- self.enemy = world;
- if (self.oldenemy.health > 0)
- {
- self.enemy = self.oldenemy;
- BotHuntTarget ();
- }
- else
- {
- if (BotFindTarget())
- {
- if ((visible(self.enemy)) == (FALSE))
- movetogoal(30);
- else if ((visible(self.enemy)) == (TRUE))
- // sprint (self.enemy, "tracing: ");
- bot_enemy_image();
- return;
- }
- else
- {
- self.movetarget = self.owner;
- self.th_walk ();
- return;
- }
- }
- }
-
- bot_ai_face();
- if ((infront(self.enemy)) && (visible(self.enemy)))
- {
- bot_enemy_image();
- bot_firebullets();
- sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
- }
- else if (!(visible(self.enemy)))
- movetogoal(20);
-
- return;
- };
- float(entity targ, entity targ2) infrontr =
- {
- local vector vec;
- local float dot;
-
- makevectors (targ2.angles);
- vec = normalize (targ.origin - targ2.origin);
- dot = vec * v_forward;
-
- if ( dot > 0.3)
- {
- return TRUE;
- }
- return FALSE;
- };
- void() bot_ai_face =
- {
- bot_enemy_image();
- self.ideal_yaw = vectoyaw(self.enemy.origin - self.origin);
- ChangeYaw ();
-
- };
- // create ghost image of enemy to move to....
-
- void () bot_enemy_image =
- {
- local entity newbot;
-
-
- newbot=spawn();
-
- newbot.classname = "enemy";
- newbot.movetype= MOVETYPE_NONE;
- newbot.solid = SOLID_TRIGGER;
-
- setsize (newbot, '0 0 1', '0 0 1');
- // setmodel (newbot, "progs/laser.mdl"); //for debugging
- setmodel (newbot, "progs/null.spr");
- newbot.origin = self.enemy.origin;
- newbot.owner=self;
- newbot.touch=bot_remove_enemy_image;
- newbot.nextthink=time+10;
- newbot.think=SUB_Remove;
- self.goalentity = newbot;
- self.movetarget = newbot;
- };
-
- void () bot_remove_enemy_image =
- {
- if (self.owner == other)
- remove(self);
- };
- void () bot_start_dodge =
- {
- self.dodge = TRUE;
- if ((random() * 1) >= 0.5)
- self.lefty = 1;
- else self.lefty = 0;
-
- };
- void () bot_end_dodge =
- {
- self.dodge = FALSE;
- };
- float() check_dodge =
- {
- if (self.dodge == FALSE)
- return FALSE;
- else if (self.dodge == TRUE)
- return TRUE;
- };
- void () bot_start_circle =
- {
- self.dodge = TRUE;
- };
- void () bot_end_circle =
- {
- self.dodge = FALSE;
- };
- void() bot_firebullets =
- {
- local vector dir;
- local entity en;
-
- bot_ai_face();
-
- // fire somewhat behind the player, so a dodging player is harder to hit
- en = self.enemy;
-
- dir = en.origin - en.velocity*0.2;
- dir = normalize (dir - self.origin);
-
- FireBullets (6, dir, '0.1 0.1 0');
- };
-
- void() bot_FireShotgun =
- {
- local vector dir;
- local entity en;
-
- self.currentammo = self.ammo_shells = self.ammo_shells - 1;
- en = self.enemy;
- dir = en.origin - en.velocity*0.2;
- dir = normalize (dir - self.origin);
-
- // dir = aim (self, 100000);
- FireBullets (6, dir, '0.1 0.1 0');
- };
-
- void() bot_FireSuperShotgun =
- {
- local vector dir;
- local entity en;
- if (self.currentammo == 1)
- {
- bot_FireShotgun ();
- return;
- }
- self.currentammo = self.ammo_shells = self.ammo_shells - 2;
- en = self.enemy;
- dir = en.origin - en.velocity*0.2;
- dir = normalize (dir - self.origin);
- FireBullets (14, dir, '0.14 0.08 0');
- };
-
- void() bot_FireRocket =
- {
- local entity missile, mpuff;
- local vector dir;
- local entity en;
- self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
-
- missile = spawn ();
- missile.owner = self;
- missile.movetype = MOVETYPE_FLYMISSILE;
- missile.solid = SOLID_BBOX;
- makevectors (self.angles);
- en = self.enemy;
- dir = en.origin - en.velocity*0.2;
- dir = normalize (dir - self.origin);
- missile.velocity = dir;
- 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_nail =
- {
- 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_nail2 =
- {
- local vector dir;
- local vector org;
-
- self.oldenemy = self.enemy;
- if (!visible (self.enemy) || (self.enemy.health <= 0))
- {
- if (BotFindTarget ())
- return;
-
- ChangeYaw ();
- self.enemy = self.oldenemy;
- }
-
- 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);
- };
-
- 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);
- };
-
- 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;
- self.th_stand = bot_stand1;
- self.th_walk = bot_walk1;
- self.th_run = bot_run1;
- self.th_stuff = bot_stuff1;
- self.th_dodge = bot_dodge1;
- self.th_pain = bot_pain;
- self.th_die = bot_die;
- self.th_missile = bot_atk1;
- self.th_qatk = bot_qatk1;
- }
- else if (self.weapon == IT_SUPER_SHOTGUN)
- {
- self.currentammo = self.ammo_shells;
- self.items = self.items | IT_SHELLS;
- self.th_stand = bot_stand1;
- self.th_walk = bot_walk1;
- self.th_run = bot_run1;
- self.th_stuff = bot_stuff1;
- self.th_dodge = bot_dodge1;
- self.th_pain = bot_pain;
- self.th_die = bot_die;
- self.th_missile = bot_atk1;
- self.th_qatk = bot_qatk1;
-
- }
- else if (self.weapon == IT_NAILGUN)
- {
- self.currentammo = self.ammo_nails;
- self.items = self.items | IT_NAILS;
- self.th_stand = bot_stand1;
- self.th_walk = bot_walk1;
- self.th_run = bot_run1;
- self.th_stuff = bot_stuff1;
- self.th_dodge = bot_dodgen1;
- self.th_pain = bot_pain;
- self.th_die = bot_die;
- self.th_missile = bot_atkn1;
- self.th_qatk = bot_qatkn1;
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- self.currentammo = self.ammo_nails;
- self.items = self.items | IT_NAILS;
- self.th_stand = bot_stand1;
- self.th_walk = bot_walk1;
- self.th_run = bot_run1;
- self.th_stuff = bot_stuff1;
- self.th_dodge = bot_dodgesn1;
- self.th_pain = bot_pain;
- self.th_die = bot_die;
- self.th_missile = bot_atksn1;
- self.th_qatk = bot_qatksn1;
- }
- else if (self.weapon == IT_GRENADE_LAUNCHER)
- {
- self.currentammo = self.ammo_rockets;
- self.items = self.items | IT_ROCKETS;
- self.th_stand = bot_stand1;
- self.th_walk = bot_walk1;
- self.th_run = bot_run1;
- self.th_stuff = bot_stuff1;
- self.th_dodge = bot_dodger1;
- self.th_pain = bot_pain;
- self.th_die = bot_die;
- self.th_missile = bot_atkr1;
- self.th_qatk = bot_qatkr1;
-
- }
- else if (self.weapon == IT_ROCKET_LAUNCHER)
- {
- self.currentammo = self.ammo_rockets;
- self.items = self.items | IT_ROCKETS;
- self.th_stand = bot_stand1;
- self.th_walk = bot_walk1;
- self.th_run = bot_run1;
- self.th_stuff = bot_stuff1;
- self.th_dodge = bot_dodger1;
- self.th_pain = bot_pain;
- self.th_die = bot_die;
- self.th_missile = bot_atkr1;
- self.th_qatk = bot_qatkr1;
-
- }
- 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;
- else if (self.ammo_rockets>= 1 && (it & IT_GRENADE_LAUNCHER) )
- return IT_GRENADE_LAUNCHER;
- 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 =
- {
- bot_SetCurrentAmmo ();
- if (BotFindRocket())
- {
- if (check_dodge() == FALSE)
- bot_dodgern1();
- }
-
- if (self.enemy.health <= 0)
- {
- self.enemy = world;
- if (self.oldenemy.health > 0)
- {
- self.enemy = self.oldenemy;
- BotHuntTarget ();
- }
- else
- {
- if (BotFindTarget())
- {
- if (visible(self.enemy) == FALSE)
- movetogoal(30);
- else if (visible(self.enemy) == TRUE)
- // sprint (self.enemy, "tracing: ");
- bot_enemy_image();
- return;
- }
- else
- {
- self.movetarget = self.owner;
- self.th_walk ();
- return;
- }
- }
- }
-
- bot_ai_face();
- if ((infront(self.enemy)) && (visible(self.enemy)))
- {
- bot_enemy_image();
- bot_shoot();
- }
- else if (!(visible(self.enemy)))
- movetogoal(20);
-
- return;
- };
- void () bot_shoot =
- {
- 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 ();
- bot_SetCurrentAmmo ();
- }
- else if (self.weapon == IT_SUPER_SHOTGUN)
- {
- bot_FireSuperShotgun ();
- bot_SetCurrentAmmo ();
- }
- else if (self.weapon == IT_NAILGUN)
- {
- bot_nail ();
- bot_SetCurrentAmmo ();
- }
- else if (self.weapon == IT_SUPER_NAILGUN)
- {
- bot_nail2 ();
- bot_SetCurrentAmmo ();
- }
- else if (self.weapon == IT_GRENADE_LAUNCHER)
- {
- BOTFireGrenade();
- bot_SetCurrentAmmo ();
- }
- else if (self.weapon == IT_ROCKET_LAUNCHER)
- {
- bot_FireRocket();
- bot_SetCurrentAmmo ();
-
- }
- };
- void() BOTGrenadeExplode =
- {
- T_RadiusDamage (self, self.owner, 30, world);
- sound (self, CHAN_VOICE, "weapons/r_exp3.wav", 1, ATTN_NORM);
-
- WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte (MSG_BROADCAST, TE_EXPLOSION);
- WriteCoord (MSG_BROADCAST, self.origin_x);
- WriteCoord (MSG_BROADCAST, self.origin_y);
- WriteCoord (MSG_BROADCAST, self.origin_z);
-
- self.velocity = '0 0 0';
- self.touch = SUB_Null;
- setmodel (self, "progs/s_explod.spr");
- self.solid = SOLID_NOT;
- s_explode1 ();
- };
-
- void() BOTGrenadeTouch =
- {
- if (other == self.owner)
- return; // don't explode on owner
- if (other.takedamage == DAMAGE_AIM)
- {
- BOTGrenadeExplode();
- return;
- }
- sound (self, CHAN_VOICE, "weapons/bounce.wav", 1, ATTN_NORM); // bounce sound
- if (self.velocity == '0 0 0')
- self.avelocity = '0 0 0';
- };
-
-
- /*
- ================
- BOTFireGrenade
- ================
- */
-
- void() BOTFireGrenade =
- {
- local entity missile, mpuff;
- local float zchange;
-
- // knock off a rocket
- self.ammo_rockets = self.ammo_rockets - 1;
-
- missile = spawn ();
- missile.owner = self;
- missile.movetype = MOVETYPE_BOUNCE;
- missile.solid = SOLID_BBOX;
-
- // set missile speed
-
- makevectors (self.angles);
-
- missile.velocity = normalize(self.enemy.origin - self.origin);
- missile.velocity = missile.velocity * 600;
- missile.velocity_z = 200;
- zchange = self.origin_z - self.enemy.origin_z;
- missile.velocity_z = missile.velocity_z - (zchange+10);
- missile.avelocity = '300 300 300';
-
- missile.angles = vectoangles(missile.velocity);
-
- missile.touch = BOTGrenadeTouch;
-
- // set missile duration
- missile.nextthink = time + 2.5;
- missile.think = BOTGrenadeExplode;
-
- setmodel (missile, "progs/grenade.mdl");
- setsize (missile, '0 0 0', '0 0 0');
- setorigin (missile, self.origin);
- };
-
- /*
- ================
- BotCheckPowerups
-
- Check for turning off powerups
- ================
- */
- void(entity oldself) BotCheckPowerups =
- {
- // sprint(self.enemy, "I'm Thinking!!!");
-
- // invisibility
- if (oldself.invisible_finished)
- {
- // sound and screen flash when items starts to run out
-
-
- if (oldself.invisible_finished < time)
- { // just stopped
- oldself.items = oldself.items - IT_INVISIBILITY;
- oldself.invisible_finished = 0;
- oldself.invisible_time = 0;
- }
-
- // use the eyes
- oldself.frame = 0;
- oldself.modelindex = modelindex_eyes;
- }
- else
- oldself.modelindex = modelindex_bot; // don't use eyes
-
- // invincibility
- if (oldself.invincible_finished)
- {
- if (oldself.invincible_finished < time)
- { // just stopped
- oldself.items = oldself.items - IT_INVULNERABILITY;
- oldself.invincible_time = 0;
- oldself.invincible_finished = 0;
- }
- if (oldself.invincible_finished > time)
- oldself.effects = oldself.effects & EF_DIMLIGHT;
- else
- oldself.effects = oldself.effects - (oldself.effects & EF_DIMLIGHT);
- }
-
- // super damage
- if (oldself.super_damage_finished)
- {
-
- if (oldself.super_damage_finished < time)
- { // just stopped
- oldself.items = oldself.items - IT_QUAD;
- oldself.super_damage_finished = 0;
- oldself.super_time = 0;
- oldself.effects = oldself.effects - (oldself.effects & EF_DIMLIGHT);
-
- }
- if (oldself.super_damage_finished > time)
- oldself.effects = oldself.effects & EF_DIMLIGHT;
- else
- oldself.effects = oldself.effects - (oldself.effects & EF_DIMLIGHT);
- }
-
- // suit
- if (oldself.radsuit_finished)
- {
- oldself.air_finished = time + 12; // don't drown
-
- if (oldself.radsuit_finished < time)
- { // just stopped
- oldself.items = oldself.items - IT_SUIT;
- oldself.rad_time = 0;
- oldself.radsuit_finished = 0;
- }
- }
-
- };
-
-
- void () bot_client =
- {
- local entity newbot;
-
- newbot=spawn();
- newbot.classname = "bot_controller";
- newbot.movetype= MOVETYPE_NONE;
- newbot.solid = SOLID_NOT;
-
- setsize (newbot, '0 0 0', '0 0 0');
- setmodel (newbot, "progs/null.spr");
- newbot.origin = self.origin;
- newbot.owner=self;
- self.controller = newbot;
- newbot.nextthink=time+1;
- newbot.think=bot_think;
-
- };
- void () bot_think =
- {
- local entity oldself;
- oldself = self.owner;
-
- if (oldself.health <=0)
- {
- remove(self);
- }
- else
- {
- Bot_PreThink(oldself);
- self.nextthink = time+1;
- }
- };
-
- void(entity oldself) Bot_PreThink =
- {
- // sprint(oldself.enemy, "I'm Thinking!!!");
- BotCheckPowerups(oldself);
- };
- void(entity oldself) Bot_PostThink =
- {
- BotCheckPowerups(oldself);
- };
-
- void () bot_thinkb =
- {
-
- Bot_PreThinkb();
- self.nextthink = time+0.1;
- };
-
- void() Bot_PreThinkb =
- {
- // sprint(self.enemy, "I'm Thinking!!!");
- BotCheckPowerupsb();
- };
- void() Bot_PostThinkb =
- {
- BotCheckPowerupsb();
- };
-
-
- /*
- ================
- BotCheckPowerupsb
-
- Check for turning off powerups
- ================
- */
- void() BotCheckPowerupsb =
- {
-
- // invisibility
- if (self.invisible_finished)
- {
- // sound and screen flash when items starts to run out
-
-
- 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
- self.modelindex = modelindex_bot; // don't use eyes
-
- // invincibility
- if (self.invincible_finished)
- {
- 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;
- else
- self.effects = self.effects - (self.effects & EF_DIMLIGHT);
- }
-
- // super damage
- if (self.super_damage_finished)
- {
-
- if (self.super_damage_finished < time)
- { // just stopped
- self.items = self.items - IT_QUAD;
- self.super_damage_finished = 0;
- self.super_time = 0;
- self.effects = self.effects - (self.effects & EF_DIMLIGHT);
-
- }
- if (self.super_damage_finished > time)
- self.effects = self.effects & EF_DIMLIGHT;
- else
- self.effects = self.effects - (self.effects & EF_DIMLIGHT);
- }
-
- // suit
- if (self.radsuit_finished)
- {
- self.air_finished = time + 12; // don't drown
-
- if (self.radsuit_finished < time)
- { // just stopped
- self.items = self.items - IT_SUIT;
- self.rad_time = 0;
- self.radsuit_finished = 0;
- }
- }
-
- };
- /*
- void() set_ai_think =
- {
- self.nextthink = time +0.1;
- self.think = bot_thinkb;
-
- };
- */
- // BG Bot - begin hack to check for items
- float() BotFindStuff =
- {
- local entity head, selected;
- local float dist;
- dist = 200;
- 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_grenadelauncher") ||
- (head.classname == "weapon_nailgun") ||
- (head.classname == "backpack") ||
- (head.classname == "shells") ||
- (head.classname == "cells") ||
- (head.classname == "nails") ||
- (head.classname == "rockets") ||
- (head.classname == "item_armor1") ||
- (head.classname == "item_armor2") ||
- (head.classname == "item_armorInv") ||
- (head.classname == "item_artifact_invulnerability") ||
- (head.classname == "item_artifact_invisibility") ||
- (head.classname == "item_artifact_envirosuit") ||
- (head.classname == "item_artifact_super_damage") ||
- ((head.healtype == 1) && (self.health < 100)) ||
- ((head.healtype == 2) && (self.health < 100)))
-
- {
- // if (visible(head))
- // {
- selected = head;
- dist = trace_plane_dist;
- // }
- }
- head = head.chain;
- }
- self.stuff = selected;
-
- if (self.stuff == world)
- return FALSE;
- else
- {
- BotFoundStuff();
- return TRUE;
- }
- };
- //=============================================================
- // BotHuntStuff - Look for items
- //=============================================================
- 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;
- };
-
- //=============================================================
- // 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_stuff - crappy hack
- //=============================================================
- 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 + 5;
-
- enemy_infront = infront(self.stuff);
- enemy_range = range(self.stuff);
- enemy_yaw = vectoyaw(self.stuff.origin - self.origin);
-
- // if (CheckAnyAttack ())
- // return; // beginning an attack
-
- movetogoal (dist); // done in C code...
- };
-
- void() bot_upabit =
- {
- self.velocity_z = (self.velocity_z + 35);
- };
-