]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/bang.c
cgram: allow providing an input file instead of the random fortune
[bsdgames-darwin.git] / warp / bang.c
1 /* Header: bang.c,v 7.0.1.3 86/12/12 16:57:00 lwall Exp */
2
3 /* Log: bang.c,v
4 * Revision 7.0.1.3 86/12/12 16:57:00 lwall
5 * Made circular explosions.
6 *
7 * Revision 7.0.1.2 86/10/20 14:36:02 lwall
8 * Picked some lint.
9 *
10 * Revision 7.0.1.1 86/10/16 10:49:45 lwall
11 * Added Damage. Fixed random bugs.
12 *
13 * Revision 7.0 86/10/08 15:11:57 lwall
14 * Split into separate files. Added amoebas and pirates.
15 *
16 */
17
18 #include "EXTERN.h"
19 #include "warp.h"
20 #include "object.h"
21 #include "move.h"
22 #include "sig.h"
23 #include "term.h"
24 #include "them.h"
25 #include "INTERN.h"
26 #include "bang.h"
27
28 void
29 bang_init(void)
30 {
31 ;
32 }
33
34 void
35 make_plink(int x, int y)
36 {
37 OBJECT *obj;
38
39 move(y+1,x*2,0);
40 beg_qwrite();
41 *filler = '@';
42 qwrite();
43 obj = occupant[y][x];
44 if (obj) {
45 if (numamoebas && obj->image == ' ')
46 qaddc(amb[y][x]);
47 else
48 qaddc(obj->image);
49 }
50 else if (numamoebas)
51 qaddc(amb[y][x]);
52 else
53 qaddspace();
54 end_qwrite();
55 }
56
57 void
58 make_blast(int x, int y, int size, long mass)
59 {
60 bangy[nxtbang] = y;
61 bangx[nxtbang] = x;
62 bangm[nxtbang] = mass;
63 bangs[nxtbang++] = size;
64 assert(nxtbang <= XSIZE * YSIZE);
65 if (numamoebas && amb[y][x] == '~') {
66 if (mass > 10000)
67 modify_amoeba(y,x,1,'~', 10);
68 else if (mass > 100)
69 modify_amoeba(y,x,1,'~', 5);
70 bangs[nxtbang-1] = 0; /* don't propagate */
71 return;
72 }
73 else if (mass >= 0) {
74 OBJECT *obj;
75
76 move(y+1,x*2,0);
77 beg_qwrite();
78 *filler = '@';
79 qwrite();
80 *filler = '#';
81 qwrite();
82 *filler = '@';
83 qwrite();
84 *filler = '#';
85 qwrite();
86 *filler = '@';
87 qwrite();
88 obj = occupant[y][x];
89 if (obj) {
90 if (numamoebas && obj->image == ' ')
91 qaddc(amb[y][x]);
92 else
93 qaddc(obj->image);
94 }
95 else if (numamoebas)
96 qaddc(amb[y][x]);
97 else
98 qaddspace();
99 end_qwrite();
100 }
101 }
102
103 void
104 do_bangs(void)
105 {
106 int x;
107 int y;
108 int i;
109 int j;
110 int k;
111 int lastxy;
112 OBJECT *obj;
113
114 /* read blast list and update blast array */
115 assert(nxtbang >= 0 && nxtbang <= XSIZE * YSIZE);
116 for (i=0; i<nxtbang; i++) {
117 if (bangm[i] != 32767)
118 bangm[i] *= 4;
119 lastxy = bangs[i] << 1;
120 if (lastxy >= MAXBDIST)
121 lastxy = MAXBDIST - 1;
122 for (y=bangy[i]-bangs[i],x=bangx[i]-bangs[i],j=lastxy;
123 j>=0;
124 y++,x++,--j) {
125 yblasted[yy[j] = (y+YSIZE00) % YSIZE] |= 1;
126 xblasted[xx[j] = (x+XSIZE00) % XSIZE] |= 1;
127 }
128 blasted = true;
129 for (y=lastxy;y>=0;--y) {
130 for (x=lastxy;x>=0;--x) {
131 if (lastxy > 2) {
132 j = abs(y-bangs[i]);
133 k = abs(x-bangs[i]);
134 if (j < k) /* distance is long + 1/2 short */
135 j += k + k;
136 else
137 j += j + k;
138 if (--j > lastxy)
139 continue;
140 }
141 if (bangm[i] != 32767 ||
142 !(obj=occupant[yy[y]][xx[x]]) || obj->type != Web)
143 blast[yy[y]][xx[x]] += bangm[i];
144 }
145 }
146 }
147 }