Source:SLASH'EM 0.0.7E7F2/borg.c

From NetHackWiki
Revision as of 18:59, 2 October 2006 by Jaytbot (talk | contribs) (Automated source code upload)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Below is the full text to borg.c from the source code of SLASH'EM 0.0.7E7F2. To link to a particular line, write [[SLASH'EM 0.0.7E7F2/borg.c#line123]], for example.

The latest source code for vanilla NetHack is at Source code.


The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1.    /* the nethack cyborg! */
2.    /* by proudft@ccnet.com */
3.    
4.    #include "hack.h"
5.    #include "func_tab.h"
6.    
7.    #ifdef BORG
8.    #define HP_TRACK 25
9.    #define HP_TREND 3
10.   
11.   char borg_on=0;
12.   char borg_line[80] = {0};
13.   int predicted_hp;
14.   
15.   void adjust_hp_list(void)
16.   {
17.      static int hp_list[HP_TRACK] = {0};
18.      int l;
19.      int hp_diff;
20.      for (l=0;l<HP_TRACK-1;l++) {
21.         hp_list[l+1] = hp_list[l];
22.      }
23.      hp_list[0] = u.uhp;
24.      hp_diff = 0;
25.   /*   for (l=0;l<HP_TREND;l++) {
26.         hp_diff += (hp_list[l] - u.uhpmax);
27.      }
28.      hp_diff /= HP_TREND;
29.      predicted_hp = u.uhp - hp_diff;*/
30.      predicted_hp = u.uhp - ((hp_list[0] - u.uhpmax)*2);
31.   }
32.   
33.   char borg_input(void)
34.   {
35.      char c;
36.      adjust_hp_list();
37.      if (predicted_hp <= 0 || (u.uhp < u.uhpmax / 8)) pline("Emergency!");
38.   
39.      /* He's quite lame for now... */
40.      c = rand()%9 + '1';
41.      if (c == '5') c = '.';
42.      sprintf(borg_line,"%c",c);
43.      return ('.');
44.   }
45.   #endif