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, version 3 of the License ONLY.
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.
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/>.
15 {$INCLUDE ../shared/a_modes.inc}
22 MAPDEF
, g_phys
, g_saveload
;
33 arrIdx
: Integer; // in ggItems
38 InitX
, InitY
: Integer;
42 QuietRespawn
: Boolean;
43 SpawnTrigger
: Integer;
45 dropped
: Boolean; // dropped from the monster? drops should be rendered after corpses, so zombie corpse will not obscure ammo container, for example
48 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
49 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
50 procedure moveBy (dx
, dy
: Integer); inline;
52 property used
: Boolean read slotIsUsed
;
53 property myid
: Integer read arrIdx
;
56 procedure g_Items_LoadData();
57 procedure g_Items_FreeData();
58 procedure g_Items_Init();
59 procedure g_Items_Free();
60 function g_Items_Create(X
, Y
: Integer; ItemType
: Byte;
61 Fall
, Respawnable
: Boolean; AdjCoord
: Boolean = False; ForcedID
: Integer = -1): DWORD
;
62 procedure g_Items_SetDrop (ID
: DWORD
);
63 procedure g_Items_PreUpdate();
64 procedure g_Items_Update();
65 procedure g_Items_Pick(ID
: DWORD
);
66 procedure g_Items_Remove(ID
: DWORD
);
67 procedure g_Items_SaveState (st
: TStream
);
68 procedure g_Items_LoadState (st
: TStream
);
70 procedure g_Items_RestartRound ();
72 function g_Items_ValidId (idx
: Integer): Boolean; inline;
73 function g_Items_ByIdx (idx
: Integer): PItem
;
74 function g_Items_ObjByIdx (idx
: Integer): PObj
;
76 procedure g_Items_EmitPickupSound (idx
: Integer); // at item position
77 procedure g_Items_EmitPickupSoundAt (idx
, x
, y
: Integer);
79 procedure g_Items_AddDynLights();
83 TItemEachAliveCB
= function (it
: PItem
): Boolean is nested
; // return `true` to stop
85 function g_Items_ForEachAlive (cb
: TItemEachAliveCB
; backwards
: Boolean=false): Boolean;
86 function g_Items_NextAlive (startIdx
: Integer): PItem
;
89 gMaxDist
: Integer = 1; // for sounds
91 var (* private state *)
92 ggItems
: Array of TItem
= nil;
101 g_basic
, g_sound
, g_map
,
102 g_game
, g_triggers
, g_console
, g_player
, g_net
, g_netmsg
,
104 g_grid
, binheap
, idpool
, utils
, xstreams
107 // ////////////////////////////////////////////////////////////////////////// //
109 freeIds
: TIdPool
= nil;
112 // ////////////////////////////////////////////////////////////////////////// //
113 function g_Items_ValidId (idx
: Integer): Boolean; inline;
116 if (idx
< 0) or (idx
> High(ggItems
)) then exit
;
117 if not ggItems
[idx
].slotIsUsed
then exit
;
122 function g_Items_ByIdx (idx
: Integer): PItem
;
124 if (idx
< 0) or (idx
> High(ggItems
)) then raise Exception
.Create('g_ItemObjByIdx: invalid index');
125 result
:= @ggItems
[idx
];
126 if not result
.slotIsUsed
then raise Exception
.Create('g_ItemObjByIdx: requested inexistent item');
130 function g_Items_ObjByIdx (idx
: Integer): PObj
;
132 if (idx
< 0) or (idx
> High(ggItems
)) then raise Exception
.Create('g_ItemObjByIdx: invalid index');
133 if not ggItems
[idx
].slotIsUsed
then raise Exception
.Create('g_ItemObjByIdx: requested inexistent item');
134 result
:= @ggItems
[idx
].Obj
;
138 // ////////////////////////////////////////////////////////////////////////// //
139 procedure TItem
.positionChanged ();
141 NeedSend
:= NeedSend
or (Obj
.X
<> Obj
.oldX
) or (Obj
.Y
<> Obj
.oldY
);
144 procedure TItem
.getMapBox (out x
, y
, w
, h
: Integer); inline;
146 x
:= Obj
.X
+Obj
.Rect
.X
;
147 y
:= Obj
.Y
+Obj
.Rect
.Y
;
149 h
:= Obj
.Rect
.Height
;
152 procedure TItem
.moveBy (dx
, dy
: Integer); inline;
154 if (dx
<> 0) or (dy
<> 0) then
162 // ////////////////////////////////////////////////////////////////////////// //
164 ITEM_SIGNATURE
= $4D455449; // 'ITEM'
166 ITEMSIZE
: Array [ITEM_MEDKIT_SMALL
..ITEM_MAX
] of Array [0..1] of Byte =
167 (((14), (15)), // MEDKIT_SMALL
168 ((28), (19)), // MEDKIT_LARGE
169 ((28), (19)), // MEDKIT_BLACK
170 ((31), (16)), // ARMOR_GREEN
171 ((31), (16)), // ARMOR_BLUE
172 ((25), (25)), // SPHERE_BLUE
173 ((25), (25)), // SPHERE_WHITE
174 ((24), (47)), // SUIT
175 ((14), (27)), // OXYGEN
176 ((25), (25)), // INVUL
177 ((62), (24)), // WEAPON_SAW
178 ((63), (12)), // WEAPON_SHOTGUN1
179 ((54), (13)), // WEAPON_SHOTGUN2
180 ((54), (16)), // WEAPON_CHAINGUN
181 ((62), (16)), // WEAPON_ROCKETLAUNCHER
182 ((54), (16)), // WEAPON_PLASMA
183 ((61), (36)), // WEAPON_BFG
184 ((54), (16)), // WEAPON_SUPERPULEMET
185 (( 9), (11)), // AMMO_BULLETS
186 ((28), (16)), // AMMO_BULLETS_BOX
187 ((15), ( 7)), // AMMO_SHELLS
188 ((32), (12)), // AMMO_SHELLS_BOX
189 ((12), (27)), // AMMO_ROCKET
190 ((54), (21)), // AMMO_ROCKET_BOX
191 ((15), (12)), // AMMO_CELL
192 ((32), (21)), // AMMO_CELL_BIG
193 ((22), (29)), // AMMO_BACKPACK
194 ((16), (16)), // KEY_RED
195 ((16), (16)), // KEY_GREEN
196 ((16), (16)), // KEY_BLUE
197 (( 1), ( 1)), // WEAPON_KASTET
198 ((43), (16)), // WEAPON_PISTOL
199 ((14), (18)), // BOTTLE
200 ((16), (15)), // HELMET
201 ((32), (24)), // JETPACK
202 ((25), (25)), // INVIS
203 ((53), (20)), // WEAPON_FLAMETHROWER
204 ((13), (20))); // AMMO_FUELCAN
206 procedure g_Items_LoadData();
208 e_WriteLog('Loading items data...', TMsgType
.Notify
);
210 g_Sound_CreateWADEx('SOUND_ITEM_RESPAWNITEM', GameWAD
+':SOUNDS\RESPAWNITEM');
211 g_Sound_CreateWADEx('SOUND_ITEM_GETRULEZ', GameWAD
+':SOUNDS\GETRULEZ');
212 g_Sound_CreateWADEx('SOUND_ITEM_GETWEAPON', GameWAD
+':SOUNDS\GETWEAPON');
213 g_Sound_CreateWADEx('SOUND_ITEM_GETITEM', GameWAD
+':SOUNDS\GETITEM');
215 freeIds
:= TIdPool
.Create();
219 procedure g_Items_FreeData();
221 e_WriteLog('Releasing items data...', TMsgType
.Notify
);
223 g_Sound_Delete('SOUND_ITEM_RESPAWNITEM');
224 g_Sound_Delete('SOUND_ITEM_GETRULEZ');
225 g_Sound_Delete('SOUND_ITEM_GETWEAPON');
226 g_Sound_Delete('SOUND_ITEM_GETITEM');
233 procedure releaseItem (idx
: Integer);
237 if (idx
< 0) or (idx
> High(ggItems
)) then raise Exception
.Create('releaseItem: invalid item id');
238 if not freeIds
.hasAlloced
[LongWord(idx
)] then raise Exception
.Create('releaseItem: trying to release unallocated item (0)');
240 if not it
.slotIsUsed
then raise Exception
.Create('releaseItem: trying to release unallocated item (1)');
241 if (it
.arrIdx
<> idx
) then raise Exception
.Create('releaseItem: arrIdx inconsistency');
242 it
.slotIsUsed
:= false;
244 it
.SpawnTrigger
:= -1;
245 it
.ItemType
:= ITEM_NONE
;
246 it
.NeedSend
:= false;
247 freeIds
.release(LongWord(idx
));
251 procedure growItemArrayTo (newsz
: Integer);
256 if (newsz
< Length(ggItems
)) then exit
;
258 olen
:= Length(ggItems
);
259 SetLength(ggItems
, newsz
);
260 for i
:= olen
to High(ggItems
) do
263 it
.slotIsUsed
:= false;
265 it
.ItemType
:= ITEM_NONE
;
267 it
.SpawnTrigger
:= -1;
268 it
.Respawnable
:= false;
269 it
.NeedSend
:= false;
270 //if not freeIds.hasFree[LongWord(i)] then raise Exception.Create('internal error in item idx manager');
275 function allocItem (): DWORD
;
277 result
:= freeIds
.alloc();
278 if (result
>= Length(ggItems
)) then growItemArrayTo(Integer(result
)+64);
279 if (Integer(result
) > High(ggItems
)) then raise Exception
.Create('allocItem: freeid list corrupted');
280 if (ggItems
[result
].arrIdx
<> Integer(result
)) then raise Exception
.Create('allocItem: arrIdx inconsistency');
284 // it will be slow if the slot is free (we have to rebuild the heap)
285 function wantItemSlot (slot
: Integer): Integer;
290 if (slot
< 0) or (slot
> $0fffffff) then raise Exception
.Create('wantItemSlot: bad item slot request');
291 // do we need to grow item storate?
292 olen
:= Length(ggItems
);
293 if (slot
>= olen
) then growItemArrayTo(slot
+64);
295 it
:= @ggItems
[slot
];
296 if not it
.slotIsUsed
then
298 freeIds
.alloc(LongWord(slot
));
302 if not freeIds
.hasAlloced
[slot
] then raise Exception
.Create('wantItemSlot: internal error in item idx manager');
304 it
.slotIsUsed
:= false;
310 // ////////////////////////////////////////////////////////////////////////// //
311 procedure g_Items_Init ();
315 if gMapInfo
.Height
> gPlayerScreenSize
.Y
then a
:= gMapInfo
.Height
-gPlayerScreenSize
.Y
else a
:= gMapInfo
.Height
;
316 if gMapInfo
.Width
> gPlayerScreenSize
.X
then b
:= gMapInfo
.Width
-gPlayerScreenSize
.X
else b
:= gMapInfo
.Width
;
317 gMaxDist
:= Trunc(Hypot(a
, b
));
321 procedure g_Items_Free ();
323 if (ggItems
<> nil) then
329 function g_Items_Create (X
, Y
: Integer; ItemType
: Byte;
330 Fall
, Respawnable
: Boolean; AdjCoord
: Boolean = False; ForcedID
: Integer = -1): DWORD
;
335 if ForcedID
< 0 then find_id
:= allocItem() else find_id
:= wantItemSlot(ForcedID
);
337 //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
339 it
:= @ggItems
[find_id
];
341 if (it
.arrIdx
<> Integer(find_id
)) then raise Exception
.Create('g_Items_Create: arrIdx inconsistency');
342 //it.arrIdx := find_id;
343 it
.slotIsUsed
:= true;
345 it
.ItemType
:= ItemType
;
346 it
.Respawnable
:= Respawnable
;
352 it
.QuietRespawn
:= False;
354 it
.NeedSend
:= false;
359 it
.Obj
.Rect
.Width
:= ITEMSIZE
[ItemType
][0];
360 it
.Obj
.Rect
.Height
:= ITEMSIZE
[ItemType
][1];
362 it
.SpawnTrigger
:= -1;
364 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà
369 Obj
.X
:= X
- (Obj
.Rect
.Width
div 2);
370 Obj
.Y
:= Y
- Obj
.Rect
.Height
;
376 it
.Obj
.oldX
:= it
.Obj
.X
;
377 it
.Obj
.oldY
:= it
.Obj
.Y
;
379 it
.positionChanged();
384 procedure g_Items_PreUpdate ();
388 if (ggItems
= nil) then Exit
;
389 for i
:= 0 to High(ggItems
) do
390 if (ggItems
[i
].ItemType
<> ITEM_NONE
) and ggItems
[i
].slotIsUsed
then
392 ggItems
[i
].Obj
.oldX
:= ggItems
[i
].Obj
.X
;
393 ggItems
[i
].Obj
.oldY
:= ggItems
[i
].Obj
.Y
;
397 procedure g_Items_Update ();
400 m
, ItemRespawnTime
: Word;
403 if (ggItems
= nil) then exit
;
405 // respawn items in 15 seconds regardless of settings during warmup
406 ItemRespawnTime
:= IfThen(gLMSRespawn
= LMS_RESPAWN_NONE
, gGameSettings
.ItemRespawnTime
, 15);
408 for i
:= 0 to High(ggItems
) do
410 if (ggItems
[i
].ItemType
= ITEM_NONE
) then continue
;
411 if not ggItems
[i
].slotIsUsed
then continue
; // just in case
421 m
:= g_Obj_Move(@Obj
, True, True);
422 positionChanged(); // this updates spatial accelerators
424 // Ñîïðîòèâëåíèå âîçäóõà
425 if gTime
mod (GAME_TICK
*2) = 0 then Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
427 // Åñëè âûïàë çà êàðòó
428 if WordBool(m
and MOVE_FALLOUT
) then
430 if SpawnTrigger
= -1 then
437 if g_Game_IsServer
and g_Game_IsNet
then MH_SEND_ItemDestroy(True, i
);
443 // Åñëè èãðîêè ïîáëèçîñòè
444 if (gPlayers
<> nil) then
446 j
:= Random(Length(gPlayers
))-1;
448 for k
:= 0 to High(gPlayers
) do
451 if j
> High(gPlayers
) then j
:= 0;
453 if (gPlayers
[j
] <> nil) and gPlayers
[j
].alive
and g_Obj_Collide(@gPlayers
[j
].Obj
, @Obj
) then
455 if g_Game_IsClient
then continue
;
457 if not gPlayers
[j
].PickItem(ItemType
, Respawnable
, r
) then continue
;
459 if g_Game_IsNet
then MH_SEND_PlayerStats(gPlayers
[j
].UID
);
463 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
464 +2. I_MEGA,I_INVL,I_SUPER
465 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
467 g_Items_EmitPickupSoundAt(i
, gPlayers
[j
].Obj
.X
, gPlayers
[j
].Obj
.Y
);
469 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì
472 if not (Respawnable
and (ItemRespawnTime
> 0)) then
476 if g_Game_IsNet
then MH_SEND_ItemDestroy(False, i
);
484 if nxt
then continue
;
487 if Respawnable
and g_Game_IsServer
then
489 DecMin(RespawnTime
, 0);
490 if (RespawnTime
= 0) and (not alive
) then
492 if not QuietRespawn
then g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', InitX
, InitY
);
496 InitX
+ (Obj
.Rect
.Width
div 2) - 16,
497 InitY
+ (Obj
.Rect
.Height
div 2) - 16
508 positionChanged(); // this updates spatial accelerators
512 if g_Game_IsNet
then MH_SEND_ItemSpawn(QuietRespawn
, i
);
513 QuietRespawn
:= false;
520 procedure g_Items_SetDrop (ID
: DWORD
);
522 if (ID
< Length(ggItems
)) then
524 ggItems
[ID
].dropped
:= true;
529 procedure g_Items_Pick (ID
: DWORD
);
531 if (ID
< Length(ggItems
)) then
533 ggItems
[ID
].Obj
.oldX
:= ggItems
[ID
].Obj
.X
;
534 ggItems
[ID
].Obj
.oldY
:= ggItems
[ID
].Obj
.Y
;
535 ggItems
[ID
].alive
:= false;
536 ggItems
[ID
].RespawnTime
:= IfThen(gLMSRespawn
= LMS_RESPAWN_NONE
, gGameSettings
.ItemRespawnTime
, 15) * 36;
541 procedure g_Items_Remove (ID
: DWORD
);
546 if not g_Items_ValidId(ID
) then
548 //writeln('g_Items_Remove: invalid item id: ', ID);
549 raise Exception
.Create('g_Items_Remove: invalid item id');
554 if (it
.arrIdx
<> Integer(ID
)) then raise Exception
.Create('g_Items_Remove: arrIdx desync');
556 it
.Obj
.oldX
:= it
.Obj
.X
;
557 it
.Obj
.oldY
:= it
.Obj
.Y
;
558 trig
:= it
.SpawnTrigger
;
562 if (trig
> -1) then g_Triggers_DecreaseSpawner(trig
);
566 procedure g_Items_SaveState (st
: TStream
);
571 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ
573 for i
:= 0 to High(ggItems
) do if (ggItems
[i
].ItemType
<> ITEM_NONE
) and (ggItems
[i
].slotIsUsed
) then Inc(count
);
575 // Êîëè÷åñòâî ïðåäìåòîâ
576 utils
.writeInt(st
, LongInt(count
));
577 if (count
= 0) then exit
;
579 for i
:= 0 to High(ggItems
) do
581 if (ggItems
[i
].ItemType
<> ITEM_NONE
) and (ggItems
[i
].slotIsUsed
) then
583 // Ñèãíàòóðà ïðåäìåòà
584 utils
.writeSign(st
, 'ITEM');
585 utils
.writeInt(st
, Byte(0));
587 tt
:= ggItems
[i
].ItemType
;
588 if ggItems
[i
].dropped
then tt
:= tt
or $80;
589 utils
.writeInt(st
, Byte(tt
));
591 utils
.writeBool(st
, ggItems
[i
].Respawnable
);
592 // Êîîðäèíàòû ðåñïóíà
593 utils
.writeInt(st
, LongInt(ggItems
[i
].InitX
));
594 utils
.writeInt(st
, LongInt(ggItems
[i
].InitY
));
596 utils
.writeInt(st
, Word(ggItems
[i
].RespawnTime
));
597 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
598 utils
.writeBool(st
, ggItems
[i
].alive
);
599 // Ìîæåò ëè îí ïàäàòü
600 utils
.writeBool(st
, ggItems
[i
].Fall
);
601 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
602 utils
.writeInt(st
, LongInt(ggItems
[i
].SpawnTrigger
));
604 Obj_SaveState(st
, @ggItems
[i
].Obj
);
610 procedure g_Items_LoadState (st
: TStream
);
612 count
, i
, a
: Integer;
619 // Êîëè÷åñòâî ïðåäìåòîâ
620 count
:= utils
.readLongInt(st
);
621 if (count
= 0) then exit
;
622 if (count
< 0) or (count
> 1024*1024) then raise XStreamError
.Create('invalid number of items');
624 for a
:= 0 to count
-1 do
626 // Ñèãíàòóðà ïðåäìåòà
627 if not utils
.checkSign(st
, 'ITEM') then raise XStreamError
.Create('invalid item signature');
628 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid item version');
630 b
:= utils
.readByte(st
); // bit7=1: monster drop
632 i
:= g_Items_Create(0, 0, b
and $7F, False, False);
633 if ((b
and $80) <> 0) then g_Items_SetDrop(i
);
635 ggItems
[i
].Respawnable
:= utils
.readBool(st
);
636 // Êîîðäèíàòû ðåñïóíà
637 ggItems
[i
].InitX
:= utils
.readLongInt(st
);
638 ggItems
[i
].InitY
:= utils
.readLongInt(st
);
640 ggItems
[i
].RespawnTime
:= utils
.readWord(st
);
641 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
642 ggItems
[i
].alive
:= utils
.readBool(st
);
643 // Ìîæåò ëè îí ïàäàòü
644 ggItems
[i
].Fall
:= utils
.readBool(st
);
645 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
646 ggItems
[i
].SpawnTrigger
:= utils
.readLongInt(st
);
648 Obj_LoadState(@ggItems
[i
].Obj
, st
);
653 procedure g_Items_RestartRound ();
658 for i
:= 0 to High(ggItems
) do
661 it
.Obj
.oldX
:= it
.Obj
.X
;
662 it
.Obj
.oldY
:= it
.Obj
.Y
;
663 if not it
.slotIsUsed
then continue
;
664 if it
.Respawnable
and (it
.ItemType
<> ITEM_NONE
) then
666 it
.QuietRespawn
:= True;
672 if g_Game_IsNet
then MH_SEND_ItemDestroy(True, i
);
678 function g_Items_ForEachAlive (cb
: TItemEachAliveCB
; backwards
: Boolean=false): Boolean;
683 if (ggItems
= nil) or not assigned(cb
) then exit
;
687 for idx
:= High(ggItems
) downto 0 do
689 if ggItems
[idx
].alive
and ggItems
[idx
].slotIsUsed
then
691 result
:= cb(@ggItems
[idx
]);
698 for idx
:= 0 to High(ggItems
) do
700 if ggItems
[idx
].alive
and ggItems
[idx
].slotIsUsed
then
702 result
:= cb(@ggItems
[idx
]);
709 function g_Items_NextAlive (startIdx
: Integer): PItem
;
714 if (ggItems
= nil) or (startIdx
>= High(ggItems
)) then exit
;
715 for idx
:= startIdx
+ 1 to High(ggItems
) do
716 if ggItems
[idx
].alive
and ggItems
[idx
].slotIsUsed
then
718 result
:= @ggItems
[idx
];
723 // ////////////////////////////////////////////////////////////////////////// //
724 procedure g_Items_EmitPickupSound (idx
: Integer);
728 if not g_Items_ValidId(idx
) then exit
;
730 g_Items_EmitPickupSoundAt(idx
, it
.Obj
.X
, it
.Obj
.Y
);
733 procedure g_Items_EmitPickupSoundAt (idx
, x
, y
: Integer);
737 if not g_Items_ValidId(idx
) then exit
;
740 if gSoundEffectsDF
then
742 if it
.ItemType
in [ITEM_SPHERE_BLUE
, ITEM_SPHERE_WHITE
, ITEM_INVUL
,
743 ITEM_INVIS
, ITEM_MEDKIT_BLACK
, ITEM_JETPACK
] then
745 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', x
, y
);
747 else if it
.ItemType
in [ITEM_WEAPON_SAW
, ITEM_WEAPON_PISTOL
, ITEM_WEAPON_SHOTGUN1
, ITEM_WEAPON_SHOTGUN2
,
748 ITEM_WEAPON_CHAINGUN
, ITEM_WEAPON_ROCKETLAUNCHER
, ITEM_WEAPON_PLASMA
,
749 ITEM_WEAPON_BFG
, ITEM_WEAPON_SUPERPULEMET
, ITEM_WEAPON_FLAMETHROWER
,
750 ITEM_AMMO_BACKPACK
] then
752 g_Sound_PlayExAt('SOUND_ITEM_GETWEAPON', x
, y
);
756 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', x
, y
);
761 if it
.ItemType
in [ITEM_SPHERE_BLUE
, ITEM_SPHERE_WHITE
, ITEM_SUIT
,
762 ITEM_MEDKIT_BLACK
, ITEM_INVUL
, ITEM_INVIS
, ITEM_JETPACK
] then
764 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', x
, y
);
766 else if it
.ItemType
in [ITEM_WEAPON_SAW
, ITEM_WEAPON_PISTOL
, ITEM_WEAPON_SHOTGUN1
, ITEM_WEAPON_SHOTGUN2
,
767 ITEM_WEAPON_CHAINGUN
, ITEM_WEAPON_ROCKETLAUNCHER
, ITEM_WEAPON_PLASMA
,
768 ITEM_WEAPON_BFG
, ITEM_WEAPON_SUPERPULEMET
, ITEM_WEAPON_FLAMETHROWER
] then
770 g_Sound_PlayExAt('SOUND_ITEM_GETWEAPON', x
, y
);
774 g_Sound_PlayExAt('SOUND_ITEM_GETITEM', x
, y
);
780 procedure g_Items_AddDynLights();
785 for f
:= 0 to High(ggItems
) do
788 if not it
.alive
then continue
;
790 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);
791 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);
792 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);
793 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);
794 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);
795 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);
796 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);
797 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);
798 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);
799 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);
800 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);
801 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);