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
40 static int tsndtm
, rsndtm
;
44 void IT_alloc (void) {
46 static char nm
[][6] = {
47 "ITEMUP", "WPNUP", "GETPOW", "ITMBK"
49 for (i
= 0; i
< 4; ++i
) {
50 snd
[i
] = Z_getsnd(nm
[i
]);
52 for (i
= 0; i
< MAXITEM
; ++i
) {
60 for (i
= 0; i
< MAXITEM
; ++i
) {
71 static void takesnd (int t
) {
74 if(t
<=I_CELP
|| (t
>=I_BPACK
&& t
<=I_BFG
) || t
==I_GUN2
)
75 {tsndtm
=Z_sound(snd
[1],128);return;}
76 if(t
==I_MEGA
|| t
==I_INVL
|| t
==I_SUPER
)
77 {tsndtm
=Z_sound(snd
[2],192);return;}
78 tsndtm
=Z_sound(snd
[0], 255);
86 for(i
=0;i
<MAXITEM
;++i
) if(it
[i
].t
)
89 FX_ifog(it
[i
].o
.x
,it
[i
].o
.y
);
90 if(!rsndtm
) rsndtm
=Z_sound(snd
[3],128);
94 case I_ARM1
: case I_ARM2
:
95 if(++it
[i
].s
>=18) it
[i
].s
=0; break;
96 case I_MEGA
: case I_INVL
:
97 case I_SUPER
: case I_RTORCH
: case I_GTORCH
: case I_BTORCH
:
98 if(++it
[i
].s
>=8) it
[i
].s
=0; break;
99 case I_GOR1
: case I_FCAN
:
100 if(++it
[i
].s
>=6) it
[i
].s
=0; break;
103 if((j
=Z_moveobj(&it
[i
].o
))&Z_FALLOUT
) {it
[i
].t
=0;continue;}
104 else if(j
&Z_HITWATER
) Z_splash(&it
[i
].o
,it
[i
].o
.r
+it
[i
].o
.h
);
106 if(Z_overlap(&it
[i
].o
,&pl1
.o
))
107 if(PL_give(&pl1
,it
[i
].t
&0x7FFF)) {
109 if(_2pl
) if((it
[i
].t
&0x7FFF)>=I_KEYR
&& (it
[i
].t
&0x7FFF)<=I_KEYB
) continue;
110 if(!(it
[i
].s
=-itm_rtime
) || (it
[i
].t
&0x8000)) it
[i
].t
=0;
113 if(_2pl
) if(Z_overlap(&it
[i
].o
,&pl2
.o
))
114 if(PL_give(&pl2
,it
[i
].t
&0x7FFF)) {
116 if((it
[i
].t
&0x7FFF)>=I_KEYR
&& (it
[i
].t
&0x7FFF)<=I_KEYB
) continue;
117 if(!(it
[i
].s
=-itm_rtime
) || (it
[i
].t
&0x8000)) it
[i
].t
=0;
123 void IT_spawn (int x
,int y
,int t
) {
126 for(i
=0;i
<MAXITEM
;++i
) if(!it
[i
].t
) {
127 it
[i
].t
=t
|0x8000;it
[i
].s
=0;
128 it
[i
].o
.x
=x
;it
[i
].o
.y
=y
;
129 it
[i
].o
.xv
=it
[i
].o
.yv
=it
[i
].o
.vx
=it
[i
].o
.vy
=0;
130 it
[i
].o
.r
=10;it
[i
].o
.h
=8;
135 void IT_drop_ammo (int t
, int n
, int x
, int y
) {
136 static int an
[8]={10,4,1,40,50,25,5,100};
140 for(a
=an
[t
-I_CLIP
];n
>=a
;n
-=a
)
141 IT_spawn(x
+myrand(3*2+1)-3,y
-myrand(7),t
);
142 if(t
>=I_AMMO
) {t
-=4;goto again
;}