1 /* Copyright (C) 1996-1997 Aleksey Volynskov
2 * Copyright (C) 2011 Rambo
3 * Copyright (C) 2020 SovietPony
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
45 static init_t bl_ini
[MAXINI
],sp_ini
[MAXINI
];
46 static int bl_r
,sp_r
,sr_r
,sxr
[MAXSR
],syr
[MAXSR
];
52 for(i
=0;i
<MAXDOT
;++i
) {dot
[i
].t
=0;dot
[i
].o
.r
=0;dot
[i
].o
.h
=1;}
56 static void incldot(void) {
57 if(++ldot
>=MAXDOT
) ldot
=0;
60 void DOT_alloc(void) {
63 for(i
=0;i
<MAXINI
;++i
) {
64 bl_ini
[i
].xv
=myrand(BL_XV
*2+1)-BL_XV
;
65 bl_ini
[i
].yv
=-myrand(BL_YV
);
66 bl_ini
[i
].c
=0xB0+myrand(16);
67 bl_ini
[i
].t
=myrand(BL_MAXT
-BL_MINT
+1)+BL_MINT
;
68 sp_ini
[i
].xv
=myrand(SP_V
*2+1)-SP_V
;
69 sp_ini
[i
].yv
=myrand(SP_V
*2+1)-SP_V
;
70 sp_ini
[i
].c
=0xA0+myrand(6);
71 sp_ini
[i
].t
=myrand(SP_MAXT
-SP_MINT
+1)+SP_MINT
;
73 for(i
=0;i
<MAXSR
;++i
) {
74 sxr
[i
]=myrand(2*2+1)-2;
75 syr
[i
]=myrand(2*2+1)-2;
84 for(i
=0;i
<MAXDOT
;++i
) if(dot
[i
].t
) {
85 xv
=dot
[i
].o
.xv
+dot
[i
].o
.vx
;
86 yv
=dot
[i
].o
.yv
+dot
[i
].o
.vy
;
87 s
=Z_moveobj(&dot
[i
].o
);
88 if(dot
[i
].t
<254) --dot
[i
].t
;
89 if(s
&(Z_HITWATER
|Z_FALLOUT
)) {dot
[i
].t
=0;continue;}
93 if(!xv
) dot
[i
].o
.vx
=(rand()&1)?-1:1;
94 else dot
[i
].o
.vx
=Z_sign(dot
[i
].o
.vx
);
95 if(rand()%yv
==0) dot
[i
].o
.vx
*=2;
100 if(dot
[i
].t
>4 && dot
[i
].t
!=255) dot
[i
].t
=4;
103 dot
[i
].o
.vx
=Z_sign(xv
)*2;
104 dot
[i
].o
.yv
=Z_sign(dot
[i
].o
.yv
);
105 if(dot
[i
].o
.yv
>=0) if(rand()&3) --dot
[i
].o
.yv
;
106 if(dot
[i
].o
.yv
>=0) if(rand()&1) --dot
[i
].o
.yv
;
108 if(s
&Z_HITCEIL
) {dot
[i
].o
.xv
=0;dot
[i
].o
.yv
=(myrand(100))?-2:0;}
113 void DOT_add(int x
,int y
,char xv
,char yv
,byte c
,byte t
) {
116 if(!Z_canfit(x
,y
,0,1)) return;
118 dot
[i
].o
.x
=x
;dot
[i
].o
.y
=y
;
119 dot
[i
].o
.xv
=xv
;dot
[i
].o
.yv
=yv
;
120 dot
[i
].c
=c
;dot
[i
].t
=t
;
121 dot
[i
].o
.vx
=dot
[i
].o
.vy
=0;
125 void DOT_blood(int x
,int y
,int xv
,int yv
,int n
) {
129 dx
=x
+sxr
[sr_r
];dy
=y
+syr
[sr_r
];
130 if(!Z_canfit(x
,y
,0,1)) continue;
132 dot
[i
].o
.x
=dx
;dot
[i
].o
.y
=dy
;
133 dot
[i
].o
.xv
=bl_ini
[bl_r
].xv
+Z_dec(xv
,3);
134 dot
[i
].o
.yv
=bl_ini
[bl_r
].yv
+Z_dec(yv
,3)-3;
135 dot
[i
].c
=bl_ini
[bl_r
].c
;
137 dot
[i
].o
.vx
=dot
[i
].o
.vy
=0;
138 if(++bl_r
>=MAXINI
) bl_r
=0;
139 if(++sr_r
>=MAXSR
) sr_r
=0;
144 void DOT_spark(int x
,int y
,int xv
,int yv
,int n
) {
148 dx
=x
+sxr
[sr_r
];dy
=y
+syr
[sr_r
];
149 if(!Z_canfit(x
,y
,0,1)) continue;
151 dot
[i
].o
.x
=dx
;dot
[i
].o
.y
=dy
;
152 dot
[i
].o
.xv
=sp_ini
[sp_r
].xv
-xv
/4;
153 dot
[i
].o
.yv
=sp_ini
[sp_r
].yv
-yv
/4;
154 dot
[i
].c
=sp_ini
[sp_r
].c
;
155 dot
[i
].t
=sp_ini
[sp_r
].t
;
156 dot
[i
].o
.vx
=dot
[i
].o
.vy
=0;
157 if(++sp_r
>=MAXINI
) sp_r
=0;
158 if(++sr_r
>=MAXSR
) sr_r
=0;
163 void DOT_water(int x
,int y
,int xv
,int yv
,int n
,int c
) {
165 static byte ct
[3]={0xC0,0x70,0xB0};
167 if(c
<0 || c
>=3) return;
170 dx
=x
+sxr
[sr_r
];dy
=y
+syr
[sr_r
];
171 if(!Z_canfit(x
,y
,0,1)) continue;
173 dot
[i
].o
.x
=dx
;dot
[i
].o
.y
=dy
;
174 dot
[i
].o
.xv
=bl_ini
[bl_r
].xv
-Z_dec(xv
,3);
175 dot
[i
].o
.yv
=bl_ini
[bl_r
].yv
-abs(yv
);
176 dot
[i
].c
=bl_ini
[bl_r
].c
-0xB0+c
;
178 dot
[i
].o
.vx
=dot
[i
].o
.vy
=0;
179 if(++bl_r
>=MAXINI
) bl_r
=0;
180 if(++sr_r
>=MAXSR
) sr_r
=0;