Advertisement
techforce

Botai.qc (Tekbotctf+)

Sep 13th, 2011
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Clone C 89.79 KB | None | 0 0
  1. void () BotIsDead =
  2. {
  3. self.think = BotRespawn;
  4. self.nextthink = ((time + 1) + (random () * (4 - self.bot_skill)));
  5. setmodel (self, "");
  6. };
  7.  
  8. void () ChangePitch =
  9. {
  10. local float ideal;
  11. local float move;
  12.  
  13. self.current_pitch = self.angles_x;
  14. ideal = self.ideal_pitch;
  15. if ((ideal > 54))
  16. {
  17. ideal = 54;
  18. }
  19. else
  20. {
  21. if ((ideal < -54))
  22. {
  23. ideal = -54;
  24. }
  25. }
  26. if ((self.current_pitch == ideal))
  27. {
  28. return;
  29. }
  30. move = (ideal - self.current_pitch);
  31. if ((move > 0))
  32. {
  33. if ((move > 6))
  34. {
  35. move = 6;
  36. }
  37. }
  38. else
  39. {
  40. if ((move < CONTENT_SKY))
  41. {
  42. move = CONTENT_SKY;
  43. }
  44. }
  45. self.current_pitch = (self.current_pitch + move);
  46. self.angles_x = self.current_pitch;
  47. };
  48.  
  49. void () wall_look =
  50. {
  51. local vector a1;
  52. local vector b1;
  53. local vector c1;
  54. local float a;
  55. local float b;
  56. local float c;
  57.  
  58. makevectors (self.angles);
  59. traceline (self.origin, ((self.origin + '0 0 16') + (v_forward * 100)), FALSE, self);
  60. a = vlen ((trace_endpos - self.origin));
  61. a1 = trace_endpos;
  62. if ((random () < 0.45))
  63. {
  64. self.angles_x = (self.angles_x - 8);
  65. }
  66. else
  67. {
  68. self.angles_x = (self.angles_x + 12);
  69. }
  70. if ((trace_fraction < 1))
  71. {
  72. self.angles_y = (self.angles_y - 45);
  73. makevectors (self.angles);
  74. traceline (self.origin, ((self.origin + '0 0 16') + (v_forward * 100)), FALSE, self);
  75. b = vlen ((trace_endpos - self.origin));
  76. b1 = trace_endpos;
  77. if ((trace_fraction < 1))
  78. {
  79. self.angles_y = (self.angles_y + 90);
  80. makevectors (self.angles);
  81. traceline (self.origin, ((self.origin + '0 0 16') + (v_forward * 100)), FALSE, self);
  82. c = vlen ((trace_endpos - self.origin));
  83. c1 = trace_endpos;
  84. }
  85. }
  86. if (((a > b) && (a > c)))
  87. self.angles_y = (self.angles_y - 45);
  88. else if (((b > a) && (b > c)))
  89. self.angles_y = (self.angles_y - 90);
  90. else if (((c > a) && (c > b)))
  91. return;
  92.  
  93.  
  94.  
  95. return;
  96. };
  97.  
  98. void () patternchange =
  99. {
  100. local float p;
  101.  
  102. if ((self.waterlevel < SPAWNFLAG_LASER))
  103. {
  104. p = random ();
  105. if ((p < 0.7))
  106. {
  107. self.pattern = 0;
  108. return;
  109. }
  110. else
  111. {
  112. if (((p > 0.9) && (pointcontents (self.origin) > CONTENT_WATER)))
  113. {
  114. self.pattern = 1;
  115. return;
  116. }
  117. }
  118. }
  119. return;
  120. };
  121.  
  122.  
  123. float (entity targ) BotCanSeeItemThroughWater =
  124. {
  125. local vector spot1;
  126. local vector spot2;
  127. local vector vec;
  128.  
  129. spot1 = (self.origin + self.view_ofs);
  130. vec = GetRandomVector ();
  131. spot2 = (targ.origin + vec);
  132. traceline (spot1, spot2, TRUE, self);
  133. if ((trace_fraction == 1))
  134. {
  135. return (TRUE);
  136. }
  137. return (FALSE);
  138. };
  139.  
  140. float (vector pt) BotCanSeePoint =
  141. {
  142. local vector spot1;
  143.  
  144. spot1 = (self.origin + self.view_ofs);
  145. traceline (spot1, pt, TRUE, self);
  146. if ((trace_inopen && trace_inwater))
  147. {
  148. return (FALSE);
  149. }
  150. if ((trace_fraction == 1))
  151. {
  152. return (TRUE);
  153. }
  154. return (FALSE);
  155. };
  156.  
  157. float (vector pt) BotCanSeePointThroughWater =
  158. {
  159. local vector spot1;
  160.  
  161. spot1 = (self.origin + self.view_ofs);
  162. traceline (spot1, pt, TRUE, self);
  163. if ((trace_fraction == 1))
  164. {
  165. return (TRUE);
  166. }
  167. return (FALSE);
  168. };
  169.  
  170. float (entity targ) BotCanSeeItem =
  171. {
  172. local vector spot1;
  173. local vector spot2;
  174. local vector vec;
  175.  
  176. spot1 = (self.origin + self.view_ofs);
  177. vec = GetRandomVector ();
  178. spot2 = (targ.origin + vec);
  179. traceline (spot1, spot2, TRUE, self);
  180. if ((trace_inopen && trace_inwater))
  181. {
  182. return (FALSE);
  183. }
  184. if ((trace_fraction == 1))
  185. {
  186. return (TRUE);
  187. }
  188. return (FALSE);
  189. };
  190.  
  191. float (entity targ) BotCanSeePlayer =
  192. {
  193. local vector spot1;
  194. local vector spot2;
  195. local vector vec;
  196. local float r;
  197.  
  198. spot1 = (self.origin + self.view_ofs);
  199. if (((targ.waterlevel == 0) || (targ.waterlevel == 3)))
  200. {
  201. vec = GetRandomVector ();
  202. }
  203. else
  204. {
  205. vec = '0 0 16';
  206. }
  207. spot2 = (targ.origin + vec);
  208. traceline (spot1, spot2, TRUE, self);
  209. if ((trace_inopen && trace_inwater))
  210. {
  211. return (FALSE);
  212. }
  213. if ((trace_fraction == 1))
  214. {
  215. return (TRUE);
  216. }
  217. return (FALSE);
  218. };
  219.  
  220. float (entity targ) BotCanSeePlayer0 =
  221. {
  222. return (BotCanSeeItem (targ));
  223. };
  224.  
  225. entity (entity targ) BotCanSeePlayerFollow =
  226. {
  227. local float vis;
  228. local entity e;
  229. local float nm;
  230.  
  231. if ((targ != world))
  232. {
  233. nm = 0;
  234. e = targ.follow_head;
  235. while (((e != world) && (nm < 10)))
  236. {
  237. vis = BotCanSeeItem (e);
  238. if (vis)
  239. {
  240. return (e);
  241. }
  242. e = e.follow_next;
  243. nm = (nm + 1);
  244. }
  245. }
  246. return (world);
  247. };
  248.  
  249. void () RemoveInaccessible =
  250. {
  251. num_inaccessible_entities = (num_inaccessible_entities - 1);
  252. if ((self.inaccessible_entity != world))
  253. {
  254. if ((self.inaccessible_entity.inaccessible_count > 0))
  255. {
  256. self.inaccessible_entity.inaccessible_count = (self.inaccessible_entity.inaccessible_count - 1);
  257. }
  258. }
  259. remove (self);
  260. };
  261.  
  262. float (entity e) ItemIsAccessible =
  263. {
  264. local entity p;
  265.  
  266. if ((e.inaccessible_count <= 0))
  267. {
  268. return (TRUE);
  269. }
  270. p = find (world, classname, "inaccessible_from_here");
  271. while ((p != world))
  272. {
  273. if ((p.inaccessible_entity == e))
  274. {
  275. if ((vlen ((p.origin - self.origin)) < 100))
  276. {
  277. return (FALSE);
  278. }
  279. }
  280. p = find (p, classname, "inaccessible_from_here");
  281. }
  282. return (TRUE);
  283. };
  284.  
  285. void (entity e) SpawnInaccessibleFromHere =
  286. {
  287. local entity p;
  288.  
  289. if (ItemIsAccessible (e))
  290. {
  291. num_inaccessible_entities = (num_inaccessible_entities + 1);
  292. p = spawn ();
  293. p.classname = "inaccessible_from_here";
  294. p.inaccessible_entity = e;
  295. e.inaccessible_count = (e.inaccessible_count + 1);
  296. p.origin = (self.origin + '0 0 16');
  297. setorigin (p, p.origin);
  298. p.solid = SOLID_NOT;
  299. p.movetype = MOVETYPE_NONE;
  300. setmodel (p, string_null);
  301. p.think = RemoveInaccessible;
  302. p.nextthink = (time + 60);
  303. }
  304. };
  305.  
  306. entity (float dist) FindNearbyItem =
  307. {
  308. local entity head;
  309. local entity selected;
  310. local float item_rating;
  311. local float best_rating;
  312. local float found;
  313.  
  314. if ((time < self.find_item_time))
  315. return (head);
  316.  
  317. self.find_item_time = (time + (self.bsk_reaction_time / 1.5));
  318. selected = world;
  319. found = FALSE;
  320. if ((self.player_flag & ITEM_ENEMY_FLAG))
  321. {
  322. if ((self.team == TEAM_COLOR1))
  323. {
  324. head = find (world, classname, "item_flag_team1");
  325. }
  326. else
  327. {
  328. if ((self.team == TEAM_COLOR2))
  329. {
  330. head = find (world, classname, "item_flag_team2");
  331. }
  332. }
  333. if ( head != world )
  334. {
  335. if ((head.solid != SOLID_NOT))
  336. {
  337. if (BotCanSeeItem (head))
  338. {
  339. found = TRUE;
  340. selected = head;
  341. }
  342. }
  343. }
  344. }
  345. if (!found)
  346. {
  347. if ((self.team == TEAM_COLOR1))
  348. {
  349. head = find (world, classname, "item_flag_team2");
  350. }
  351. else
  352. {
  353. if ((self.team == TEAM_COLOR2))
  354. {
  355. head = find (world, classname, "item_flag_team1");
  356. }
  357. }
  358. if ((head != world))
  359. {
  360. if (((time >= head.bot_ignore_until_time) || (self.team != head.bot_ignore_team)))
  361. {
  362. if ((head.solid != SOLID_NOT))
  363. {
  364. if ((vlen ((head.origin - self.origin)) < 700))
  365. {
  366. if (BotCanSeeItem (head))
  367. {
  368. found = TRUE;
  369. selected = head;
  370. }
  371. }
  372. }
  373. }
  374. }
  375. }
  376. if (!found)
  377. {
  378. head = findradius (self.origin, dist);
  379. while (head)
  380. {
  381. if (((head.solid != SOLID_NOT) || (time < self.ltime)))
  382. {
  383. if (head.bot_wants_item)
  384. {
  385. if (((time >= head.bot_ignore_until_time) || (self.team != head.bot_ignore_team)))
  386. {
  387. if (BotCanSeeItem (head))
  388. {
  389. if (ItemIsAccessible (head))
  390. {
  391. item_rating = IsGoodItem (self, head);
  392. if ((item_rating > 0))
  393. {
  394. if (((trace_plane_dist - item_rating) < dist))
  395. {
  396. best_rating = item_rating;
  397. selected = head;
  398. dist = trace_plane_dist;
  399. found = TRUE;
  400. }
  401. }
  402. }
  403. }
  404. }
  405. }
  406. }
  407. head = head.chain;
  408. }
  409. }
  410. return (selected);
  411. };
  412.  
  413. entity (entity bot, float dist) HelpTeammate =
  414. {
  415. local entity head;
  416. local entity selected1;
  417. local entity selected2;
  418. local entity selected3;
  419. local float d;
  420. local float best_dist1;
  421. local float best_dist2;
  422. local float best_dist3;
  423. local float thisdist;
  424. local entity follow_ent;
  425.  
  426. if ((((bot.goalentity.classname == "player") || (bot.goalentity.classname == "bot")) && (bot.goalentity != bot)))
  427. {
  428. if ((bot.goalentity.team == self.team))
  429. {
  430. if ((bot.goalentity.health > 0))
  431. {
  432. if (BotCanSeePlayer (bot.goalentity))
  433. {
  434. return (bot.goalentity);
  435. }
  436. if ((bot.goalentity.classname == "player"))
  437. {
  438. follow_ent = BotCanSeePlayerFollow (bot.goalentity);
  439. if ((follow_ent != world))
  440. {
  441. return (follow_ent);
  442. }
  443. }
  444. }
  445. }
  446. }
  447. if ((time < bot.help_teammate_time))
  448. {
  449. return (world);
  450. }
  451. bot.help_teammate_time = (time + 5);
  452. selected1 = world;
  453. selected2 = world;
  454. selected3 = world;
  455. best_dist1 = 100000000;
  456. best_dist2 = 100000000;
  457. best_dist3 = 100000000;
  458. head = findradius (bot.origin, dist);
  459. while (head)
  460. {
  461. if (((head.classname == "player") || (head.classname == "bot")))
  462. {
  463. if ((head.team == bot.team))
  464. {
  465. if ((head != bot))
  466. {
  467. if (!(head.observer_flags & PLAYER_NO_TARGET))
  468. {
  469. if (!head.observer)
  470. {
  471. d = vlen ((head.origin - bot.origin));
  472. if ((head.classname == "player"))
  473. {
  474. if (((head.observer_flags & PLAYER_ALWAYS_ESCORT) || ((time < (self.escort_time + ESCORT_TIME)) && (self.escort_entity == head))))
  475. {
  476. if ((d < best_dist1))
  477. {
  478. if (BotCanSeePlayer (head))
  479. {
  480. selected1 = head;
  481. best_dist1 = d;
  482. }
  483. }
  484. }
  485. }
  486. if ((head.player_flag & ITEM_ENEMY_FLAG))
  487. {
  488. if ((self != head.goalentity))
  489. {
  490. if ((d < best_dist2))
  491. {
  492. if (BotCanSeePlayer (head))
  493. {
  494. selected2 = head;
  495. best_dist2 = d;
  496. }
  497. }
  498. }
  499. }
  500. if ((head.classname == "bot"))
  501. {
  502. if ((head.enemy != world))
  503. {
  504. if (((head.enemy.classname == "player") || (head.enemy.classname == "bot")))
  505. {
  506. if ((d < best_dist3))
  507. {
  508. if (BotCanSeePlayer (head))
  509. {
  510. selected3 = head;
  511. best_dist3 = d;
  512. }
  513. }
  514. }
  515. }
  516. }
  517. }
  518. }
  519. }
  520. }
  521. }
  522. head = head.chain;
  523. }
  524. if ((selected1 != world))
  525. {
  526. return (selected1);
  527. }
  528. else
  529. {
  530. if ((selected2 != world))
  531. {
  532. return (selected2);
  533. }
  534. else
  535. {
  536. if ((selected3 != world))
  537. {
  538. return (selected3);
  539. }
  540. else
  541. {
  542. return (world);
  543. }
  544. }
  545. }
  546. };
  547.  
  548. entity (float fteam) BotFindClosestTempWaypoint =
  549. {
  550. local entity e;
  551. local entity selected;
  552. local float best_waypoint_dist;
  553.  
  554. selected = world;
  555. best_waypoint_dist = 99999997952;
  556. e = find (world, classname, "waypoint_temp");
  557. while ((e != world))
  558. {
  559. if ((e.team == fteam))
  560. {
  561. if (BotCanSeeItemThroughWater (e))
  562. {
  563. if ((vlen ((e.origin - self.origin)) < best_waypoint_dist))
  564. {
  565. selected = e;
  566. best_waypoint_dist = vlen ((e.origin - self.origin));
  567. }
  568. }
  569. }
  570. e = find (e, classname, "waypoint_temp");
  571. }
  572. return (selected);
  573. };
  574.  
  575. entity (float fteam) BotFindLeastWaypoint =
  576. {
  577. local entity e;
  578. local entity selected;
  579. local float best_waypoint_num;
  580. local float current_waypoint_num;
  581. local float choose;
  582.  
  583. current_waypoint_num = 999999;
  584. best_waypoint_num = 999999;
  585. selected = world;
  586. if ((fteam == TEAM_COLOR1))
  587. {
  588. e = wp_first_red;
  589. }
  590. else
  591. {
  592. if ((fteam == TEAM_COLOR2))
  593. {
  594. e = wp_first_blue;
  595. }
  596. else
  597. {
  598. if ((fteam == -1))
  599. {
  600. e = wp_first_general;
  601. }
  602. }
  603. }
  604. while ((e != world))
  605. {
  606. if ((e.waypoint_num < current_waypoint_num))
  607. {
  608. if ((e.waypoint_num < best_waypoint_num))
  609. {
  610. if ((e.waypoint_num != -1))
  611. {
  612. if (BotCanSeeItemThroughWater (e))
  613. {
  614. selected = e;
  615. best_waypoint_num = e.waypoint_num;
  616. }
  617. }
  618. else
  619. {
  620. if (((((e.waypoint_num == -1) && self.use_defensive_way) && (self.bot_plan == BOT_DEFEND)) && !(self.player_flag & ITEM_ENEMY_FLAG)))
  621. {
  622. if (BotCanSeeItemThroughWater (e))
  623. {
  624. selected = e;
  625. best_waypoint_num = e.waypoint_num;
  626. }
  627. }
  628. }
  629. }
  630. else
  631. {
  632. if ((e.waypoint_num == best_waypoint_num))
  633. {
  634. if (BotCanSeeItemThroughWater (e))
  635. {
  636. choose = TRUE;
  637. if ((self.goalentity.classname == "waypoint"))
  638. {
  639. choose = FALSE;
  640. }
  641. if ((self.goalentity.waypoint_num > e.waypoint_num))
  642. {
  643. choose = TRUE;
  644. }
  645. if (choose)
  646. {
  647. if ((random () < 0.5))
  648. {
  649. selected = e;
  650. best_waypoint_num = e.waypoint_num;
  651. }
  652. }
  653. }
  654. }
  655. }
  656. }
  657. e = e.wp_chain;
  658. }
  659. return (selected);
  660. };
  661.  
  662. entity (float fteam) BotFindGreatestWaypoint =
  663. {
  664. local entity e;
  665. local entity selected;
  666. local float best_waypoint_num;
  667. local float current_waypoint_num;
  668. local float choose;
  669.  
  670. current_waypoint_num = -1;
  671. best_waypoint_num = -1;
  672. selected = world;
  673. if ((fteam == TEAM_COLOR1))
  674. {
  675. e = wp_first_red;
  676. }
  677. else
  678. {
  679. if ((fteam == TEAM_COLOR2))
  680. {
  681. e = wp_first_blue;
  682. }
  683. else
  684. {
  685. if ((fteam == -1))
  686. {
  687. e = wp_first_general;
  688. }
  689. }
  690. }
  691. while ((e != world))
  692. {
  693. if ((e.waypoint_num > current_waypoint_num))
  694. {
  695. if ((e.waypoint_num > best_waypoint_num))
  696. {
  697. if (BotCanSeeItemThroughWater (e))
  698. {
  699. selected = e;
  700. best_waypoint_num = e.waypoint_num;
  701. }
  702. }
  703. else
  704. {
  705. if ((e.waypoint_num == best_waypoint_num))
  706. {
  707. if (BotCanSeeItemThroughWater (e))
  708. {
  709. choose = TRUE;
  710. if ((self.goalentity.classname == "waypoint"))
  711. {
  712. choose = FALSE;
  713. }
  714. if ((self.goalentity.waypoint_num > e.waypoint_num))
  715. {
  716. choose = TRUE;
  717. }
  718. if (choose)
  719. {
  720. if ((random () < 0.5))
  721. {
  722. selected = e;
  723. best_waypoint_num = e.waypoint_num;
  724. }
  725. }
  726. }
  727. }
  728. }
  729. }
  730. e = e.wp_chain;
  731. }
  732. return (selected);
  733. };
  734.  
  735. void () BotFireHook =
  736. {
  737. if (!hook_use_enabled) return;
  738.  
  739. if ((temp1 & TEMP1_MULTI))
  740. {
  741. self.lastweapon_shot = self.weapon;
  742. self.weapon = IT_HOOK;
  743. set_player_weapon ();
  744. self.button0 = TRUE;
  745. Bot_Attack ();
  746. self.weapon = self.lastweapon_shot;
  747. }
  748. else
  749. {
  750. if ((self.player_flag & ITEM_RUNE3_FLAG))
  751. {
  752. self.attack_finished = (time + 0.06);
  753. HasteSound ();
  754. }
  755. else
  756. {
  757. self.attack_finished = (time + 0.1);
  758. }
  759. self.weapon = IT_HOOK;
  760. self.button0 = TRUE;
  761. Bot_Attack ();
  762. if ((self.nextjump < 4))
  763. {
  764. PlayerJump ();
  765. }
  766. }
  767. };
  768.  
  769. float (entity bot, entity en, float dist) CanSeeInvisibleEntity =
  770. {
  771. local float can_see_eyes;
  772. local float chance;
  773.  
  774. can_see_eyes = TRUE;
  775. if ((en.invisible_finished > time))
  776. {
  777. if ((dist < 80))
  778. {
  779. chance = 5;
  780. }
  781. else
  782. {
  783. if ((dist < 200))
  784. {
  785. chance = SECRET_NO_SHOOT;
  786. }
  787. else
  788. {
  789. chance = 1;
  790. }
  791. }
  792. if (((random () * 100) < (chance + (bot.bot_skill * (chance / 4)))))
  793. {
  794. can_see_eyes = TRUE;
  795. }
  796. else
  797. {
  798. can_see_eyes = FALSE;
  799. }
  800. }
  801. return (can_see_eyes);
  802. };
  803.  
  804. entity () FindNearbyEnemy =
  805. {
  806. local entity head;
  807. local entity selected;
  808. local float dist;
  809. local float thisdist;
  810.  
  811. if ((time < self.find_enemy_time))
  812. {
  813. return (head);
  814. }
  815. self.find_enemy_time = (time + self.bsk_reaction_time);
  816. if ((time > self.large_dist_pulse))
  817. {
  818. self.large_dist_pulse = (time + self.bsk_next_pulse_time);
  819. dist = large_pulse_dist;
  820. if ((random () < 0.02))
  821. dist = (dist + self.bsk_extra_large_pulse_dist);
  822. }
  823. else
  824. {
  825. dist = awareness_dist;
  826. if ((random () < 0.008))
  827. {
  828. dist = (dist + self.bsk_extra_awareness_dist);
  829. }
  830. }
  831. selected = world;
  832. head = findradius (self.origin, dist);
  833. while (head)
  834. {
  835. if ((head.classname != "image"))
  836. {
  837. if ((head.team != self.team))
  838. {
  839. if (((head.health > 0) && (head != self)))
  840. {
  841. if (EntityInFieldOfView (head))
  842. {
  843. if (BotCanSeePlayer (head))
  844. {
  845. if ((trace_plane_dist < dist))
  846. {
  847. if (CanSeeInvisibleEntity (self, head, trace_plane_dist))
  848. {
  849. if (!(head.observer_flags & PLAYER_NO_TARGET))
  850. {
  851. if (!head.observer)
  852. {
  853. selected = head;
  854. dist = trace_plane_dist;
  855. }
  856. }
  857. }
  858. }
  859. }
  860. }
  861. }
  862. }
  863. }
  864. head = head.chain;
  865. }
  866. if (((selected != world) && (bot_debug >= 3)))
  867. {
  868. dprint (self.netname);
  869. dprint (" found ");
  870. dprint (selected.netname);
  871. dprint ("\n");
  872. }
  873. return (selected);
  874. };
  875.  
  876. void () BotJump =
  877. {
  878. if (self.hook_out)
  879. {
  880. return;
  881. }
  882. makevectors (self.angles);
  883. v_forward_z = 0;
  884. v_forward = normalize (v_forward);
  885. if ((self.waterlevel >= SPAWNFLAG_LASER))
  886. {
  887. if ((self.watertype == CONTENT_WATER))
  888. {
  889. self.velocity = (VEC_ORIGIN + (v_forward * 100));
  890. }
  891. else
  892. {
  893. if ((self.watertype == CONTENT_SLIME))
  894. {
  895. self.velocity = (VEC_ORIGIN + (v_forward * 80));
  896. }
  897. else
  898. {
  899. if ((self.watertype == CONTENT_LAVA))
  900. {
  901. self.velocity = (VEC_ORIGIN + (v_forward * 50));
  902. }
  903. }
  904. }
  905. }
  906. else
  907. {
  908. self.velocity = (VEC_ORIGIN + (v_forward * 100));
  909. }
  910. self.flags = (self.flags | FL_JUMPRELEASED);
  911. PlayerJump ();
  912. };
  913.  
  914. float () IsJumpSafe =
  915. {
  916. local vector org;
  917. local vector spot2;
  918.  
  919. if ((self.nextjump < 1))
  920. {
  921. self.nextjump = 1;
  922. }
  923. makevectors (self.angles);
  924. org = (self.origin + (v_forward * 100));
  925. spot2 = org;
  926. spot2_z = (spot2_z - 500);
  927. traceline (org, spot2, TRUE, self);
  928. if ((trace_ent.classname == "plat"))
  929. {
  930. return (TRUE);
  931. }
  932. if ((pointcontents (trace_endpos) == CONTENT_LAVA))
  933. {
  934. return (FALSE);
  935. }
  936. if ((pointcontents (trace_endpos) == CONTENT_SLIME))
  937. {
  938. return (FALSE);
  939. }
  940. org = (self.origin + (v_forward * 200));
  941. spot2 = org;
  942. spot2_z = (spot2_z - 500);
  943. traceline (org, spot2, TRUE, self);
  944. if ((pointcontents (trace_endpos) == CONTENT_LAVA))
  945. {
  946. return (FALSE);
  947. }
  948. if ((pointcontents (trace_endpos) == CONTENT_SLIME))
  949. {
  950. return (FALSE);
  951. }
  952. return (TRUE);
  953. };
  954.  
  955. float () BotShouldJump =
  956. {
  957. local float chance;
  958. local float jump_to_goal;
  959. local vector v;
  960.  
  961. if (!IsJumpSafe ())
  962. {
  963. if (((pointcontents (self.origin) != CONTENT_SLIME) && (pointcontents (self.origin) != CONTENT_LAVA)))
  964. {
  965. return (FALSE);
  966. }
  967. }
  968. jump_to_goal = FALSE;
  969. v = (self.origin - self.goalentity.origin);
  970. if ((vlen (v) < 50))
  971. {
  972. if ((self.origin_z < self.goalentity.origin_z))
  973. {
  974. if (((self.goalentity.origin_z - self.origin_z) < 100))
  975. {
  976. jump_to_goal = TRUE;
  977. }
  978. }
  979. }
  980. else
  981. {
  982. if ((vlen (v) > 60))
  983. {
  984. if ((self.origin_z > self.goalentity.origin_z))
  985. {
  986. if (((self.origin_z - self.goalentity.origin_z) > 100))
  987. {
  988. jump_to_goal = TRUE;
  989. }
  990. }
  991. }
  992. }
  993. if (jump_to_goal)
  994. {
  995. chance = self.bsk_extra_jump_chance;
  996. }
  997. else
  998. {
  999. if ((pointcontents (self.origin) == CONTENT_SLIME))
  1000. {
  1001. chance = self.bsk_extra_jump_chance;
  1002. }
  1003. else
  1004. {
  1005. if ((pointcontents (self.origin) == CONTENT_LAVA))
  1006. {
  1007. chance = self.bsk_extra_jump_chance;
  1008. }
  1009. else
  1010. {
  1011. if (self.bot_blocked)
  1012. {
  1013. chance = 0.1;
  1014. }
  1015. else
  1016. {
  1017. if ((self.bot_action == BOT_FIGHTING))
  1018. {
  1019. chance = 0.03;
  1020. }
  1021. else
  1022. {
  1023. chance = 0.002;
  1024. }
  1025. }
  1026. }
  1027. }
  1028. }
  1029. if ((random () < chance))
  1030. {
  1031. return (TRUE);
  1032. }
  1033. else
  1034. {
  1035. return (FALSE);
  1036. }
  1037. };
  1038.  
  1039. void (vector org) SpawnTempDebugMarker =
  1040. {
  1041. local entity st;
  1042.  
  1043. st = spawn ();
  1044. st.origin = org;
  1045. setorigin (st, org);
  1046. st.solid = SOLID_NOT;
  1047. st.movetype = MOVETYPE_NONE;
  1048. setmodel (st, "progs/s_bubble.spr");
  1049. st.think = SUB_Remove;
  1050. st.nextthink = (time + 0.1);
  1051. };
  1052.  
  1053. float () StepUpZ =
  1054. {
  1055. local vector spot1;
  1056. local vector spot2;
  1057. local vector vf2;
  1058. local vector vr2;
  1059. local vector org;
  1060. local float diff1;
  1061. local float diff2;
  1062. local float diff3;
  1063. local float maxx;
  1064.  
  1065. makevectors (self.angles);
  1066. vf2 = v_forward;
  1067. vf2_z = 0;
  1068. vf2 = normalize (vf2);
  1069. org = (self.origin + (vf2 * 24));
  1070. spot1 = org;
  1071. spot2 = (spot1 - '0 0 64');
  1072. traceline (spot1, spot2, TRUE, self);
  1073. diff1 = (trace_endpos_z - (self.origin_z - 24));
  1074. vr2 = v_right;
  1075. vr2_z = 0;
  1076. vr2 = normalize (vr2);
  1077. org = ((self.origin + (vf2 * 24)) + (vr2 * SECRET_YES_SHOOT));
  1078. spot1 = org;
  1079. spot2 = (spot1 - '0 0 64');
  1080. traceline (spot1, spot2, TRUE, self);
  1081. diff2 = (trace_endpos_z - (self.origin_z - 24));
  1082. org = ((self.origin + (vf2 * 24)) + (vr2 * -16));
  1083. spot1 = org;
  1084. spot2 = (spot1 - '0 0 64');
  1085. traceline (spot1, spot2, TRUE, self);
  1086. diff3 = (trace_endpos_z - (self.origin_z - 24));
  1087. maxx = diff1;
  1088. if ((diff2 > maxx))
  1089. {
  1090. maxx = diff2;
  1091. }
  1092. if ((diff3 > maxx))
  1093. {
  1094. maxx = diff3;
  1095. }
  1096. if ((maxx > SECRET_YES_SHOOT))
  1097. {
  1098. maxx = SECRET_YES_SHOOT;
  1099. }
  1100. if ((maxx > 0))
  1101. {
  1102. return (maxx);
  1103. }
  1104. else
  1105. {
  1106. return (0);
  1107. }
  1108. };
  1109.  
  1110. float () ShouldReleaseHook =
  1111. {
  1112. if (((self.stuck_count > SPAWNFLAG_LASER) && !self.hooked_on_someone))
  1113. {
  1114. return (TRUE);
  1115. }
  1116. else
  1117. {
  1118. if (((time > (self.hook_snag_time + 3)) && !self.hooked_on_someone))
  1119. {
  1120. return (TRUE);
  1121. }
  1122. }
  1123. return (FALSE);
  1124. };
  1125.  
  1126. float () MoveForwardSafe =
  1127. {
  1128. local vector spot1;
  1129. local vector spot2;
  1130. local vector vf2;
  1131. local vector org;
  1132. local float diff;
  1133.  
  1134. makevectors (self.angles);
  1135. vf2 = v_forward;
  1136. vf2_z = 0;
  1137. vf2 = normalize (vf2);
  1138. org = (self.origin + (vf2 * 24));
  1139. spot1 = org;
  1140. spot2 = (org - '0 0 2000');
  1141. traceline (spot1, spot2, TRUE, self);
  1142. diff = (trace_endpos_z - (self.origin_z - 24));
  1143. if (((diff < 0) && (trace_inopen && trace_inwater)))
  1144. {
  1145. return (FALSE);
  1146. }
  1147. else
  1148. {
  1149. return (TRUE);
  1150. }
  1151. };
  1152.  
  1153. void () ExtraWalkMoveFrameThink =
  1154. {
  1155. walkmove (self.extramove_yaw, self.extramove_dist);
  1156. if (self.extramove_lastframewasextra)
  1157. {
  1158. self.think = BotAnimationThink;
  1159. }
  1160. else
  1161. {
  1162. self.think = self.extramove_oldthink;
  1163. }
  1164. self.extramove_lastframewasextra = TRUE;
  1165. self.nextthink = (time + 0.1);
  1166. };
  1167.  
  1168. void () ExtraMoveToGoalFrameThink =
  1169. {
  1170.  
  1171. movetogoal (self.extramove_dist);
  1172. if (self.extramove_lastframewasextra)
  1173. {
  1174. self.think = BotAnimationThink;
  1175. }
  1176. else
  1177. {
  1178. self.think = self.extramove_oldthink;
  1179. }
  1180. self.extramove_lastframewasextra = TRUE;
  1181. self.nextthink = (time + 0.15);
  1182. };
  1183.  
  1184. float (float yaw, float dist) BotWalkMove =
  1185. {
  1186.  
  1187. if ((self.pattern == 1))
  1188. {
  1189. self.nextthink = (time + 0.1);
  1190. return (walkmove (yaw, self.extramove_dist));
  1191. }
  1192. else
  1193. {
  1194. self.extramove_yaw = yaw;
  1195. self.extramove_dist = (dist / SPAWNFLAG_LASER);
  1196. self.think = ExtraWalkMoveFrameThink;
  1197. self.nextthink = (time + 0.05);
  1198. return (walkmove (yaw, self.extramove_dist));
  1199. }
  1200. };
  1201.  
  1202. void (float dist) BotMoveToGoal =
  1203. {
  1204.  
  1205. if ((self.pattern == 1))
  1206. {
  1207. self.nextthink = (time + 0.1);
  1208. self.ideal_yaw = vectoyaw ((self.goalentity.origin - self.origin));
  1209. ChangeYaw ();
  1210. if (!EntityInFieldOfView (self.goalentity))
  1211. {
  1212. wall_look ();
  1213. }
  1214. if ((self.watertype == CONTENT_WATER))
  1215. {
  1216. self.speed = 175;
  1217. }
  1218. if ((self.watertype == CONTENT_SLIME))
  1219. {
  1220. self.speed = 100;
  1221. }
  1222. if ((self.watertype == CONTENT_LAVA))
  1223. {
  1224. self.speed = 20;
  1225. }
  1226. if ((self.bot_plan == BOT_ATTACK))
  1227. {
  1228. self.speed = (floor (((random () * 6) + 1)) * 100);
  1229. }
  1230. else
  1231. {
  1232. self.speed = 450;
  1233. }
  1234. norse_movetogoal (TRUE);
  1235. }
  1236. else
  1237. {
  1238. self.ideal_yaw = vectoyaw ((self.movement));
  1239. self.extramove_dist = (dist / SPAWNFLAG_LASER);
  1240.  
  1241.  
  1242. self.think = ExtraMoveToGoalFrameThink;
  1243. self.nextthink = (time + 0.05);
  1244. movetogoal (self.extramove_dist);
  1245. }
  1246. };
  1247.  
  1248. float (vector desired_velocity) GetMoveDist =
  1249. {
  1250. local float dist;
  1251. local float dp;
  1252. local vector des_vel;
  1253.  
  1254. if ((desired_velocity == VEC_ORIGIN))
  1255. {
  1256. makevectors (self.angles);
  1257. des_vel = normalize (v_forward);
  1258. }
  1259. else
  1260. {
  1261. des_vel = normalize (desired_velocity);
  1262. }
  1263. self.current_velocity = normalize (self.current_velocity);
  1264. dp = (self.current_velocity * des_vel);
  1265. self.current_velocity = des_vel;
  1266. if ((dp < 0))
  1267. {
  1268. dp = 0;
  1269. }
  1270. dist = (SECRET_NEVER * dp);
  1271. if ((self.waterlevel == 3))
  1272. {
  1273. dist = (dist / SPAWNFLAG_LASER);
  1274. }
  1275.  
  1276. return (dist);
  1277. };
  1278.  
  1279. void () MoveBot =
  1280. {
  1281. local float dist;
  1282. local vector vec;
  1283. local vector oldorg;
  1284. local vector vec2;
  1285. local float stepup;
  1286. self.bot_action = BOT_MOVING;
  1287. if (!(self.flags & FL_ONGROUND))
  1288. return;
  1289. self.v_angle = normalize(self.goalentity.origin - self.origin);
  1290. self.v_angle_z = 0; // let the engine handle roll with physics
  1291.  
  1292. dist = GetMoveDist ((self.goalentity.origin - self.origin));
  1293. movedist = dist;
  1294.  
  1295. if (BotShouldJump ())
  1296. {
  1297. BotJump ();
  1298. }
  1299. else
  1300. {
  1301. if (!smooth_move)
  1302. {
  1303. oldorg = self.origin;
  1304.  
  1305. BotMoveToGoal (dist);
  1306. self.bot_blocked = FALSE;
  1307. if (((self.origin == oldorg) && (dist != 0)))
  1308. {
  1309. self.bot_blocked = TRUE;
  1310. }
  1311. }
  1312. else
  1313. {
  1314. self.flags = (self.flags | FL_JUMPRELEASED);
  1315. self.flags = (self.flags - (self.flags & FL_ONGROUND));
  1316. if (!norse_checkgap (self))
  1317. {
  1318. vec2 = self.origin;
  1319. stepup = StepUpZ ();
  1320. vec2_z = (vec2_z + stepup);
  1321. setorigin (self, vec2);
  1322. vec = (self.goalentity.origin - self.origin);
  1323. vec_z = stepup;
  1324. vec = normalize (vec);
  1325.  
  1326. if ((self.goalentity != self))
  1327. {
  1328. self.movement_x = vec_x;
  1329. self.movement_y = vec_y;
  1330. //self.movement = self.velocity;
  1331. }
  1332. else
  1333. {
  1334. makevectors (self.angles);
  1335. self.movement_x = vec_x;
  1336. self.movement_y = vec_y;
  1337. //self.movement = self.velocity;
  1338. //self.velocity = (v_forward * 640);
  1339. }
  1340. }
  1341. }
  1342. }
  1343. };
  1344.  
  1345. float () MaybeFightFlagCarrier =
  1346. {
  1347. local entity p;
  1348. local float x;
  1349.  
  1350. if ((random () < self.bsk_skill_lin3))
  1351. {
  1352. if ((self.team == TEAM_COLOR1))
  1353. {
  1354. p = find (world, classname, "item_flag_team1");
  1355. }
  1356. else
  1357. {
  1358. if ((self.team == TEAM_COLOR2))
  1359. {
  1360. p = find (world, classname, "item_flag_team2");
  1361. }
  1362. }
  1363. if ((p.cnt == FLAG_CARRIED))
  1364. {
  1365. if ((p.owner != world))
  1366. {
  1367. if (((p.owner.classname == "player") || (p.owner.classname == "bot")))
  1368. {
  1369. if ((p.owner != self.enemy))
  1370. {
  1371. if (((p.owner.health > 0) && (p.owner != self)))
  1372. {
  1373. if (EntityInFieldOfView (p.owner))
  1374. {
  1375. if (BotCanSeePlayer (p.owner))
  1376. {
  1377. if (CanSeeInvisibleEntity (self, p.owner, trace_plane_dist))
  1378. {
  1379. if (!(p.owner.observer_flags & PLAYER_NO_TARGET))
  1380. {
  1381. if (!p.owner.observer)
  1382. {
  1383. if ((trace_plane_dist < 1500))
  1384. {
  1385. self.goalentity = p.owner;
  1386. self.movetarget = p.owner;
  1387. self.enemy = p.owner;
  1388. self.suspicious_about = p.owner.origin;
  1389. self.suspicious_about_time = (time - 5);
  1390. self.repeat = -1;
  1391. self.enemy_notice_time = (time - 999);
  1392. fBotSayTeam (": ENGAGING EMEMY CARRIER!!!\n");
  1393.  
  1394. x = random ();
  1395. if ((x < 0.33))
  1396. {
  1397. sound (self, CHAN_AUTO, "enforcer/sight2.wav", 1, ATTN_NORM);
  1398. }
  1399. else
  1400. {
  1401. if ((x < 0.66))
  1402. {
  1403. sound (self, CHAN_AUTO, "enforcer/sight1.wav", 1, ATTN_NORM);
  1404. }
  1405. else
  1406. {
  1407. if ((x > 0.66))
  1408. {
  1409. sound (self, CHAN_AUTO, "enforcer/sight3.wav", 1, ATTN_NORM);
  1410. }
  1411. }
  1412. }
  1413. powerup ();
  1414. self.bot_action = BOT_FIGHTING;
  1415. return (TRUE);
  1416. }
  1417. }
  1418. }
  1419. }
  1420. }
  1421. }
  1422. }
  1423. }
  1424. }
  1425. }
  1426. }
  1427. }
  1428. return (FALSE);
  1429. };
  1430.  
  1431. float () MaybeFight =
  1432. {
  1433. local entity en;
  1434.  
  1435. en = FindNearbyEnemy ();
  1436. if (((en.owner.team != self.team) || !en.team))
  1437. {
  1438. if ((((en.health < 1) || (en.health > 300)) || !en.team))
  1439. {
  1440. return (FALSE);
  1441. }
  1442. if ((self.health > 5))
  1443. {
  1444. self.goalentity = en;
  1445. self.movetarget = en;
  1446. }
  1447. self.enemy = en;
  1448. self.suspicious_about = en.origin;
  1449. self.suspicious_about_time = time;
  1450. self.enemy_notice_time = time;
  1451. self.bot_action = BOT_FIGHTING;
  1452. return (TRUE);
  1453. }
  1454. return (FALSE);
  1455. };
  1456.  
  1457. void () StopFighting =
  1458. {
  1459. if ((self.bot_action == BOT_FIGHTING))
  1460. {
  1461. self.bot_action = BOT_MOVING;
  1462. }
  1463. self.think = BotAnimationThink;
  1464. self.extramove_oldthink = BotAnimationThink;
  1465. self.button0 = FALSE;
  1466. self.button1 = FALSE;
  1467. self.angles_x = 0;
  1468. if (((self.goalentity.classname == "player") || (self.goalentity.classname == "bot")))
  1469. {
  1470. if ((self.goalentity.team != self.team))
  1471. {
  1472. self.goalentity = self;
  1473. self.movetarget = self;
  1474. }
  1475. }
  1476. self.enemy = world;
  1477. };
  1478.  
  1479. void () ContinueFighting =
  1480. {
  1481. if (((((random () * 3) < self.bot_skill) && (self.flags & FL_ONGROUND)) && (self.health < 50)))
  1482. {
  1483. if (((self.frame < 52) || (self.frame >= 62)))
  1484. {
  1485. if ((random () < 0.5))
  1486. {
  1487. self.frame = 52;
  1488. }
  1489. else
  1490. {
  1491. self.frame = 61;
  1492. }
  1493. }
  1494. if ((self.health > 25))
  1495. {
  1496. self.frame = (self.frame + 1);
  1497. }
  1498. else
  1499. {
  1500. self.frame = (self.frame - 1);
  1501. }
  1502. if ((self.health < SVC_SELLSCREEN))
  1503. {
  1504. self.nextjump = 10;
  1505. self.swing = random ();
  1506. if ((random () < 0.5))
  1507. {
  1508. BotFireHookUpRandomly ((vlen ((self.origin - self.enemy.origin)) * 0.5));
  1509. }
  1510. else
  1511. {
  1512. BotFireHookUpRandomly ((vectoyaw ((self.enemy.origin - self.origin)) * 1.5));
  1513. }
  1514. }
  1515. }
  1516. if ((random () < self.bsk_move_while_firing))
  1517. {
  1518. if ((random () < 0.7))
  1519. {
  1520. MoveWhileFiring ();
  1521. }
  1522. else
  1523. {
  1524. BotEvade (world);
  1525. }
  1526. }
  1527. BotLeadTarget (FALSE);
  1528. if (((self.enemy.team == self.team) && (time > self.enemy.invisible_finished)))
  1529. {
  1530. StopFighting ();
  1531. }
  1532. else
  1533. {
  1534. if ((time > self.attack_finished))
  1535. {
  1536. Bot_BestWeapon ();
  1537. if ((temp1 & TEMP1_MULTI))
  1538. {
  1539. set_player_weapon ();
  1540. }
  1541. self.lastweapon_shot = self.weapon;
  1542. BotFireWeapon (FALSE);
  1543. }
  1544. }
  1545. };
  1546.  
  1547. void () MoveWhileFiring =
  1548. {
  1549. local float dist;
  1550. local float r;
  1551. local float rad;
  1552. local float moved;
  1553. local entity item;
  1554. local entity e;
  1555. local float chance;
  1556.  
  1557. self.extramove_oldthink = self.think;
  1558. self.extramove_lastframewasextra = FALSE;
  1559. moved = FALSE;
  1560. BotLeadTarget (FALSE);
  1561. if ((self.player_flag & ITEM_ENEMY_FLAG))
  1562. {
  1563. if ((self.team == TEAM_COLOR1))
  1564. {
  1565. e = find (world, classname, "item_flag_team1");
  1566. }
  1567. if ((self.team == TEAM_COLOR2))
  1568. {
  1569. e = find (world, classname, "item_flag_team2");
  1570. }
  1571. if ((e.cnt == 0))
  1572. {
  1573. if ((vlen ((self.origin - e.origin)) < 35))
  1574. {
  1575. self.angles_y = vectoyaw ((e.origin - self.origin));
  1576. if (EntityInFieldOfView (e))
  1577. {
  1578. self.goalentity = e;
  1579. BotMoveTowardTarget ();
  1580. }
  1581. }
  1582. }
  1583. }
  1584. if (!moved)
  1585. {
  1586. if ((random () < self.bsk_move_while_firing))
  1587. {
  1588. rad = 250;
  1589. if ((random () < 0.01))
  1590. {
  1591. rad = (rad + 200);
  1592. }
  1593. dist = rad;
  1594. item = FindNearbyItem (dist);
  1595. if ((((item.origin_z - self.origin_z) > 30) || ((item.origin_z - self.origin_z) < -30)))
  1596. {
  1597. item = world;
  1598. }
  1599. if ((random () < 0.02))
  1600. {
  1601. item = world;
  1602. }
  1603. if ((((item.classname == "mine") || (item.classname == "grenade")) || (item.classname == "missile")))
  1604. {
  1605. if (((item.owner == self) || (item.owner.team != self.team)))
  1606. {
  1607. BotEvade (item);
  1608. }
  1609. }
  1610. if (((item != world) || (item.classname == "light_torch_small_walltorch")))
  1611. BotEvade (item);
  1612. else
  1613. {
  1614. self.goalentity = self.enemy;
  1615. self.movetarget = self.enemy;
  1616. dist = vlen ((self.enemy.origin - self.origin));
  1617. if ((dist > 100))
  1618. {
  1619. if ((self.enemy.player_flag & ITEM_ENEMY_FLAG))
  1620. {
  1621. chance = 0.95;
  1622. }
  1623. else
  1624. {
  1625. chance = 0.8;
  1626. }
  1627. }
  1628. else
  1629. {
  1630. chance = 0.7;
  1631. }
  1632. if ((random () < chance))
  1633. {
  1634. BotMoveTowardTarget ();
  1635. }
  1636. else
  1637. {
  1638. BotEvade (world);
  1639. }
  1640. }
  1641. }
  1642. }
  1643. };
  1644.  
  1645. void () MaybeChangeYaw =
  1646. {
  1647. local float r;
  1648.  
  1649. r = random ();
  1650. makevectors (self.angles);
  1651. traceline ((self.origin + '0 0 22'), ((self.origin + '0 0 22') + (v_forward * 40)), FALSE, self);
  1652. if (((trace_fraction < 1) || (random () < 0.3)))
  1653. {
  1654. if ((r < 0.1))
  1655. {
  1656. self.ideal_yaw = ((self.ideal_yaw + 30) + (((random () * SPAWNFLAG_LASER) - 1) * 50));
  1657. if ((self.ideal_yaw > 360))
  1658. {
  1659. self.ideal_yaw = (self.ideal_yaw - 360);
  1660. }
  1661. if ((self.ideal_yaw < 0))
  1662. {
  1663. self.ideal_yaw = (360 + self.ideal_yaw);
  1664. }
  1665. ChangeYaw ();
  1666. }
  1667. else
  1668. {
  1669. if ((r < LMQUOTA_ARMOR))
  1670. {
  1671. self.ideal_yaw = (self.ideal_yaw + (((random () * SPAWNFLAG_LASER) - 1) * 10));
  1672. if ((self.ideal_yaw > 360))
  1673. {
  1674. self.ideal_yaw = (self.ideal_yaw - 360);
  1675. }
  1676. if ((self.ideal_yaw < 0))
  1677. {
  1678. self.ideal_yaw = (360 + self.ideal_yaw);
  1679. }
  1680. ChangeYaw ();
  1681. }
  1682. }
  1683. }
  1684. };
  1685.  
  1686. entity (vector org) SpawnTempDebugMarker2 =
  1687. {
  1688. local entity e;
  1689.  
  1690. e = spawn ();
  1691. e.classname = "debug_marker";
  1692. e.owner = self;
  1693. e.origin = org;
  1694. setorigin (e, org);
  1695. e.solid = SOLID_NOT;
  1696. e.movetype = MOVETYPE_NONE;
  1697. setmodel (e, "progs/s_bubble.spr");
  1698. setsize (e, VEC_ORIGIN, VEC_ORIGIN);
  1699. e.nextthink = (time + 0.3);
  1700. e.think = SUB_Remove;
  1701. return (e);
  1702. };
  1703.  
  1704. void (float perfect_accuracy) BotLeadTarget =
  1705. {
  1706. local vector move;
  1707. local vector vlead;
  1708. local vector evec;
  1709. local vector d;
  1710. local vector org;
  1711. local vector eorg;
  1712. local vector err1;
  1713. local vector err2;
  1714. local vector face_vec;
  1715. local vector ang;
  1716. local float fly;
  1717. local float rng;
  1718. local float misjudge_position;
  1719. local float onground;
  1720. local float e;
  1721. local float ez;
  1722.  
  1723. if (((self.enemy.classname == "player") || (self.enemy.classname == "bot")))
  1724. {
  1725. eorg = (self.enemy.origin + '0 0 16');
  1726. evec = self.enemy.velocity;
  1727. if (!(self.enemy.flags & FL_ONGROUND))
  1728. {
  1729. onground = FALSE;
  1730. }
  1731. }
  1732. else
  1733. {
  1734. eorg = (self.enemy.absmax + self.enemy.absmin);
  1735. eorg_x = (eorg_x / SPAWNFLAG_LASER);
  1736. eorg_y = (eorg_y / SPAWNFLAG_LASER);
  1737. eorg_z = (eorg_z / SPAWNFLAG_LASER);
  1738. evec = VEC_ORIGIN;
  1739. }
  1740. org = (self.origin + '0 0 16');
  1741. face_vec = normalize (((eorg + '0 0 8') - org));
  1742. rng = vlen ((org - eorg));
  1743. if (((self.weapon == IT_SHOTGUN) || (self.weapon == IT_SUPER_SHOTGUN)))
  1744. {
  1745. e = 20;
  1746. if (onground)
  1747. {
  1748. ez = 20;
  1749. }
  1750. else
  1751. {
  1752. ez = 50;
  1753. }
  1754. }
  1755. else
  1756. {
  1757. e = 5;
  1758. if (onground)
  1759. {
  1760. ez = 20;
  1761. }
  1762. else
  1763. {
  1764. ez = 50;
  1765. }
  1766. }
  1767. if (!perfect_accuracy)
  1768. {
  1769. err1_x = ((self.bot_skill_inverse * (rng * 0.005)) * (((random () * SPAWNFLAG_LASER) - 1) * e));
  1770. err1_y = ((self.bot_skill_inverse * (rng * 0.005)) * (((random () * SPAWNFLAG_LASER) - 1) * e));
  1771. err1_z = ((self.bot_skill_inverse * (rng * 0.005)) * (((random () * SPAWNFLAG_LASER) - 1) * ez));
  1772. eorg_x = (eorg_x + err1_x);
  1773. eorg_y = (eorg_y + err1_y);
  1774. eorg_z = (eorg_z + err1_z);
  1775. }
  1776. if (!perfect_accuracy)
  1777. {
  1778. err2_x = (self.bot_skill_inverse * (((random () * SPAWNFLAG_LASER) - 1) * (evec_x * 1)));
  1779. err2_y = (self.bot_skill_inverse * (((random () * SPAWNFLAG_LASER) - 1) * (evec_y * 1)));
  1780. err2_z = (self.bot_skill_inverse * (((random () * SPAWNFLAG_LASER) - 1) * (evec_z * SPAWNFLAG_LASER)));
  1781. evec_x = (evec_x + err2_x);
  1782. evec_y = (evec_y + err2_y);
  1783. evec_z = (evec_z + err2_z);
  1784. }
  1785. if (((self.weapon == IT_NAILGUN) || (self.weapon == IT_SUPER_NAILGUN)))
  1786. {
  1787. if ((self.player_flag & ITEM_RUNE3_FLAG))
  1788. {
  1789. fly = (vlen ((eorg - org)) / 2000);
  1790. }
  1791. else
  1792. {
  1793. fly = (vlen ((eorg - org)) / 1000);
  1794. }
  1795. }
  1796. else
  1797. {
  1798. if ((self.weapon == IT_ROCKET_LAUNCHER))
  1799. {
  1800. fly = (vlen ((eorg - org)) / 1000);
  1801. }
  1802. else
  1803. {
  1804. if ((self.weapon == IT_GRENADE_LAUNCHER))
  1805. {
  1806. fly = (vlen ((eorg - org)) / 600);
  1807. }
  1808. else
  1809. {
  1810. fly = 0;
  1811. }
  1812. }
  1813. }
  1814. d = (eorg + (fly * evec));
  1815. if ((bot_debug >= 1))
  1816. {
  1817. SpawnTempDebugMarker2 (d);
  1818. }
  1819. vlead = normalize ((d - org));
  1820. self.bot_aim = vlead;
  1821. ang = vectoangles (face_vec);
  1822. ang_x = (ang_x / 3);
  1823. if ((face_vec_z < 0))
  1824. {
  1825. ang_x = (ang_x * -1);
  1826. }
  1827. if ((ang_x < -26.2))
  1828. {
  1829. ang_x = -26.2;
  1830. }
  1831. if ((ang_x > SVC_TEMPENTITY))
  1832. {
  1833. ang_x = SVC_TEMPENTITY;
  1834. }
  1835. self.angles = ang;
  1836. };
  1837.  
  1838. void (float perfect_accuracy) BotFireWeapon =
  1839. {
  1840. if (!W_CheckNoAmmo ()) return;
  1841.  
  1842. BotLeadTarget (perfect_accuracy);
  1843. self.v_angle = self.angles;
  1844. self.button0 = TRUE;
  1845. if ((self.player_flag & ITEM_ENEMY_FLAG))
  1846. {
  1847. fBotSayTeam (": Need Escort To Base!!!\n");
  1848.  
  1849. powerup ();
  1850. }
  1851. Bot_WeaponFrame ();
  1852. if (self.hooked_on_someone) self.button0 = TRUE;
  1853.  
  1854. };
  1855.  
  1856. void () BotMoveTowardTarget =
  1857. {
  1858. if ((self.enemy == world))
  1859. {
  1860. return;
  1861. }
  1862. BotLeadTarget (FALSE);
  1863. MoveBot ();
  1864. };
  1865.  
  1866. void () DropDown =
  1867. {
  1868. local float r;
  1869.  
  1870. traceline (self.origin, (self.origin + '0 0 -1000'), TRUE, self);
  1871. if ((trace_inopen && trace_inwater))
  1872. {
  1873. if (((pointcontents (trace_endpos) == CONTENT_LAVA) || (pointcontents (trace_endpos) == CONTENT_SLIME)))
  1874. {
  1875. self.bot_blocked = TRUE;
  1876. if ((random () < 0.7))
  1877. {
  1878. r = random ();
  1879. self.angles_y = (self.angles_y + (r * 10));
  1880. }
  1881. else
  1882. {
  1883. self.fire_hook_immediately = TRUE;
  1884. }
  1885. }
  1886. }
  1887. self.button0 = FALSE;
  1888. };
  1889.  
  1890. void (float change_yaw) BotMoveTowardGoal =
  1891. {
  1892. local float should_fire_hook;
  1893. local float chance;
  1894. local vector vyaw;
  1895. local vector goalorg;
  1896. local vector pos;
  1897.  
  1898. should_fire_hook = FALSE;
  1899. if (((self.goalentity != self) && hook_use_enabled))
  1900. {
  1901. chance = 0;
  1902. if (((self.goalentity.origin_z - self.origin_z) > 30))
  1903. {
  1904. chance = 0.04;
  1905. }
  1906. else
  1907. {
  1908. if (((self.goalentity.origin_z - self.origin_z) < -30))
  1909. {
  1910. chance = 0.04;
  1911. }
  1912. else
  1913. {
  1914. if ((vlen ((self.goalentity.origin - self.origin)) > 700))
  1915. {
  1916. chance = 0.04;
  1917. }
  1918. else
  1919. {
  1920. if ((self.get_item_stuck_count > 3))
  1921. {
  1922. chance = 0.04;
  1923. }
  1924. else
  1925. {
  1926. chance = 0.008;
  1927. }
  1928. }
  1929. }
  1930. }
  1931. if ((self.goalentity.classname == "player"))
  1932. {
  1933. chance = 0.1;
  1934. }
  1935. else
  1936. {
  1937. if ((vlen (self.goalentity.velocity) != 0))
  1938. {
  1939. chance = 0.000100;
  1940. }
  1941. }
  1942. if ((self.bot_action == BOT_FIGHTING))
  1943. {
  1944. chance = 0.01;
  1945. }
  1946. if ((random () < chance))
  1947. {
  1948. should_fire_hook = TRUE;
  1949. }
  1950. }
  1951. if (!should_fire_hook)
  1952. {
  1953. if ((self.goalentity != self))
  1954. {
  1955. vyaw = (self.goalentity.origin - self.origin);
  1956. vyaw_z = 0;
  1957. vyaw = normalize (vyaw);
  1958. }
  1959. MoveBot ();
  1960. }
  1961. else
  1962. {
  1963. if ((self.goalentity != self))
  1964. {
  1965. vyaw = (self.goalentity.origin - self.origin);
  1966. vyaw_z = 0;
  1967. vyaw = normalize (vyaw);
  1968. if ((self.goalentity.classname == "player"))
  1969. {
  1970. chance = 0.9;
  1971. }
  1972. if ((self.goalentity.classname == "bot"))
  1973. {
  1974. chance = 0.3;
  1975. }
  1976. else
  1977. {
  1978. chance = 0.1;
  1979. }
  1980. traceline (self.goalentity.origin, (self.goalentity.origin + '0 0 50000'), TRUE, self);
  1981. if ((pointcontents (trace_endpos) == CONTENT_SKY))
  1982. {
  1983. chance = 1;
  1984. }
  1985. if ((random () < chance))
  1986. {
  1987. goalorg = self.goalentity.origin;
  1988. MoveDebugMarker (goalorg);
  1989. self.bot_aim = (goalorg - (self.origin + '0 0 16'));
  1990. self.bot_aim = normalize (self.bot_aim);
  1991. }
  1992. else
  1993. {
  1994. traceline (self.goalentity.origin, (self.goalentity.origin + '0 0 50000'), TRUE, self);
  1995. if (TRUE)
  1996. {
  1997. pos = trace_endpos;
  1998. traceline ((self.origin + '0 0 16'), pos, TRUE, self);
  1999. if ((trace_fraction == 1))
  2000. {
  2001. MoveDebugMarker (pos);
  2002. self.bot_aim = (pos - (self.origin + '0 0 16'));
  2003. self.bot_aim = normalize (self.bot_aim);
  2004. }
  2005. else
  2006. {
  2007. if ((random () < 0.7))
  2008. {
  2009. goalorg = self.goalentity.origin;
  2010. goalorg_x = (goalorg_x + (((random () * SPAWNFLAG_LASER) - 1) * 5));
  2011. goalorg_y = (goalorg_y + (((random () * SPAWNFLAG_LASER) - 1) * 5));
  2012. goalorg_z = (goalorg_z + (((random () * SPAWNFLAG_LASER) - 1) * 5));
  2013. MoveDebugMarker (goalorg);
  2014. self.bot_aim = (goalorg - (self.origin + '0 0 16'));
  2015. self.bot_aim = normalize (self.bot_aim);
  2016. }
  2017. }
  2018. }
  2019. }
  2020. PlayerJump ();
  2021. BotFireHook ();
  2022. }
  2023. }
  2024. };
  2025.  
  2026. void (entity combat_item) BotEvade =
  2027. {
  2028. local float dist;
  2029. local float r;
  2030. local float evade_yaw;
  2031. local float move_blocked;
  2032. local vector targorigin;
  2033. local float oldlefty;
  2034.  
  2035. r = random ();
  2036. if (TRUE)
  2037. {
  2038. if (!smooth_move)
  2039. {
  2040. if ((combat_item != world))
  2041. {
  2042. self.current_evade_yaw = vectoyaw ((combat_item.origin - self.origin));
  2043. targorigin = combat_item.origin;
  2044. }
  2045. else
  2046. {
  2047. self.current_evade_yaw = vectoyaw ((self.enemy.origin - self.origin));
  2048. if ((random () < 0.03))
  2049. {
  2050. self.lefty = !self.lefty;
  2051. }
  2052. else
  2053. {
  2054. if ((random () < 0.01))
  2055. {
  2056. oldlefty = self.lefty;
  2057. self.lefty = 3;
  2058. }
  2059. }
  2060. if ((self.lefty == 3))
  2061. {
  2062. self.current_evade_yaw = (self.current_evade_yaw + 180);
  2063. self.lefty = oldlefty;
  2064. }
  2065. else
  2066. {
  2067. if (self.lefty)
  2068. {
  2069. self.current_evade_yaw = (self.current_evade_yaw + 90);
  2070. }
  2071. else
  2072. {
  2073. self.current_evade_yaw = (self.current_evade_yaw - 90);
  2074. }
  2075. }
  2076. self.current_evade_yaw = (self.current_evade_yaw + (((random () * SPAWNFLAG_LASER) - 1) * 10));
  2077. targorigin = self.goalentity.origin;
  2078. }
  2079. if ((self.current_evade_yaw < 0))
  2080. {
  2081. self.current_evade_yaw = (self.current_evade_yaw + 360);
  2082. }
  2083. if ((self.current_evade_yaw >= 360))
  2084. {
  2085. self.current_evade_yaw = (self.current_evade_yaw - 360);
  2086. }
  2087. dist = GetMoveDist ((targorigin - self.origin));
  2088. move_blocked = !BotWalkMove (self.current_evade_yaw, dist);
  2089. if (move_blocked)
  2090. {
  2091. self.lefty = !self.lefty;
  2092. }
  2093. }
  2094. else
  2095. {
  2096. makevectors (self.angles);
  2097. self.velocity = (self.velocity + (normalize (v_right) * 640));
  2098. }
  2099. }
  2100. };
  2101.  
  2102. void () SetBotWaterLevel =
  2103. {
  2104. local vector start;
  2105. local vector end;
  2106. local float wlevel;
  2107. local float wtype;
  2108. local float fc;
  2109. local float wc;
  2110. local float ec;
  2111.  
  2112. wlevel = 0;
  2113. wtype = -1;
  2114. fc = pointcontents ((self.origin + '0 0 -23'));
  2115. wc = pointcontents ((self.origin + '0 0 4'));
  2116. ec = pointcontents ((self.origin + '0 0 22'));
  2117. if ((((fc != -1) || (wc != -1)) || (ec != -1)))
  2118. {
  2119. if ((((fc == CONTENT_WATER) || (wc == CONTENT_WATER)) || (ec == CONTENT_WATER)))
  2120. {
  2121. wlevel = 1;
  2122. wtype = CONTENT_WATER;
  2123. if ((wc == CONTENT_WATER))
  2124. {
  2125. wlevel = SPAWNFLAG_LASER;
  2126. }
  2127. if ((ec == CONTENT_WATER))
  2128. {
  2129. wlevel = 3;
  2130. }
  2131. }
  2132. else
  2133. {
  2134. if ((((fc == CONTENT_SLIME) || (wc == CONTENT_SLIME)) || (ec == CONTENT_SLIME)))
  2135. {
  2136. wlevel = 1;
  2137. wtype = CONTENT_SLIME;
  2138. if ((wc == CONTENT_SLIME))
  2139. {
  2140. wlevel = SPAWNFLAG_LASER;
  2141. }
  2142. if ((ec == CONTENT_SLIME))
  2143. {
  2144. wlevel = 3;
  2145. }
  2146. }
  2147. else
  2148. {
  2149. if ((((fc == CONTENT_LAVA) || (wc == CONTENT_LAVA)) || (ec == CONTENT_LAVA)))
  2150. {
  2151. wlevel = 1;
  2152. wtype = CONTENT_LAVA;
  2153. if ((wc == CONTENT_LAVA))
  2154. {
  2155. wlevel = SPAWNFLAG_LASER;
  2156. }
  2157. if ((ec == CONTENT_LAVA))
  2158. {
  2159. wlevel = 3;
  2160. }
  2161. }
  2162. }
  2163. }
  2164. }
  2165. self.waterlevel = wlevel;
  2166. self.watertype = wtype;
  2167. };
  2168.  
  2169. void () BotPreThink =
  2170. {
  2171. if (self.bot_type == "rbot")
  2172. return;
  2173. self.message = "PRETHINK";
  2174. CheckRules ();
  2175. SetBotWaterLevel ();
  2176. self.old_waterlevel = self.waterlevel;
  2177. self.old_watertype = self.watertype;
  2178. WaterMove ();
  2179. self.waterlevel = self.old_waterlevel;
  2180. self.watertype = self.old_watertype;
  2181. if ((self.health <= 0))
  2182. {
  2183. //self.think = PlayerDie;
  2184. }
  2185. else
  2186. {
  2187. if ((self.waterlevel == SPAWNFLAG_LASER))
  2188. {
  2189. CheckWaterJump ();
  2190. }
  2191. }
  2192. if (((self.nextthink < (time - 1)) && self.health)|| (self.nextthink > (time +1)) && self.health)
  2193.     self.nextthink = time + 0.2;
  2194. };
  2195.  
  2196. void () checkyaw =
  2197. {
  2198. local vector los;
  2199. local vector los_angles;
  2200. local float o_range;
  2201. local float missile_factor;
  2202. local vector spotty_squid;
  2203.  
  2204. o_range = vlen ((self.enemy.origin - self.origin));
  2205. if (self.weapon == IT_ROCKET_LAUNCHER || self.weapon == IT_NAILGUN || self.weapon == IT_SUPER_NAILGUN || self.weapon == IT_HOOK)
  2206. {
  2207. missile_factor = (o_range / (1900 + (random () * 700)));
  2208. }
  2209. else
  2210. {
  2211. if ((self.weapon == IT_GRENADE_LAUNCHER))
  2212. {
  2213. missile_factor = (o_range / (1000 + (random () * 50)));
  2214. }
  2215. else
  2216. {
  2217. missile_factor = 0;
  2218. }
  2219. }
  2220. if ((o_range > 300))
  2221. {
  2222. spotty_squid = ('9 9 8' * (random () - 0.5));
  2223. }
  2224. else spotty_squid = VEC_ORIGIN;
  2225. if (self.altweap)
  2226. spotty_squid = '15 15 15';
  2227. los = (((self.enemy.origin - self.origin) + (self.enemy.velocity * missile_factor)) + spotty_squid);
  2228. los_angles = vectoangles (los);
  2229. self.ideal_pitch = los_angles_x;
  2230. if ((self.ideal_pitch > 180))
  2231. {
  2232. self.ideal_pitch = (self.ideal_pitch - 360);
  2233. }
  2234. ChangePitch ();
  2235. };
  2236.  
  2237. void () BotPostThink =
  2238. {
  2239. self.message = "POSTTHINK";
  2240. if ((((self.jump_flag < -300) && (self.flags & FL_ONGROUND)) && (self.health > 0)))
  2241. {
  2242. if (((self.watertype == CONTENT_WATER) && (self.waterlevel < 1)))
  2243. {
  2244. if (((self.sex == SPAWNFLAG_LASER) && (temp1 & TEMP1_PLAYER2SOUNDS)))
  2245. {
  2246. sound (self, CHAN_BODY, "player_f/h2ojump.wav", 1, ATTN_NORM);
  2247. }
  2248. else
  2249. {
  2250. if (((self.sex == 3) && (temp1 & TEMP1_PLAYER3SOUNDS)))
  2251. {
  2252. sound (self, CHAN_BODY, "player3/h2ojump.wav", 1, ATTN_NORM);
  2253. }
  2254. else
  2255. {
  2256. if (((self.sex == 4) && (temp1 & TEMP1_PLAYER4SOUNDS)))
  2257. {
  2258. sound (self, CHAN_BODY, "player4/h2ojump.wav", 1, ATTN_NORM);
  2259. }
  2260. else
  2261. {
  2262. sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  2263. }
  2264. }
  2265. }
  2266. }
  2267. else
  2268. {
  2269. if ((self.jump_flag < -650))
  2270. {
  2271. if (!(deathmatch & DM_NO_FALLING))
  2272. {
  2273. T_Damage (self, world, world, 5);
  2274. }
  2275. if (((self.sex == SPAWNFLAG_LASER) && (temp1 & TEMP1_PLAYER2SOUNDS)))
  2276. {
  2277. sound (self, CHAN_VOICE, "player_f/land2.wav", 1, ATTN_NORM);
  2278. }
  2279. else
  2280. {
  2281. if (((self.sex == 3) && (temp1 & TEMP1_PLAYER3SOUNDS)))
  2282. {
  2283. sound (self, CHAN_VOICE, "player3/land2.wav", 1, ATTN_NORM);
  2284. }
  2285. else
  2286. {
  2287. if (((self.sex == 4) && (temp1 & TEMP1_PLAYER4SOUNDS)))
  2288. {
  2289. sound (self, CHAN_VOICE, "player4/land2.wav", 1, ATTN_NORM);
  2290. }
  2291. else
  2292. {
  2293. sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  2294. }
  2295. }
  2296. }
  2297. self.deathtype = "falling";
  2298. }
  2299. else
  2300. {
  2301. if (((self.sex == SPAWNFLAG_LASER) && (temp1 & TEMP1_PLAYER2SOUNDS)))
  2302. {
  2303. sound (self, CHAN_VOICE, "player_f/land.wav", 1, ATTN_NORM);
  2304. }
  2305. else
  2306. {
  2307. if (((self.sex == 3) && (temp1 & TEMP1_PLAYER3SOUNDS)))
  2308. {
  2309. sound (self, CHAN_VOICE, "player3/land.wav", 1, ATTN_NORM);
  2310. }
  2311. else
  2312. {
  2313. if (((self.sex == 4) && (temp1 & TEMP1_PLAYER4SOUNDS)))
  2314. {
  2315. sound (self, CHAN_VOICE, "player4/land.wav", 1, ATTN_NORM);
  2316. }
  2317. else
  2318. {
  2319. sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  2320. }
  2321. }
  2322. }
  2323. }
  2324. }
  2325. self.jump_flag = 0;
  2326. }
  2327. if (!(self.flags & FL_ONGROUND))
  2328. {
  2329. self.jump_flag = self.velocity_z;
  2330. }
  2331. CheckPowerups ();
  2332. if (((self.nextthink < (time - 1)) && self.health)|| (self.nextthink > (time +1)) && self.health)
  2333.     self.nextthink = time + 0.2;
  2334. };
  2335.  
  2336. float (float enemy_base, float change_yaw) MoveTowardBase =
  2337. {
  2338. local entity e;
  2339. local float team_lo;
  2340. local float team_hi;
  2341. local float fteam;
  2342.  
  2343. if ((time < self.next_waypoint_time))
  2344. {
  2345. return (FALSE);
  2346. }
  2347. self.next_waypoint_time = (time + 0.35);
  2348. if (enemy_base)
  2349. {
  2350. team_lo = self.enemy_team;
  2351. team_hi = self.team;
  2352. }
  2353. else
  2354. {
  2355. team_lo = self.team;
  2356. team_hi = self.enemy_team;
  2357. }
  2358. if ((self.goalentity.classname == "waypoint"))
  2359. {
  2360. if (!(((self.use_defensive_way == 1) && (self.bot_plan == BOT_DEFEND)) && (team_lo == self.team)))
  2361. {
  2362. if ((self.goalentity.team == team_lo))
  2363. {
  2364. if ((self.goalentity.waypoint_num == 0))
  2365. {
  2366. BotMoveTowardGoal (change_yaw);
  2367. return (TRUE);
  2368. }
  2369. }
  2370. }
  2371. if ((((self.use_defensive_way == 1) && (self.bot_plan == BOT_DEFEND)) && (team_lo == self.team)))
  2372. {
  2373. if ((self.goalentity.waypoint_num == -1))
  2374. {
  2375. BotMoveTowardGoal (change_yaw);
  2376. return (TRUE);
  2377. }
  2378. }
  2379. }
  2380. e = BotFindLeastWaypoint (team_lo);
  2381. if ((e != world))
  2382. {
  2383. self.goalentity = e;
  2384. self.movetarget = e;
  2385. self.enemy = world;
  2386. BotMoveTowardGoal (change_yaw);
  2387. return (TRUE);
  2388. }
  2389. else
  2390. {
  2391. e = BotFindGreatestWaypoint (team_hi);
  2392. if ((e != world))
  2393. {
  2394. self.goalentity = e;
  2395. self.movetarget = e;
  2396. self.enemy = world;
  2397. BotMoveTowardGoal (change_yaw);
  2398. return (TRUE);
  2399. }
  2400. else
  2401. {
  2402. e = BotFindLeastWaypoint (-1);
  2403. if ((e != world))
  2404. {
  2405. self.goalentity = e;
  2406. self.movetarget = e;
  2407. self.enemy = world;
  2408. BotMoveTowardGoal (change_yaw);
  2409. return (TRUE);
  2410. }
  2411. }
  2412. }
  2413. return (FALSE);
  2414. };
  2415.  
  2416. float (float fteam) NumBotsDefending =
  2417. {
  2418. local entity p;
  2419. local float nm;
  2420.  
  2421. nm = 0;
  2422. p = find (world, classname, "bot");
  2423. while ((p != world))
  2424. {
  2425. if ((p.team == fteam))
  2426. {
  2427. if ((p.bot_plan == BOT_DEFEND))
  2428. {
  2429. nm = (nm + 1);
  2430. }
  2431. }
  2432. p = find (p, classname, "bot");
  2433. }
  2434. return (nm);
  2435. };
  2436.  
  2437. float () MaybeGoToTempWaypoint =
  2438. {
  2439. local entity e;
  2440.  
  2441. e = BotFindClosestTempWaypoint (self.team);
  2442. if ((e != world))
  2443. {
  2444. self.goalentity = e;
  2445. self.movetarget = e;
  2446. self.enemy = world;
  2447. BotMoveTowardGoal (TRUE);
  2448. return (TRUE);
  2449. }
  2450. return (FALSE);
  2451. };
  2452.  
  2453. void () SetBotPlan =
  2454. {
  2455. local entity flag;
  2456. local entity eflag;
  2457. local float nm;
  2458. local float r;
  2459. local float oldplan;
  2460. local float numbots;
  2461. local entity f;
  2462. local entity e;
  2463.  
  2464. oldplan = self.bot_plan;
  2465. if ((time < (self.camping_time + CAMPING_TIME)))
  2466. return;
  2467.  
  2468. if ((time < (self.escort_time + ESCORT_TIME)))
  2469. return;
  2470.  
  2471. if ((time > qtr_3))
  2472. {
  2473. if (self.team == TEAM_COLOR2)
  2474.    {
  2475. f = find (world, classname, "item_flag_team2");
  2476. if (f.cnt == 0 && captures_red > captures_blue)
  2477. {
  2478. if (self.bot_action != BOT_FIGHTING && visible(f))
  2479. if (random() < 0.2)
  2480. fBotSayTeam (": Our Base is Clear, I'm attacking....\n");
  2481. else if (self.bot_action == BOT_FIGHTING && visible(f))
  2482. fBotSayTeam (": Base Defenses Compromised!!\n");
  2483. self.bot_plan = BOT_ATTACK;
  2484. }
  2485. if ((self.reserve > 0))
  2486. powerup ();
  2487. return;
  2488. }
  2489. }
  2490.  
  2491.  
  2492. if (self.team == TEAM_COLOR1)
  2493. {
  2494. f = find (world, classname, "item_flag_team1");
  2495. if ((f.cnt == 0 && captures_red < captures_blue))
  2496. {
  2497. if (self.bot_action != BOT_FIGHTING && visible(f))
  2498. if (random() < 0.2)
  2499. fBotSayTeam (": Our Base is Clear, I'm attacking....\n");
  2500. else if (self.bot_action == BOT_FIGHTING && visible(f))
  2501. fBotSayTeam (": Base Defenses Compromised!!\n");
  2502. self.bot_plan = BOT_ATTACK;
  2503. }
  2504. if ((self.reserve > 0))
  2505. powerup ();
  2506.  
  2507. return;
  2508. }
  2509.  
  2510.  
  2511.  
  2512. if ((time < qtr_1))
  2513. {
  2514. if ((time < (cvar ("timelimit") * 8)))
  2515. if (random() < 0.65)
  2516. {
  2517. self.bot_plan = BOT_ATTACK;
  2518. return;
  2519. }
  2520. if (self.team == TEAM_COLOR2)
  2521. {
  2522. e = find (world, classname, "item_flag_team2");
  2523. if ((e.cnt == 0 && captures_red > captures_blue))
  2524. {
  2525. if (self.bot_action != BOT_FIGHTING && visible(e))
  2526. if (random() < 0.2)
  2527. fBotSayTeam (": Our Base is Clear, I'm attacking....\n");
  2528. else if (self.bot_action == BOT_FIGHTING && visible(e))
  2529. fBotSayTeam (": Base Defenses Compromised!!\n");
  2530. self.bot_plan = BOT_ATTACK;
  2531. return;
  2532. }
  2533. else if (self.bot_plan == BOT_ATTACK)
  2534. {
  2535. if (((self.repeat > time) && (random () < 0.3)))
  2536. {
  2537. fBotSayTeam (": I'm On Defense Now, Heading to Base...\n");
  2538. self.bot_plan = BOT_DEFEND;
  2539. return;
  2540. }
  2541. else if (visible(e)&& e.cnt == 0 && self.bot_action != BOT_FIGHTING)
  2542. fBotSayTeam (": Base is Clear...\n");
  2543.  
  2544.  
  2545. return;
  2546. }
  2547. if (self.team == TEAM_COLOR1)
  2548. {
  2549. e = find (world, classname, "item_flag_team1");
  2550. if ((e.cnt == 0 && captures_red < captures_blue))
  2551. {
  2552. if (self.bot_action != BOT_FIGHTING && visible(e))
  2553. if (random() < 0.2)
  2554. fBotSayTeam (": Our Base is Clear, I'm attacking....\n");
  2555. else if (self.bot_action == BOT_FIGHTING && visible(e))
  2556. fBotSayTeam (": Base Defenses Compromised!!\n");
  2557. self.bot_plan = BOT_ATTACK;
  2558. return;
  2559. }
  2560. else if (self.bot_plan == BOT_ATTACK)
  2561. {
  2562. fBotSayTeam (": I'm On Defense Now, Heading to Base...\n");
  2563. self.bot_plan = BOT_DEFEND;
  2564. return;
  2565. }
  2566. else if (visible(e)&& e.cnt == 0 && self.bot_action != BOT_FIGHTING)
  2567. fBotSayTeam (": Base is Clear...\n");
  2568.  
  2569.  
  2570.  
  2571. return;
  2572. }
  2573. }
  2574. if (IsHumanOnTeam (self.team))
  2575. {
  2576. if ((random () < 0.9))
  2577. {
  2578. return;
  2579. }
  2580. }
  2581. if ((self.team == TEAM_COLOR1))
  2582. {
  2583. flag = find (world, classname, "item_flag_team1");
  2584. eflag = find (world, classname, "item_flag_team2");
  2585. numbots = next_bot_red;
  2586. }
  2587. else
  2588. {
  2589. if ((self.team == TEAM_COLOR2))
  2590. {
  2591. flag = find (world, classname, "item_flag_team2");
  2592. eflag = find (world, classname, "item_flag_team1");
  2593. numbots = next_bot_blue;
  2594. }
  2595. }
  2596. if ((self.bot_plan == BOT_ATTACK))
  2597. {
  2598. nm = NumBotsDefending (self.team);
  2599. if (((nm < (numbots / SPAWNFLAG_LASER)) && ((flag.cnt == 0) || (eflag.cnt == FLAG_CARRIED))))
  2600. {
  2601. if ((random () < 0.02))
  2602. {
  2603. self.bot_plan = BOT_DEFEND;
  2604. }
  2605. }
  2606. else
  2607. {
  2608. if ((self.player_flag & ITEM_RUNE3_FLAG))
  2609. {
  2610. if ((random () < 0.01))
  2611. {
  2612. self.bot_plan = BOT_DEFEND;
  2613. }
  2614. }
  2615. else
  2616. {
  2617. if ((self.player_flag & ITEM_RUNE4_FLAG))
  2618. {
  2619. if ((random () < 0.01))
  2620. {
  2621. self.bot_plan = BOT_DEFEND;
  2622. }
  2623. }
  2624. else
  2625. {
  2626. if ((random () < 0.001))
  2627. {
  2628. self.bot_plan = BOT_DEFEND;
  2629. }
  2630. else
  2631. {
  2632. if ((random () < 0.001))
  2633. {
  2634. self.bot_plan = BOT_ROAM;
  2635. }
  2636. }
  2637. }
  2638. }
  2639. }
  2640. }
  2641. else
  2642. {
  2643. if ((self.bot_plan == BOT_DEFEND))
  2644. {
  2645. if ((((time < self.super_damage_finished) || (time < self.invisible_finished)) || (time < self.invincible_finished)))
  2646. {
  2647. self.bot_plan = BOT_ATTACK;
  2648. }
  2649. else
  2650. {
  2651. if (((time < (last_flag_capture + 10)) && (self.team == last_capture_team)))
  2652. {
  2653. if ((random () < 0.02))
  2654. {
  2655. self.bot_plan = BOT_ATTACK;
  2656. }
  2657. }
  2658. else
  2659. {
  2660. if (((flag.cnt == FLAG_CARRIED) && (eflag.cnt == FLAG_CARRIED)))
  2661. {
  2662. if (!(self.player_flag & ITEM_ENEMY_FLAG))
  2663. {
  2664. if ((random () < 0.02))
  2665. {
  2666. self.bot_plan = BOT_ATTACK;
  2667. }
  2668. }
  2669. }
  2670. else
  2671. {
  2672. if ((self.player_flag & ITEM_RUNE1_FLAG))
  2673. {
  2674. if ((random () < 0.01))
  2675. {
  2676. self.bot_plan = BOT_ATTACK;
  2677. }
  2678. }
  2679. else
  2680. {
  2681. if ((self.player_flag & ITEM_RUNE2_FLAG))
  2682. {
  2683. if ((random () < 0.01))
  2684. {
  2685. self.bot_plan = BOT_ATTACK;
  2686. }
  2687. }
  2688. else
  2689. {
  2690. if ((random () < 0.001))
  2691. {
  2692. self.bot_plan = BOT_ATTACK;
  2693. }
  2694. else
  2695. {
  2696. if ((random () < 0.001))
  2697. {
  2698. self.bot_plan = BOT_ROAM;
  2699. }
  2700. }
  2701. }
  2702. }
  2703. }
  2704. }
  2705. }
  2706. }
  2707. else
  2708. {
  2709. nm = NumBotsDefending (self.team);
  2710. if ((((time < self.super_damage_finished) || (time < self.invisible_finished)) || (time < self.invincible_finished)))
  2711. {
  2712. self.bot_plan = BOT_ATTACK;
  2713. }
  2714. else
  2715. {
  2716. if (((nm < (numbots / SPAWNFLAG_LASER)) && ((flag.cnt == 0) || (eflag.cnt == FLAG_CARRIED))))
  2717. {
  2718. if ((random () < 0.02))
  2719. {
  2720. self.bot_plan = BOT_DEFEND;
  2721. }
  2722. }
  2723. else
  2724. {
  2725. if (((flag.cnt == FLAG_CARRIED) && (eflag.cnt == FLAG_CARRIED)))
  2726. {
  2727. if (!(self.player_flag & ITEM_ENEMY_FLAG))
  2728. {
  2729. if ((random () < 0.02))
  2730. {
  2731. self.bot_plan = BOT_ATTACK;
  2732. }
  2733. }
  2734. }
  2735. else
  2736. {
  2737. if (((time < (last_flag_capture + 10)) && (self.team == last_capture_team)))
  2738. {
  2739. if ((random () < 0.02))
  2740. {
  2741. self.bot_plan = BOT_ATTACK;
  2742. }
  2743. }
  2744. else
  2745. {
  2746. if ((random () < 0.001))
  2747. {
  2748. self.bot_plan = BOT_DEFEND;
  2749. }
  2750. else
  2751. {
  2752. if ((random () < 0.001))
  2753. {
  2754. self.bot_plan = BOT_ATTACK;
  2755. }
  2756. }
  2757. }
  2758. }
  2759. }
  2760. }
  2761. }
  2762. }
  2763. }
  2764. }
  2765. float () SetSpecialGoals =
  2766. {
  2767. local entity p;
  2768. local entity e;
  2769. local float maxrad;
  2770. local float moved;
  2771. local entity old_goal;
  2772.  
  2773. moved = FALSE;
  2774. if ((map_has_waypoints && (self.player_flag & ITEM_ENEMY_FLAG)))
  2775. {
  2776. moved = MoveTowardBase (0, TRUE);
  2777. }
  2778. if (!moved)
  2779. {
  2780. e = HelpTeammate (self, 600);
  2781. if ((e != world))
  2782. {
  2783. if ((e.classname == "follow_ent"))
  2784. {
  2785. old_goal = self.goalentity;
  2786. self.goalentity = e;
  2787. self.movetarget = e;
  2788. BotMoveTowardGoal (TRUE);
  2789. self.goalentity = old_goal;
  2790. self.movetarget = old_goal;
  2791. return (TRUE);
  2792. }
  2793. else
  2794. {
  2795. if ((vlen ((e.origin - self.origin)) > 150))
  2796. {
  2797. self.goalentity = e;
  2798. self.movetarget = e;
  2799. self.enemy = world;
  2800. if ((e.classname == "player"))
  2801. {
  2802. if (((self.escort_entity == e) || (e.observer_flags & PLAYER_ALWAYS_ESCORT)))
  2803. {
  2804. BotSayEscort (e);
  2805. }
  2806. }
  2807. BotMoveTowardGoal (TRUE);
  2808. return (TRUE);
  2809. }
  2810. }
  2811. }
  2812. else
  2813. {
  2814. if ((time < (self.camping_time + CAMPING_TIME)))
  2815. {
  2816. self.goalentity = self.camping_entity;
  2817. self.movetarget = self.camping_entity;
  2818. self.enemy = world;
  2819. BotMoveTowardGoal (TRUE);
  2820. return (TRUE);
  2821. }
  2822. else
  2823. {
  2824. if (map_has_waypoints)
  2825. {
  2826. SetBotPlan ();
  2827. if ((self.bot_plan == BOT_ATTACK))
  2828. {
  2829. moved = MoveTowardBase (ENEMY_BASE, TRUE);
  2830. }
  2831. if (!moved)
  2832. {
  2833. if ((self.bot_plan == BOT_DEFEND))
  2834. {
  2835. moved = MoveTowardBase (0, TRUE);
  2836. }
  2837. }
  2838. }
  2839. }
  2840. }
  2841. }
  2842. return (moved);
  2843. };
  2844.  
  2845. void (float old_dist, entity goal_item) CheckStuck =
  2846. {
  2847. if ((goal_item != world))
  2848. {
  2849. if (((old_dist - vlen ((self.origin - goal_item.origin))) < 5))
  2850. {
  2851. self.get_item_stuck_count = (self.get_item_stuck_count + 1);
  2852. if (((self.get_item_stuck_count > 10) && (num_inaccessible_entities < 5)))
  2853. {
  2854. self.get_item_stuck_count = 0;
  2855. SpawnInaccessibleFromHere (goal_item);
  2856. }
  2857. }
  2858. }
  2859. };
  2860.  
  2861. float () MaybeGetItems =
  2862. {
  2863. local entity item;
  2864. local float dist;
  2865. local float old_dist;
  2866.  
  2867. if ((time > self.large_dist_pulse_items))
  2868. {
  2869. self.large_dist_pulse_items = (time + self.bsk_next_pulse_time_items);
  2870. dist = item_large_pulse_dist;
  2871. if ((random () < 0.02))
  2872. {
  2873. dist = (dist + self.bsk_extra_large_pulse_dist);
  2874. }
  2875. }
  2876. else
  2877. {
  2878. dist = item_awareness_dist;
  2879. }
  2880. item = FindNearbyItem (dist);
  2881. if ((item != world))
  2882. {
  2883. if ((item != self.goalentity))
  2884. {
  2885. self.get_item_stuck_count = 0;
  2886. }
  2887.  
  2888. self.goalentity = item;
  2889. self.movetarget = item;
  2890. self.enemy = world;
  2891. old_dist = vlen ((self.origin - self.goalentity.origin));
  2892. BotMoveTowardGoal (TRUE);
  2893. CheckStuck (old_dist, self.goalentity);
  2894. return (TRUE);
  2895. }
  2896. return (FALSE);
  2897. };
  2898.  
  2899. float (float force_search) MaybeShootTriggers =
  2900. {
  2901. local entity selected;
  2902. local entity e;
  2903. local float dist;
  2904. local float best_dist;
  2905. local vector org;
  2906. local vector selected_org;
  2907. local entity old_enemy;
  2908.  
  2909. if (((time < self.trigger_search_time) && !force_search))
  2910. {
  2911. return (FALSE);
  2912. }
  2913. self.trigger_search_time = (time + (TE_WIZSPIKE * (random () * 5)));
  2914. dist = 150;
  2915. dist = (dist + 400);
  2916. best_dist = 1000000000;
  2917. e = find (world, classname, "door");
  2918. while (e)
  2919. {
  2920. org = (e.absmin + e.absmax);
  2921. org_x = (org_x / SPAWNFLAG_LASER);
  2922. org_y = (org_y / SPAWNFLAG_LASER);
  2923. org_z = (org_z / SPAWNFLAG_LASER);
  2924. if (BotCanSeePoint (org))
  2925. {
  2926. if ((vlen ((self.origin - org)) < best_dist))
  2927. {
  2928. if ((e.health > 0))
  2929. {
  2930. selected = e;
  2931. selected_org = org;
  2932. best_dist = vlen ((self.origin - org));
  2933. }
  2934. }
  2935. }
  2936. e = find (e, classname, "door");
  2937. }
  2938. if (((selected != world) && (random () < 0.8)))
  2939. {
  2940. best_dist = 1000000000;
  2941. e = find (world, classname, "func_button");
  2942. while (e)
  2943. {
  2944. org = e.origin;
  2945. if (BotCanSeePoint (org))
  2946. {
  2947. if ((vlen ((self.origin - org)) < best_dist))
  2948. {
  2949. if ((e.health > 0))
  2950. {
  2951. selected = e;
  2952. selected_org = org;
  2953. best_dist = vlen ((self.origin - org));
  2954. }
  2955. }
  2956. }
  2957. e = find (e, classname, "func_button");
  2958. }
  2959. }
  2960. if ((selected != world))
  2961. {
  2962. if ((random () < 0.5))
  2963. {
  2964. old_enemy = self.enemy;
  2965. self.enemy = selected;
  2966. if (((time > self.attack_finished) && (self.ammo_shells > 0)))
  2967. {
  2968. self.weapon = IT_SHOTGUN;
  2969. if ((temp1 & TEMP1_MULTI))
  2970. {
  2971. set_player_weapon ();
  2972. }
  2973. BotFireWeapon (TRUE);
  2974. if ((selected.classname == "door"))
  2975. {
  2976. SpawnTempWaypoint (selected_org, 5, self.team);
  2977. }
  2978. }
  2979. self.enemy = old_enemy;
  2980. return (TRUE);
  2981. }
  2982. }
  2983. return (FALSE);
  2984. };
  2985.  
  2986. float (entity newwp, entity oldwp) WaypointBetter =
  2987. {
  2988. if ((oldwp == world))
  2989. {
  2990. return (TRUE);
  2991. }
  2992. if ((oldwp.health > 1))
  2993. {
  2994. self.enemy = oldwp;
  2995. }
  2996. if ((newwp.health > 1))
  2997. {
  2998. self.enemy = newwp;
  2999. }
  3000. if ((newwp.path_1 || newwp.path_2))
  3001. {
  3002. dprint (self.netname);
  3003. dprint (" choosing path ");
  3004. if ((random () < 0.5))
  3005. {
  3006. //self.angles_y = oldwp.path_1;
  3007. }
  3008. else
  3009. {
  3010. //self.angles_y = oldwp.path_2;
  3011. }
  3012. }
  3013. if ((self.bot_plan == BOT_ATTACK))
  3014. {
  3015. if (((newwp.team == self.team) && (oldwp.team == self.team)))
  3016. {
  3017. if ((newwp.waypoint_num == oldwp.waypoint_num))
  3018. {
  3019. vlen ((newwp.origin - self.origin));
  3020. if ((vlen ((oldwp.origin - self.origin)) < vlen ((oldwp.origin - self.origin))))
  3021. {
  3022. return (TRUE);
  3023. }
  3024. }
  3025. else
  3026. {
  3027. if ((newwp.waypoint_num < oldwp.waypoint_num))
  3028. {
  3029. return (FALSE);
  3030. }
  3031. else
  3032. {
  3033. if ((newwp.waypoint_num > oldwp.waypoint_num))
  3034. {
  3035. return (TRUE);
  3036. }
  3037. }
  3038. }
  3039. }
  3040. else
  3041. {
  3042. if (((newwp.team == self.team) && (oldwp.team != self.team)))
  3043. {
  3044. return (FALSE);
  3045. }
  3046. else
  3047. {
  3048. if (((newwp.team != self.team) && (oldwp.team == self.team)))
  3049. {
  3050. return (TRUE);
  3051. }
  3052. else
  3053. {
  3054. if (((newwp.team != self.team) && (oldwp.team != self.team)))
  3055. {
  3056. if ((newwp.waypoint_num == oldwp.waypoint_num))
  3057. {
  3058. vlen ((newwp.origin - self.origin));
  3059. if ((vlen ((oldwp.origin - self.origin)) < vlen ((oldwp.origin - self.origin))))
  3060. {
  3061. return (TRUE);
  3062. }
  3063. }
  3064. else
  3065. {
  3066. if ((newwp.waypoint_num < oldwp.waypoint_num))
  3067. {
  3068. return (TRUE);
  3069. }
  3070. else
  3071. {
  3072. if ((newwp.waypoint_num > oldwp.waypoint_num))
  3073. {
  3074. return (FALSE);
  3075. }
  3076. }
  3077. }
  3078. }
  3079. }
  3080. }
  3081. }
  3082. }
  3083. else
  3084. {
  3085. if ((self.bot_plan == BOT_DEFEND))
  3086. {
  3087. if (((newwp.team == self.team) && (oldwp.team == self.team)))
  3088. {
  3089. if ((newwp.waypoint_num == oldwp.waypoint_num))
  3090. {
  3091. vlen ((newwp.origin - self.origin));
  3092. if ((vlen ((oldwp.origin - self.origin)) < vlen ((oldwp.origin - self.origin))))
  3093. {
  3094. return (TRUE);
  3095. }
  3096. }
  3097. else
  3098. {
  3099. if ((newwp.waypoint_num < oldwp.waypoint_num))
  3100. {
  3101. return (TRUE);
  3102. }
  3103. else
  3104. {
  3105. if ((newwp.waypoint_num > oldwp.waypoint_num))
  3106. {
  3107. return (FALSE);
  3108. }
  3109. }
  3110. }
  3111. }
  3112. else
  3113. {
  3114. if (((newwp.team == self.team) && (oldwp.team != self.team)))
  3115. {
  3116. return (TRUE);
  3117. }
  3118. else
  3119. {
  3120. if (((newwp.team != self.team) && (oldwp.team == self.team)))
  3121. {
  3122. return (FALSE);
  3123. }
  3124. else
  3125. {
  3126. if (((newwp.team != self.team) && (oldwp.team != self.team)))
  3127. {
  3128. if ((newwp.waypoint_num == oldwp.waypoint_num))
  3129. {
  3130. vlen ((newwp.origin - self.origin));
  3131. if ((vlen ((oldwp.origin - self.origin)) < vlen ((oldwp.origin - self.origin))))
  3132. {
  3133. return (TRUE);
  3134. }
  3135. }
  3136. else
  3137. {
  3138. if ((newwp.waypoint_num < oldwp.waypoint_num))
  3139. {
  3140. return (FALSE);
  3141. }
  3142. else
  3143. {
  3144. if ((newwp.waypoint_num > oldwp.waypoint_num))
  3145. {
  3146. return (TRUE);
  3147. }
  3148. }
  3149. }
  3150. }
  3151. }
  3152. }
  3153. }
  3154. }
  3155. else
  3156. {
  3157. if ((random () < 0.3))
  3158. {
  3159. return (TRUE);
  3160. }
  3161. }
  3162. }
  3163. return (FALSE);
  3164. };
  3165.  
  3166. float () FireHookAtBestOutOfWaterWaypoint =
  3167. {
  3168. local float best_dist;
  3169. local vector selected_pos;
  3170. local entity e;
  3171. local entity selected;
  3172. local entity selected_wp;
  3173. local vector pos;
  3174. local float wp_better;
  3175.  
  3176. selected_pos = VEC_ORIGIN;
  3177. selected_wp = world;
  3178. best_dist = 10000000000;
  3179. e = find (world, classname, "waypoint");
  3180. while ((e != world))
  3181. {
  3182. if (visible (e))
  3183. {
  3184. if ((pointcontents (e.origin) != CONTENT_WATER))
  3185. {
  3186. if ((pointcontents (e.origin) != CONTENT_SLIME))
  3187. {
  3188. if ((pointcontents (e.origin) != CONTENT_LAVA))
  3189. {
  3190. traceline (e.origin, (e.origin + '0 0 50000'), TRUE, self);
  3191. pos = trace_endpos;
  3192. if (BotCanSeePointThroughWater (pos))
  3193. {
  3194. wp_better = WaypointBetter (e, selected_wp);
  3195. if ((wp_better || (selected_pos == VEC_ORIGIN)))
  3196. {
  3197. selected_pos = pos;
  3198. selected_wp = e;
  3199. self.angles_x = vectoyaw ((e.origin - self.origin));
  3200. e.velocity = ((self.origin - e.origin) * 0.45);
  3201. e.nextthink = (time + 6);
  3202. best_dist = vlen ((e.origin - self.origin));
  3203. }
  3204. }
  3205. }
  3206. }
  3207. }
  3208. }
  3209. e = find (e, classname, "waypoint");
  3210. }
  3211. if ((selected_pos != VEC_ORIGIN))
  3212. {
  3213. MoveDebugMarker (selected_pos);
  3214. self.bot_aim = (selected_pos - (self.origin + '0 0 16'));
  3215. self.bot_aim = normalize (self.bot_aim);
  3216. self.swing = (random () * 0.9);
  3217. PlayerJump ();
  3218. BotFireHook ();
  3219. if ((e.angles != VEC_ORIGIN))
  3220. {
  3221. self.angles = e.angles;
  3222. BotFireHook ();
  3223. }
  3224. return (TRUE);
  3225. }
  3226. return (FALSE);
  3227. };
  3228.  
  3229. void (entity ent) BotFireHookAtEntity =
  3230. {
  3231. local vector org;
  3232.  
  3233. if (!hook_use_enabled)
  3234. {
  3235. return;
  3236. }
  3237. if ((time > self.attack_finished))
  3238. {
  3239. org = ent.origin;
  3240. MoveDebugMarker (org);
  3241. self.bot_aim = (org - self.origin);
  3242. self.bot_aim = normalize (self.bot_aim);
  3243. self.swing = 0.55;
  3244. BotFireHook ();
  3245. }
  3246. };
  3247.  
  3248. void (float zdist) BotFireHookUpRandomly =
  3249. {
  3250. local vector org;
  3251. //bprint(self.netname);
  3252. //bprint("BotFireHookUpRandomly\n");
  3253. if (!hook_use_enabled)
  3254. return;
  3255.  
  3256. if ((time > self.attack_finished))
  3257. {
  3258. org = self.origin;
  3259. org_z = (org_z + zdist);
  3260. org_x = (org_x + (((random () * -1) - 1) * 25));
  3261. org_y = (org_y + (((random () * -1) - 1) * 25));
  3262. if ((random () < 0.5))
  3263. {
  3264. org_x = (org_x * -1);
  3265. }
  3266. if ((random () < 0.5))
  3267. {
  3268. org_y = (org_y * -1);
  3269. }
  3270. if ((random () < 0.5))
  3271. {
  3272. org_z = (org_z * -1);
  3273. }
  3274. MoveDebugMarker (org);
  3275. self.bot_aim = (org - self.origin);
  3276. self.bot_aim = normalize (self.bot_aim);
  3277. self.goalentity = self.debug_marker;
  3278. BotFireHook ();
  3279. }
  3280. };
  3281.  
  3282. float () MaybeGetOutOfWater =
  3283. {
  3284. if (self.hook_out) return (FALSE);
  3285. if ((time < self.getoutofwater_time)) return (FALSE);
  3286.  
  3287. self.getoutofwater_time = (time + 1);
  3288. if ((self.watertype == CONTENT_WATER))
  3289. {
  3290. if ((self.waterlevel == 3))
  3291. {
  3292. if (FireHookAtBestOutOfWaterWaypoint ())
  3293. {
  3294. return (TRUE);
  3295. }
  3296. }
  3297. }
  3298. return (FALSE);
  3299. };
  3300.  
  3301. float () MaybeTryNotToDrown =
  3302. {
  3303. if (self.waterlevel < 3) return(0);
  3304.  
  3305. local entity e;
  3306. local float r;
  3307.  
  3308. if (((self.watertype == CONTENT_WATER) || (self.flags == FL_INWATER)))
  3309. {
  3310. if ((self.air_finished - 4) < time)
  3311. {
  3312.  
  3313. self.flags = (self.flags - (self.flags & FL_ONGROUND));
  3314. if (!FireHookAtBestOutOfWaterWaypoint ())
  3315. {
  3316. local entity x;
  3317. x = FindNearbyItem(random() * 500);
  3318. if (visible(x))
  3319. BotFireHookAtEntity(x);
  3320. else
  3321. {
  3322. BotFireHookUpRandomly (random() * 1500);
  3323. wall_look ();
  3324. }
  3325. }
  3326.  
  3327. return (TRUE);
  3328. }
  3329. }
  3330. else
  3331. {
  3332. if (((self.watertype == CONTENT_SLIME) || (self.watertype == CONTENT_LAVA)))
  3333. {
  3334. self.bot_blocked = TRUE;
  3335. if (!FireHookAtBestOutOfWaterWaypoint () && self.watertype == CONTENT_SLIME)
  3336. {
  3337. wall_look ();
  3338. BotFireHook ();
  3339. }
  3340.  
  3341. if (!FireHookAtBestOutOfWaterWaypoint ())
  3342. BotFireHookUpRandomly (1500);
  3343.  
  3344. return (TRUE);
  3345. }
  3346. }
  3347. return (FALSE);
  3348. };
  3349.  
  3350. float () MaybeFireHook =
  3351. {
  3352. if ((random () < 0.003))
  3353. {
  3354. if ((time > self.attack_finished))
  3355. {
  3356. BotFireHook ();
  3357. return (TRUE);
  3358. }
  3359. }
  3360. return (FALSE);
  3361. };
  3362.  
  3363. float () BotCanSeeHisFlagAtBase =
  3364. {
  3365. local entity flag;
  3366.  
  3367. if ((self.team == TEAM_COLOR1))
  3368. {
  3369. flag = find (world, classname, "item_flag_team1");
  3370. }
  3371. else
  3372. {
  3373. if ((self.team == TEAM_COLOR2))
  3374. {
  3375. flag = find (world, classname, "item_flag_team2");
  3376. }
  3377. }
  3378. if ((self.bot_plan == BOT_DEFEND))
  3379. {
  3380. if ((flag.cnt == 0))
  3381. {
  3382. if (BotCanSeeItem (flag))
  3383. {
  3384. return (TRUE);
  3385. }
  3386. }
  3387. }
  3388. return (FALSE);
  3389. };
  3390.  
  3391. float () BotShouldStand =
  3392. {
  3393. if ((self.bot_plan == BOT_DEFEND))
  3394. {
  3395. if (BotCanSeeHisFlagAtBase ())
  3396. {
  3397. if ((random () < 0.3))
  3398. {
  3399. dprint (self.netname);
  3400. dprint (" decides to stand\n");
  3401. return (TRUE);
  3402. }
  3403. }
  3404. }
  3405. if ((random () < 0.003))
  3406. {
  3407. return (TRUE);
  3408. }
  3409. return (FALSE);
  3410. };
  3411.  
  3412. void () NothingToDo =
  3413. {
  3414. MaybeChangeYaw ();
  3415. self.trigger_search_time = (time + (TE_WIZSPIKE * (random () * 5)));
  3416. MaybeShootTriggers (FALSE);
  3417. MoveBot ();
  3418. };
  3419.  
  3420. void () CheckGiveUpCamping =
  3421. {
  3422. if (((time < (self.camping_time + CAMPING_TIME)) && (self.camping_entity != world)))
  3423. {
  3424. if (BotCanSeeItem (self.camping_entity))
  3425. {
  3426. self.last_see_camp_ent = time;
  3427. }
  3428. else
  3429. {
  3430. if ((time > (self.last_see_camp_ent + 30)))
  3431. {
  3432. BotSayTeamStart2 ();
  3433. BotSayTeamMiddle ("I'm going to stop camping");
  3434. BotSayTeamEnd ();
  3435. self.camping_time = (time - 999);
  3436. remove (self.camping_entity);
  3437. self.camping_entity = world;
  3438. }
  3439. }
  3440. }
  3441. };
  3442.  
  3443. entity (vector org) SpawnDebugMarker =
  3444. {
  3445. local entity e;
  3446.  
  3447. e = spawn ();
  3448. e.classname = "debug_marker";
  3449. e.owner = self;
  3450. e.origin = org;
  3451. setorigin (e, org);
  3452. e.solid = SOLID_NOT;
  3453. e.movetype = MOVETYPE_NONE;
  3454. setmodel (e, string_null);
  3455. setsize (e, VEC_ORIGIN, VEC_ORIGIN);
  3456. return (e);
  3457. };
  3458.  
  3459. void () BotThink =
  3460. {
  3461. if (self.bot_type == "rbot")
  3462. return;
  3463. local float visi;
  3464. local entity follow_ent;
  3465. local entity old_goal;
  3466. self.yaw_speed = 15;
  3467. self.message = "THINK";
  3468.  
  3469. if (self.ltime == 120)
  3470. {
  3471. BotSayLetsGetEm();
  3472. self.ltime = (time + 120);
  3473. }
  3474.  
  3475.  
  3476. if ((pointcontents ((self.origin + '0 0 10')) == CONTENT_SOLID))
  3477. {
  3478. BotIsDead();
  3479. return;
  3480. }
  3481. if ((self.goalentity.classname == "waypoint"))
  3482. {
  3483. self.goalentity.nextjump = (self.goalentity.nextjump + 1);
  3484. if (EntityInFieldOfView (self.goalentity))
  3485. {
  3486. self.goalentity.velocity = (self.goalentity.velocity * 0.66);
  3487. }
  3488. if ((self.goalentity.nextjump > 90))
  3489. {
  3490. self.goalentity.nextthink = (time + 0.33);
  3491. }
  3492. }
  3493. if ((bot_dump == 50))
  3494. return;
  3495.  
  3496. if (self.timing < 0.33)
  3497. {
  3498. if (self.bot_action == BOT_FIGHTING || (self.player_flag & ITEM_ENEMY_FLAG))
  3499. {
  3500. if (random() < 0.33)
  3501. self.nextthink = (time + (sys_ticrate * 2));
  3502. }
  3503. else
  3504. {
  3505.  
  3506. self.nextthink = (time + (sys_ticrate * 3));
  3507. }
  3508. }
  3509. if ((pointcontents (self.origin) == CONTENT_WATER))
  3510. {
  3511. self.pattern = 0;
  3512. if ((pointcontents (self.origin + '0 0 18') == CONTENT_WATER))
  3513. {
  3514. if ((self.flags & !FL_SWIM))
  3515. {
  3516. self.flags = (self.flags + FL_SWIM);
  3517. }
  3518. self.movetype = MOVETYPE_FLY;
  3519. self.yaw_speed = 60;
  3520. }
  3521. }
  3522. else
  3523. {
  3524. self.movetype = MOVETYPE_WALK;
  3525. if ((self.flags & FL_SWIM))
  3526. self.flags = (self.flags - FL_SWIM);
  3527.  
  3528. }
  3529. if (((self.attacked > time) && (self.bot_action != BOT_FIGHTING)))
  3530. {
  3531. makevectors (self.angles);
  3532. self.angles_y = vectoyaw (self.turn);
  3533. if ((EntityInFieldOfView (self.enemy) && (self.attack_finished < time)))
  3534. {
  3535. checkyaw ();
  3536. MaybeFight ();
  3537. }
  3538. else
  3539. self.attacked = 0;
  3540.  
  3541. }
  3542. else
  3543. self.turn = '0 0 0';
  3544. if ((self.hooked_on_someone || (self.imhooked > time)))
  3545. {
  3546. self.weapon = Bot_BestWeapon ();
  3547. checkyaw ();
  3548. }
  3549. if (time < (self.suspicious_about_time + 4))
  3550. {
  3551. if (self.bot_action == BOT_FIGHTING && self.enemy.health > 0)
  3552. self.angles_y = vectoyaw ((self.enemy.origin - self.origin));
  3553. else
  3554. {
  3555. if (!visible (self.enemy))
  3556. self.angles_y = vectoyaw ((self.suspicious_about - self.origin));
  3557. checkyaw();
  3558. }
  3559.  
  3560. if (((self.flags == FL_ONGROUND) && (random () < 0.5)))
  3561. {
  3562. self.yaw_speed = (self.yaw_speed * 2);
  3563. if ((self.flags == FL_ONGROUND))
  3564. self.frame = 13;
  3565.  
  3566. }
  3567. if (((self.weapon == IT_GRENADE_LAUNCHER) || (self.weapon == IT_ROCKET_LAUNCHER)))
  3568. {
  3569. //EntityInFieldOfView (self.enemy);
  3570. if ((EntityInFieldOfView (self.enemy) && (self.attack_finished < time)))
  3571. {
  3572. if ((self.enemy.health > 0))
  3573. {
  3574. Bot_Attack ();
  3575. }
  3576. }
  3577. }
  3578. }
  3579. else
  3580. {
  3581. self.yaw_speed = 100;
  3582. }
  3583. if (((self.repeat > time) && (random () < 0.8)))
  3584. {
  3585. sound (self, CHAN_BODY, "misc/talk.wav", 1, ATTN_NONE);
  3586. bprint (self.talkname);
  3587. bprint ("º ");
  3588. BotSayMiddle (self.repeated);
  3589. }
  3590. if ((!self.goalentity && !(self.flags & FL_SWIM)))
  3591. {
  3592. if (!FireHookAtBestOutOfWaterWaypoint ())
  3593. {
  3594. wall_look ();
  3595. }
  3596. }
  3597. if (((self.waterlevel > SPAWNFLAG_LASER) && (self.bot_action != BOT_FIGHTING)))
  3598. {
  3599. EntityInFieldOfView (self.goalentity);
  3600. if ((BotCanSeePlayer (self.goalentity) && BotCanSeePlayer (self.goalentity)))
  3601. {
  3602. self.velocity = (self.goalentity.origin - self.origin);
  3603. }
  3604. if ((self.goalentity.origin_z > self.origin_z))
  3605. {
  3606. self.velocity_z = (self.velocity_z + 3);
  3607. }
  3608. if ((self.goalentity.origin_z < self.origin_z))
  3609. {
  3610. self.velocity_z = (self.velocity_z + 3);
  3611. }
  3612. }
  3613. self.extramove_oldthink = self.think;
  3614. self.extramove_lastframewasextra = FALSE;
  3615. if ((self.health <= 0))
  3616. {
  3617. self.think = BotRespawn;
  3618. self.nextthink = ((time + 1) + (random () * 4));
  3619. return;
  3620. }
  3621. //BotPreThink ();
  3622. if (self.timing > 0.33 && self.timing < 0.66)
  3623. {
  3624. if (self.bot_action == BOT_FIGHTING || (self.player_flag & ITEM_ENEMY_FLAG))
  3625. self.nextthink = (time + (sys_ticrate * 2));
  3626. else
  3627. self.nextthink = (time + (sys_ticrate * 3));
  3628. }
  3629.  
  3630.  
  3631. if ((self.health <= 0))
  3632. {
  3633. return;
  3634. }
  3635. if (!(temp1 & TEMP1_MULTI))
  3636. {
  3637. self.weapon = Bot_BestWeapon ();
  3638. }
  3639. if ((temp1 & TEMP1_MULTI))
  3640. {
  3641. set_player_weapon ();
  3642. }
  3643. MaybeFightFlagCarrier ();
  3644. if ((self.enemy != world))
  3645. {
  3646. visi = BotCanSeePlayer (self.enemy);
  3647. follow_ent = world;
  3648. if ((!visi && !(self.player_flag & ITEM_ENEMY_FLAG)))
  3649. {
  3650. follow_ent = BotCanSeePlayerFollow (self.enemy);
  3651. }
  3652. }
  3653. else
  3654. {
  3655. visi = FALSE;
  3656. }
  3657. CheckGiveUpCamping ();
  3658. if (self.fire_hook_immediately)
  3659. {
  3660. BotFireHookUpRandomly (30);
  3661. self.swing = 0.55;
  3662. self.fire_hook_immediately = FALSE;
  3663. }
  3664. else
  3665. {
  3666. if ((((self.enemy.health > 0) && visi) && (self.bot_action == BOT_FIGHTING)))
  3667. {
  3668. if ((time > (self.enemy_notice_time + (self.bsk_reaction_time / SPAWNFLAG_LASER))))
  3669. {
  3670. ContinueFighting ();
  3671. }
  3672. }
  3673. else
  3674. {
  3675. if ((((self.enemy.health > 0) && (follow_ent != world)) && (self.bot_action == BOT_FIGHTING)))
  3676. {
  3677. old_goal = self.goalentity;
  3678. self.goalentity = follow_ent;
  3679. self.movetarget = follow_ent;
  3680. BotMoveTowardGoal (TRUE);
  3681. self.goalentity = old_goal;
  3682. self.movetarget = old_goal;
  3683. }
  3684. else
  3685. {
  3686. if (!MaybeFight ())
  3687. {
  3688. StopFighting ();
  3689. if (!MaybeGoToTempWaypoint ())
  3690. {
  3691. if (!MaybeTryNotToDrown ())
  3692. {
  3693. if (!MaybeGetItems ())
  3694. {
  3695. if (!SetSpecialGoals ())
  3696. {
  3697. if (!MaybeGetOutOfWater ())
  3698. {
  3699. if (!MaybeShootTriggers (FALSE))
  3700. {
  3701. if (!MaybeFireHook ())
  3702. {
  3703. NothingToDo ();
  3704. }
  3705. }
  3706. }
  3707. }
  3708. }
  3709. }
  3710. }
  3711. }
  3712. }
  3713. }
  3714. }
  3715. BotSaySomething ();
  3716. //BotPostThink ();
  3717. if (((pointcontents (self.origin) != CONTENT_WATER) && (random () < 0.01)))
  3718. {
  3719. patternchange ();
  3720. }
  3721. if (self.timing > 0.66)
  3722. {
  3723. if (self.bot_action == BOT_FIGHTING || (self.player_flag & ITEM_ENEMY_FLAG))
  3724. self.nextthink = (time + (sys_ticrate * 5));
  3725. else
  3726. self.nextthink = (time + (sys_ticrate * 3));
  3727. }
  3728.  
  3729. if (((self.nextthink < (time - 1)) && self.health)|| (self.nextthink > (time +1)) && self.health)
  3730.     self.nextthink = time + 0.2;
  3731. };
  3732.  
  3733.  
  3734. void () BotSelfDeActivate =
  3735. {
  3736. local float forward;
  3737.  
  3738. if ((self.classname != "bot"))
  3739. return;
  3740.  
  3741. self.solid = SOLID_NOT;
  3742. self.deadflag = DEAD_DEAD;
  3743. if ((self.flags & FL_ONGROUND))
  3744. {
  3745. forward = vlen (self.velocity);
  3746. forward = (forward - 20);
  3747. if ((forward <= 0))
  3748. {
  3749. self.velocity = VEC_ORIGIN;
  3750. }
  3751. else
  3752. {
  3753. self.velocity = (forward * normalize (self.velocity));
  3754. }
  3755. }
  3756. if ((self.nextjump > -1))
  3757. self.nextjump = 0;
  3758.  
  3759. CopyToBodyQue (self);
  3760. BotIsDead ();
  3761. };
  3762.  
  3763. void () Bot_Precache =
  3764. {
  3765. bot_debug = 0;
  3766. next_bot_num = 0;
  3767. next_bot_red = 0;
  3768. next_bot_blue = 0;
  3769. smooth_move = FALSE;
  3770. use_extra_move_frame = TRUE;
  3771. last_flag_capture = (time - 999);
  3772. last_flag_pickup = (time - 999);
  3773. last_order_time_team1 = (time - 999);
  3774. last_order_time_team2 = (time - 999);
  3775. level_over_time = (time - 999);
  3776. hook_use_enabled = TRUE;
  3777. auto_camera_view = FALSE;
  3778. auto_fov_control = FALSE;
  3779. cur_camera_watch_ent = world;
  3780. last_camera_ent = world;
  3781. bots_have_normal_names = TRUE;
  3782. SpawnWaypointsForMap (mapname);
  3783. InitCPU ();
  3784. goal_winner = world;
  3785. precache_model ("maps/b_shell1.bsp");
  3786. precache_model ("maps/b_nail1.bsp");
  3787. precache_model ("progs/g_shot.mdl");
  3788. precache_model ("progs/g_nail2.mdl");
  3789. precache_model ("maps/b_bh25.bsp");
  3790. precache_sound ("items/health1.wav");
  3791. precache_model ("progs/armor.mdl");
  3792. if (!(cvar ("teamplay") & TEAM_NO_FLAG_TOSS))
  3793. {
  3794. precache_sound ("shalrath/attack2.wav");
  3795. }
  3796. if (!(cvar ("temp1") & TEMP1_NOMESS))
  3797. {
  3798. precache_sound ("misc/secret.wav");
  3799. bot_chatter_off = 0;
  3800. }
  3801. precache_model ("progs/s_bubble.spr");
  3802. precache_model ("progs/s_light.spr");
  3803. if ((cvar ("teamplay") & TEAM_CAPTURE_CUSTOM))
  3804. {
  3805. precache_model ("progs/flag.mdl");
  3806. precache_sound ("misc/flagtk.wav");
  3807. precache_sound ("misc/flagcap.wav");
  3808. precache_sound ("doors/runetry.wav");
  3809. }
  3810. else
  3811. {
  3812. precache_model ("progs/w_g_key.mdl");
  3813. precache_sound ("ogre/ogwake.wav");
  3814. precache_sound ("boss2/pop2.wav");
  3815. precache_sound ("doors/drclos4.wav");
  3816. }
  3817. };
  3818.  
  3819. entity (entity bot) TeamCaptureSpawnBot =
  3820. {
  3821.  
  3822. local float ss;
  3823. local entity p;
  3824. local entity spot;
  3825.  
  3826. if ((mapname == "start"))
  3827. {
  3828.  
  3829. spot = MultiSelectSpawnPoint ();
  3830.  
  3831. return (spot);
  3832. }
  3833. else
  3834. {
  3835. if ((bot.team == TEAM_COLOR1))
  3836. {
  3837. team1_lastspawn = find (team1_lastspawn, classname, "info_player_team1");
  3838. if ((team1_lastspawn == world))
  3839. {
  3840. team1_lastspawn = find (team1_lastspawn, classname, "info_player_team1");
  3841. }
  3842. return (team1_lastspawn);
  3843. }
  3844.  
  3845. if ((bot.team == TEAM_COLOR2))
  3846. {
  3847. team2_lastspawn = find (team2_lastspawn, classname, "info_player_team2");
  3848. if ((team2_lastspawn == world))
  3849. {
  3850. team2_lastspawn = find (team2_lastspawn, classname, "info_player_team2");
  3851. }
  3852. return (team2_lastspawn);
  3853. }
  3854.  
  3855. return (HeadSelectSpawnPoint ());
  3856. }
  3857. };
  3858.  
  3859. void (float make_visible) SetDebugMarkersVisible =
  3860. {
  3861. local entity e;
  3862.  
  3863. e = find (world, classname, "debug_marker");
  3864. while ((e != world))
  3865. {
  3866. if (make_visible)
  3867. {
  3868. debug_markers_visible = TRUE;
  3869. setmodel (e, "progs/s_light.spr");
  3870. }
  3871. else
  3872. {
  3873. debug_markers_visible = TRUE;
  3874. setmodel (e, "");
  3875. }
  3876. e = find (e, classname, "debug_marker");
  3877. }
  3878. };
  3879.  
  3880. void (vector org) MoveDebugMarker =
  3881. {
  3882. if (debug_markers_visible)
  3883. {
  3884. setorigin (self.debug_marker, org);
  3885. }
  3886. };
  3887.  
  3888. void (entity p) SetBotSkin =
  3889. {
  3890. if ((p.team == TEAM_COLOR1))
  3891. p.skin = 1;
  3892. else
  3893. {
  3894. if ((p.team == TEAM_COLOR2))
  3895. p.skin = 3;
  3896. }
  3897. if ((p.bot_skill >= SPAWNFLAG_LASER))
  3898. p.skin = (p.skin + 1);
  3899. p.oldskin = p.skin;
  3900. };
  3901.  
  3902. void () bot_touch =
  3903. {
  3904. /* debug code
  3905. bprint (self.model);
  3906. bprint ("\n");
  3907. bprint (ftos (self.skin));
  3908. bprint ("\n");
  3909. bprint (ftos(self.modelindex));
  3910. bprint ("\n");
  3911. */
  3912. if (self.watertype == CONTENT_LAVA)
  3913. {
  3914. if (!FireHookAtBestOutOfWaterWaypoint ())
  3915. BotFireHookUpRandomly (1500);
  3916. }
  3917.  
  3918. if ((other.classname == "bot" && other.team == self.team))
  3919. if ((random () < 0.25))
  3920. fBotSayTeam (": Move!!\n");
  3921. if ((other.classname == "bot" || other.classname == "player" && other.team != self.team))
  3922. {
  3923. self.attacked = time + 2.5;
  3924. self.enemy = other;
  3925. }
  3926.  
  3927.  
  3928.  
  3929. if ((other.solid == SOLID_BSP && other != world))
  3930. {
  3931. traceline (self.origin, (self.origin + '0 0 -120'), TRUE, self);
  3932. if (((trace_ent.classname == "plat") && (self.bot_action != BOT_FIGHTING)))
  3933. {
  3934. if (trace_ent.velocity_z != 0 && trace_ent == other)
  3935. {
  3936. self.yaw_speed = ((self.yaw_speed * 0.8) + 0.15);
  3937. self.nextthink = self.nextthink + 0.075;
  3938. self.frame = 36;
  3939. }
  3940. }
  3941. if (((trace_ent.classname == "door") && trace_ent.health))
  3942. {
  3943. self.enemy = trace_ent;
  3944. }
  3945. traceline ((self.origin + '0 0 12'), (self.origin + '0 120 12'), TRUE, self);
  3946. if (((trace_ent.classname == "door") && trace_ent.health))
  3947. {
  3948. self.enemy = trace_ent;
  3949. }
  3950. }
  3951. if ((other.classname == "waypoint"))
  3952. {
  3953. other.velocity = VEC_ORIGIN;
  3954. setorigin (other, other.oldorigin);
  3955. other.nextthink = (time + 8);
  3956. if (((other.waypoint_num == -1) && (other == self.goalentity)))
  3957. {
  3958. self.yaw_speed = 10;
  3959. }
  3960. else
  3961. {
  3962. self.yaw_speed = (random () * 10);
  3963. }
  3964. }
  3965. if ((other.classname == "image"))
  3966. {
  3967. if (self.bot_action != BOT_FIGHTING && self.enemy != other)
  3968. {
  3969. self.enemy = other;
  3970. self.bot_action = BOT_FIGHTING;
  3971. self.flags = self.flags | FL_ONGROUND;
  3972. if (((random () < 0.5)) && (other.health < 7))
  3973. self.repeated = "Get off Me!!!!!!!\n";
  3974. else
  3975. self.repeated = "Say Hello to my Little Friend!!!!\n";
  3976. if (((random () < 0.3))) self.repeat = (time + (random () * 1));
  3977. }
  3978. }
  3979. if (((other == world) && (self.movetype == MOVETYPE_FLY)))
  3980. {
  3981. if ((self.air_finished < time))
  3982. {
  3983. self.velocity = normalize((self.goalentity.origin - self.origin) * 1.5);
  3984. }
  3985. }
  3986. makevectors (self.angles);
  3987. };
  3988.  
  3989. entity (string name, float botteam, float bskill) BotCreate =
  3990. {
  3991. local entity self;
  3992. local float lfClientNo;
  3993. lfClientNo = clientNextAvailable ();
  3994. /*
  3995. if (lfClientNo == -1)
  3996. {
  3997. //sprint2 ("Max Clients Full......No bot created.\n");
  3998. return (world);
  3999. }
  4000. */
  4001.  
  4002. local entity spot,tekbot,store;
  4003. local float mapper;
  4004. local float counter;
  4005. local string st;
  4006.  
  4007. if (!deathmatch)
  4008. {
  4009. sprint2 ("Deathmatch is not enabled.\n");
  4010. sprint2 ("No bot created.\n");
  4011. return (self);
  4012. }
  4013.  
  4014.  
  4015.    
  4016.  
  4017.  
  4018. tekbot = spawnclient();
  4019. tekbot.botname = name;
  4020. RandomNormalName (tekbot);
  4021.  
  4022. //tekbot.solid = SOLID_SLIDEBOX;
  4023. //tekbot.movetype = MOVETYPE_STEP;
  4024. clientSetUsed (lfClientNo);
  4025. //tekbot.simulated_client = TRUE;
  4026. tekbot.colormap = (lfClientNo + 1);
  4027. tekbot.fClientNo = lfClientNo;
  4028.  
  4029.  
  4030. if (bots_have_normal_names)
  4031. tekbot.netname = tekbot.altname;
  4032. else
  4033. tekbot.netname = tekbot.botname;
  4034.  
  4035. tekbot.classname = "bot";
  4036.  
  4037. tekbot.team = botteam;
  4038. tekbot.lastteam = botteam;
  4039. tekbot.ltime = 120;
  4040. tekbot.gtimer = 1.75;
  4041. tekbot.deathtype = "?????";
  4042. tekbot.timing = random ();
  4043. tekbot.waterlevel = 0;
  4044. tekbot.health = 100;
  4045. tekbot.max_health = 100;
  4046. tekbot.frags = 0;
  4047. tekbot.flags = FL_CLIENT;
  4048. tekbot.takedamage = DAMAGE_AIM;
  4049. tekbot.goalentity = self;
  4050. tekbot.movetarget = self;
  4051. tekbot.enemy = world;
  4052. tekbot.pausetime = 0;
  4053. tekbot.deadflag = DEAD_NO;
  4054. tekbot.escort_time = (time - 999);
  4055. tekbot.escort_entity = world;
  4056. tekbot.pattern = 0;
  4057. tekbot.camping_time = (time - 999);
  4058. tekbot.reserve = 0;
  4059. tekbot.repeat = 0;
  4060. tekbot.repeated = "";
  4061. tekbot.swing = 0;
  4062. tekbot.nextjump = 0;
  4063. tekbot.games = rint (random () * 10);
  4064. //if (tekbot.games < 1)
  4065. tekbot.playtime = ((cvar ("timelimit") * (random () * 60)));
  4066. tekbot.camping_entity = world;
  4067. tekbot.camping_spot = VEC_ORIGIN;
  4068.  
  4069. tekbot.last_kill_time = (time - 999);
  4070. tekbot.last_kill_ent = world;
  4071. tekbot.num_kills = 0;
  4072. tekbot.num_deaths = 0;
  4073. tekbot.num_suicides = 0;
  4074. tekbot.num_captures = 0;
  4075. tekbot.num_pickups = 0;
  4076. tekbot.num_recovery = 0;
  4077. tekbot.num_assists = 0;
  4078. tekbot.num_bonus = 0;
  4079. tekbot.player_flag = (tekbot.player_flag - (tekbot.player_flag & ITEM_RUNE_MASK));
  4080. tekbot.player_flag = (tekbot.player_flag - (tekbot.player_flag & ITEM_ENEMY_FLAG));
  4081. tekbot.spawn_time = time;
  4082. tekbot.yaw_speed = 15;
  4083. tekbot.show_hostile = 0;
  4084. tekbot.weapon = 1;
  4085. tekbot.effects = 0;
  4086. tekbot.ammo_shells = 25;
  4087. tekbot.ammo_nails = 0;
  4088. tekbot.ammo_rockets = 0;
  4089. tekbot.ammo_cells = 0;
  4090. tekbot.last_say = 0;
  4091. tekbot.armorvalue = rint(random() * 50 + random() + 25);
  4092. tekbot.items = IT_SHOTGUN | IT_ARMOR1;
  4093. tekbot.turn = '0 0 0';
  4094. tekbot.view_ofs = '0 0 22';
  4095. tekbot.hook_out = FALSE;
  4096. tekbot.bot_plan = rint(random() * 3);
  4097. tekbot.th_pain = bot_pain;
  4098. tekbot.th_die = PlayerDie;
  4099. tekbot.touch = bot_touch;
  4100. tekbot.debug_marker = world;
  4101.  
  4102.  
  4103. if ((temp1 & TEMP1_MULTI))
  4104. {
  4105. //oself = self;
  4106. //self = self;
  4107. set_player_modelindexes ();
  4108. //self = oself;
  4109. }
  4110. else
  4111. {
  4112. if (!(temp1 & TEMP1_SUPPORT_PLAYER2))
  4113. tekbot.sex = 1;
  4114.  
  4115. if ((tekbot.sex == SPAWNFLAG_LASER))
  4116. {
  4117. setmodel (tekbot, "progs/player_f.mdl");
  4118. }
  4119. else
  4120. {
  4121. if ((tekbot.sex == 3))
  4122. {
  4123. setmodel (tekbot, "progs/player3.mdl");
  4124. }
  4125. else
  4126. {
  4127. if ((tekbot.sex == 4))
  4128. {
  4129. setmodel (tekbot, "progs/player4.mdl");
  4130. }
  4131. else
  4132. {
  4133. setmodel (tekbot, "progs/bot.mdl");
  4134. modelindex_bot = tekbot.modelindex;
  4135. tekbot.modelindex = modelindex_bot;
  4136. }
  4137. }
  4138. }
  4139. }
  4140.  
  4141. tekbot.bot_skill = bskill;
  4142. if ((tekbot.bot_skill < 0))
  4143. {
  4144. tekbot.bot_skill = 0;
  4145. }
  4146. if ((tekbot.bot_skill > 3))
  4147. {
  4148. tekbot.bot_skill = 3;
  4149. }
  4150. tekbot.bot_skill_inverse = (3 - tekbot.bot_skill);
  4151. tekbot.bsk_skill_lin1 = (0.7 + (tekbot.bot_skill * 0.1));
  4152. tekbot.bsk_skill_lin2 = (LMQUOTA_ARMOR + (tekbot.bot_skill * 0.2));
  4153. tekbot.bsk_skill_lin3 = (0.1 + (tekbot.bot_skill * 0.3));
  4154. tekbot.bsk_next_pulse_time = (0.3 + (0.3 * tekbot.bot_skill_inverse));
  4155. tekbot.bsk_next_pulse_time_items = (0.2 + (0.2 * tekbot.bot_skill_inverse));
  4156. tekbot.bsk_extra_large_pulse_dist = (200 * tekbot.bot_skill);
  4157. tekbot.bsk_extra_awareness_dist = (300 * tekbot.bot_skill);
  4158. tekbot.bsk_extra_jump_chance = (0.05 + (0.05 * tekbot.bot_skill));
  4159. tekbot.bsk_move_while_firing = (0.85 + (tekbot.bot_skill * 0.05));
  4160. tekbot.bsk_evade_chance = (LMQUOTA_ARMOR + (tekbot.bot_skill * 0.2));
  4161. tekbot.bsk_bot_fov = (tekbot.bot_skill_inverse * 0.15);
  4162. tekbot.bsk_reaction_time = (0.2 * tekbot.bot_skill_inverse);
  4163. tekbot.shirt_color = TeamGetShirt (tekbot.team, self);
  4164. tekbot.clientcolors = (tekbot.shirt_color) * 16 + (tekbot.team - 1);
  4165.  
  4166. if ((botteam == TEAM_COLOR1))
  4167. {
  4168. tekbot.enemy_team = TEAM_COLOR2;
  4169. }
  4170. else
  4171. {
  4172. if ((botteam == TEAM_COLOR2))
  4173. {
  4174. tekbot.enemy_team = TEAM_COLOR1;
  4175. }
  4176. }
  4177.  
  4178.  
  4179. SetBotSkin (tekbot);
  4180.  
  4181.  
  4182. /* Debug code
  4183. bprint (tekbot.model);
  4184. bprint ("\n");
  4185. bprint (ftos(tekbot.skin));
  4186. bprint ("\n");
  4187. bprint (ftos(tekbot.modelindex));
  4188. bprint ("\n");
  4189. */
  4190. if (((random () * 3) <= tekbot.bot_skill))
  4191. {
  4192. tekbot.use_defensive_way = 1;
  4193. }
  4194. else
  4195. {
  4196. tekbot.use_defensive_way = 0;
  4197. }
  4198. if (!(temp1 & TEMP1_USEDEFWAYS))
  4199. {
  4200. tekbot.use_defensive_way = 0;
  4201. }
  4202. tekbot.air_finished = (time + 300);
  4203. tekbot.dmg = SPAWNFLAG_LASER;
  4204. setsize (tekbot, VEC_HULL_MIN, VEC_HULL_MAX);
  4205.  
  4206.  
  4207. //tekbot.angles = tekbot.v_angle = spot.angles;  
  4208. waypoint_idle = 0;
  4209. Waypoint_Toggle();
  4210.  
  4211. //tekbot.origin = (spot.origin + '0 0 1');
  4212. //setorigin (self, tekbot.origin);
  4213. //tekbot.angles_y = spot.angles_y;
  4214. //tekbot.angles_x = 0;
  4215. //tekbot.ideal_yaw = (tekbot.angles * '0 1 0');
  4216. //tekbot.v_angle = tekbot.angles;
  4217. //makevectors (tekbot.angles);
  4218.  
  4219. tekbot.bot_action = BOT_MOVING;
  4220. tekbot.think = BotAnimationThink ;
  4221. tekbot.extramove_oldthink = BotAnimationThink;
  4222. tekbot.nextthink = ((time + 0.1) + (random () * 0.1));
  4223.  
  4224. bprint ("[Fclient: ");
  4225. st = ftos (tekbot.fClientNo);
  4226. bprint (st);
  4227. bprint ("]");
  4228. tekbot.fixangle = FALSE;
  4229.    
  4230. if ((tekbot.team == TEAM_COLOR1))
  4231. {
  4232. bprint ("[r");
  4233. st = ftos (next_bot_red);
  4234. bprint (st);
  4235. bprint ("] ");
  4236. }
  4237. else
  4238. {
  4239. if ((tekbot.team == TEAM_COLOR2))
  4240. {
  4241. bprint ("[b");
  4242. st = ftos (next_bot_blue);
  4243. bprint (st);
  4244. bprint ("] ");
  4245. }
  4246. }
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252. if ((deathmatch & DM_START_SMALL))
  4253. {
  4254. tekbot.items = ((IT_HOOK | IT_SUPER_SHOTGUN) | IT_NAILGUN);
  4255. tekbot.ammo_shells = 69;
  4256. tekbot.ammo_rockets = 0;
  4257. tekbot.ammo_nails = 40;
  4258. tekbot.ammo_cells = 0;
  4259. tekbot.armortype = 0.31;
  4260. tekbot.armorvalue = 100;
  4261. tekbot.weapon = IT_NAILGUN;
  4262. }
  4263. if ((deathmatch & DM_START_BIG))
  4264. {
  4265. tekbot.items = (((IT_HOOK | IT_SUPER_SHOTGUN) | IT_SUPER_NAILGUN) | IT_ROCKET_LAUNCHER);
  4266. tekbot.ammo_shells = 69;
  4267. tekbot.ammo_rockets = 5;
  4268. tekbot.ammo_nails = 60;
  4269. tekbot.ammo_cells = 0;
  4270. tekbot.armortype = 0.31;
  4271. tekbot.armorvalue = 100;
  4272. tekbot.weapon = IT_ROCKET_LAUNCHER;
  4273.  
  4274. }
  4275. if ((temp1 & TEMP1_MULTI))
  4276. {
  4277. set_player_weapon ();
  4278. }
  4279. if (tekbot.simulated_client)
  4280. {
  4281. tekbot.fShirt = tekbot.shirt_color;
  4282. tekbot.fPants = (tekbot.team - 1);
  4283. //msgUpdateNameToAll (tekbot.fClientNo, tekbot.netname);
  4284. //msgUpdateColorsToAll (tekbot.fClientNo, tekbot.fShirt, tekbot.fPants);
  4285. //msgUpdateFragsToAll (tekbot.fClientNo, tekbot.frags);
  4286. }
  4287. tekbot.observer_flags = 0;
  4288. tekbot.observer  = 0;
  4289.  
  4290. spawn_tdeath (tekbot.origin, self);
  4291. spawn_tfog ((tekbot.origin + (v_forward * 20)));
  4292. bprint (tekbot.netname);
  4293. bprint (" [skill ");
  4294. st = ftos (floor (tekbot.bot_skill));
  4295. bprint (st);
  4296. bprint ("] entered the game\n");
  4297. store = self;
  4298. self = tekbot;
  4299.     ClientConnect ();
  4300.     PutClientInServer();
  4301.     self = store;
  4302. return (tekbot);
  4303.  
  4304. };
  4305.  
  4306. void () BotRespawn =
  4307. {
  4308. local entity spot;
  4309. local string type;
  4310. local float ss;
  4311. local entity p;
  4312.  
  4313. if (!deathmatch) return;
  4314.  
  4315. self.sFloating = string_null;
  4316. self.turn = '0 0 0';
  4317. self.onfire = FALSE;
  4318. self.teleport_time = time + rint ((random () * 4));
  4319. self.deathtype = "Factory Defect!";
  4320. self.ltime = (time + 120);
  4321. self.flags = FL_CLIENT;
  4322. self.touch = bot_touch;
  4323. self.solid = SOLID_SLIDEBOX;
  4324. self.movetype = MOVETYPE_WALK;
  4325. self.waterlevel = 0;
  4326. self.air_finished = (time + 300);
  4327. self.dmg = SPAWNFLAG_LASER;
  4328. self.classname = "bot";
  4329. self.health = 100;
  4330. self.max_health = 100;
  4331. self.takedamage = DAMAGE_AIM;
  4332. self.deadflag = DEAD_NO;
  4333. self.goalentity = self;
  4334. self.movetarget = self;
  4335. self.enemy = world;
  4336. self.pausetime = 0;
  4337. self.armortype = 0.31;
  4338. self.armorvalue = 75;
  4339. self.nextjump = 0;
  4340. self.super_damage_finished = 0;
  4341. self.invincible_finished = 0;
  4342. self.invisible_finished = 0;
  4343. self.radsuit_finished = 0;
  4344. self.player_flag = (self.player_flag - (self.player_flag & ITEM_RUNE_MASK));
  4345. self.player_flag = (self.player_flag - (self.player_flag & ITEM_ENEMY_FLAG));
  4346. self.suspicious_about = VEC_ORIGIN;
  4347. self.suspicious_about_time = 0;
  4348. self.yaw_speed = 75;
  4349. self.show_hostile = 0;
  4350. self.effects = 0;
  4351. self.view_ofs = '0 0 22';
  4352. self.items = IT_SHOTGUN;
  4353. self.weapon = IT_SHOTGUN;
  4354. self.ammo_shells = 25;
  4355. self.ammo_nails = 0;
  4356. self.ammo_rockets = 0;
  4357. self.ammo_cells = 0;
  4358. self.escort_time = (time - 999);
  4359. self.escort_entity = world;
  4360. self.camping_time = (time - 999);
  4361. if ((self.camping_entity != world))
  4362. {
  4363. remove (self.camping_entity);
  4364. }
  4365. self.camping_entity = world;
  4366. self.camping_spot = VEC_ORIGIN;
  4367. self.hook_out = FALSE;
  4368. self.th_pain = bot_pain;
  4369. self.th_die = PlayerDie;
  4370. if (random() < 0.5)
  4371. bot_chatter_rated_g = !bot_chatter_rated_g;
  4372.  
  4373.  
  4374. if ((self.skin < 1))
  4375. SetBotSkin (self);
  4376.  
  4377. if (((self.sex == 2) && (temp1 & TEMP1_SUPPORT_PLAYER2)))
  4378. setmodel (self, "progs/player_f.mdl");
  4379. else
  4380. {
  4381. if ((self.sex == 3))
  4382. {
  4383. setmodel (self, "progs/player3.mdl");
  4384. }
  4385. else
  4386. {
  4387. if ((self.sex == 4))
  4388. {
  4389. setmodel (self, "progs/player4.mdl");
  4390. }
  4391. else
  4392. {
  4393. setmodel (self, "progs/bot.mdl");
  4394. }
  4395. }
  4396.    
  4397. }
  4398. setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  4399.  
  4400. //if ((deathmatch & DM_SPAWN_RANDOM))
  4401.  
  4402. spot = Get_Botspawn(self);
  4403.  
  4404. self.angles = self.v_angle = spot.angles;  //
  4405. self.pattern = 0;
  4406. spawn_tdeath (spot.origin, self);
  4407. spot.spawn_time = spot.spawn_time + 5;
  4408. self.origin = (spot.origin + '0 0 3');
  4409. setorigin (self, self.origin);
  4410. //droptofloor ();
  4411.  
  4412. //self.angles_y = spot.angles_y;
  4413. //self.angles_z = 0;
  4414. //self.angles_x = 0;
  4415. //self.ideal_yaw = (self.angles * '0 1 0');
  4416. //self.v_angle = self.angles;
  4417. makevectors (self.angles);
  4418. spawn_tfog ((self.origin + (v_forward * 20)));
  4419. //self.bot_action = BOT_MOVING;
  4420. self.think = BotAnimationThink;
  4421. self.extramove_oldthink = BotAnimationThink;
  4422. self.nextthink = (time + 0.075);
  4423. if ((deathmatch & DM_START_SMALL))
  4424. {
  4425. self.items = ((IT_HOOK | IT_SUPER_SHOTGUN) | IT_NAILGUN);
  4426. self.ammo_shells = 69;
  4427. self.ammo_rockets = 0;
  4428. self.ammo_nails = 40;
  4429. self.ammo_cells = 0;
  4430. self.armortype = 0.31;
  4431. self.armorvalue = 100;
  4432. self.weapon = IT_NAILGUN;
  4433. }
  4434. if ((deathmatch & DM_START_BIG))
  4435. {
  4436. self.items = (((IT_HOOK | IT_SUPER_SHOTGUN) | IT_SUPER_NAILGUN) | IT_ROCKET_LAUNCHER);
  4437. self.ammo_shells = 69;
  4438. self.ammo_rockets = 5;
  4439. self.ammo_nails = 60;
  4440. self.ammo_cells = 0;
  4441. self.armortype = 0.31;
  4442. self.armorvalue = 100;
  4443. self.weapon = IT_ROCKET_LAUNCHER;
  4444. }
  4445. if ((temp1 & TEMP1_MULTI))
  4446. {
  4447. set_player_weapon ();
  4448. }
  4449. };
  4450.  
  4451. void (entity to) BotList =
  4452. {
  4453. local entity head;
  4454. local string frag;
  4455. local float best;
  4456. local string bestname;
  4457. local float num;
  4458.  
  4459. if ((to.classname != "player"))
  4460. {
  4461. return;
  4462. }
  4463. bestname = "";
  4464. best = 0;
  4465. num = 0;
  4466. sprint (to, "Bot frags:\n");
  4467. head = find (world, classname, "bot");
  4468. while (head)
  4469. {
  4470. num = (num + 1);
  4471. frag = ftos (head.frags);
  4472. sprint (to, head.netname);
  4473. sprint (to, " = ");
  4474. sprint (to, frag);
  4475. if ((best < head.frags))
  4476. {
  4477. best = head.frags;
  4478. bestname = head.netname;
  4479. }
  4480. head = find (head, classname, "bot");
  4481. }
  4482. };
  4483.  
  4484.  
  4485.  
  4486. void (string name, float botteam, float bskill) QBotCreate =
  4487. {
  4488.  
  4489. local float lfClientNo;
  4490. lfClientNo = clientNextAvailable ();
  4491. //if (lfClientNo == -1)
  4492. //{
  4493. //sprint2 ("Max Clients Full......No bot created.\n");
  4494. //return (world);
  4495. //}
  4496.  
  4497.  
  4498.  
  4499.  
  4500. local string st;
  4501.  
  4502. local entity que,qbot;
  4503.  
  4504.  
  4505.  
  4506. if (!deathmatch)
  4507. {
  4508. sprint2 ("Deathmatch is not enabled.\n");
  4509. sprint2 ("No bot created.\n");
  4510. return;
  4511. }
  4512.  
  4513.  
  4514.  
  4515. qbot = spawnclient ();
  4516.  
  4517. qbot.search_time = time;
  4518. qbot.attack_finished = time;
  4519. qbot.th_pain = bot_pain;
  4520. //qbot.th_die = BotDie;
  4521. //qbot.th_stand = bot_stand1;
  4522. //qbot.th_walk = bot_walk;
  4523. //qbot.th_run = bot_run;
  4524. //qbot.th_melee = dmbot_melee;
  4525. //qbot.th_cache = cacheenemy;
  4526. //qbot.think = bot_start;
  4527. //qbot.nextthink = (time + 0.1);
  4528. //qbot.enemy = world;
  4529. //qbot.pathtype = NEVERTARGET;
  4530. qbot.deadflag = DEAD_NO;
  4531. qbot.pausetime = FALSE;
  4532.  
  4533. qbot.movetype = MOVETYPE_STEP;
  4534. clientSetUsed (lfClientNo);
  4535. qbot.simulated_client = TRUE;
  4536. qbot.colormap = (lfClientNo + 1);
  4537. qbot.fClientNo = lfClientNo;
  4538.  
  4539.  
  4540. if (bots_have_normal_names)
  4541. {
  4542. qbot.netname = qbot.altname;
  4543. }
  4544. else
  4545. {
  4546. qbot.netname = qbot.botname;
  4547. }
  4548. qbot.classname = "bot";
  4549.  
  4550. qbot.team = botteam;
  4551. qbot.lastteam = botteam;
  4552. qbot.ltime = 120;
  4553. qbot.gtimer = 1.75;
  4554. qbot.deathtype = "?????";
  4555. qbot.timing = random ();
  4556. qbot.waterlevel = 0;
  4557. qbot.health = 100;
  4558. qbot.max_health = 100;
  4559. qbot.frags = 0;
  4560. qbot.flags = FL_CLIENT;
  4561. qbot.takedamage = DAMAGE_AIM;
  4562. qbot.goalentity = qbot;
  4563. qbot.movetarget = qbot;
  4564. qbot.enemy = world;
  4565. qbot.pausetime = 0;
  4566. qbot.deadflag = DEAD_NO;
  4567. qbot.escort_time = (time - 999);
  4568. qbot.escort_entity = world;
  4569. qbot.pattern = 0;
  4570. qbot.camping_time = (time - 999);
  4571. qbot.reserve = 0;
  4572. qbot.repeat = 0;
  4573. qbot.repeated = "";
  4574. qbot.swing = 0;
  4575. qbot.nextjump = 0;
  4576. qbot.games = rint (random () * 10);
  4577. qbot.playtime = 0;
  4578. qbot.camping_entity = world;
  4579. qbot.camping_spot = VEC_ORIGIN;
  4580.  
  4581. qbot.last_kill_time = (time - 999);
  4582. qbot.last_kill_ent = world;
  4583. qbot.num_kills = 0;
  4584. qbot.num_deaths = 0;
  4585. qbot.num_suicides = 0;
  4586. qbot.num_captures = 0;
  4587. qbot.num_pickups = 0;
  4588. qbot.num_recovery = 0;
  4589. qbot.num_assists = 0;
  4590. qbot.num_bonus = 0;
  4591. qbot.player_flag = (qbot.player_flag - (qbot.player_flag & ITEM_RUNE_MASK));
  4592. qbot.player_flag = (qbot.player_flag - (qbot.player_flag & ITEM_ENEMY_FLAG));
  4593. qbot.spawn_time = time;
  4594. qbot.yaw_speed = 15;
  4595. qbot.show_hostile = 0;
  4596. qbot.weapon = 1;
  4597. qbot.effects = 0;
  4598. qbot.ammo_shells = 25;
  4599. qbot.ammo_nails = 0;
  4600. qbot.ammo_rockets = 0;
  4601. qbot.ammo_cells = 0;
  4602. qbot.last_say = 0;
  4603. qbot.armorvalue = rint(random() * 50 + random() + 25);
  4604. qbot.items = IT_SHOTGUN | IT_ARMOR1;
  4605. qbot.turn = '0 0 0';
  4606. qbot.view_ofs = '0 0 22';
  4607. qbot.hook_out = FALSE;
  4608. qbot.bot_plan = rint(random() * 3);
  4609. qbot.th_pain = bot_pain;
  4610. qbot.th_die = PlayerDie;
  4611. qbot.touch = bot_touch;
  4612. qbot.debug_marker = world;
  4613.  
  4614.  
  4615. if ((temp1 & TEMP1_MULTI))
  4616. {
  4617. qbot = qbot;
  4618. qbot = qbot;
  4619. set_player_modelindexes ();
  4620. qbot = qbot;
  4621. }
  4622. else
  4623. {
  4624. if (!(temp1 & TEMP1_SUPPORT_PLAYER2))
  4625. {
  4626. qbot.sex = 1;
  4627. }
  4628. if ((qbot.sex == SPAWNFLAG_LASER))
  4629. {
  4630. setmodel (qbot, "progs/player_f.mdl");
  4631. }
  4632. else
  4633. {
  4634. if ((qbot.sex == 3))
  4635. {
  4636. setmodel (qbot, "progs/player3.mdl");
  4637. }
  4638. else
  4639. {
  4640. if ((qbot.sex == 4))
  4641. {
  4642. setmodel (qbot, "progs/player4.mdl");
  4643. }
  4644. else
  4645. {
  4646. setmodel (qbot, "progs/bot.mdl");
  4647. modelindex_bot = qbot.modelindex;
  4648. qbot.modelindex = modelindex_bot;
  4649. }
  4650. }
  4651. }
  4652. }
  4653.  
  4654. qbot.bot_skill = bskill;
  4655. if ((qbot.bot_skill < 0))
  4656. {
  4657. qbot.bot_skill = 0;
  4658. }
  4659. if ((qbot.bot_skill > 3))
  4660. {
  4661. qbot.bot_skill = 3;
  4662. }
  4663. qbot.bot_skill_inverse = (3 - qbot.bot_skill);
  4664. qbot.bsk_skill_lin1 = (0.7 + (qbot.bot_skill * 0.1));
  4665. qbot.bsk_skill_lin2 = (LMQUOTA_ARMOR + (qbot.bot_skill * 0.2));
  4666. qbot.bsk_skill_lin3 = (0.1 + (qbot.bot_skill * 0.3));
  4667. qbot.bsk_next_pulse_time = (0.3 + (0.3 * qbot.bot_skill_inverse));
  4668. qbot.bsk_next_pulse_time_items = (0.2 + (0.2 * qbot.bot_skill_inverse));
  4669. qbot.bsk_extra_large_pulse_dist = (200 * qbot.bot_skill);
  4670. qbot.bsk_extra_awareness_dist = (300 * qbot.bot_skill);
  4671. qbot.bsk_extra_jump_chance = (0.05 + (0.05 * qbot.bot_skill));
  4672. qbot.bsk_move_while_firing = (0.85 + (qbot.bot_skill * 0.05));
  4673. qbot.bsk_evade_chance = (LMQUOTA_ARMOR + (qbot.bot_skill * 0.2));
  4674. qbot.bsk_bot_fov = (qbot.bot_skill_inverse * 0.15);
  4675. qbot.bsk_reaction_time = (0.2 * qbot.bot_skill_inverse);
  4676. qbot.shirt_color = TeamGetShirt (qbot.team, qbot);
  4677. qbot.clientcolors = (qbot.shirt_color) * 16 + (qbot.team - 1);
  4678.  
  4679. if ((botteam == TEAM_COLOR1))
  4680. {
  4681. qbot.enemy_team = TEAM_COLOR2;
  4682. }
  4683. else
  4684. {
  4685. if ((botteam == TEAM_COLOR2))
  4686. {
  4687. qbot.enemy_team = TEAM_COLOR1;
  4688. }
  4689. }
  4690.  
  4691.  
  4692. SetBotSkin (qbot);
  4693.  
  4694.  
  4695. /* Debug code
  4696. bprint (qbot.model);
  4697. bprint ("\n");
  4698. bprint (ftos(qbot.skin));
  4699. bprint ("\n");
  4700. bprint (ftos(qbot.modelindex));
  4701. bprint ("\n");
  4702. */
  4703. if (((random () * 3) <= qbot.bot_skill))
  4704. {
  4705. qbot.use_defensive_way = 1;
  4706. }
  4707. else
  4708. {
  4709. qbot.use_defensive_way = 0;
  4710. }
  4711. if (!(temp1 & TEMP1_USEDEFWAYS))
  4712. {
  4713. qbot.use_defensive_way = 0;
  4714. }
  4715. qbot.air_finished = (time + 300);
  4716. qbot.dmg = 2;
  4717. setsize (qbot, VEC_HULL_MIN, VEC_HULL_MAX);
  4718. //spot = TeamCaptureSpawnBot (qbot);
  4719.  
  4720.  
  4721. //qbot.angles = qbot.v_angle = spot.angles;  
  4722. waypoint_idle = 0;
  4723. Waypoint_Toggle();
  4724. //PutClientInServer();
  4725. //qbot.origin = (spot.origin + '0 0 1');
  4726. //setorigin (qbot, qbot.origin);
  4727. //qbot.angles_y = spot.angles_y;
  4728. //qbot.angles_x = 0;
  4729. //qbot.ideal_yaw = (qbot.angles * '0 1 0');
  4730. //qbot.v_angle = qbot.angles;
  4731. //makevectors (qbot.angles);
  4732. spawn_tfog ((qbot.origin + (v_forward * 20)));
  4733. qbot.bot_action = BOT_MOVING;
  4734. qbot.think = BotAnimationThink ;
  4735. qbot.extramove_oldthink = BotAnimationThink;
  4736. qbot.nextthink = ((time + 0.1) + (random () * 0.1));
  4737. spawn_tdeath (qbot.origin, qbot);
  4738. bprint ("[Fclient: ");
  4739. st = ftos (qbot.fClientNo);
  4740. bprint (st);
  4741. bprint ("]");
  4742. qbot.fixangle = FALSE;
  4743.    
  4744. if ((qbot.team == TEAM_COLOR1))
  4745. {
  4746. bprint ("[r");
  4747. st = ftos (next_bot_red);
  4748. bprint (st);
  4749. bprint ("] ");
  4750. }
  4751. else
  4752. {
  4753. if ((qbot.team == TEAM_COLOR2))
  4754. {
  4755. bprint ("[b");
  4756. st = ftos (next_bot_blue);
  4757. bprint (st);
  4758. bprint ("] ");
  4759. }
  4760. }
  4761. spawn_tfog (qbot.origin);
  4762. bprint (qbot.netname);
  4763. bprint (" [skill ");
  4764. st = ftos (floor (qbot.bot_skill));
  4765. bprint (st);
  4766. bprint ("] entered the game\n");
  4767.  
  4768.  
  4769.  
  4770. if ((deathmatch & DM_START_SMALL))
  4771. {
  4772. qbot.items = ((IT_HOOK | IT_SUPER_SHOTGUN) | IT_NAILGUN);
  4773. qbot.ammo_shells = 69;
  4774. qbot.ammo_rockets = 0;
  4775. qbot.ammo_nails = 40;
  4776. qbot.ammo_cells = 0;
  4777. qbot.armortype = 0.31;
  4778. qbot.armorvalue = 100;
  4779. qbot.weapon = IT_NAILGUN;
  4780. }
  4781. if ((deathmatch & DM_START_BIG))
  4782. {
  4783. qbot.items = (((IT_HOOK | IT_SUPER_SHOTGUN) | IT_SUPER_NAILGUN) | IT_ROCKET_LAUNCHER);
  4784. qbot.ammo_shells = 69;
  4785. qbot.ammo_rockets = 5;
  4786. qbot.ammo_nails = 60;
  4787. qbot.ammo_cells = 0;
  4788. qbot.armortype = 0.31;
  4789. qbot.armorvalue = 100;
  4790. qbot.weapon = IT_ROCKET_LAUNCHER;
  4791.  
  4792. }
  4793. if ((temp1 & TEMP1_MULTI))
  4794. {
  4795. set_player_weapon ();
  4796. }
  4797. if (qbot.simulated_client)
  4798. {
  4799. qbot.fShirt = qbot.shirt_color;
  4800. qbot.fPants = (qbot.team - 1);
  4801. //msgUpdateNameToAll (qbot.fClientNo, qbot.netname);
  4802. //msgUpdateColorsToAll (qbot.fClientNo, qbot.fShirt, qbot.fPants);
  4803. //msgUpdateFragsToAll (qbot.fClientNo, qbot.frags);
  4804. }
  4805.  
  4806. //
  4807. qbot.botname = name;
  4808. RandomNormalName (qbot);
  4809. que = self;
  4810. local entity x;
  4811. x = spawn ();
  4812. x = qbot;
  4813. self = que;
  4814.  
  4815.  
  4816. ClientConnect ();
  4817. self = que;
  4818.  
  4819. x.origin = (DMHEAD.origin);
  4820. setorigin (x, DMHEAD.origin);
  4821. /*
  4822. msgUpdateNameToAll (qbot.fClientNo, qbot.netname);
  4823. msgUpdateColorsToAll (qbot.fClientNo, qbot.fShirt, qbot.fPants);
  4824. msgUpdateFragsToAll (qbot.fClientNo, qbot.frags);
  4825. */
  4826. //spot = TeamCaptureSpawnBot (qbot);
  4827.  
  4828.  
  4829. //qbot.angles = qbot.v_angle = spot.angles;  
  4830.  
  4831.  
  4832.  
  4833.  
  4834. //self = qbot;
  4835.  
  4836. //self = x = qbot;
  4837.  
  4838.  
  4839.  
  4840.  
  4841.  
  4842.  
  4843.  
  4844.  
  4845. return;
  4846.  
  4847. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement