2 Copyright (C) Prikol Software 1996-1997
3 Copyright (C) Aleksey Volynskov 1996-1997
4 Copyright (C) <ARembo@gmail.com> 2011
6 This file is part of the Doom2D:Rembo project.
8 Doom2D:Rembo is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as
10 published by the Free Software Foundation.
12 Doom2D:Rembo is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/> or
19 write to the Free Software Foundation, Inc.,
20 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
37 static int sr_r
,sxr
[MAXSR
],syr
[MAXSR
];
43 void SMK_init (void) {
46 for(i
=0;i
<MAXSMOK
;++i
) {sm
[i
].t
=0;}
51 void SMK_alloc (void) {
53 burnsnd
=Z_getsnd("BURN");
54 for(i
=0;i
<MAXSR
;++i
) {
55 sxr
[i
]=myrand(256*2+1)-256;
56 syr
[i
]=myrand(256*2+1)-256;
61 static void inclast(void) {
62 if(++lsm
>=MAXSMOK
) lsm
=0;
70 for(i
=0;i
<MAXSMOK
;++i
) if(sm
[i
].t
) {
72 ox
=sm
[i
].x
;oy
=sm
[i
].y
;
73 sm
[i
].xv
=Z_dec(sm
[i
].xv
,20);
74 sm
[i
].yv
=Z_dec(sm
[i
].yv
,20);
75 sm
[i
].x
+=sm
[i
].xv
/2;sm
[i
].y
+=sm
[i
].yv
/2;
76 if(!Z_canfit(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
77 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
78 }else if(Z_inwater(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
79 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
81 ox
=sm
[i
].x
;oy
=sm
[i
].y
;
82 sm
[i
].x
+=sm
[i
].xv
/2;sm
[i
].y
+=sm
[i
].yv
/2;
83 if(!Z_canfit(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
84 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
85 }else if(Z_inwater(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
86 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
89 o
.x
=sm
[i
].x
>>8;o
.y
=sm
[i
].y
>>8;
90 o
.xv
=sm
[i
].xv
>>10;o
.yv
=sm
[i
].yv
>>10;
92 if(!(g_time
&3)) Z_hit(&o
,1,sm
[i
].o
,HIT_FLAME
);
95 ox
=sm
[i
].x
;oy
=sm
[i
].y
;
96 sm
[i
].xv
=Z_dec(sm
[i
].xv
,20);
97 sm
[i
].yv
=Z_dec(sm
[i
].yv
,20);
98 sm
[i
].x
+=sm
[i
].xv
;sm
[i
].y
+=sm
[i
].yv
;
99 if(!Z_canfit(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
100 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
101 }else if(Z_inwater(sm
[i
].x
>>8,(sm
[i
].y
>>8)+3,3,7)) {
102 sm
[i
].x
=ox
;sm
[i
].y
=oy
;
109 static void SMK_add (int x
, int y
, int xv
, int yv
, byte t
, byte s
, short o
) {
112 if(!Z_canfit(x
>>8,(y
>>8)+3,3,7)) return;
113 if(Z_inwater(x
>>8,(y
>>8)+3,3,7)) {FX_bubble(x
>>8,y
>>8,xv
,yv
,1);return;}
116 sm
[i
].xv
=xv
;sm
[i
].yv
=yv
;
122 void SMK_gas (int x0
, int y0
, int xr
, int yr
, int xv
, int yv
, int k
) {
128 k
=max(abs(xv
),abs(yv
));
131 x
=((xv
*i
/k
+x0
)<<8)+sxr
[sr_r
]*xr
;
132 y
=((yv
*i
/k
+y0
)<<8)+syr
[sr_r
]*yr
;
133 if(++sr_r
>=MAXSR
) sr_r
=0;
134 SMK_add(x
,y
,sxv
,syv
,SMSN
*3,0,-3);
138 void SMK_flame (int x0
, int y0
, int ox
, int oy
, int xr
, int yr
, int xv
, int yv
, int k
, int o
) {
143 xv
=xv
-(ox
<<8);yv
=yv
-(oy
<<8);
144 k
=max(abs(xv
),abs(yv
));
146 if(!burntm
) burntm
=Z_sound(burnsnd
,128);
147 for(i
=0;i
<=k
;i
+=200) {
148 x
=xv
*i
/k
+(x0
<<8)+sxr
[sr_r
]*xr
;
149 y
=yv
*i
/k
+(y0
<<8)+syr
[sr_r
]*yr
;
150 if(++sr_r
>=MAXSR
) sr_r
=0;
151 SMK_add(x
,y
,sxv
,syv
,FLSN
,1,o
);