ew-progs/xsniperbot/xsniper.qc
2011-09-06 00:00:00 +00:00

1054 lines
34 KiB
C++

/*
=============================
xsniper.qc
coded by
Michael Rogers a.k.a Xsniper
ssj_xsniper@yahoo.com
http://www.xsniper.net/
Description:
This is the core code behind, Xsniper Bot.
Xsniper Bot is a new bot coded entirely from scratch by Xsniper.
I'm very proud of this bot, I consider it to be one
of my finest accomplishments while coding on EW.
=============================
*/
//Prototypes
void() xsn_jumpdone;
void() respawn_xsniper;
//================================================================================================================
//Animation Frames Below
$frame idle101 idle102 idle103 idle104 idle105 idle106 idle107 idle108 idle109 idle110
$frame idle111 idle112 idle113 idle114 idle115 idle116 idle117 idle118 idle119 idle120
$frame idle121 idle122 idle123 idle124 idle125 idle126 idle127 idle128 idle129 idle130
$frame idle131 idle132 idle133 idle134 idle135 idle136 idle137 idle138 idle139 idle140
$frame idle141 idle142 idle143 idle144 idle145 idle146 idle147 idle148 idle149
$frame idle201 idle202 idle203 idle204 idle205 idle206 idle207 idle208 idle209 idle210
$frame idle211 idle212 idle213 idle214 idle215 idle216 idle217 idle218 idle219 idle220
$frame idle221 idle222 idle223 idle224 idle225
$frame run01 run02 run03 run04 run05 run06
$frame walk01 walk02 walk03 walk04 walk05 walk06 walk07 walk08 walk09 walk10
$frame walk11 walk12
$frame pain101 pain102 pain103 pain104
$frame pain201 pain202 pain203 pain204
$frame pain301 pain302 pain303 pain304
$frame death101 death102 death103 death104 death105 death106 death107
$frame death201 death202 death203 death204 death205 death206 death207 death208 death209 death210
$frame death211 death212 death213 death214 death215 death216 death217 death218 death219
$frame death301 death302 death303 death304 death305 death306 death307
$frame death401 death402 death403 death404 death405 death406 death407
$frame jump101 jump102 jump103 jump104 jump105 jump106
$frame use101 use102 use103 use104 use105 use106 use108
$frame talk101 talk102 talk103 talk104 talk105 talk106 talk107 talk108 talk109 talk110
$frame talk111 talk112 talk113 talk114
$frame talk201 talk202 talk203 talk204 talk205 talk206 talk207 talk208 talk209 talk210
$frame talk211 talk212 talk213 talk214 talk215 talk216 talk217 talk218 talk219 talk220
$frame talk221 talk222 talk223 talk224 talk225 talk226 talk227 talk228 talk229 talk230
$frame talk231 talk232 talk233 talk234 talk235
$frame talk301 talk302 talk303 talk304 talk305 talk306 talk307 talk308 talk309 talk310
$frame talk311 talk312 talk313 talk314 talk315 talk316
$frame arm101 arm102 arm103 arm104 arm105 arm106 arm107 arm108
$frame kattack101 kattack102 kattack103 kattack104 kattack105 kattack106
$frame kattack201 kattack202 kattack203 kattack204 kattack205 kattack206
$frame kattack301 kattack302 kattack303 kattack304 kattack305 kattack306
$frame kattack401 kattack402 kattack403 kattack404 kattack405 kattack406
$frame sattack101 sattack102 sattack103 sattack104 sattack105 sattack106 sattack107 sattack108 sattack109
$frame sattack201 sattack202 sattack203 sattack204 sattack205 sattack206 sattack207 sattack208 sattack209
$frame sattack301 sattack302 sattack303 sattack304 sattack305 sattack306 sattack307 sattack308 sattack309 sattack310
$frame sattack311
$frame sattack401 sattack402 sattack403 sattack404 sattack405 sattack406 sattack407 sattack408 sattack409 sattack410
$frame sattack411 sattack412 sattack413 sattack414 sattack415 sattack416
$frame sattack501 sattack502 sattack503 sattack504 sattack505 sattack506 sattack507 sattack508
$frame sattack601 sattack602 sattack603 sattack604 sattack605 sattack606 sattack607 sattack608 sattack609 sattack610
$frame sattack611 sattack612
$frame battack101 battack102 battack103 battack104 battack105
$frame battack201 battack202 battack203 battack204 battack205 battack206 battack207 battack208
$frame qattack101 qattack102 qattack103 qattack104 qattack105 qattack106 qattack107 qattack108 qattack109 qattack110
$frame qattack111 qattack112 qattack113 qattack114 qattack115 qattack116 qattack117 qattack118 qattack119 qattack120
$frame dattack101 dattack102 dattack103 dattack104 dattack105 dattack106 dattack107
$frame cridle101 cridle102 cridle103 cridle104 cridle105 cridle106 cridle107 cridle108 cridle109 cridle110
$frame cridle111 cridle112 cridle113 cridle114 cridle115 cridle116 cridle117 cridle118 cridle119
$frame crwalk01 crwalk02 crwalk03 crwalk04 crwalk05 crwalk06
$frame crpain101 crpain102 crpain103 crpain104
$frame crdeath101 crdeath102 crdeath103 crdeath104 crdeath105 crdeath106 crdeath107
$frame ckattack101 ckattack102 ckattack103 ckattack104 ckattack105 ckattack106
$frame ckattack201 ckattack202 ckattack203 ckattack204 ckattack205 ckattack206
$frame ckattack301 ckattack302 ckattack303 ckattack304 ckattack305 ckattack306
$frame csattack101 csattack102 csattack103 csattack104 csattack105 csattack106 csattack107 csattack108 csattack109
$frame csattack201 csattack202 csattack203 csattack204 csattack205 csattack206 csattack207 csattack208 csattack209 csattack210
$frame csattack211
$frame csattack301 csattack302 csattack303 csattack304 csattack305 csattack306 csattack307 csattack308
$frame cbattack101 cbattack102 cbattack103 cbattack104 cbattack105
$frame cbattack201 cbattack202 cbattack203 cbattack204 cbattack205 cbattack206 cbattack207 cbattack208
$frame cqattack101 cqattack102 cqattack103 cqattack104 cqattack105 cqattack106 cqattack107 cqattack108 cqattack109 cqattack110
$frame cqattack111 cqattack112 cqattack113 cqattack114 cqattack115 cqattack116 cqattack117 cqattack118 cqattack119 cqattack120
$frame cdattack101 cdattack102 cdattack103 cdattack104 cdattack105 cdattack106 cdattack107
$frame strafe101 strafe102 strafe103 strafe104 strafe105 strafe106
$frame strafe201 strafe202 strafe203 strafe204 strafe205 strafe206
$frame swim101 swim102 swim103 swim104 swim105 swim106 swim107 swim108 swim109 swim110
$frame swim111 swim112 swim113 swim114 swim115 swim116
//================================================================================================================
//Animation Code Below
//Standing Code ==================================================================================================
void() xsn_standa1 =[ $idle101, xsn_standa2 ] {xi_stand();};
void() xsn_standa2 =[ $idle102, xsn_standa3 ] {xi_stand();};
void() xsn_standa3 =[ $idle103, xsn_standa4 ] {xi_stand();};
void() xsn_standa4 =[ $idle104, xsn_standa5 ] {xi_stand();};
void() xsn_standa5 =[ $idle105, xsn_standa6 ] {xi_stand();};
void() xsn_standa6 =[ $idle106, xsn_standa7 ] {xi_stand();};
void() xsn_standa7 =[ $idle107, xsn_standa8 ] {xi_stand();};
void() xsn_standa8 =[ $idle108, xsn_standa9 ] {xi_stand();};
void() xsn_standa9 =[ $idle109, xsn_standa10 ] {xi_stand();};
void() xsn_standa10 =[ $idle110, xsn_standa11 ] {xi_stand();};
void() xsn_standa11 =[ $idle111, xsn_standa12 ] {xi_stand();};
void() xsn_standa12 =[ $idle112, xsn_standa13 ] {xi_stand();};
void() xsn_standa13 =[ $idle113, xsn_standa14 ] {xi_stand();};
void() xsn_standa14 =[ $idle114, xsn_standa15 ] {xi_stand();};
void() xsn_standa15 =[ $idle115, xsn_standa16 ] {xi_stand();};
void() xsn_standa16 =[ $idle116, xsn_standa17 ] {xi_stand();};
void() xsn_standa17 =[ $idle117, xsn_standa18 ] {xi_stand();};
void() xsn_standa18 =[ $idle118, xsn_standa19 ] {xi_stand();};
void() xsn_standa19 =[ $idle119, xsn_standa20 ] {xi_stand();};
void() xsn_standa20 =[ $idle120, xsn_standa21 ] {xi_stand();};
void() xsn_standa21 =[ $idle121, xsn_standa22 ] {xi_stand();};
void() xsn_standa22 =[ $idle122, xsn_standa23 ] {xi_stand();};
void() xsn_standa23 =[ $idle123, xsn_standa24 ] {xi_stand();};
void() xsn_standa24 =[ $idle124, xsn_standa25 ] {xi_stand();};
void() xsn_standa25 =[ $idle125, xsn_standa26 ] {xi_stand();};
void() xsn_standa26 =[ $idle126, xsn_standa27 ] {xi_stand();};
void() xsn_standa27 =[ $idle127, xsn_standa28 ] {xi_stand();};
void() xsn_standa28 =[ $idle128, xsn_standa29 ] {xi_stand();};
void() xsn_standa29 =[ $idle129, xsn_standa30 ] {xi_stand();};
void() xsn_standa30 =[ $idle130, xsn_standa31 ] {xi_stand();};
void() xsn_standa31 =[ $idle131, xsn_standa32 ] {xi_stand();};
void() xsn_standa32 =[ $idle132, xsn_standa33 ] {xi_stand();};
void() xsn_standa33 =[ $idle133, xsn_standa34 ] {xi_stand();};
void() xsn_standa34 =[ $idle134, xsn_standa35 ] {xi_stand();};
void() xsn_standa35 =[ $idle135, xsn_standa36 ] {xi_stand();};
void() xsn_standa36 =[ $idle136, xsn_standa37 ] {xi_stand();};
void() xsn_standa37 =[ $idle137, xsn_standa38 ] {xi_stand();};
void() xsn_standa38 =[ $idle138, xsn_standa39 ] {xi_stand();};
void() xsn_standa39 =[ $idle139, xsn_standa40 ] {xi_stand();};
void() xsn_standa40 =[ $idle140, xsn_standa41 ] {xi_stand();};
void() xsn_standa41 =[ $idle141, xsn_standa42 ] {xi_stand();};
void() xsn_standa42 =[ $idle142, xsn_standa43 ] {xi_stand();};
void() xsn_standa43 =[ $idle143, xsn_standa44 ] {xi_stand();};
void() xsn_standa44 =[ $idle144, xsn_standa45 ] {xi_stand();};
void() xsn_standa45 =[ $idle145, xsn_standa46 ] {xi_stand();};
void() xsn_standa46 =[ $idle146, xsn_standa47 ] {xi_stand();};
void() xsn_standa47 =[ $idle147, xsn_standa48 ] {xi_stand();};
void() xsn_standa48 =[ $idle148, xsn_standa49 ] {xi_stand();};
void() xsn_standa49 =[ $idle149, xsn_stand ] {xi_stand();};
void() xsn_standb1 =[ $idle201, xsn_standb2 ] {xi_stand();};
void() xsn_standb2 =[ $idle202, xsn_standb3 ] {xi_stand();};
void() xsn_standb3 =[ $idle203, xsn_standb4 ] {xi_stand();};
void() xsn_standb4 =[ $idle204, xsn_standb5 ] {xi_stand();};
void() xsn_standb5 =[ $idle205, xsn_standb6 ] {xi_stand();};
void() xsn_standb6 =[ $idle206, xsn_standb7 ] {xi_stand();};
void() xsn_standb7 =[ $idle207, xsn_standb8 ] {xi_stand();};
void() xsn_standb8 =[ $idle208, xsn_standb9 ] {xi_stand();};
void() xsn_standb9 =[ $idle209, xsn_standb10 ] {xi_stand();};
void() xsn_standb10 =[ $idle210, xsn_standb11 ] {xi_stand();};
void() xsn_standb11 =[ $idle211, xsn_standb12 ] {xi_stand();};
void() xsn_standb12 =[ $idle212, xsn_standb13 ] {xi_stand();};
void() xsn_standb13 =[ $idle213, xsn_standb14 ] {xi_stand();};
void() xsn_standb14 =[ $idle214, xsn_standb15 ] {xi_stand();};
void() xsn_standb15 =[ $idle215, xsn_standb16 ] {xi_stand();};
void() xsn_standb16 =[ $idle216, xsn_standb17 ] {xi_stand();};
void() xsn_standb17 =[ $idle217, xsn_standb18 ] {xi_stand();};
void() xsn_standb18 =[ $idle218, xsn_standb19 ] {xi_stand();};
void() xsn_standb19 =[ $idle219, xsn_standb20 ] {xi_stand();};
void() xsn_standb20 =[ $idle220, xsn_standb21 ] {xi_stand();};
void() xsn_standb21 =[ $idle221, xsn_standb22 ] {xi_stand();};
void() xsn_standb22 =[ $idle222, xsn_standb23 ] {xi_stand();};
void() xsn_standb23 =[ $idle223, xsn_standb24 ] {xi_stand();};
void() xsn_standb24 =[ $idle224, xsn_standb25 ] {xi_stand();};
void() xsn_standb25 =[ $idle225, xsn_stand ] {xi_stand();};
void() xsn_stand =
{
//execute random standing animation
if (random() <= 0.5)
xsn_standa1();
else
xsn_standb1();
};
//Walking Code ==================================================================================================
void() xsn_walk1 =[ $walk01, xsn_walk2 ] {xi_walk(4);};
void() xsn_walk2 =[ $walk02, xsn_walk3 ] {xi_walk(8);};
void() xsn_walk3 =[ $walk03, xsn_walk4 ] {xi_walk(16);};
void() xsn_walk4 =[ $walk04, xsn_walk5 ] {xi_walk(8);};
void() xsn_walk5 =[ $walk05, xsn_walk6 ] {xi_walk(4);};
void() xsn_walk6 =[ $walk06, xsn_walk7 ] {xi_walk(8);};
void() xsn_walk7 =[ $walk07, xsn_walk8 ] {xi_walk(16);};
void() xsn_walk8 =[ $walk08, xsn_walk9 ] {xi_walk(8);};
void() xsn_walk9 =[ $walk09, xsn_walk10 ] {xi_walk(4);};
void() xsn_walk10 =[ $walk10, xsn_walk11 ] {xi_walk(8);};
void() xsn_walk11 =[ $walk11, xsn_walk12 ] {xi_walk(16);};
void() xsn_walk12 =[ $walk12, xsn_walk1 ] {xi_walk(8);};
void() xsn_walk =
{
//we are currently walking
self.isrunning = 0;
//execute our walking animation
xsn_walk1();
};
//Running Code ==================================================================================================
void() xsn_run1 =[ $run01, xsn_run2 ] {xi_run(16);};
void() xsn_run2 =[ $run02, xsn_run3 ] {xi_run(20);};
void() xsn_run3 =[ $run03, xsn_run4 ] {xi_run(24);};
void() xsn_run4 =[ $run04, xsn_run5 ] {xi_run(16);};
void() xsn_run5 =[ $run05, xsn_run6 ] {xi_run(20);};
void() xsn_run6 =[ $run06, xsn_run1 ] {xi_run(24);};
void() xsn_run =
{
//we are currently running
self.isrunning = 1;
//execute our running animation
xsn_run1();
};
//Jumping Code ==================================================================================================
void() xsn_jump1 =[ $jump101, xsn_jump2 ] {xi_jump();};
void() xsn_jump2 =[ $jump102, xsn_jump3 ] {};
void() xsn_jump3 =[ $jump103, xsn_jump4 ] {};
void() xsn_jump4 =[ $jump104, xsn_jump5 ] {};
void() xsn_jump5 =[ $jump105, xsn_jump6 ] {};
void() xsn_jump6 =[ $jump106, xsn_jumpdone ] {};
void() xsn_jumpdone =
{
//set up our nextthink
self.nextthink = time + 0.1;
//if we found an object then reset our goalentity
if (self.object_found == 1)
self.goalentity = self.oldgoalentity;
//if we are running then continue running after jump
if (self.isrunning == 1)
self.think = self.th_run;
else
self.think = self.th_walk;
};
void() xsn_jumpsound =
{
//play jumping sound
sound (self, CHAN_VOICE, "player/plyrjmp8.wav", 1, ATTN_NORM);
};
void() xsn_jump =
{
//play jumping sound
xsn_jumpsound();
//execute our jumping animation
xsn_jump1();
};
//Attacking Code ================================================================================================
//Knife
void() xsn_knifea1 =[ $kattack101, xsn_knifea2 ] {ai_charge(20);};
void() xsn_knifea2 =[ $kattack102, xsn_knifea3 ] {ai_charge(22);};
void() xsn_knifea3 =[ $kattack103, xsn_knifea4 ]
{
ai_charge(18);
//attack based on wmode
if (self.wmode == 1)
W_FireDagger();
else
W_FireDagger2();
};
void() xsn_knifea4 =[ $kattack104, xsn_knifea5 ] {ai_charge(20);};
void() xsn_knifea5 =[ $kattack105, xsn_knifea6 ] {ai_charge(22);};
void() xsn_knifea6 =[ $kattack106, xsn_run ] {ai_charge(18);};
void() xsn_knifeb1 =[ $kattack201, xsn_knifeb2 ] {ai_charge(20);};
void() xsn_knifeb2 =[ $kattack202, xsn_knifeb3 ] {ai_charge(22);};
void() xsn_knifeb3 =[ $kattack203, xsn_knifeb4 ]
{
ai_charge(18);
//attack based on wmode
if (self.wmode == 1)
W_FireDagger();
else
W_FireDagger2();
};
void() xsn_knifeb4 =[ $kattack204, xsn_knifeb5 ] {ai_charge(20);};
void() xsn_knifeb5 =[ $kattack205, xsn_knifeb6 ] {ai_charge(22);};
void() xsn_knifeb6 =[ $kattack206, xsn_run ] {ai_charge(18);};
void() xsn_knife =
{
//pick which animation to play at random
if (random() <= 0.5)
xsn_knifea1();
else
xsn_knifeb1();
};
//Crossbow
void() xsn_xbow1 =[ $battack201, xsn_xbow2 ] {ai_face();};
void() xsn_xbow2 =[ $battack202, xsn_xbow3 ] {ai_face();};
void() xsn_xbow3 =[ $battack203, xsn_xbow4 ] {ai_face();};
void() xsn_xbow4 =[ $battack204, xsn_xbow5 ] {ai_face();};
void() xsn_xbow5 =[ $battack205, xsn_xbow6 ] {ai_face();};
void() xsn_xbow6 =[ $battack206, xsn_xbow7 ] {ai_face();};
void() xsn_xbow7 =[ $battack207, xsn_xbow8 ] {ai_face();};
void() xsn_xbow8 =[ $battack208, xsn_xbow9 ] {ai_face();};
void() xsn_xbow9 =[ $battack101, xsn_xbow10 ] {ai_face();};
void() xsn_xbow10 =[ $battack102, xsn_xbow11 ] {ai_face();};
void() xsn_xbow11 =[ $battack103, xsn_xbow12 ] {ai_face();};
void() xsn_xbow12 =[ $battack104, xsn_xbow13 ]
{
//attack based on wmode
if (self.wmode == 1)
W_FireCrossbow();
else
W_FireCrossbow2();
};
void() xsn_xbow13 =[ $battack105, xsn_run ] {};
void() xsn_xbow =
{
//random chance of loading the bow before firing
if (random() <= 0.2)
xsn_xbow1();
else //fire right away
xsn_xbow9();
};
//Trinity Blast
void() xsn_tblast1 =[ $kattack401, xsn_tblast2 ] {ai_face();};
void() xsn_tblast2 =[ $kattack402, xsn_tblast3 ] {ai_face();};
void() xsn_tblast3 =[ $kattack403, xsn_tblast4 ]
{
//attack based on wmode
if (self.wmode == 1)
DoTrinBlast();
else
DoTrinBlast2();
};
void() xsn_tblast4 =[ $kattack404, xsn_tblast5 ] {};
void() xsn_tblast5 =[ $kattack405, xsn_tblast6 ] {};
void() xsn_tblast6 =[ $kattack406, xsn_run ] {};
//Ice Shards
void() xsn_ishards1 =[ $kattack401, xsn_ishards2 ] {ai_face();};
void() xsn_ishards2 =[ $kattack402, xsn_ishards3 ] {ai_face();};
void() xsn_ishards3 =[ $kattack403, xsn_ishards4 ]
{
//attack based on wmode
if (self.wmode == 1)
DoIceShards();
else
W_FireIceshard2();
};
void() xsn_ishards4 =[ $kattack404, xsn_ishards5 ] {};
void() xsn_ishards5 =[ $kattack405, xsn_ishards6 ] {};
void() xsn_ishards6 =[ $kattack406, xsn_run ] {};
//Lightning Arc
void() xsn_larc1 =[ $sattack501, xsn_larc2 ] {ai_face();};
void() xsn_larc2 =[ $sattack502, xsn_larc3 ] {ai_face();};
void() xsn_larc3 =[ $sattack503, xsn_larc4 ] {ai_face();};
void() xsn_larc4 =[ $sattack504, xsn_larc5 ] {CastLightning();};
void() xsn_larc5 =[ $sattack505, xsn_larc6 ] {};
void() xsn_larc6 =[ $sattack506, xsn_larc7 ] {};
void() xsn_larc7 =[ $sattack507, xsn_larc8 ] {};
void() xsn_larc8 =[ $sattack508, xsn_run ] {};
//Smite
void() xsn_smite1 =[ $kattack301, xsn_smite2 ] {ai_face();};
void() xsn_smite2 =[ $kattack302, xsn_smite3 ] {ai_face();};
void() xsn_smite3 =[ $kattack303, xsn_smite4 ] {W_FireSmite();};
void() xsn_smite4 =[ $kattack304, xsn_smite5 ] {};
void() xsn_smite5 =[ $kattack305, xsn_smite6 ] {};
void() xsn_smite6 =[ $kattack306, xsn_run ] {};
//Soul Disc
void() xsn_sdisc1 =[ $sattack101, xsn_sdisc2 ] {ai_face();};
void() xsn_sdisc2 =[ $sattack102, xsn_sdisc3 ] {ai_face();};
void() xsn_sdisc3 =[ $sattack103, xsn_sdisc4 ]
{
//attack based on wmode
if (self.wmode == 1)
DoSoulDisc();
else
DoSoulDisc2();
};
void() xsn_sdisc4 =[ $sattack104, xsn_sdisc5 ] {};
void() xsn_sdisc5 =[ $sattack105, xsn_sdisc6 ] {};
void() xsn_sdisc6 =[ $sattack106, xsn_sdisc7 ] {};
void() xsn_sdisc7 =[ $sattack107, xsn_sdisc8 ] {};
void() xsn_sdisc8 =[ $sattack108, xsn_sdisc9 ] {};
void() xsn_sdisc9 =[ $sattack109, xsn_run ] {};
//Sword
void() xsn_sworda1 =[ $sattack301, xsn_sworda2 ] {ai_charge(20);};
void() xsn_sworda2 =[ $sattack302, xsn_sworda3 ] {ai_charge(22);};
void() xsn_sworda3 =[ $sattack303, xsn_sworda4 ] {ai_charge(18);};
void() xsn_sworda4 =[ $sattack304, xsn_sworda5 ] {ai_charge(16);};
void() xsn_sworda5 =[ $sattack305, xsn_sworda6 ] {ai_charge(20);W_FireSword();};
void() xsn_sworda6 =[ $sattack306, xsn_sworda7 ] {ai_charge(22);};
void() xsn_sworda7 =[ $sattack307, xsn_sworda8 ] {ai_charge(18);};
void() xsn_sworda8 =[ $sattack308, xsn_sworda9 ] {ai_charge(16);};
void() xsn_sworda9 =[ $sattack309, xsn_sworda10 ] {ai_charge(20);};
void() xsn_sworda10 =[ $sattack310, xsn_sworda11 ] {ai_charge(22);};
void() xsn_sworda11 =[ $sattack311, xsn_run ] {ai_charge(18);};
void() xsn_swordb1 =[ $sattack401, xsn_swordb2 ] {ai_charge(20);};
void() xsn_swordb2 =[ $sattack402, xsn_swordb3 ] {ai_charge(22);};
void() xsn_swordb3 =[ $sattack403, xsn_swordb4 ] {ai_charge(18);};
void() xsn_swordb4 =[ $sattack404, xsn_swordb5 ] {ai_charge(16);};
void() xsn_swordb5 =[ $sattack405, xsn_swordb6 ] {ai_charge(20);};
void() xsn_swordb6 =[ $sattack406, xsn_swordb7 ] {ai_charge(22);};
void() xsn_swordb7 =[ $sattack407, xsn_swordb8 ] {ai_charge(18);};
void() xsn_swordb8 =[ $sattack408, xsn_swordb9 ] {ai_charge(16);W_FireSword();};
void() xsn_swordb9 =[ $sattack409, xsn_swordb10 ] {ai_charge(20);};
void() xsn_swordb10 =[ $sattack410, xsn_swordb11 ] {ai_charge(22);};
void() xsn_swordb11 =[ $sattack411, xsn_swordb12 ] {ai_charge(18);};
void() xsn_swordb12 =[ $sattack412, xsn_swordb13 ] {ai_charge(16);};
void() xsn_swordb13 =[ $sattack413, xsn_swordb14 ] {ai_charge(20);};
void() xsn_swordb14 =[ $sattack414, xsn_swordb15 ] {ai_charge(22);};
void() xsn_swordb15 =[ $sattack415, xsn_swordb16 ] {ai_charge(18);};
void() xsn_swordb16 =[ $sattack416, xsn_run ] {ai_charge(16);};
void() xsn_swordc1 =[ $sattack401, xsn_swordc2 ] {ai_face();};
void() xsn_swordc2 =[ $sattack402, xsn_swordc3 ] {ai_face();};
void() xsn_swordc3 =[ $sattack403, xsn_swordc4 ] {ai_face();};
void() xsn_swordc4 =[ $sattack404, xsn_swordc5 ] {ai_face();};
void() xsn_swordc5 =[ $sattack405, xsn_swordc6 ] {ai_face();};
void() xsn_swordc6 =[ $sattack406, xsn_swordc7 ] {ai_face();};
void() xsn_swordc7 =[ $sattack407, xsn_swordc8 ] {ai_face();};
void() xsn_swordc8 =[ $sattack408, xsn_swordc9 ] {ai_face();W_FireSword2();};
void() xsn_swordc9 =[ $sattack409, xsn_swordc10 ] {};
void() xsn_swordc10 =[ $sattack410, xsn_swordc11 ] {};
void() xsn_swordc11 =[ $sattack411, xsn_swordc12 ] {};
void() xsn_swordc12 =[ $sattack412, xsn_swordc13 ] {};
void() xsn_swordc13 =[ $sattack413, xsn_swordc14 ] {};
void() xsn_swordc14 =[ $sattack414, xsn_swordc15 ] {};
void() xsn_swordc15 =[ $sattack415, xsn_swordc16 ] {};
void() xsn_swordc16 =[ $sattack416, xsn_run ] {};
void() xsn_sword =
{
//attack based on wmode
if (self.wmode == 1)
{
//play sword animation at random
if (random() <= 0.5)
xsn_sworda1();
else
xsn_swordb1();
}
else
xsn_swordc1();
};
vector() xsn_aim_at_enemy =
{
return normalize(self.enemy.origin - self.origin);
};
void() xsn_attack =
{
//attack based on our current weapon
if (self.weapon == IT_DAGGER) //Knife
{
sound (self, CHAN_WEAPON, "weapons/holy/punchmiss.wav", 1, ATTN_NORM);
xsn_knife();
self.attack_finished = time + 0.5;
}
else if (self.weapon == IT_CROSSBOW) //Crossbow
{
xsn_xbow();
self.attack_finished = time + 0.5;
}
else if (self.weapon == IT_TRINITY_BLAST) //Trinity Blast
{
xsn_tblast1();
self.attack_finished = time + 0.7;
}
else if (self.weapon == IT_ICE_SHARDS) //Iceshards
{
xsn_ishards1();
self.attack_finished = time + 0.45;
}
else if (self.weapon == IT_LIGHTNING_ARC) //Lightning Arc
{
sound (self, CHAN_WEAPON, "weapons/holy/lightarc.wav", 1, ATTN_NORM);
xsn_larc1();
self.attack_finished = time + 0.7;
}
else if (self.weapon == IT_SMITE) //Smite
{
xsn_smite1();
self.attack_finished = time + 0.7;
}
else if (self.weapon == IT_SOUL_DISC) //Soul Disc
{
xsn_sdisc1();
self.attack_finished = time + 0.5;
}
else if (self.weapon == IT_SWORD) //Sword
{
xsn_sword();
self.attack_finished = time + 0.5;
}
};
//Pain Code =====================================================================================================
void() xsn_paina1 =[ $pain101, xsn_paina2 ] {};
void() xsn_paina2 =[ $pain102, xsn_paina3 ] {};
void() xsn_paina3 =[ $pain103, xsn_paina4 ] {};
void() xsn_paina4 =[ $pain104, xsn_run ] {};
void() xsn_painb1 =[ $pain201, xsn_painb2 ] {};
void() xsn_painb2 =[ $pain202, xsn_painb3 ] {};
void() xsn_painb3 =[ $pain203, xsn_painb4 ] {};
void() xsn_painb4 =[ $pain204, xsn_run ] {};
void() xsn_painc1 =[ $pain301, xsn_painc2 ] {};
void() xsn_painc2 =[ $pain302, xsn_painc3 ] {};
void() xsn_painc3 =[ $pain303, xsn_painc4 ] {};
void() xsn_painc4 =[ $pain304, xsn_run ] {};
void() xsn_painsound =
{
local float r;
//set up random variable
r = random();
//play pain sound at random
if (r <= 0.16)
sound (self, CHAN_VOICE, "player/pain1.wav", 1, ATTN_NORM);
else if (r <= 0.32)
sound (self, CHAN_VOICE, "player/pain2.wav", 1, ATTN_NORM);
else if (r <= 0.48)
sound (self, CHAN_VOICE, "player/pain3.wav", 1, ATTN_NORM);
else if (r <= 0.64)
sound (self, CHAN_VOICE, "player/pain4.wav", 1, ATTN_NORM);
else if (r <= 0.8)
sound (self, CHAN_VOICE, "player/pain5.wav", 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, "player/pain6.wav", 1, ATTN_NORM);
};
void() xsn_pain =
{
local float r;
//we don't want to be wallowing in pain too much now
if (random() <= 0.65)
return;
//set up random variable
r = random();
//play a random pain sound
xsn_painsound();
//pick pain animation at random
if (r <= 0.33)
xsn_paina1();
else if (r <= 0.66)
xsn_painb1();
else
xsn_painc1();
};
//Death Code ==================================================================================================
void() th_respawn =
{
self.think = respawn_xsniper;
self.nextthink = time + 1 + random();
};
void() xsn_diea1 =[ $death101, xsn_diea2 ] {};
void() xsn_diea2 =[ $death102, xsn_diea3 ] {};
void() xsn_diea3 =[ $death103, xsn_diea4 ] {};
void() xsn_diea4 =[ $death104, xsn_diea5 ] {};
void() xsn_diea5 =[ $death105, xsn_diea6 ] {};
void() xsn_diea6 =[ $death106, xsn_diea7 ] {};
void() xsn_diea7 =[ $death107, xsn_diea7 ] {th_respawn();};
void() xsn_dieb1 =[ $death201, xsn_dieb2 ] {};
void() xsn_dieb2 =[ $death202, xsn_dieb3 ] {};
void() xsn_dieb3 =[ $death203, xsn_dieb4 ] {};
void() xsn_dieb4 =[ $death204, xsn_dieb5 ] {};
void() xsn_dieb5 =[ $death205, xsn_dieb6 ] {};
void() xsn_dieb6 =[ $death206, xsn_dieb7 ] {};
void() xsn_dieb7 =[ $death207, xsn_dieb8 ] {};
void() xsn_dieb8 =[ $death208, xsn_dieb9 ] {};
void() xsn_dieb9 =[ $death209, xsn_dieb10 ] {};
void() xsn_dieb10 =[ $death210, xsn_dieb11 ] {};
void() xsn_dieb11 =[ $death211, xsn_dieb12 ] {};
void() xsn_dieb12 =[ $death212, xsn_dieb13 ] {};
void() xsn_dieb13 =[ $death213, xsn_dieb14 ] {};
void() xsn_dieb14 =[ $death214, xsn_dieb15 ] {};
void() xsn_dieb15 =[ $death215, xsn_dieb16 ] {};
void() xsn_dieb16 =[ $death216, xsn_dieb17 ] {};
void() xsn_dieb17 =[ $death217, xsn_dieb18 ] {};
void() xsn_dieb18 =[ $death218, xsn_dieb19 ] {};
void() xsn_dieb19 =[ $death219, xsn_dieb20 ] {};
void() xsn_dieb20 =[ $death301, xsn_dieb21 ] {};
void() xsn_dieb21 =[ $death302, xsn_dieb22 ] {};
void() xsn_dieb22 =[ $death303, xsn_dieb23 ] {};
void() xsn_dieb23 =[ $death304, xsn_dieb24 ] {};
void() xsn_dieb24 =[ $death305, xsn_dieb25 ] {};
void() xsn_dieb25 =[ $death306, xsn_dieb26 ] {};
void() xsn_dieb26 =[ $death307, xsn_dieb27 ] {};
void() xsn_dieb27 =[ $death401, xsn_dieb28 ] {};
void() xsn_dieb28 =[ $death402, xsn_dieb29 ] {};
void() xsn_dieb29 =[ $death403, xsn_dieb30 ] {};
void() xsn_dieb30 =[ $death404, xsn_dieb31 ] {};
void() xsn_dieb31 =[ $death405, xsn_dieb32 ] {};
void() xsn_dieb32 =[ $death406, xsn_dieb33 ] {};
void() xsn_dieb33 =[ $death407, xsn_dieb33 ] {th_respawn();};
void() xsn_deathsound =
{
local float r;
//set up random variable
r = random();
//play death sound at random
if (r <= 0.2)
sound (self, CHAN_VOICE, "player/death1.wav", 1, ATTN_NORM);
else if (r <= 0.4)
sound (self, CHAN_VOICE, "player/death2.wav", 1, ATTN_NORM);
else if (r <= 0.6)
sound (self, CHAN_VOICE, "player/death3.wav", 1, ATTN_NORM);
else if (r <= 0.8)
sound (self, CHAN_VOICE, "player/death4.wav", 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, "player/death5.wav", 1, ATTN_NORM);
};
void() xsn_die =
{
//we are dying so we aren't solid anymore
self.solid = SOLID_NOT;
//other death stuff
self.deadflag = DEAD_DYING;
self.solid = SOLID_NOT;
self.invincible_finished = 0;
self.super_damage_finished = 0;
self.flags = self.flags - (self.flags & FL_ONGROUND);
//play random deathsound
xsn_deathsound();
//execute random death animation
if (random() <= 0.5)
xsn_diea1();
else
xsn_dieb1();
};
/*
======================
terminate_xsniper
Removes an xsniper bot from the game.
======================
*/
void() terminate_xsniper =
{
local entity bot;
//find a bot
bot = find(world,classname,"xsniperbot");
if (bot != world)
{
bprint(bot.netname);
bprint(" has left the game.\n");
remove(bot);
}
else
bprint("No bots to remove!\n");
};
/*
======================================
give_random_weapon
Used to give Xsniper a random weapon.
======================================
*/
void(entity targ) give_random_weapon =
{
local float it;
it = floor(random() * 6);
if (it == 0)
{
targ.items = targ.items | IT_TRINITY_BLAST;
targ.currentammo = targ.ammo_mana_green = targ.ammo_mana_green + 50;
targ.weapon = IT_TRINITY_BLAST;
}
else if (it == 1)
{
targ.items = targ.items | IT_ICE_SHARDS;
targ.currentammo = targ.ammo_mana_blue = targ.ammo_mana_blue + 50;
targ.weapon = IT_ICE_SHARDS;
}
else if (it == 2)
{
targ.items = targ.items | IT_LIGHTNING_ARC;
targ.currentammo = targ.ammo_mana_green = targ.ammo_mana_green + 50;
targ.weapon = IT_LIGHTNING_ARC;
}
else if (it == 3)
{
targ.items = targ.items | IT_SMITE;
targ.currentammo = targ.ammo_mana_green = targ.ammo_mana_green + 50;
targ.weapon = IT_SMITE;
}
else if (it == 4)
{
targ.items = targ.items | IT_SOUL_DISC;
targ.currentammo = targ.ammo_mana_grey = targ.ammo_mana_grey + 50;
targ.weapon = IT_SOUL_DISC;
}
else
{
targ.items = targ.items | IT_SWORD;
targ.weapon = IT_SWORD;
}
};
/*
====================
respawn_xsniper
When Xsniper Bot dies he will respawn into the
game after roughly 1 second.
====================
*/
void() respawn_xsniper =
{
local entity spot;
// putting him back in game
spot = SelectSpawnPoint();
self.origin = spot.origin + '0 0 1';
self.angles = spot.angles;
self.fixangle = TRUE;
spawn_tfog (self.origin);
spawn_tdeath (self.origin, self);
self.solid = SOLID_SLIDEBOX;
self.movetype = MOVETYPE_STEP;
self.flags = self.flags - (self.flags & FL_ONGROUND);
makevectors(self.angles);
self.velocity = self.velocity + v_forward*20;
// making him normal again
setmodel(self, "models/players/mike/player.md2");
setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
self.deadflag = DEAD_NO;
self.takedamage = DAMAGE_AIM;
self.ideal_yaw = self.angles * '0 1 0';
self.yaw_speed = 120;
self.view_ofs = '0 0 22';
self.frame = $idle101;
self.button1 = 60;
// finishing his characteristics
self.items = IT_CROSSBOW;
self.items = self.items | IT_DAGGER;
self.currentammo = self.ammo_bolts = 25;
self.weapon = IT_CROSSBOW;
self.health = 100;
self.classname = "xsniperbot";
self.enemy = world;
self.search_time = 0;
self.wmode = 1;
self.path = assign_path(self);
// set up his goal entity
if (cvar("coop") > 0)
{
local entity player, tempplayer;
player = find(world, classname, "player");
while(player)
{
if (player.admin == 1)
tempplayer = player;
player = find(player, classname, "player");
}
player = tempplayer;
self.goalentity = player;
self.oldgoalentity = player;
}
else
{
self.goalentity = world;
self.oldgoalentity = world;
}
// give him a random weapon if we are on final level
if (mapname == "ewend")
give_random_weapon(self);
// making him stand for a bit
self.pausetime = time + 3;
self.nextthink = time + 0.1 + random();
self.think = self.th_stand;
};
/*
================
get_name
Used to give a random name to each Xsniper bot spawned into the game.
================
*/
string() get_name =
{
local float r;
local string botname;
//set up random variable
r = random();
//pick name based on random variable
if (r <= 0.1)
botname = "Xsniper"; //Michael Rogers
else if (r <= 0.2)
botname = "Mr. Diffrence"; //Mackenzie Ponech
else if (r <= 0.3)
botname = "Miriamele"; //Andrea Smith
else if (r <= 0.4)
botname = "Gunda Truda"; //Charmaine Suprovich
else if (r <= 0.5)
botname = "Puff Man"; //Patrick Ponech
else if (r <= 0.6)
botname = "Zookey"; //Joshua Hughes
else if (r <= 0.7)
botname = "Pathogenicus"; //Sean Dinwiddie
else if (r <= 0.8)
botname = "Koolio"; //Robert de Heus
else if (r <= 0.9)
botname = "Tomaz"; //Tomas Jakobson
else
botname = "WardSix"; //Ward Six Entertainment
return botname;
};
/*
=========================
xsniper
Isn't it great having a function named after yourself?
Anyway this function is called through ImpulseCommands.
It puts Xsniper Bot into the world.
=========================
*/
void() xsniper =
{
local entity bot;
local entity spot;
// select spawn spot
spot = SelectSpawnPoint();
// start entity and place it in world
bot = spawn();
bot.angles = spot.angles;
setorigin (bot, spot.origin);
bot.fixangle = TRUE;
spawn_tfog (bot.origin);
spawn_tdeath (bot.origin, bot);
// set size and shape
bot.solid = SOLID_SLIDEBOX;
bot.movetype = MOVETYPE_STEP;
setmodel (bot, "models/players/mike/player.md2");
setsize (bot, VEC_HULL_MIN, VEC_HULL_MAX);
bot.takedamage = DAMAGE_AIM;
// define his animation
bot.th_stand = xsn_stand;
bot.th_walk = xsn_walk;
bot.th_run = xsn_run;
bot.th_jump = xsn_jump;
bot.th_pain = xsn_pain;
bot.th_die = xsn_die;
bot.th_missile = xsn_attack;
bot.health = 100;
bot.speed = 300;
// polish him up
bot.classname = "xsniperbot";
bot.ideal_yaw = bot.angles * '0 1 0';
bot.yaw_speed = 120;
bot.button1 = 60;
bot.view_ofs = '0 0 22';
bot.alpha = 1;
bot.wmode = 1;
// give him a weapon
bot.items = bot.items | IT_CROSSBOW;
bot.items = bot.items | IT_DAGGER;
bot.currentammo = bot.ammo_bolts = bot.ammo_bolts + 25;
bot.weapon = IT_CROSSBOW;
// set up his skin
bot.skin = 1;
// set up his name
bot.netname = get_name();
// set up his goal entity
if (cvar("coop") > 0)
{
local entity player, tempplayer;
player = find(world, classname, "player");
while(player)
{
if (player.admin == 1)
tempplayer = player;
player = find(player, classname, "player");
}
player = tempplayer;
bot.goalentity = player;
bot.oldgoalentity = player;
}
else
{
bot.goalentity = world;
bot.oldgoalentity = world;
}
// waypoint stuff
bot.waypoint = 0;
bot.direction = 0;
bot.path = assign_path(bot);
// make him stand for a little while
bot.pausetime = time + 3;
// begin his thinking
bot.nextthink = time + 0.1 + random();
bot.think = bot.th_stand;
// give him a random weapon if we are on final level
if (mapname == "ewend")
give_random_weapon(bot);
// remove delayholders from the game
if (self.classname == "delayholder")
remove(self);
// let the world know we are here
bprint(bot.netname);
bprint(" has entered the game!\n");
};
void(float delaytime) delay_xsniper =
{
local entity delayholder;
//create a delay entity and put it into the world
delayholder = spawn();
delayholder.solid = SOLID_NOT;
delayholder.movetype = MOVETYPE_NONE;
setorigin (delayholder, self.origin);
setmodel (delayholder, "");
delayholder.classname = "delayholder";
//set up its thinking
delayholder.nextthink = time + delaytime;
delayholder.think = xsniper;
};