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/>.
35 static int tsndtm
, rsndtm
;
39 void IT_alloc (void) {
41 static char nm
[][6] = {
42 "ITEMUP", "WPNUP", "GETPOW", "ITMBK"
44 for (i
= 0; i
< 4; ++i
) {
45 snd
[i
] = Z_getsnd(nm
[i
]);
47 for (i
= 0; i
< MAXITEM
; ++i
) {
55 for (i
= 0; i
< MAXITEM
; ++i
) {
66 static void takesnd (int t
) {
69 if(t
<=I_CELP
|| (t
>=I_BPACK
&& t
<=I_BFG
) || t
==I_GUN2
)
70 {tsndtm
=Z_sound(snd
[1],128);return;}
71 if(t
==I_MEGA
|| t
==I_INVL
|| t
==I_SUPER
)
72 {tsndtm
=Z_sound(snd
[2],192);return;}
73 tsndtm
=Z_sound(snd
[0], 255);
81 for(i
=0;i
<MAXITEM
;++i
) if(it
[i
].t
)
84 FX_ifog(it
[i
].o
.x
,it
[i
].o
.y
);
85 if(!rsndtm
) rsndtm
=Z_sound(snd
[3],128);
89 case I_ARM1
: case I_ARM2
:
90 if(++it
[i
].s
>=18) it
[i
].s
=0; break;
91 case I_MEGA
: case I_INVL
:
92 case I_SUPER
: case I_RTORCH
: case I_GTORCH
: case I_BTORCH
:
93 if(++it
[i
].s
>=8) it
[i
].s
=0; break;
94 case I_GOR1
: case I_FCAN
:
95 if(++it
[i
].s
>=6) it
[i
].s
=0; break;
98 if((j
=Z_moveobj(&it
[i
].o
))&Z_FALLOUT
) {it
[i
].t
=0;continue;}
99 else if(j
&Z_HITWATER
) Z_splash(&it
[i
].o
,it
[i
].o
.r
+it
[i
].o
.h
);
101 if(Z_overlap(&it
[i
].o
,&pl1
.o
))
102 if(PL_give(&pl1
,it
[i
].t
&0x7FFF)) {
104 if(_2pl
) if((it
[i
].t
&0x7FFF)>=I_KEYR
&& (it
[i
].t
&0x7FFF)<=I_KEYB
) continue;
105 if(!(it
[i
].s
=-itm_rtime
) || (it
[i
].t
&0x8000)) it
[i
].t
=0;
108 if(_2pl
) if(Z_overlap(&it
[i
].o
,&pl2
.o
))
109 if(PL_give(&pl2
,it
[i
].t
&0x7FFF)) {
111 if((it
[i
].t
&0x7FFF)>=I_KEYR
&& (it
[i
].t
&0x7FFF)<=I_KEYB
) continue;
112 if(!(it
[i
].s
=-itm_rtime
) || (it
[i
].t
&0x8000)) it
[i
].t
=0;
118 void IT_spawn (int x
,int y
,int t
) {
121 for(i
=0;i
<MAXITEM
;++i
) if(!it
[i
].t
) {
122 it
[i
].t
=t
|0x8000;it
[i
].s
=0;
123 it
[i
].o
.x
=x
;it
[i
].o
.y
=y
;
124 it
[i
].o
.xv
=it
[i
].o
.yv
=it
[i
].o
.vx
=it
[i
].o
.vy
=0;
125 it
[i
].o
.r
=10;it
[i
].o
.h
=8;
130 void IT_drop_ammo (int t
, int n
, int x
, int y
) {
131 static int an
[8]={10,4,1,40,50,25,5,100};
135 for(a
=an
[t
-I_CLIP
];n
>=a
;n
-=a
)
136 IT_spawn(x
+myrand(3*2+1)-3,y
-myrand(7),t
);
137 if(t
>=I_AMMO
) {t
-=4;goto again
;}