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/>.
22 g_textures
, g_phys
, g_saveload
, BinEditor
;
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..35] 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
105 procedure InitTextures();
107 g_Texture_Get('ITEM_MEDKIT_SMALL', gItemsTexturesID
[ITEM_MEDKIT_SMALL
]);
108 g_Texture_Get('ITEM_MEDKIT_LARGE', gItemsTexturesID
[ITEM_MEDKIT_LARGE
]);
109 g_Texture_Get('ITEM_MEDKIT_BLACK', gItemsTexturesID
[ITEM_MEDKIT_BLACK
]);
110 g_Texture_Get('ITEM_SUIT', gItemsTexturesID
[ITEM_SUIT
]);
111 g_Texture_Get('ITEM_OXYGEN', gItemsTexturesID
[ITEM_OXYGEN
]);
112 g_Texture_Get('ITEM_WEAPON_SAW', gItemsTexturesID
[ITEM_WEAPON_SAW
]);
113 g_Texture_Get('ITEM_WEAPON_SHOTGUN1', gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
]);
114 g_Texture_Get('ITEM_WEAPON_SHOTGUN2', gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
]);
115 g_Texture_Get('ITEM_WEAPON_CHAINGUN', gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
]);
116 g_Texture_Get('ITEM_WEAPON_ROCKETLAUNCHER', gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
]);
117 g_Texture_Get('ITEM_WEAPON_PLASMA', gItemsTexturesID
[ITEM_WEAPON_PLASMA
]);
118 g_Texture_Get('ITEM_WEAPON_BFG', gItemsTexturesID
[ITEM_WEAPON_BFG
]);
119 g_Texture_Get('ITEM_WEAPON_SUPERPULEMET', gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
]);
120 g_Texture_Get('ITEM_AMMO_BULLETS', gItemsTexturesID
[ITEM_AMMO_BULLETS
]);
121 g_Texture_Get('ITEM_AMMO_BULLETS_BOX', gItemsTexturesID
[ITEM_AMMO_BULLETS_BOX
]);
122 g_Texture_Get('ITEM_AMMO_SHELLS', gItemsTexturesID
[ITEM_AMMO_SHELLS
]);
123 g_Texture_Get('ITEM_AMMO_SHELLS_BOX', gItemsTexturesID
[ITEM_AMMO_SHELLS_BOX
]);
124 g_Texture_Get('ITEM_AMMO_ROCKET', gItemsTexturesID
[ITEM_AMMO_ROCKET
]);
125 g_Texture_Get('ITEM_AMMO_ROCKET_BOX', gItemsTexturesID
[ITEM_AMMO_ROCKET_BOX
]);
126 g_Texture_Get('ITEM_AMMO_CELL', gItemsTexturesID
[ITEM_AMMO_CELL
]);
127 g_Texture_Get('ITEM_AMMO_CELL_BIG', gItemsTexturesID
[ITEM_AMMO_CELL_BIG
]);
128 g_Texture_Get('ITEM_AMMO_BACKPACK', gItemsTexturesID
[ITEM_AMMO_BACKPACK
]);
129 g_Texture_Get('ITEM_KEY_RED', gItemsTexturesID
[ITEM_KEY_RED
]);
130 g_Texture_Get('ITEM_KEY_GREEN', gItemsTexturesID
[ITEM_KEY_GREEN
]);
131 g_Texture_Get('ITEM_KEY_BLUE', gItemsTexturesID
[ITEM_KEY_BLUE
]);
132 g_Texture_Get('ITEM_WEAPON_KASTET', gItemsTexturesID
[ITEM_WEAPON_KASTET
]);
133 g_Texture_Get('ITEM_WEAPON_PISTOL', gItemsTexturesID
[ITEM_WEAPON_PISTOL
]);
134 g_Texture_Get('ITEM_JETPACK', gItemsTexturesID
[ITEM_JETPACK
]);
137 procedure g_Items_LoadData();
139 e_WriteLog('Loading items data...', MSG_NOTIFY
);
141 g_Sound_CreateWADEx('SOUND_ITEM_RESPAWNITEM', GameWAD
+':SOUNDS\RESPAWNITEM');
142 g_Sound_CreateWADEx('SOUND_ITEM_GETRULEZ', GameWAD
+':SOUNDS\GETRULEZ');
143 g_Sound_CreateWADEx('SOUND_ITEM_GETWEAPON', GameWAD
+':SOUNDS\GETWEAPON');
144 g_Sound_CreateWADEx('SOUND_ITEM_GETITEM', GameWAD
+':SOUNDS\GETITEM');
146 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BLUESPHERE', GameWAD
+':TEXTURES\SBLUE', 32, 32, 4, True);
147 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_WHITESPHERE', GameWAD
+':TEXTURES\SWHITE', 32, 32, 4, True);
148 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORGREEN', GameWAD
+':TEXTURES\ARMORGREEN', 32, 16, 3, True);
149 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORBLUE', GameWAD
+':TEXTURES\ARMORBLUE', 32, 16, 3, True);
150 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVUL', GameWAD
+':TEXTURES\INVUL', 32, 32, 4, True);
151 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVIS', GameWAD
+':TEXTURES\INVIS', 32, 32, 4, True);
152 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_RESPAWN', GameWAD
+':TEXTURES\ITEMRESPAWN', 32, 32, 5, True);
153 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BOTTLE', GameWAD
+':TEXTURES\BOTTLE', 16, 32, 4, True);
154 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_HELMET', GameWAD
+':TEXTURES\HELMET', 16, 16, 4, True);
155 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_RED', GameWAD
+':TEXTURES\FLAGRED', 64, 64, 5, False);
156 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_BLUE', GameWAD
+':TEXTURES\FLAGBLUE', 64, 64, 5, False);
157 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_DOM', GameWAD
+':TEXTURES\FLAGDOM', 64, 64, 5, False);
158 g_Texture_CreateWADEx('ITEM_MEDKIT_SMALL', GameWAD
+':TEXTURES\MED1');
159 g_Texture_CreateWADEx('ITEM_MEDKIT_LARGE', GameWAD
+':TEXTURES\MED2');
160 g_Texture_CreateWADEx('ITEM_WEAPON_SAW', GameWAD
+':TEXTURES\SAW');
161 g_Texture_CreateWADEx('ITEM_WEAPON_PISTOL', GameWAD
+':TEXTURES\PISTOL');
162 g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD
+':TEXTURES\KASTET');
163 g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN1', GameWAD
+':TEXTURES\SHOTGUN1');
164 g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN2', GameWAD
+':TEXTURES\SHOTGUN2');
165 g_Texture_CreateWADEx('ITEM_WEAPON_CHAINGUN', GameWAD
+':TEXTURES\MGUN');
166 g_Texture_CreateWADEx('ITEM_WEAPON_ROCKETLAUNCHER', GameWAD
+':TEXTURES\RLAUNCHER');
167 g_Texture_CreateWADEx('ITEM_WEAPON_PLASMA', GameWAD
+':TEXTURES\PGUN');
168 g_Texture_CreateWADEx('ITEM_WEAPON_BFG', GameWAD
+':TEXTURES\BFG');
169 g_Texture_CreateWADEx('ITEM_WEAPON_SUPERPULEMET', GameWAD
+':TEXTURES\SPULEMET');
170 g_Texture_CreateWADEx('ITEM_AMMO_BULLETS', GameWAD
+':TEXTURES\CLIP');
171 g_Texture_CreateWADEx('ITEM_AMMO_BULLETS_BOX', GameWAD
+':TEXTURES\AMMO');
172 g_Texture_CreateWADEx('ITEM_AMMO_SHELLS', GameWAD
+':TEXTURES\SHELL1');
173 g_Texture_CreateWADEx('ITEM_AMMO_SHELLS_BOX', GameWAD
+':TEXTURES\SHELL2');
174 g_Texture_CreateWADEx('ITEM_AMMO_ROCKET', GameWAD
+':TEXTURES\ROCKET');
175 g_Texture_CreateWADEx('ITEM_AMMO_ROCKET_BOX', GameWAD
+':TEXTURES\ROCKETS');
176 g_Texture_CreateWADEx('ITEM_AMMO_CELL', GameWAD
+':TEXTURES\CELL');
177 g_Texture_CreateWADEx('ITEM_AMMO_CELL_BIG', GameWAD
+':TEXTURES\CELL2');
178 g_Texture_CreateWADEx('ITEM_AMMO_BACKPACK', GameWAD
+':TEXTURES\BPACK');
179 g_Texture_CreateWADEx('ITEM_KEY_RED', GameWAD
+':TEXTURES\KEYR');
180 g_Texture_CreateWADEx('ITEM_KEY_GREEN', GameWAD
+':TEXTURES\KEYG');
181 g_Texture_CreateWADEx('ITEM_KEY_BLUE', GameWAD
+':TEXTURES\KEYB');
182 g_Texture_CreateWADEx('ITEM_OXYGEN', GameWAD
+':TEXTURES\OXYGEN');
183 g_Texture_CreateWADEx('ITEM_SUIT', GameWAD
+':TEXTURES\SUIT');
184 g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD
+':TEXTURES\KASTET');
185 g_Texture_CreateWADEx('ITEM_MEDKIT_BLACK', GameWAD
+':TEXTURES\BMED');
186 g_Texture_CreateWADEx('ITEM_JETPACK', GameWAD
+':TEXTURES\JETPACK');
191 procedure g_Items_FreeData();
193 e_WriteLog('Releasing items data...', MSG_NOTIFY
);
195 g_Sound_Delete('SOUND_ITEM_RESPAWNITEM');
196 g_Sound_Delete('SOUND_ITEM_GETRULEZ');
197 g_Sound_Delete('SOUND_ITEM_GETWEAPON');
198 g_Sound_Delete('SOUND_ITEM_GETITEM');
200 g_Frames_DeleteByName('FRAMES_ITEM_BLUESPHERE');
201 g_Frames_DeleteByName('FRAMES_ITEM_WHITESPHERE');
202 g_Frames_DeleteByName('FRAMES_ITEM_ARMORGREEN');
203 g_Frames_DeleteByName('FRAMES_ITEM_ARMORBLUE');
204 g_Frames_DeleteByName('FRAMES_ITEM_INVUL');
205 g_Frames_DeleteByName('FRAMES_ITEM_INVIS');
206 g_Frames_DeleteByName('FRAMES_ITEM_RESPAWN');
207 g_Frames_DeleteByName('FRAMES_ITEM_BOTTLE');
208 g_Frames_DeleteByName('FRAMES_ITEM_HELMET');
209 g_Frames_DeleteByName('FRAMES_FLAG_RED');
210 g_Frames_DeleteByName('FRAMES_FLAG_BLUE');
211 g_Frames_DeleteByName('FRAMES_FLAG_DOM');
212 g_Texture_Delete('ITEM_MEDKIT_SMALL');
213 g_Texture_Delete('ITEM_MEDKIT_LARGE');
214 g_Texture_Delete('ITEM_WEAPON_SAW');
215 g_Texture_Delete('ITEM_WEAPON_PISTOL');
216 g_Texture_Delete('ITEM_WEAPON_KASTET');
217 g_Texture_Delete('ITEM_WEAPON_SHOTGUN1');
218 g_Texture_Delete('ITEM_WEAPON_SHOTGUN2');
219 g_Texture_Delete('ITEM_WEAPON_CHAINGUN');
220 g_Texture_Delete('ITEM_WEAPON_ROCKETLAUNCHER');
221 g_Texture_Delete('ITEM_WEAPON_PLASMA');
222 g_Texture_Delete('ITEM_WEAPON_BFG');
223 g_Texture_Delete('ITEM_WEAPON_SUPERPULEMET');
224 g_Texture_Delete('ITEM_AMMO_BULLETS');
225 g_Texture_Delete('ITEM_AMMO_BULLETS_BOX');
226 g_Texture_Delete('ITEM_AMMO_SHELLS');
227 g_Texture_Delete('ITEM_AMMO_SHELLS_BOX');
228 g_Texture_Delete('ITEM_AMMO_ROCKET');
229 g_Texture_Delete('ITEM_AMMO_ROCKET_BOX');
230 g_Texture_Delete('ITEM_AMMO_CELL');
231 g_Texture_Delete('ITEM_AMMO_CELL_BIG');
232 g_Texture_Delete('ITEM_AMMO_BACKPACK');
233 g_Texture_Delete('ITEM_KEY_RED');
234 g_Texture_Delete('ITEM_KEY_GREEN');
235 g_Texture_Delete('ITEM_KEY_BLUE');
236 g_Texture_Delete('ITEM_OXYGEN');
237 g_Texture_Delete('ITEM_SUIT');
238 g_Texture_Delete('ITEM_WEAPON_KASTET');
239 g_Texture_Delete('ITEM_MEDKIT_BLACK');
240 g_Texture_Delete('ITEM_JETPACK');
243 function FindItem(): DWORD
;
247 if gItems
<> nil then
248 for i
:= 0 to High(gItems
) do
249 if gItems
[i
].ItemType
= ITEM_NONE
then
257 SetLength(gItems
, 32);
262 Result
:= High(gItems
) + 1;
263 SetLength(gItems
, Length(gItems
) + 32);
267 procedure g_Items_Init();
271 if gMapInfo
.Height
> gPlayerScreenSize
.Y
then
272 a
:= gMapInfo
.Height
- gPlayerScreenSize
.Y
274 a
:= gMapInfo
.Height
;
276 if gMapInfo
.Width
> gPlayerScreenSize
.X
then
277 b
:= gMapInfo
.Width
- gPlayerScreenSize
.X
281 gMaxDist
:= Trunc(Hypot(a
, b
));
284 procedure g_Items_Free();
288 if gItems
<> nil then
290 for i
:= 0 to High(gItems
) do
291 gItems
[i
].Animation
.Free();
296 function g_Items_Create(X
, Y
: Integer; ItemType
: Byte;
297 Fall
, Respawnable
: Boolean; AdjCoord
: Boolean = False; ForcedID
: Integer = -1): DWORD
;
303 find_id
:= FindItem()
307 if Integer(find_id
) > High(gItems
) then
308 SetLength(gItems
, find_id
+ 32);
311 gItems
[find_id
].ItemType
:= ItemType
;
312 gItems
[find_id
].Respawnable
:= Respawnable
;
313 if g_Game_IsServer
and (ITEM_RESPAWNTIME
= 0) then
314 gItems
[find_id
].Respawnable
:= False;
315 gItems
[find_id
].InitX
:= X
;
316 gItems
[find_id
].InitY
:= Y
;
317 gItems
[find_id
].RespawnTime
:= 0;
318 gItems
[find_id
].Fall
:= Fall
;
319 gItems
[find_id
].Live
:= True;
320 gItems
[find_id
].QuietRespawn
:= False;
322 g_Obj_Init(@gItems
[find_id
].Obj
);
323 gItems
[find_id
].Obj
.X
:= X
;
324 gItems
[find_id
].Obj
.Y
:= Y
;
325 gItems
[find_id
].Obj
.Rect
.Width
:= ITEMSIZE
[ItemType
][0];
326 gItems
[find_id
].Obj
.Rect
.Height
:= ITEMSIZE
[ItemType
][1];
328 gItems
[find_id
].Animation
:= nil;
329 gItems
[find_id
].SpawnTrigger
:= -1;
331 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà:
333 with gItems
[find_id
] do
335 Obj
.X
:= X
- (Obj
.Rect
.Width
div 2);
336 Obj
.Y
:= Y
- Obj
.Rect
.Height
;
341 // Óñòàíîâêà àíèìàöèè:
342 with gItems
[find_id
] do
346 if g_Frames_Get(ID
, 'FRAMES_ITEM_ARMORGREEN') then
347 Animation
:= TAnimation
.Create(ID
, True, 20);
349 if g_Frames_Get(ID
, 'FRAMES_ITEM_ARMORBLUE') then
350 Animation
:= TAnimation
.Create(ID
, True, 20);
352 if g_Frames_Get(ID
, 'FRAMES_ITEM_BLUESPHERE') then
353 Animation
:= TAnimation
.Create(ID
, True, 15);
355 if g_Frames_Get(ID
, 'FRAMES_ITEM_WHITESPHERE') then
356 Animation
:= TAnimation
.Create(ID
, True, 20);
358 if g_Frames_Get(ID
, 'FRAMES_ITEM_INVUL') then
359 Animation
:= TAnimation
.Create(ID
, True, 20);
361 if g_Frames_Get(ID
, 'FRAMES_ITEM_INVIS') then
362 Animation
:= TAnimation
.Create(ID
, True, 20);
364 if g_Frames_Get(ID
, 'FRAMES_ITEM_BOTTLE') then
365 Animation
:= TAnimation
.Create(ID
, True, 20);
367 if g_Frames_Get(ID
, 'FRAMES_ITEM_HELMET') then
368 Animation
:= TAnimation
.Create(ID
, True, 20);
375 procedure g_Items_Update();
383 if gItems
<> nil then
384 for i
:= 0 to High(gItems
) do
385 if gItems
[i
].ItemType
<> ITEM_NONE
then
394 m
:= g_Obj_Move(@Obj
, True, True);
396 // Ñîïðîòèâëåíèå âîçäóõà:
397 if gTime
mod (GAME_TICK
*2) = 0 then
398 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
399 // Åñëè âûïàë çà êàðòó:
400 if WordBool(m
and MOVE_FALLOUT
) then
402 if SpawnTrigger
= -1 then
406 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_ItemDestroy(True, i
);
412 // Åñëè èãðîêè ïîáëèçîñòè:
413 if gPlayers
<> nil then
415 j
:= Random(Length(gPlayers
)) - 1;
417 for k
:= 0 to High(gPlayers
) do
420 if j
> High(gPlayers
) then
423 if (gPlayers
[j
] <> nil) and gPlayers
[j
].Live
and
424 g_Obj_Collide(@gPlayers
[j
].Obj
, @Obj
) then
426 if g_Game_IsClient
then Continue
;
428 if not gPlayers
[j
].PickItem(ItemType
, Respawnable
, r
) then
431 if g_Game_IsNet
then MH_SEND_PlayerStats(gPlayers
[j
].UID
);
435 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
436 +2. I_MEGA,I_INVL,I_SUPER
437 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
440 if gSoundEffectsDF
then
442 if ItemType
in [ITEM_SPHERE_BLUE
, ITEM_SPHERE_WHITE
, ITEM_INVUL
,
443 ITEM_INVIS
, ITEM_MEDKIT_BLACK
, ITEM_JETPACK
] then
444 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ',
445 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
)
447 if ItemType
in [ITEM_WEAPON_SAW
, ITEM_WEAPON_PISTOL
, ITEM_WEAPON_SHOTGUN1
, ITEM_WEAPON_SHOTGUN2
,
448 ITEM_WEAPON_CHAINGUN
, ITEM_WEAPON_ROCKETLAUNCHER
, ITEM_WEAPON_PLASMA
,
449 ITEM_WEAPON_BFG
, ITEM_WEAPON_SUPERPULEMET
, ITEM_AMMO_BACKPACK
] then
450 g_Sound_PlayExAt('SOUND_ITEM_GETWEAPON',
451 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
)
453 g_Sound_PlayExAt('SOUND_ITEM_GETITEM',
454 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
);
458 if ItemType
in [ITEM_SPHERE_BLUE
, ITEM_SPHERE_WHITE
, ITEM_SUIT
,
459 ITEM_MEDKIT_BLACK
, ITEM_INVUL
, ITEM_INVIS
, ITEM_JETPACK
] then
460 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ',
461 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
)
463 if ItemType
in [ITEM_WEAPON_SAW
, ITEM_WEAPON_PISTOL
, ITEM_WEAPON_SHOTGUN1
, ITEM_WEAPON_SHOTGUN2
,
464 ITEM_WEAPON_CHAINGUN
, ITEM_WEAPON_ROCKETLAUNCHER
, ITEM_WEAPON_PLASMA
,
465 ITEM_WEAPON_BFG
, ITEM_WEAPON_SUPERPULEMET
] then
466 g_Sound_PlayExAt('SOUND_ITEM_GETWEAPON',
467 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
)
469 g_Sound_PlayExAt('SOUND_ITEM_GETITEM',
470 gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
);
473 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì:
476 if not Respawnable
then
481 if g_Game_IsNet
then MH_SEND_ItemDestroy(False, i
);
493 if Respawnable
and g_Game_IsServer
then
495 DecMin(RespawnTime
, 0);
496 if (RespawnTime
= 0) and (not Live
) then
498 if not QuietRespawn
then
499 g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', InitX
, InitY
);
501 if g_Frames_Get(ID
, 'FRAMES_ITEM_RESPAWN') then
503 Anim
:= TAnimation
.Create(ID
, False, 4);
504 g_GFX_OnceAnim(InitX
+(Obj
.Rect
.Width
div 2)-16, InitY
+(Obj
.Rect
.Height
div 2)-16, Anim
);
517 if g_Game_IsNet
then MH_SEND_ItemSpawn(QuietRespawn
, i
);
518 QuietRespawn
:= False;
522 if Animation
<> nil then
527 procedure g_Items_Draw();
531 if gItems
<> nil then
532 for i
:= 0 to High(gItems
) do
533 if gItems
[i
].Live
then
535 if g_Collide(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
,
536 sX
, sY
, sWidth
, sHeight
) then
538 if Animation
= nil then
539 e_Draw(gItemsTexturesID
[ItemType
], Obj
.X
, Obj
.Y
, 0, True, False)
541 Animation
.Draw(Obj
.X
, Obj
.Y
, M_NONE
);
543 if g_debug_Frames
then
545 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
547 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
548 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
554 procedure g_Items_Pick(ID
: DWORD
);
556 gItems
[ID
].Live
:= False;
557 gItems
[ID
].RespawnTime
:= ITEM_RESPAWNTIME
;
560 procedure g_Items_Remove(ID
: DWORD
);
562 gItems
[ID
].ItemType
:= ITEM_NONE
;
564 if gItems
[ID
].Animation
<> nil then
566 gItems
[ID
].Animation
.Free();
567 gItems
[ID
].Animation
:= nil;
570 gItems
[ID
].Live
:= False;
572 if gItems
[ID
].SpawnTrigger
> -1 then
574 g_Triggers_DecreaseSpawner(gItems
[ID
].SpawnTrigger
);
575 gItems
[ID
].SpawnTrigger
:= -1;
579 procedure g_Items_SaveState(var Mem
: TBinMemoryWriter
);
584 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ:
586 if gItems
<> nil then
587 for i
:= 0 to High(gItems
) do
588 if gItems
[i
].ItemType
<> ITEM_NONE
then
591 Mem
:= TBinMemoryWriter
.Create((count
+1) * 60);
593 // Êîëè÷åñòâî ïðåäìåòîâ:
599 for i
:= 0 to High(gItems
) do
600 if gItems
[i
].ItemType
<> ITEM_NONE
then
602 // Ñèãíàòóðà ïðåäìåòà:
603 sig
:= ITEM_SIGNATURE
; // 'ITEM'
606 Mem
.WriteByte(gItems
[i
].ItemType
);
608 Mem
.WriteBoolean(gItems
[i
].Respawnable
);
609 // Êîîðäèíàòû ðåñïóíà:
610 Mem
.WriteInt(gItems
[i
].InitX
);
611 Mem
.WriteInt(gItems
[i
].InitY
);
612 // Âðåìÿ äî ðåñïàóíà:
613 Mem
.WriteWord(gItems
[i
].RespawnTime
);
614 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò:
615 Mem
.WriteBoolean(gItems
[i
].Live
);
616 // Ìîæåò ëè îí ïàäàòü:
617 Mem
.WriteBoolean(gItems
[i
].Fall
);
618 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò:
619 Mem
.WriteInt(gItems
[i
].SpawnTrigger
);
621 Obj_SaveState(@gItems
[i
].Obj
, Mem
);
625 procedure g_Items_LoadState(var Mem
: TBinMemoryReader
);
627 count
, i
, a
: Integer;
636 // Êîëè÷åñòâî ïðåäìåòîâ:
642 for a
:= 0 to count
-1 do
644 // Ñèãíàòóðà ïðåäìåòà:
646 if sig
<> ITEM_SIGNATURE
then // 'ITEM'
648 raise EBinSizeError
.Create('g_Items_LoadState: Wrong Item Signature');
653 i
:= g_Items_Create(0, 0, b
, False, False);
655 Mem
.ReadBoolean(gItems
[i
].Respawnable
);
656 // Êîîðäèíàòû ðåñïóíà:
657 Mem
.ReadInt(gItems
[i
].InitX
);
658 Mem
.ReadInt(gItems
[i
].InitY
);
659 // Âðåìÿ äî ðåñïàóíà:
660 Mem
.ReadWord(gItems
[i
].RespawnTime
);
661 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò:
662 Mem
.ReadBoolean(gItems
[i
].Live
);
663 // Ìîæåò ëè îí ïàäàòü:
664 Mem
.ReadBoolean(gItems
[i
].Fall
);
665 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò:
666 Mem
.ReadInt(gItems
[i
].SpawnTrigger
);
668 Obj_LoadState(@gItems
[i
].Obj
, Mem
);