DEADSOFTWARE

Add client-side model override option
[d2df-sdl.git] / src / game / g_items.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
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, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 unit g_items;
18 interface
20 uses
21 SysUtils, Classes,
22 MAPDEF, g_textures, g_phys, g_saveload;
24 Type
25 PItem = ^TItem;
26 TItem = record
27 private
28 //treeNode: Integer;
29 slotIsUsed: Boolean;
30 arrIdx: Integer; // in ggItems
32 public
33 ItemType: Byte;
34 Respawnable: Boolean;
35 InitX, InitY: Integer;
36 RespawnTime: Word;
37 alive: Boolean;
38 Fall: Boolean;
39 QuietRespawn: Boolean;
40 SpawnTrigger: Integer;
41 Obj: TObj;
42 Animation: TAnimation;
43 dropped: Boolean; // dropped from the monster? drops should be rendered after corpses, so zombie corpse will not obscure ammo container, for example
44 NeedSend: Boolean;
46 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
47 procedure getMapBox (out x, y, w, h: Integer); inline;
48 procedure moveBy (dx, dy: Integer); inline;
50 property myid: Integer read arrIdx;
51 end;
53 procedure g_Items_LoadData();
54 procedure g_Items_FreeData();
55 procedure g_Items_Init();
56 procedure g_Items_Free();
57 function g_Items_Create(X, Y: Integer; ItemType: Byte;
58 Fall, Respawnable: Boolean; AdjCoord: Boolean = False; ForcedID: Integer = -1): DWORD;
59 procedure g_Items_SetDrop (ID: DWORD);
60 procedure g_Items_PreUpdate();
61 procedure g_Items_Update();
62 procedure g_Items_Draw();
63 procedure g_Items_DrawDrop();
64 procedure g_Items_Pick(ID: DWORD);
65 procedure g_Items_Remove(ID: DWORD);
66 procedure g_Items_SaveState (st: TStream);
67 procedure g_Items_LoadState (st: TStream);
69 procedure g_Items_RestartRound ();
71 function g_Items_ValidId (idx: Integer): Boolean; inline;
72 function g_Items_ByIdx (idx: Integer): PItem;
73 function g_Items_ObjByIdx (idx: Integer): PObj;
75 procedure g_Items_EmitPickupSound (idx: Integer); // at item position
76 procedure g_Items_EmitPickupSoundAt (idx, x, y: Integer);
78 procedure g_Items_AddDynLights();
81 type
82 TItemEachAliveCB = function (it: PItem): Boolean is nested; // return `true` to stop
84 function g_Items_ForEachAlive (cb: TItemEachAliveCB; backwards: Boolean=false): Boolean;
85 function g_Items_NextAlive (startIdx: Integer): PItem;
87 var
88 gItemsTexturesID: Array [1..ITEM_MAX] of DWORD;
89 gMaxDist: Integer = 1; // for sounds
91 implementation
93 uses
94 Math,
95 g_basic, e_graphics, g_sound, g_main, g_gfx, g_map,
96 g_game, g_triggers, g_console, g_player, g_net, g_netmsg,
97 e_log,
98 g_grid, binheap, idpool, utils, xstreams;
101 var
102 ggItems: Array of TItem = nil;
105 // ////////////////////////////////////////////////////////////////////////// //
106 var
107 freeIds: TIdPool = nil;
110 // ////////////////////////////////////////////////////////////////////////// //
111 function g_Items_ValidId (idx: Integer): Boolean; inline;
112 begin
113 result := false;
114 if (idx < 0) or (idx > High(ggItems)) then exit;
115 if not ggItems[idx].slotIsUsed then exit;
116 result := true;
117 end;
120 function g_Items_ByIdx (idx: Integer): PItem;
121 begin
122 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
123 result := @ggItems[idx];
124 if not result.slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
125 end;
128 function g_Items_ObjByIdx (idx: Integer): PObj;
129 begin
130 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
131 if not ggItems[idx].slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
132 result := @ggItems[idx].Obj;
133 end;
136 // ////////////////////////////////////////////////////////////////////////// //
137 procedure TItem.positionChanged ();
138 begin
139 NeedSend := NeedSend or (Obj.X <> Obj.oldX) or (Obj.Y <> Obj.oldY);
140 end;
142 procedure TItem.getMapBox (out x, y, w, h: Integer); inline;
143 begin
144 x := Obj.X+Obj.Rect.X;
145 y := Obj.Y+Obj.Rect.Y;
146 w := Obj.Rect.Width;
147 h := Obj.Rect.Height;
148 end;
150 procedure TItem.moveBy (dx, dy: Integer); inline;
151 begin
152 if (dx <> 0) or (dy <> 0) then
153 begin
154 Obj.X += dx;
155 Obj.Y += dy;
156 positionChanged();
157 end;
158 end;
160 // ////////////////////////////////////////////////////////////////////////// //
161 const
162 ITEM_SIGNATURE = $4D455449; // 'ITEM'
164 ITEMSIZE: Array [ITEM_MEDKIT_SMALL..ITEM_MAX] of Array [0..1] of Byte =
165 (((14), (15)), // MEDKIT_SMALL
166 ((28), (19)), // MEDKIT_LARGE
167 ((28), (19)), // MEDKIT_BLACK
168 ((31), (16)), // ARMOR_GREEN
169 ((31), (16)), // ARMOR_BLUE
170 ((25), (25)), // SPHERE_BLUE
171 ((25), (25)), // SPHERE_WHITE
172 ((24), (47)), // SUIT
173 ((14), (27)), // OXYGEN
174 ((25), (25)), // INVUL
175 ((62), (24)), // WEAPON_SAW
176 ((63), (12)), // WEAPON_SHOTGUN1
177 ((54), (13)), // WEAPON_SHOTGUN2
178 ((54), (16)), // WEAPON_CHAINGUN
179 ((62), (16)), // WEAPON_ROCKETLAUNCHER
180 ((54), (16)), // WEAPON_PLASMA
181 ((61), (36)), // WEAPON_BFG
182 ((54), (16)), // WEAPON_SUPERPULEMET
183 (( 9), (11)), // AMMO_BULLETS
184 ((28), (16)), // AMMO_BULLETS_BOX
185 ((15), ( 7)), // AMMO_SHELLS
186 ((32), (12)), // AMMO_SHELLS_BOX
187 ((12), (27)), // AMMO_ROCKET
188 ((54), (21)), // AMMO_ROCKET_BOX
189 ((15), (12)), // AMMO_CELL
190 ((32), (21)), // AMMO_CELL_BIG
191 ((22), (29)), // AMMO_BACKPACK
192 ((16), (16)), // KEY_RED
193 ((16), (16)), // KEY_GREEN
194 ((16), (16)), // KEY_BLUE
195 (( 1), ( 1)), // WEAPON_KASTET
196 ((43), (16)), // WEAPON_PISTOL
197 ((14), (18)), // BOTTLE
198 ((16), (15)), // HELMET
199 ((32), (24)), // JETPACK
200 ((25), (25)), // INVIS
201 ((53), (20)), // WEAPON_FLAMETHROWER
202 ((13), (20))); // AMMO_FUELCAN
204 procedure InitTextures();
205 begin
206 g_Texture_Get('ITEM_MEDKIT_SMALL', gItemsTexturesID[ITEM_MEDKIT_SMALL]);
207 g_Texture_Get('ITEM_MEDKIT_LARGE', gItemsTexturesID[ITEM_MEDKIT_LARGE]);
208 g_Texture_Get('ITEM_MEDKIT_BLACK', gItemsTexturesID[ITEM_MEDKIT_BLACK]);
209 g_Texture_Get('ITEM_SUIT', gItemsTexturesID[ITEM_SUIT]);
210 g_Texture_Get('ITEM_OXYGEN', gItemsTexturesID[ITEM_OXYGEN]);
211 g_Texture_Get('ITEM_WEAPON_SAW', gItemsTexturesID[ITEM_WEAPON_SAW]);
212 g_Texture_Get('ITEM_WEAPON_SHOTGUN1', gItemsTexturesID[ITEM_WEAPON_SHOTGUN1]);
213 g_Texture_Get('ITEM_WEAPON_SHOTGUN2', gItemsTexturesID[ITEM_WEAPON_SHOTGUN2]);
214 g_Texture_Get('ITEM_WEAPON_CHAINGUN', gItemsTexturesID[ITEM_WEAPON_CHAINGUN]);
215 g_Texture_Get('ITEM_WEAPON_ROCKETLAUNCHER', gItemsTexturesID[ITEM_WEAPON_ROCKETLAUNCHER]);
216 g_Texture_Get('ITEM_WEAPON_PLASMA', gItemsTexturesID[ITEM_WEAPON_PLASMA]);
217 g_Texture_Get('ITEM_WEAPON_BFG', gItemsTexturesID[ITEM_WEAPON_BFG]);
218 g_Texture_Get('ITEM_WEAPON_SUPERPULEMET', gItemsTexturesID[ITEM_WEAPON_SUPERPULEMET]);
219 g_Texture_Get('ITEM_WEAPON_FLAMETHROWER', gItemsTexturesID[ITEM_WEAPON_FLAMETHROWER]);
220 g_Texture_Get('ITEM_AMMO_BULLETS', gItemsTexturesID[ITEM_AMMO_BULLETS]);
221 g_Texture_Get('ITEM_AMMO_BULLETS_BOX', gItemsTexturesID[ITEM_AMMO_BULLETS_BOX]);
222 g_Texture_Get('ITEM_AMMO_SHELLS', gItemsTexturesID[ITEM_AMMO_SHELLS]);
223 g_Texture_Get('ITEM_AMMO_SHELLS_BOX', gItemsTexturesID[ITEM_AMMO_SHELLS_BOX]);
224 g_Texture_Get('ITEM_AMMO_ROCKET', gItemsTexturesID[ITEM_AMMO_ROCKET]);
225 g_Texture_Get('ITEM_AMMO_ROCKET_BOX', gItemsTexturesID[ITEM_AMMO_ROCKET_BOX]);
226 g_Texture_Get('ITEM_AMMO_CELL', gItemsTexturesID[ITEM_AMMO_CELL]);
227 g_Texture_Get('ITEM_AMMO_CELL_BIG', gItemsTexturesID[ITEM_AMMO_CELL_BIG]);
228 g_Texture_Get('ITEM_AMMO_FUELCAN', gItemsTexturesID[ITEM_AMMO_FUELCAN]);
229 g_Texture_Get('ITEM_AMMO_BACKPACK', gItemsTexturesID[ITEM_AMMO_BACKPACK]);
230 g_Texture_Get('ITEM_KEY_RED', gItemsTexturesID[ITEM_KEY_RED]);
231 g_Texture_Get('ITEM_KEY_GREEN', gItemsTexturesID[ITEM_KEY_GREEN]);
232 g_Texture_Get('ITEM_KEY_BLUE', gItemsTexturesID[ITEM_KEY_BLUE]);
233 g_Texture_Get('ITEM_WEAPON_KASTET', gItemsTexturesID[ITEM_WEAPON_KASTET]);
234 g_Texture_Get('ITEM_WEAPON_PISTOL', gItemsTexturesID[ITEM_WEAPON_PISTOL]);
235 end;
237 procedure g_Items_LoadData();
238 begin
239 e_WriteLog('Loading items data...', TMsgType.Notify);
241 g_Sound_CreateWADEx('SOUND_ITEM_RESPAWNITEM', GameWAD+':SOUNDS\RESPAWNITEM');
242 g_Sound_CreateWADEx('SOUND_ITEM_GETRULEZ', GameWAD+':SOUNDS\GETRULEZ');
243 g_Sound_CreateWADEx('SOUND_ITEM_GETWEAPON', GameWAD+':SOUNDS\GETWEAPON');
244 g_Sound_CreateWADEx('SOUND_ITEM_GETITEM', GameWAD+':SOUNDS\GETITEM');
246 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BLUESPHERE', GameWAD+':TEXTURES\SBLUE', 32, 32, 4, True);
247 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_WHITESPHERE', GameWAD+':TEXTURES\SWHITE', 32, 32, 4, True);
248 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORGREEN', GameWAD+':TEXTURES\ARMORGREEN', 32, 16, 3, True);
249 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORBLUE', GameWAD+':TEXTURES\ARMORBLUE', 32, 16, 3, True);
250 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_JETPACK', GameWAD+':TEXTURES\JETPACK', 32, 32, 3, True);
251 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVUL', GameWAD+':TEXTURES\INVUL', 32, 32, 4, True);
252 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVIS', GameWAD+':TEXTURES\INVIS', 32, 32, 4, True);
253 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_RESPAWN', GameWAD+':TEXTURES\ITEMRESPAWN', 32, 32, 5, True);
254 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BOTTLE', GameWAD+':TEXTURES\BOTTLE', 16, 32, 4, True);
255 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_HELMET', GameWAD+':TEXTURES\HELMET', 16, 16, 4, True);
256 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_RED', GameWAD+':TEXTURES\FLAGRED', 64, 64, 5, False);
257 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_BLUE', GameWAD+':TEXTURES\FLAGBLUE', 64, 64, 5, False);
258 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_DOM', GameWAD+':TEXTURES\FLAGDOM', 64, 64, 5, False);
259 g_Texture_CreateWADEx('ITEM_MEDKIT_SMALL', GameWAD+':TEXTURES\MED1');
260 g_Texture_CreateWADEx('ITEM_MEDKIT_LARGE', GameWAD+':TEXTURES\MED2');
261 g_Texture_CreateWADEx('ITEM_WEAPON_SAW', GameWAD+':TEXTURES\SAW');
262 g_Texture_CreateWADEx('ITEM_WEAPON_PISTOL', GameWAD+':TEXTURES\PISTOL');
263 g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD+':TEXTURES\KASTET');
264 g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN1', GameWAD+':TEXTURES\SHOTGUN1');
265 g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN2', GameWAD+':TEXTURES\SHOTGUN2');
266 g_Texture_CreateWADEx('ITEM_WEAPON_CHAINGUN', GameWAD+':TEXTURES\MGUN');
267 g_Texture_CreateWADEx('ITEM_WEAPON_ROCKETLAUNCHER', GameWAD+':TEXTURES\RLAUNCHER');
268 g_Texture_CreateWADEx('ITEM_WEAPON_PLASMA', GameWAD+':TEXTURES\PGUN');
269 g_Texture_CreateWADEx('ITEM_WEAPON_BFG', GameWAD+':TEXTURES\BFG');
270 g_Texture_CreateWADEx('ITEM_WEAPON_SUPERPULEMET', GameWAD+':TEXTURES\SPULEMET');
271 g_Texture_CreateWADEx('ITEM_WEAPON_FLAMETHROWER', GameWAD+':TEXTURES\FLAMETHROWER');
272 g_Texture_CreateWADEx('ITEM_AMMO_BULLETS', GameWAD+':TEXTURES\CLIP');
273 g_Texture_CreateWADEx('ITEM_AMMO_BULLETS_BOX', GameWAD+':TEXTURES\AMMO');
274 g_Texture_CreateWADEx('ITEM_AMMO_SHELLS', GameWAD+':TEXTURES\SHELL1');
275 g_Texture_CreateWADEx('ITEM_AMMO_SHELLS_BOX', GameWAD+':TEXTURES\SHELL2');
276 g_Texture_CreateWADEx('ITEM_AMMO_ROCKET', GameWAD+':TEXTURES\ROCKET');
277 g_Texture_CreateWADEx('ITEM_AMMO_ROCKET_BOX', GameWAD+':TEXTURES\ROCKETS');
278 g_Texture_CreateWADEx('ITEM_AMMO_CELL', GameWAD+':TEXTURES\CELL');
279 g_Texture_CreateWADEx('ITEM_AMMO_CELL_BIG', GameWAD+':TEXTURES\CELL2');
280 g_Texture_CreateWADEx('ITEM_AMMO_FUELCAN', GameWAD+':TEXTURES\FUELCAN');
281 g_Texture_CreateWADEx('ITEM_AMMO_BACKPACK', GameWAD+':TEXTURES\BPACK');
282 g_Texture_CreateWADEx('ITEM_KEY_RED', GameWAD+':TEXTURES\KEYR');
283 g_Texture_CreateWADEx('ITEM_KEY_GREEN', GameWAD+':TEXTURES\KEYG');
284 g_Texture_CreateWADEx('ITEM_KEY_BLUE', GameWAD+':TEXTURES\KEYB');
285 g_Texture_CreateWADEx('ITEM_OXYGEN', GameWAD+':TEXTURES\OXYGEN');
286 g_Texture_CreateWADEx('ITEM_SUIT', GameWAD+':TEXTURES\SUIT');
287 g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD+':TEXTURES\KASTET');
288 g_Texture_CreateWADEx('ITEM_MEDKIT_BLACK', GameWAD+':TEXTURES\BMED');
290 InitTextures();
292 freeIds := TIdPool.Create();
293 end;
296 procedure g_Items_FreeData();
297 begin
298 e_WriteLog('Releasing items data...', TMsgType.Notify);
300 g_Sound_Delete('SOUND_ITEM_RESPAWNITEM');
301 g_Sound_Delete('SOUND_ITEM_GETRULEZ');
302 g_Sound_Delete('SOUND_ITEM_GETWEAPON');
303 g_Sound_Delete('SOUND_ITEM_GETITEM');
305 g_Frames_DeleteByName('FRAMES_ITEM_BLUESPHERE');
306 g_Frames_DeleteByName('FRAMES_ITEM_WHITESPHERE');
307 g_Frames_DeleteByName('FRAMES_ITEM_ARMORGREEN');
308 g_Frames_DeleteByName('FRAMES_ITEM_ARMORBLUE');
309 g_Frames_DeleteByName('FRAMES_ITEM_JETPACK');
310 g_Frames_DeleteByName('FRAMES_ITEM_INVUL');
311 g_Frames_DeleteByName('FRAMES_ITEM_INVIS');
312 g_Frames_DeleteByName('FRAMES_ITEM_RESPAWN');
313 g_Frames_DeleteByName('FRAMES_ITEM_BOTTLE');
314 g_Frames_DeleteByName('FRAMES_ITEM_HELMET');
315 g_Frames_DeleteByName('FRAMES_FLAG_RED');
316 g_Frames_DeleteByName('FRAMES_FLAG_BLUE');
317 g_Frames_DeleteByName('FRAMES_FLAG_DOM');
318 g_Texture_Delete('ITEM_MEDKIT_SMALL');
319 g_Texture_Delete('ITEM_MEDKIT_LARGE');
320 g_Texture_Delete('ITEM_WEAPON_SAW');
321 g_Texture_Delete('ITEM_WEAPON_PISTOL');
322 g_Texture_Delete('ITEM_WEAPON_KASTET');
323 g_Texture_Delete('ITEM_WEAPON_SHOTGUN1');
324 g_Texture_Delete('ITEM_WEAPON_SHOTGUN2');
325 g_Texture_Delete('ITEM_WEAPON_CHAINGUN');
326 g_Texture_Delete('ITEM_WEAPON_ROCKETLAUNCHER');
327 g_Texture_Delete('ITEM_WEAPON_PLASMA');
328 g_Texture_Delete('ITEM_WEAPON_BFG');
329 g_Texture_Delete('ITEM_WEAPON_SUPERPULEMET');
330 g_Texture_Delete('ITEM_WEAPON_FLAMETHROWER');
331 g_Texture_Delete('ITEM_AMMO_BULLETS');
332 g_Texture_Delete('ITEM_AMMO_BULLETS_BOX');
333 g_Texture_Delete('ITEM_AMMO_SHELLS');
334 g_Texture_Delete('ITEM_AMMO_SHELLS_BOX');
335 g_Texture_Delete('ITEM_AMMO_ROCKET');
336 g_Texture_Delete('ITEM_AMMO_ROCKET_BOX');
337 g_Texture_Delete('ITEM_AMMO_CELL');
338 g_Texture_Delete('ITEM_AMMO_CELL_BIG');
339 g_Texture_Delete('ITEM_AMMO_FUELCAN');
340 g_Texture_Delete('ITEM_AMMO_BACKPACK');
341 g_Texture_Delete('ITEM_KEY_RED');
342 g_Texture_Delete('ITEM_KEY_GREEN');
343 g_Texture_Delete('ITEM_KEY_BLUE');
344 g_Texture_Delete('ITEM_OXYGEN');
345 g_Texture_Delete('ITEM_SUIT');
346 g_Texture_Delete('ITEM_WEAPON_KASTET');
347 g_Texture_Delete('ITEM_MEDKIT_BLACK');
349 freeIds.Free();
350 freeIds := nil;
351 end;
354 procedure releaseItem (idx: Integer);
355 var
356 it: PItem;
357 begin
358 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('releaseItem: invalid item id');
359 if not freeIds.hasAlloced[LongWord(idx)] then raise Exception.Create('releaseItem: trying to release unallocated item (0)');
360 it := @ggItems[idx];
361 if not it.slotIsUsed then raise Exception.Create('releaseItem: trying to release unallocated item (1)');
362 if (it.arrIdx <> idx) then raise Exception.Create('releaseItem: arrIdx inconsistency');
363 it.slotIsUsed := false;
364 if (it.Animation <> nil) then
365 begin
366 it.Animation.Free();
367 it.Animation := nil;
368 end;
369 it.alive := False;
370 it.SpawnTrigger := -1;
371 it.ItemType := ITEM_NONE;
372 it.NeedSend := false;
373 freeIds.release(LongWord(idx));
374 end;
377 procedure growItemArrayTo (newsz: Integer);
378 var
379 i, olen: Integer;
380 it: PItem;
381 begin
382 if (newsz < Length(ggItems)) then exit;
383 // no free slots
384 olen := Length(ggItems);
385 SetLength(ggItems, newsz);
386 for i := olen to High(ggItems) do
387 begin
388 it := @ggItems[i];
389 it.slotIsUsed := false;
390 it.arrIdx := i;
391 it.ItemType := ITEM_NONE;
392 it.Animation := nil;
393 it.alive := false;
394 it.SpawnTrigger := -1;
395 it.Respawnable := false;
396 it.NeedSend := false;
397 //if not freeIds.hasFree[LongWord(i)] then raise Exception.Create('internal error in item idx manager');
398 end;
399 end;
402 function allocItem (): DWORD;
403 begin
404 result := freeIds.alloc();
405 if (result >= Length(ggItems)) then growItemArrayTo(Integer(result)+64);
406 if (Integer(result) > High(ggItems)) then raise Exception.Create('allocItem: freeid list corrupted');
407 if (ggItems[result].arrIdx <> Integer(result)) then raise Exception.Create('allocItem: arrIdx inconsistency');
408 end;
411 // it will be slow if the slot is free (we have to rebuild the heap)
412 function wantItemSlot (slot: Integer): Integer;
413 var
414 olen: Integer;
415 it: PItem;
416 begin
417 if (slot < 0) or (slot > $0fffffff) then raise Exception.Create('wantItemSlot: bad item slot request');
418 // do we need to grow item storate?
419 olen := Length(ggItems);
420 if (slot >= olen) then growItemArrayTo(slot+64);
422 it := @ggItems[slot];
423 if not it.slotIsUsed then
424 begin
425 freeIds.alloc(LongWord(slot));
426 end
427 else
428 begin
429 if not freeIds.hasAlloced[slot] then raise Exception.Create('wantItemSlot: internal error in item idx manager');
430 end;
431 it.slotIsUsed := false;
433 result := slot;
434 end;
437 // ////////////////////////////////////////////////////////////////////////// //
438 procedure g_Items_Init ();
439 var
440 a, b: Integer;
441 begin
442 if gMapInfo.Height > gPlayerScreenSize.Y then a := gMapInfo.Height-gPlayerScreenSize.Y else a := gMapInfo.Height;
443 if gMapInfo.Width > gPlayerScreenSize.X then b := gMapInfo.Width-gPlayerScreenSize.X else b := gMapInfo.Width;
444 gMaxDist := Trunc(Hypot(a, b));
445 end;
448 procedure g_Items_Free ();
449 var
450 i: Integer;
451 begin
452 if (ggItems <> nil) then
453 begin
454 for i := 0 to High(ggItems) do ggItems[i].Animation.Free();
455 ggItems := nil;
456 end;
457 freeIds.clear();
458 end;
461 function g_Items_Create (X, Y: Integer; ItemType: Byte;
462 Fall, Respawnable: Boolean; AdjCoord: Boolean = False; ForcedID: Integer = -1): DWORD;
463 var
464 find_id: DWORD;
465 ID: DWORD;
466 it: PItem;
467 begin
468 if ForcedID < 0 then find_id := allocItem() else find_id := wantItemSlot(ForcedID);
470 //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
472 it := @ggItems[find_id];
474 if (it.arrIdx <> Integer(find_id)) then raise Exception.Create('g_Items_Create: arrIdx inconsistency');
475 //it.arrIdx := find_id;
476 it.slotIsUsed := true;
478 it.ItemType := ItemType;
479 it.Respawnable := Respawnable;
480 it.InitX := X;
481 it.InitY := Y;
482 it.RespawnTime := 0;
483 it.Fall := Fall;
484 it.alive := True;
485 it.QuietRespawn := False;
486 it.dropped := false;
487 it.NeedSend := false;
489 g_Obj_Init(@it.Obj);
490 it.Obj.X := X;
491 it.Obj.Y := Y;
492 it.Obj.Rect.Width := ITEMSIZE[ItemType][0];
493 it.Obj.Rect.Height := ITEMSIZE[ItemType][1];
495 it.Animation := nil;
496 it.SpawnTrigger := -1;
498 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà
499 if AdjCoord then
500 begin
501 with it^ do
502 begin
503 Obj.X := X - (Obj.Rect.Width div 2);
504 Obj.Y := Y - Obj.Rect.Height;
505 InitX := Obj.X;
506 InitY := Obj.Y;
507 end;
508 end;
510 it.Obj.oldX := it.Obj.X;
511 it.Obj.oldY := it.Obj.Y;
513 // Óñòàíîâêà àíèìàöèè
514 case it.ItemType of
515 ITEM_ARMOR_GREEN: if g_Frames_Get(ID, 'FRAMES_ITEM_ARMORGREEN') then it.Animation := TAnimation.Create(ID, True, 20);
516 ITEM_ARMOR_BLUE: if g_Frames_Get(ID, 'FRAMES_ITEM_ARMORBLUE') then it.Animation := TAnimation.Create(ID, True, 20);
517 ITEM_JETPACK: if g_Frames_Get(ID, 'FRAMES_ITEM_JETPACK') then it.Animation := TAnimation.Create(ID, True, 15);
518 ITEM_SPHERE_BLUE: if g_Frames_Get(ID, 'FRAMES_ITEM_BLUESPHERE') then it.Animation := TAnimation.Create(ID, True, 15);
519 ITEM_SPHERE_WHITE: if g_Frames_Get(ID, 'FRAMES_ITEM_WHITESPHERE') then it.Animation := TAnimation.Create(ID, True, 20);
520 ITEM_INVUL: if g_Frames_Get(ID, 'FRAMES_ITEM_INVUL') then it.Animation := TAnimation.Create(ID, True, 20);
521 ITEM_INVIS: if g_Frames_Get(ID, 'FRAMES_ITEM_INVIS') then it.Animation := TAnimation.Create(ID, True, 20);
522 ITEM_BOTTLE: if g_Frames_Get(ID, 'FRAMES_ITEM_BOTTLE') then it.Animation := TAnimation.Create(ID, True, 20);
523 ITEM_HELMET: if g_Frames_Get(ID, 'FRAMES_ITEM_HELMET') then it.Animation := TAnimation.Create(ID, True, 20);
524 end;
526 it.positionChanged();
528 result := find_id;
529 end;
531 procedure g_Items_PreUpdate ();
532 var
533 i: Integer;
534 begin
535 if (ggItems = nil) then Exit;
536 for i := 0 to High(ggItems) do
537 if (ggItems[i].ItemType <> ITEM_NONE) and ggItems[i].slotIsUsed then
538 begin
539 ggItems[i].Obj.oldX := ggItems[i].Obj.X;
540 ggItems[i].Obj.oldY := ggItems[i].Obj.Y;
541 end;
542 end;
544 procedure g_Items_Update ();
545 var
546 i, j, k: Integer;
547 ID: DWord;
548 Anim: TAnimation;
549 m, ItemRespawnTime: Word;
550 r, nxt: Boolean;
551 begin
552 if (ggItems = nil) then exit;
554 // respawn items in 15 seconds regardless of settings during warmup
555 ItemRespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15);
557 for i := 0 to High(ggItems) do
558 begin
559 if (ggItems[i].ItemType = ITEM_NONE) then continue;
560 if not ggItems[i].slotIsUsed then continue; // just in case
562 with ggItems[i] do
563 begin
564 nxt := False;
566 if alive then
567 begin
568 if Fall then
569 begin
570 m := g_Obj_Move(@Obj, True, True);
571 positionChanged(); // this updates spatial accelerators
573 // Ñîïðîòèâëåíèå âîçäóõà
574 if gTime mod (GAME_TICK*2) = 0 then Obj.Vel.X := z_dec(Obj.Vel.X, 1);
576 // Åñëè âûïàë çà êàðòó
577 if WordBool(m and MOVE_FALLOUT) then
578 begin
579 if SpawnTrigger = -1 then
580 begin
581 g_Items_Pick(i);
582 end
583 else
584 begin
585 g_Items_Remove(i);
586 if g_Game_IsServer and g_Game_IsNet then MH_SEND_ItemDestroy(True, i);
587 end;
588 continue;
589 end;
590 end;
592 // Åñëè èãðîêè ïîáëèçîñòè
593 if (gPlayers <> nil) then
594 begin
595 j := Random(Length(gPlayers))-1;
597 for k := 0 to High(gPlayers) do
598 begin
599 Inc(j);
600 if j > High(gPlayers) then j := 0;
602 if (gPlayers[j] <> nil) and gPlayers[j].alive and g_Obj_Collide(@gPlayers[j].Obj, @Obj) then
603 begin
604 if g_Game_IsClient then continue;
606 if not gPlayers[j].PickItem(ItemType, Respawnable, r) then continue;
608 if g_Game_IsNet then MH_SEND_PlayerStats(gPlayers[j].UID);
611 Doom 2D: Original:
612 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
613 +2. I_MEGA,I_INVL,I_SUPER
614 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
616 g_Items_EmitPickupSoundAt(i, gPlayers[j].Obj.X, gPlayers[j].Obj.Y);
618 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì
619 if r then
620 begin
621 if not (Respawnable and (ItemRespawnTime > 0)) then
622 g_Items_Remove(i)
623 else
624 g_Items_Pick(i);
625 if g_Game_IsNet then MH_SEND_ItemDestroy(False, i);
626 nxt := True;
627 break;
628 end;
629 end;
630 end;
631 end;
633 if nxt then continue;
634 end;
636 if Respawnable and g_Game_IsServer then
637 begin
638 DecMin(RespawnTime, 0);
639 if (RespawnTime = 0) and (not alive) then
640 begin
641 if not QuietRespawn then g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', InitX, InitY);
643 if g_Frames_Get(ID, 'FRAMES_ITEM_RESPAWN') then
644 begin
645 Anim := TAnimation.Create(ID, False, 4);
646 g_GFX_OnceAnim(InitX+(Obj.Rect.Width div 2)-16, InitY+(Obj.Rect.Height div 2)-16, Anim);
647 Anim.Free();
648 end;
650 Obj.oldX := InitX;
651 Obj.oldY := InitY;
652 Obj.X := InitX;
653 Obj.Y := InitY;
654 Obj.Vel.X := 0;
655 Obj.Vel.Y := 0;
656 Obj.Accel.X := 0;
657 Obj.Accel.Y := 0;
658 positionChanged(); // this updates spatial accelerators
660 alive := true;
662 if g_Game_IsNet then MH_SEND_ItemSpawn(QuietRespawn, i);
663 QuietRespawn := false;
664 end;
665 end;
667 if (Animation <> nil) then Animation.Update();
668 end;
669 end;
670 end;
673 procedure itemsDrawInternal (dropflag: Boolean);
674 var
675 i, fX, fY: Integer;
676 it: PItem;
677 begin
678 if (ggItems = nil) then exit;
680 for i := 0 to High(ggItems) do
681 begin
682 it := @ggItems[i];
683 if (not it.slotIsUsed) or (it.ItemType = ITEM_NONE) then continue; // just in case
684 if not it.alive then continue;
685 if (it.dropped <> dropflag) then continue;
687 with it^ do
688 begin
689 if g_Collide(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height, sX, sY, sWidth, sHeight) then
690 begin
691 Obj.lerp(gLerpFactor, fX, fY);
692 if (Animation = nil) then
693 begin
694 e_Draw(gItemsTexturesID[ItemType], fX, fY, 0, true, false);
695 end
696 else
697 begin
698 Animation.Draw(fX, fY, TMirrorType.None);
699 end;
701 if g_debug_Frames then
702 begin
703 e_DrawQuad(Obj.X+Obj.Rect.X,
704 Obj.Y+Obj.Rect.Y,
705 Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
706 Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
707 0, 255, 0);
708 end;
709 end;
710 end;
711 end;
712 end;
715 procedure g_Items_Draw ();
716 begin
717 itemsDrawInternal(false);
718 end;
720 procedure g_Items_DrawDrop ();
721 begin
722 itemsDrawInternal(true);
723 end;
726 procedure g_Items_SetDrop (ID: DWORD);
727 begin
728 if (ID < Length(ggItems)) then
729 begin
730 ggItems[ID].dropped := true;
731 end;
732 end;
735 procedure g_Items_Pick (ID: DWORD);
736 begin
737 if (ID < Length(ggItems)) then
738 begin
739 ggItems[ID].Obj.oldX := ggItems[ID].Obj.X;
740 ggItems[ID].Obj.oldY := ggItems[ID].Obj.Y;
741 ggItems[ID].alive := false;
742 ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36;
743 end;
744 end;
747 procedure g_Items_Remove (ID: DWORD);
748 var
749 it: PItem;
750 trig: Integer;
751 begin
752 if not g_Items_ValidId(ID) then
753 begin
754 //writeln('g_Items_Remove: invalid item id: ', ID);
755 raise Exception.Create('g_Items_Remove: invalid item id');
756 //exit;
757 end;
759 it := @ggItems[ID];
760 if (it.arrIdx <> Integer(ID)) then raise Exception.Create('g_Items_Remove: arrIdx desync');
762 it.Obj.oldX := it.Obj.X;
763 it.Obj.oldY := it.Obj.Y;
764 trig := it.SpawnTrigger;
766 releaseItem(ID);
768 if (trig > -1) then g_Triggers_DecreaseSpawner(trig);
769 end;
772 procedure g_Items_SaveState (st: TStream);
773 var
774 count, i: Integer;
775 tt: Byte;
776 begin
777 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ
778 count := 0;
779 for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then Inc(count);
781 // Êîëè÷åñòâî ïðåäìåòîâ
782 utils.writeInt(st, LongInt(count));
783 if (count = 0) then exit;
785 for i := 0 to High(ggItems) do
786 begin
787 if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then
788 begin
789 // Ñèãíàòóðà ïðåäìåòà
790 utils.writeSign(st, 'ITEM');
791 utils.writeInt(st, Byte(0));
792 // Òèï ïðåäìåòà
793 tt := ggItems[i].ItemType;
794 if ggItems[i].dropped then tt := tt or $80;
795 utils.writeInt(st, Byte(tt));
796 // Åñòü ëè ðåñïàóí
797 utils.writeBool(st, ggItems[i].Respawnable);
798 // Êîîðäèíàòû ðåñïóíà
799 utils.writeInt(st, LongInt(ggItems[i].InitX));
800 utils.writeInt(st, LongInt(ggItems[i].InitY));
801 // Âðåìÿ äî ðåñïàóíà
802 utils.writeInt(st, Word(ggItems[i].RespawnTime));
803 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
804 utils.writeBool(st, ggItems[i].alive);
805 // Ìîæåò ëè îí ïàäàòü
806 utils.writeBool(st, ggItems[i].Fall);
807 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
808 utils.writeInt(st, LongInt(ggItems[i].SpawnTrigger));
809 // Îáúåêò ïðåäìåòà
810 Obj_SaveState(st, @ggItems[i].Obj);
811 end;
812 end;
813 end;
816 procedure g_Items_LoadState (st: TStream);
817 var
818 count, i, a: Integer;
819 b: Byte;
820 begin
821 assert(st <> nil);
823 g_Items_Free();
825 // Êîëè÷åñòâî ïðåäìåòîâ
826 count := utils.readLongInt(st);
827 if (count = 0) then exit;
828 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid number of items');
830 for a := 0 to count-1 do
831 begin
832 // Ñèãíàòóðà ïðåäìåòà
833 if not utils.checkSign(st, 'ITEM') then raise XStreamError.Create('invalid item signature');
834 if (utils.readByte(st) <> 0) then raise XStreamError.Create('invalid item version');
835 // Òèï ïðåäìåòà
836 b := utils.readByte(st); // bit7=1: monster drop
837 // Ñîçäàåì ïðåäìåò
838 i := g_Items_Create(0, 0, b and $7F, False, False);
839 if ((b and $80) <> 0) then g_Items_SetDrop(i);
840 // Åñòü ëè ðåñïàóí
841 ggItems[i].Respawnable := utils.readBool(st);
842 // Êîîðäèíàòû ðåñïóíà
843 ggItems[i].InitX := utils.readLongInt(st);
844 ggItems[i].InitY := utils.readLongInt(st);
845 // Âðåìÿ äî ðåñïàóíà
846 ggItems[i].RespawnTime := utils.readWord(st);
847 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
848 ggItems[i].alive := utils.readBool(st);
849 // Ìîæåò ëè îí ïàäàòü
850 ggItems[i].Fall := utils.readBool(st);
851 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
852 ggItems[i].SpawnTrigger := utils.readLongInt(st);
853 // Îáúåêò ïðåäìåòà
854 Obj_LoadState(@ggItems[i].Obj, st);
855 end;
856 end;
859 procedure g_Items_RestartRound ();
860 var
861 i: Integer;
862 it: PItem;
863 begin
864 for i := 0 to High(ggItems) do
865 begin
866 it := @ggItems[i];
867 it.Obj.oldX := it.Obj.X;
868 it.Obj.oldY := it.Obj.Y;
869 if not it.slotIsUsed then continue;
870 if it.Respawnable and (it.ItemType <> ITEM_NONE) then
871 begin
872 it.QuietRespawn := True;
873 it.RespawnTime := 0;
874 end
875 else
876 begin
877 g_Items_Remove(i);
878 if g_Game_IsNet then MH_SEND_ItemDestroy(True, i);
879 end;
880 end;
881 end;
884 function g_Items_ForEachAlive (cb: TItemEachAliveCB; backwards: Boolean=false): Boolean;
885 var
886 idx: Integer;
887 begin
888 result := false;
889 if (ggItems = nil) or not assigned(cb) then exit;
891 if backwards then
892 begin
893 for idx := High(ggItems) downto 0 do
894 begin
895 if ggItems[idx].alive and ggItems[idx].slotIsUsed then
896 begin
897 result := cb(@ggItems[idx]);
898 if result then exit;
899 end;
900 end;
901 end
902 else
903 begin
904 for idx := 0 to High(ggItems) do
905 begin
906 if ggItems[idx].alive and ggItems[idx].slotIsUsed then
907 begin
908 result := cb(@ggItems[idx]);
909 if result then exit;
910 end;
911 end;
912 end;
913 end;
915 function g_Items_NextAlive (startIdx: Integer): PItem;
916 var
917 idx: Integer;
918 begin
919 result := nil;
920 if (ggItems = nil) or (startIdx >= High(ggItems)) then exit;
921 for idx := startIdx + 1 to High(ggItems) do
922 if ggItems[idx].alive and ggItems[idx].slotIsUsed then
923 begin
924 result := @ggItems[idx];
925 exit;
926 end;
927 end;
929 // ////////////////////////////////////////////////////////////////////////// //
930 procedure g_Items_EmitPickupSound (idx: Integer);
931 var
932 it: PItem;
933 begin
934 if not g_Items_ValidId(idx) then exit;
935 it := @ggItems[idx];
936 g_Items_EmitPickupSoundAt(idx, it.Obj.X, it.Obj.Y);
937 end;
939 procedure g_Items_EmitPickupSoundAt (idx, x, y: Integer);
940 var
941 it: PItem;
942 begin
943 if not g_Items_ValidId(idx) then exit;
945 it := @ggItems[idx];
946 if gSoundEffectsDF then
947 begin
948 if it.ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL,
949 ITEM_INVIS, ITEM_MEDKIT_BLACK, ITEM_JETPACK] then
950 begin
951 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', x, y);
952 end
953 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
954 ITEM_WEAPON_CHAINGUN, ITEM_WEAPON_ROCKETLAUNCHER, ITEM_WEAPON_PLASMA,
955 ITEM_WEAPON_BFG, ITEM_WEAPON_SUPERPULEMET, ITEM_WEAPON_FLAMETHROWER,
956 ITEM_AMMO_BACKPACK] then
957 begin
958 g_Sound_PlayExAt('SOUND_ITEM_GETWEAPON', x, y);
959 end
960 else
961 begin
962 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', x, y);
963 end;
964 end
965 else
966 begin
967 if it.ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_SUIT,
968 ITEM_MEDKIT_BLACK, ITEM_INVUL, ITEM_INVIS, ITEM_JETPACK] then
969 begin
970 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', x, y);
971 end
972 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
973 ITEM_WEAPON_CHAINGUN, ITEM_WEAPON_ROCKETLAUNCHER, ITEM_WEAPON_PLASMA,
974 ITEM_WEAPON_BFG, ITEM_WEAPON_SUPERPULEMET, ITEM_WEAPON_FLAMETHROWER] then
975 begin
976 g_Sound_PlayExAt('SOUND_ITEM_GETWEAPON', x, y);
977 end
978 else
979 begin
980 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', x, y);
981 end;
982 end;
983 end;
986 procedure g_Items_AddDynLights();
987 var
988 f: Integer;
989 it: PItem;
990 begin
991 for f := 0 to High(ggItems) do
992 begin
993 it := @ggItems[f];
994 if not it.alive then continue;
995 case it.ItemType of
996 ITEM_KEY_RED: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 24, 1.0, 0.0, 0.0, 0.6);
997 ITEM_KEY_GREEN: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 24, 0.0, 1.0, 0.0, 0.6);
998 ITEM_KEY_BLUE: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 24, 0.0, 0.0, 1.0, 0.6);
999 ITEM_ARMOR_GREEN: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 42, 0.0, 1.0, 0.0, 0.6);
1000 ITEM_ARMOR_BLUE: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 42, 0.0, 0.0, 1.0, 0.6);
1001 ITEM_JETPACK: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 32, 1.0, 1.0, 1.0, 0.6);
1002 ITEM_SPHERE_BLUE: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 32, 0.0, 1.0, 0.0, 0.6);
1003 ITEM_SPHERE_WHITE: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 32, 1.0, 1.0, 1.0, 0.6);
1004 ITEM_INVUL: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 32, 1.0, 0.0, 0.0, 0.6);
1005 ITEM_INVIS: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 32, 1.0, 1.0, 0.0, 0.6);
1006 ITEM_BOTTLE: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 16, 0.0, 0.0, 0.8, 0.6);
1007 ITEM_HELMET: g_AddDynLight(it.Obj.X+(it.Obj.Rect.Width div 2), it.Obj.Y+(it.Obj.Rect.Height div 2), 16, 0.0, 0.8, 0.0, 0.6);
1008 end;
1009 end;
1010 end;
1013 end.