1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
22 g_textures
, g_phys
, g_saveload
, BinEditor
, MAPDEF
;
28 InitX
, InitY
: Integer;
32 QuietRespawn
: Boolean;
33 SpawnTrigger
: Integer;
35 Animation
: TAnimation
;
38 procedure g_Items_LoadData();
39 procedure g_Items_FreeData();
40 procedure g_Items_Init();
41 procedure g_Items_Free();
42 function g_Items_Create(X
, Y
: Integer; ItemType
: Byte;
43 Fall
, Respawnable
: Boolean; AdjCoord
: Boolean = False; ForcedID
: Integer = -1): DWORD
;
44 procedure g_Items_Update();
45 procedure g_Items_Draw();
46 procedure g_Items_Pick(ID
: DWORD
);
47 procedure g_Items_Remove(ID
: DWORD
);
48 procedure g_Items_SaveState(var Mem
: TBinMemoryWriter
);
49 procedure g_Items_LoadState(var Mem
: TBinMemoryReader
);
52 gItems
: Array of TItem
= nil;
53 gItemsTexturesID
: Array [1..ITEM_MAX
] of DWORD
;
54 gMaxDist
: Integer = 1;
55 ITEM_RESPAWNTIME
: Integer = 60 * 36;
60 g_basic
, e_graphics
, g_sound
, g_main
, g_gfx
, g_map
,
61 Math
, g_game
, g_triggers
, g_console
, SysUtils
, g_player
, g_net
, g_netmsg
,
65 ITEM_SIGNATURE
= $4D455449; // 'ITEM'
67 ITEMSIZE
: Array [ITEM_MEDKIT_SMALL
..ITEM_MAX
] of Array [0..1] of Byte =
68 (((14), (15)), // MEDKIT_SMALL
69 ((28), (19)), // MEDKIT_LARGE
70 ((28), (19)), // MEDKIT_BLACK
71 ((31), (16)), // ARMOR_GREEN
72 ((31), (16)), // ARMOR_BLUE
73 ((25), (25)), // SPHERE_BLUE
74 ((25), (25)), // SPHERE_WHITE
76 ((14), (27)), // OXYGEN
77 ((25), (25)), // INVUL
78 ((62), (24)), // WEAPON_SAW
79 ((63), (12)), // WEAPON_SHOTGUN1
80 ((54), (13)), // WEAPON_SHOTGUN2
81 ((54), (16)), // WEAPON_CHAINGUN
82 ((62), (16)), // WEAPON_ROCKETLAUNCHER
83 ((54), (16)), // WEAPON_PLASMA
84 ((61), (36)), // WEAPON_BFG
85 ((54), (16)), // WEAPON_SUPERPULEMET
86 (( 9), (11)), // AMMO_BULLETS
87 ((28), (16)), // AMMO_BULLETS_BOX
88 ((15), ( 7)), // AMMO_SHELLS
89 ((32), (12)), // AMMO_SHELLS_BOX
90 ((12), (27)), // AMMO_ROCKET
91 ((54), (21)), // AMMO_ROCKET_BOX
92 ((15), (12)), // AMMO_CELL
93 ((32), (21)), // AMMO_CELL_BIG
94 ((22), (29)), // AMMO_BACKPACK
95 ((16), (16)), // KEY_RED
96 ((16), (16)), // KEY_GREEN
97 ((16), (16)), // KEY_BLUE
98 (( 1), ( 1)), // WEAPON_KASTET
99 ((43), (16)), // WEAPON_PISTOL
100 ((14), (18)), // BOTTLE
101 ((16), (15)), // HELMET
102 ((32), (24)), // JETPACK
103 ((25), (25)), // INVIS
104 ((53), (20)), // WEAPON_FLAMETHROWER
105 ((13), (20))); // AMMO_FUELCAN
107 procedure InitTextures();
109 g_Texture_Get('ITEM_MEDKIT_SMALL', gItemsTexturesID
[ITEM_MEDKIT_SMALL
]);
110 g_Texture_Get('ITEM_MEDKIT_LARGE', gItemsTexturesID
[ITEM_MEDKIT_LARGE
]);
111 g_Texture_Get('ITEM_MEDKIT_BLACK', gItemsTexturesID
[ITEM_MEDKIT_BLACK
]);
112 g_Texture_Get('ITEM_SUIT', gItemsTexturesID
[ITEM_SUIT
]);
113 g_Texture_Get('ITEM_OXYGEN', gItemsTexturesID
[ITEM_OXYGEN
]);
114 g_Texture_Get('ITEM_WEAPON_SAW', gItemsTexturesID
[ITEM_WEAPON_SAW
]);
115 g_Texture_Get('ITEM_WEAPON_SHOTGUN1', gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
]);
116 g_Texture_Get('ITEM_WEAPON_SHOTGUN2', gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
]);
117 g_Texture_Get('ITEM_WEAPON_CHAINGUN', gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
]);
118 g_Texture_Get('ITEM_WEAPON_ROCKETLAUNCHER', gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
]);
119 g_Texture_Get('ITEM_WEAPON_PLASMA', gItemsTexturesID
[ITEM_WEAPON_PLASMA
]);
120 g_Texture_Get('ITEM_WEAPON_BFG', gItemsTexturesID
[ITEM_WEAPON_BFG
]);
121 g_Texture_Get('ITEM_WEAPON_SUPERPULEMET', gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
]);
122 g_Texture_Get('ITEM_WEAPON_FLAMETHROWER', gItemsTexturesID
[ITEM_WEAPON_FLAMETHROWER
]);
123 g_Texture_Get('ITEM_AMMO_BULLETS', gItemsTexturesID
[ITEM_AMMO_BULLETS
]);
124 g_Texture_Get('ITEM_AMMO_BULLETS_BOX', gItemsTexturesID
[ITEM_AMMO_BULLETS_BOX
]);
125 g_Texture_Get('ITEM_AMMO_SHELLS', gItemsTexturesID
[ITEM_AMMO_SHELLS
]);
126 g_Texture_Get('ITEM_AMMO_SHELLS_BOX', gItemsTexturesID
[ITEM_AMMO_SHELLS_BOX
]);
127 g_Texture_Get('ITEM_AMMO_ROCKET', gItemsTexturesID
[ITEM_AMMO_ROCKET
]);
128 g_Texture_Get('ITEM_AMMO_ROCKET_BOX', gItemsTexturesID
[ITEM_AMMO_ROCKET_BOX
]);
129 g_Texture_Get('ITEM_AMMO_CELL', gItemsTexturesID
[ITEM_AMMO_CELL
]);
130 g_Texture_Get('ITEM_AMMO_CELL_BIG', gItemsTexturesID
[ITEM_AMMO_CELL_BIG
]);
131 g_Texture_Get('ITEM_AMMO_FUELCAN', gItemsTexturesID
[ITEM_AMMO_FUELCAN
]);
132 g_Texture_Get('ITEM_AMMO_BACKPACK', gItemsTexturesID
[ITEM_AMMO_BACKPACK
]);
133 g_Texture_Get('ITEM_KEY_RED', gItemsTexturesID
[ITEM_KEY_RED
]);
134 g_Texture_Get('ITEM_KEY_GREEN', gItemsTexturesID
[ITEM_KEY_GREEN
]);
135 g_Texture_Get('ITEM_KEY_BLUE', gItemsTexturesID
[ITEM_KEY_BLUE
]);
136 g_Texture_Get('ITEM_WEAPON_KASTET', gItemsTexturesID
[ITEM_WEAPON_KASTET
]);
137 g_Texture_Get('ITEM_WEAPON_PISTOL', gItemsTexturesID
[ITEM_WEAPON_PISTOL
]);
138 g_Texture_Get('ITEM_JETPACK', gItemsTexturesID
[ITEM_JETPACK
]);
141 procedure g_Items_LoadData();
143 e_WriteLog('Loading items data...', MSG_NOTIFY
);
145 g_Sound_CreateWADEx('SOUND_ITEM_RESPAWNITEM', GameWAD
+':SOUNDS\RESPAWNITEM');
146 g_Sound_CreateWADEx('SOUND_ITEM_GETRULEZ', GameWAD
+':SOUNDS\GETRULEZ');
147 g_Sound_CreateWADEx('SOUND_ITEM_GETWEAPON', GameWAD
+':SOUNDS\GETWEAPON');
148 g_Sound_CreateWADEx('SOUND_ITEM_GETITEM', GameWAD
+':SOUNDS\GETITEM');
150 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BLUESPHERE', GameWAD
+':TEXTURES\SBLUE', 32, 32, 4, True);
151 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_WHITESPHERE', GameWAD
+':TEXTURES\SWHITE', 32, 32, 4, True);
152 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORGREEN', GameWAD
+':TEXTURES\ARMORGREEN', 32, 16, 3, True);
153 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORBLUE', GameWAD
+':TEXTURES\ARMORBLUE', 32, 16, 3, True);
154 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVUL', GameWAD
+':TEXTURES\INVUL', 32, 32, 4, True);
155 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVIS', GameWAD
+':TEXTURES\INVIS', 32, 32, 4, True);
156 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_RESPAWN', GameWAD
+':TEXTURES\ITEMRESPAWN', 32, 32, 5, True);
157 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BOTTLE', GameWAD
+':TEXTURES\BOTTLE', 16, 32, 4, True);
158 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_HELMET', GameWAD
+':TEXTURES\HELMET', 16, 16, 4, True);
159 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_RED', GameWAD
+':TEXTURES\FLAGRED', 64, 64, 5, False);
160 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_BLUE', GameWAD
+':TEXTURES\FLAGBLUE', 64, 64, 5, False);
161 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_DOM', GameWAD
+':TEXTURES\FLAGDOM', 64, 64, 5, False);
162 g_Texture_CreateWADEx('ITEM_MEDKIT_SMALL', GameWAD
+':TEXTURES\MED1');
163 g_Texture_CreateWADEx('ITEM_MEDKIT_LARGE', GameWAD
+':TEXTURES\MED2');
164 g_Texture_CreateWADEx('ITEM_WEAPON_SAW', GameWAD
+':TEXTURES\SAW');
165 g_Texture_CreateWADEx('ITEM_WEAPON_PISTOL', GameWAD
+':TEXTURES\PISTOL');
166 g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD
+':TEXTURES\KASTET');
167 g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN1', GameWAD
+':TEXTURES\SHOTGUN1');
168 g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN2', GameWAD
+':TEXTURES\SHOTGUN2');
169 g_Texture_CreateWADEx('ITEM_WEAPON_CHAINGUN', GameWAD
+':TEXTURES\MGUN');
170 g_Texture_CreateWADEx('ITEM_WEAPON_ROCKETLAUNCHER', GameWAD
+':TEXTURES\RLAUNCHER');
171 g_Texture_CreateWADEx('ITEM_WEAPON_PLASMA', GameWAD
+':TEXTURES\PGUN');
172 g_Texture_CreateWADEx('ITEM_WEAPON_BFG', GameWAD
+':TEXTURES\BFG');
173 g_Texture_CreateWADEx('ITEM_WEAPON_SUPERPULEMET', GameWAD
+':TEXTURES\SPULEMET');
174 g_Texture_CreateWADEx('ITEM_WEAPON_FLAMETHROWER', GameWAD
+':TEXTURES\FLAMETHROWER');
175 g_Texture_CreateWADEx('ITEM_AMMO_BULLETS', GameWAD
+':TEXTURES\CLIP');
176 g_Texture_CreateWADEx('ITEM_AMMO_BULLETS_BOX', GameWAD
+':TEXTURES\AMMO');
177 g_Texture_CreateWADEx('ITEM_AMMO_SHELLS', GameWAD
+':TEXTURES\SHELL1');
178 g_Texture_CreateWADEx('ITEM_AMMO_SHELLS_BOX', GameWAD
+':TEXTURES\SHELL2');
179 g_Texture_CreateWADEx('ITEM_AMMO_ROCKET', GameWAD
+':TEXTURES\ROCKET');
180 g_Texture_CreateWADEx('ITEM_AMMO_ROCKET_BOX', GameWAD
+':TEXTURES\ROCKETS');
181 g_Texture_CreateWADEx('ITEM_AMMO_CELL', GameWAD
+':TEXTURES\CELL');
182 g_Texture_CreateWADEx('ITEM_AMMO_CELL_BIG', GameWAD
+':TEXTURES\CELL2');
183 g_Texture_CreateWADEx('ITEM_AMMO_FUELCAN', GameWAD
+':TEXTURES\FUELCAN');
184 g_Texture_CreateWADEx('ITEM_AMMO_BACKPACK', GameWAD
+':TEXTURES\BPACK');
185 g_Texture_CreateWADEx('ITEM_KEY_RED', GameWAD
+':TEXTURES\KEYR');
186 g_Texture_CreateWADEx('ITEM_KEY_GREEN', GameWAD
+':TEXTURES\KEYG');
187 g_Texture_CreateWADEx('ITEM_KEY_BLUE', GameWAD
+':TEXTURES\KEYB');
188 g_Texture_CreateWADEx('ITEM_OXYGEN', GameWAD
+':TEXTURES\OXYGEN');
189 g_Texture_CreateWADEx('ITEM_SUIT', GameWAD
+':TEXTURES\SUIT');
190 g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD
+':TEXTURES\KASTET');
191 g_Texture_CreateWADEx('ITEM_MEDKIT_BLACK', GameWAD
+':TEXTURES\BMED');
192 g_Texture_CreateWADEx('ITEM_JETPACK', GameWAD
+':TEXTURES\JETPACK');
197 procedure g_Items_FreeData();
199 e_WriteLog('Releasing items data...', MSG_NOTIFY
);
201 g_Sound_Delete('SOUND_ITEM_RESPAWNITEM');
202 g_Sound_Delete('SOUND_ITEM_GETRULEZ');
203 g_Sound_Delete('SOUND_ITEM_GETWEAPON');
204 g_Sound_Delete('SOUND_ITEM_GETITEM');
206 g_Frames_DeleteByName('FRAMES_ITEM_BLUESPHERE');
207 g_Frames_DeleteByName('FRAMES_ITEM_WHITESPHERE');
208 g_Frames_DeleteByName('FRAMES_ITEM_ARMORGREEN');
209 g_Frames_DeleteByName('FRAMES_ITEM_ARMORBLUE');
210 g_Frames_DeleteByName('FRAMES_ITEM_INVUL');
211 g_Frames_DeleteByName('FRAMES_ITEM_INVIS');
212 g_Frames_DeleteByName('FRAMES_ITEM_RESPAWN');
213 g_Frames_DeleteByName('FRAMES_ITEM_BOTTLE');
214 g_Frames_DeleteByName('FRAMES_ITEM_HELMET');
215 g_Frames_DeleteByName('FRAMES_FLAG_RED');
216 g_Frames_DeleteByName('FRAMES_FLAG_BLUE');
217 g_Frames_DeleteByName('FRAMES_FLAG_DOM');
218 g_Texture_Delete('ITEM_MEDKIT_SMALL');
219 g_Texture_Delete('ITEM_MEDKIT_LARGE');
220 g_Texture_Delete('ITEM_WEAPON_SAW');
221 g_Texture_Delete('ITEM_WEAPON_PISTOL');
222 g_Texture_Delete('ITEM_WEAPON_KASTET');
223 g_Texture_Delete('ITEM_WEAPON_SHOTGUN1');
224 g_Texture_Delete('ITEM_WEAPON_SHOTGUN2');
225 g_Texture_Delete('ITEM_WEAPON_CHAINGUN');
226 g_Texture_Delete('ITEM_WEAPON_ROCKETLAUNCHER');
227 g_Texture_Delete('ITEM_WEAPON_PLASMA');
228 g_Texture_Delete('ITEM_WEAPON_BFG');
229 g_Texture_Delete('ITEM_WEAPON_SUPERPULEMET');
230 g_Texture_Delete('ITEM_WEAPON_FLAMETHROWER');
231 g_Texture_Delete('ITEM_AMMO_BULLETS');
232 g_Texture_Delete('ITEM_AMMO_BULLETS_BOX');
233 g_Texture_Delete('ITEM_AMMO_SHELLS');
234 g_Texture_Delete('ITEM_AMMO_SHELLS_BOX');
235 g_Texture_Delete('ITEM_AMMO_ROCKET');
236 g_Texture_Delete('ITEM_AMMO_ROCKET_BOX');
237 g_Texture_Delete('ITEM_AMMO_CELL');
238 g_Texture_Delete('ITEM_AMMO_CELL_BIG');
239 g_Texture_Delete('ITEM_AMMO_FUELCAN');
240 g_Texture_Delete('ITEM_AMMO_BACKPACK');
241 g_Texture_Delete('ITEM_KEY_RED');
242 g_Texture_Delete('ITEM_KEY_GREEN');
243 g_Texture_Delete('ITEM_KEY_BLUE');
244 g_Texture_Delete('ITEM_OXYGEN');
245 g_Texture_Delete('ITEM_SUIT');
246 g_Texture_Delete('ITEM_WEAPON_KASTET');
247 g_Texture_Delete('ITEM_MEDKIT_BLACK');
248 g_Texture_Delete('ITEM_JETPACK');
251 function FindItem(): DWORD
;
255 if gItems
<> nil then
256 for i
:= 0 to High(gItems
) do
257 if gItems
[i
].ItemType
= ITEM_NONE
then
265 SetLength(gItems
, 32);
270 Result
:= High(gItems
) + 1;
271 SetLength(gItems
, Length(gItems
) + 32);
275 procedure g_Items_Init();
279 if gMapInfo
.Height
> gPlayerScreenSize
.Y
then
280 a
:= gMapInfo
.Height
- gPlayerScreenSize
.Y
282 a
:= gMapInfo
.Height
;
284 if gMapInfo
.Width
> gPlayerScreenSize
.X
then
285 b
:= gMapInfo
.Width
- gPlayerScreenSize
.X
289 gMaxDist
:= Trunc(Hypot(a
, b
));
292 procedure g_Items_Free();
296 if gItems
<> nil then
298 for i
:= 0 to High(gItems
) do
299 gItems
[i
].Animation
.Free();
304 function g_Items_Create(X
, Y
: Integer; ItemType
: Byte;
305 Fall
, Respawnable
: Boolean; AdjCoord
: Boolean = False; ForcedID
: Integer = -1): DWORD
;
311 find_id
:= FindItem()
315 if Integer(find_id
) > High(gItems
) then
316 SetLength(gItems
, find_id
+ 32);
319 gItems
[find_id
].ItemType
:= ItemType
;
320 gItems
[find_id
].Respawnable
:= Respawnable
;
321 if g_Game_IsServer
and (ITEM_RESPAWNTIME
= 0) then
322 gItems
[find_id
].Respawnable
:= False;
323 gItems
[find_id
].InitX
:= X
;
324 gItems
[find_id
].InitY
:= Y
;
325 gItems
[find_id
].RespawnTime
:= 0;
326 gItems
[find_id
].Fall
:= Fall
;
327 gItems
[find_id
].Live
:= True;
328 gItems
[find_id
].QuietRespawn
:= False;
330 g_Obj_Init(@gItems
[find_id
].Obj
);
331 gItems
[find_id
].Obj
.X
:= X
;
332 gItems
[find_id
].Obj
.Y
:= Y
;
333 gItems
[find_id
].Obj
.Rect
.Width
:= ITEMSIZE
[ItemType
][0];
334 gItems
[find_id
].Obj
.Rect
.Height
:= ITEMSIZE
[ItemType
][1];
336 gItems
[find_id
].Animation
:= nil;
337 gItems
[find_id
].SpawnTrigger
:= -1;
339 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà:
341 with gItems
[find_id
] do
343 Obj
.X
:= X
- (Obj
.Rect
.Width
div 2);
344 Obj
.Y
:= Y
- Obj
.Rect
.Height
;
349 // Óñòàíîâêà àíèìàöèè:
350 with gItems
[find_id
] do
354 if g_Frames_Get(ID
, 'FRAMES_ITEM_ARMORGREEN') then
355 Animation
:= TAnimation
.Create(ID
, True, 20);
357 if g_Frames_Get(ID
, 'FRAMES_ITEM_ARMORBLUE') then
358 Animation
:= TAnimation
.Create(ID
, True, 20);
360 if g_Frames_Get(ID
, 'FRAMES_ITEM_BLUESPHERE') then
361 Animation
:= TAnimation
.Create(ID
, True, 15);
363 if g_Frames_Get(ID
, 'FRAMES_ITEM_WHITESPHERE') then
364 Animation
:= TAnimation
.Create(ID
, True, 20);
366 if g_Frames_Get(ID
, 'FRAMES_ITEM_INVUL') then
367 Animation
:= TAnimation
.Create(ID
, True, 20);
369 if g_Frames_Get(ID
, 'FRAMES_ITEM_INVIS') then
370 Animation
:= TAnimation
.Create(ID
, True, 20);
372 if g_Frames_Get(ID
, 'FRAMES_ITEM_BOTTLE') then
373 Animation
:= TAnimation
.Create(ID
, True, 20);
375 if g_Frames_Get(ID
, 'FRAMES_ITEM_HELMET') then
376 Animation
:= TAnimation
.Create(ID
, True, 20);
383 procedure g_Items_Update();
391 if gItems
<> nil then
392 for i
:= 0 to High(gItems
) do
393 if gItems
[i
].ItemType
<> ITEM_NONE
then
402 m
:= g_Obj_Move(@Obj
, True, True);
404 // Ñîïðîòèâëåíèå âîçäóõà:
405 if gTime
mod (GAME_TICK
*2) = 0 then
406 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
407 // Åñëè âûïàë çà êàðòó:
408 if WordBool(m
and MOVE_FALLOUT
) then
410 if SpawnTrigger
= -1 then
414 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_ItemDestroy(True, i
);
420 // Åñëè èãðîêè ïîáëèçîñòè:
421 if gPlayers
<> nil then
423 j
:= Random(Length(gPlayers
)) - 1;
425 for k
:= 0 to High(gPlayers
) do
428 if j
> High(gPlayers
) then
431 if (gPlayers
[j
] <> nil) and gPlayers
[j
].Live
and
432 g_Obj_Collide(@gPlayers
[j
].Obj
, @Obj
) then
434 if g_Game_IsClient
then Continue
;
436 if not gPlayers
[j
].PickItem(ItemType
, Respawnable
, r
) then
439 if g_Game_IsNet
then MH_SEND_PlayerStats(gPlayers
[j
].UID
);
443 1. I_NONE,I_CLIP,I_SHEL,I_ROCKET,I_CELL,I_AMMO,I_SBOX,I_RBOX,I_CELP,I_BPACK,I_CSAW,I_SGUN,I_SGUN2,I_MGUN,I_LAUN,I_PLAS,I_BFG,I_GUN2
444 +2. I_MEGA,I_INVL,I_SUPER
445 3. I_STIM,I_MEDI,I_ARM1,I_ARM2,I_AQUA,I_KEYR,I_KEYG,I_KEYB,I_SUIT,I_RTORCH,I_GTORCH,I_BTORCH,I_GOR1,I_FCAN
448 if gSoundEffectsDF
then
450 if ItemType
in [ITEM_SPHERE_BLUE
, ITEM_SPHERE_WHITE
, ITEM_INVUL
,
451 ITEM_INVIS
, ITEM_MEDKIT_BLACK
, ITEM_JETPACK
] then
452 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ',
453 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
)
455 if ItemType
in [ITEM_WEAPON_SAW
, ITEM_WEAPON_PISTOL
, ITEM_WEAPON_SHOTGUN1
, ITEM_WEAPON_SHOTGUN2
,
456 ITEM_WEAPON_CHAINGUN
, ITEM_WEAPON_ROCKETLAUNCHER
, ITEM_WEAPON_PLASMA
,
457 ITEM_WEAPON_BFG
, ITEM_WEAPON_SUPERPULEMET
, ITEM_WEAPON_FLAMETHROWER
,
458 ITEM_AMMO_BACKPACK
] then
459 g_Sound_PlayExAt('SOUND_ITEM_GETWEAPON',
460 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
)
462 g_Sound_PlayExAt('SOUND_ITEM_GETITEM',
463 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
);
467 if ItemType
in [ITEM_SPHERE_BLUE
, ITEM_SPHERE_WHITE
, ITEM_SUIT
,
468 ITEM_MEDKIT_BLACK
, ITEM_INVUL
, ITEM_INVIS
, ITEM_JETPACK
] then
469 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ',
470 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
)
472 if ItemType
in [ITEM_WEAPON_SAW
, ITEM_WEAPON_PISTOL
, ITEM_WEAPON_SHOTGUN1
, ITEM_WEAPON_SHOTGUN2
,
473 ITEM_WEAPON_CHAINGUN
, ITEM_WEAPON_ROCKETLAUNCHER
, ITEM_WEAPON_PLASMA
,
474 ITEM_WEAPON_BFG
, ITEM_WEAPON_SUPERPULEMET
, ITEM_WEAPON_FLAMETHROWER
] then
475 g_Sound_PlayExAt('SOUND_ITEM_GETWEAPON',
476 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
)
478 g_Sound_PlayExAt('SOUND_ITEM_GETITEM',
479 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
);
482 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì:
485 if not Respawnable
then
490 if g_Game_IsNet
then MH_SEND_ItemDestroy(False, i
);
502 if Respawnable
and g_Game_IsServer
then
504 DecMin(RespawnTime
, 0);
505 if (RespawnTime
= 0) and (not Live
) then
507 if not QuietRespawn
then
508 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', InitX
, InitY
);
510 if g_Frames_Get(ID
, 'FRAMES_ITEM_RESPAWN') then
512 Anim
:= TAnimation
.Create(ID
, False, 4);
513 g_GFX_OnceAnim(InitX
+(Obj
.Rect
.Width
div 2)-16, InitY
+(Obj
.Rect
.Height
div 2)-16, Anim
);
526 if g_Game_IsNet
then MH_SEND_ItemSpawn(QuietRespawn
, i
);
527 QuietRespawn
:= False;
531 if Animation
<> nil then
536 procedure g_Items_Draw();
540 if gItems
<> nil then
541 for i
:= 0 to High(gItems
) do
542 if gItems
[i
].Live
then
544 if g_Collide(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
545 sX
, sY
, sWidth
, sHeight
) then
547 if Animation
= nil then
548 e_Draw(gItemsTexturesID
[ItemType
], Obj
.X
, Obj
.Y
, 0, True, False)
550 Animation
.Draw(Obj
.X
, Obj
.Y
, M_NONE
);
552 if g_debug_Frames
then
554 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
556 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
557 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
563 procedure g_Items_Pick(ID
: DWORD
);
565 gItems
[ID
].Live
:= False;
566 gItems
[ID
].RespawnTime
:= ITEM_RESPAWNTIME
;
569 procedure g_Items_Remove(ID
: DWORD
);
571 gItems
[ID
].ItemType
:= ITEM_NONE
;
573 if gItems
[ID
].Animation
<> nil then
575 gItems
[ID
].Animation
.Free();
576 gItems
[ID
].Animation
:= nil;
579 gItems
[ID
].Live
:= False;
581 if gItems
[ID
].SpawnTrigger
> -1 then
583 g_Triggers_DecreaseSpawner(gItems
[ID
].SpawnTrigger
);
584 gItems
[ID
].SpawnTrigger
:= -1;
588 procedure g_Items_SaveState(var Mem
: TBinMemoryWriter
);
593 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ:
595 if gItems
<> nil then
596 for i
:= 0 to High(gItems
) do
597 if gItems
[i
].ItemType
<> ITEM_NONE
then
600 Mem
:= TBinMemoryWriter
.Create((count
+1) * 60);
602 // Êîëè÷åñòâî ïðåäìåòîâ:
608 for i
:= 0 to High(gItems
) do
609 if gItems
[i
].ItemType
<> ITEM_NONE
then
611 // Ñèãíàòóðà ïðåäìåòà:
612 sig
:= ITEM_SIGNATURE
; // 'ITEM'
615 Mem
.WriteByte(gItems
[i
].ItemType
);
617 Mem
.WriteBoolean(gItems
[i
].Respawnable
);
618 // Êîîðäèíàòû ðåñïóíà:
619 Mem
.WriteInt(gItems
[i
].InitX
);
620 Mem
.WriteInt(gItems
[i
].InitY
);
621 // Âðåìÿ äî ðåñïàóíà:
622 Mem
.WriteWord(gItems
[i
].RespawnTime
);
623 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò:
624 Mem
.WriteBoolean(gItems
[i
].Live
);
625 // Ìîæåò ëè îí ïàäàòü:
626 Mem
.WriteBoolean(gItems
[i
].Fall
);
627 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò:
628 Mem
.WriteInt(gItems
[i
].SpawnTrigger
);
630 Obj_SaveState(@gItems
[i
].Obj
, Mem
);
634 procedure g_Items_LoadState(var Mem
: TBinMemoryReader
);
636 count
, i
, a
: Integer;
645 // Êîëè÷åñòâî ïðåäìåòîâ:
651 for a
:= 0 to count
-1 do
653 // Ñèãíàòóðà ïðåäìåòà:
655 if sig
<> ITEM_SIGNATURE
then // 'ITEM'
657 raise EBinSizeError
.Create('g_Items_LoadState: Wrong Item Signature');
662 i
:= g_Items_Create(0, 0, b
, False, False);
664 Mem
.ReadBoolean(gItems
[i
].Respawnable
);
665 // Êîîðäèíàòû ðåñïóíà:
666 Mem
.ReadInt(gItems
[i
].InitX
);
667 Mem
.ReadInt(gItems
[i
].InitY
);
668 // Âðåìÿ äî ðåñïàóíà:
669 Mem
.ReadWord(gItems
[i
].RespawnTime
);
670 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò:
671 Mem
.ReadBoolean(gItems
[i
].Live
);
672 // Ìîæåò ëè îí ïàäàòü:
673 Mem
.ReadBoolean(gItems
[i
].Fall
);
674 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò:
675 Mem
.ReadInt(gItems
[i
].SpawnTrigger
);
677 Obj_LoadState(@gItems
[i
].Obj
, Mem
);