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}
18 interface
20 uses
24 Type
27 private
28 //treeNode: Integer;
32 public
43 dropped: Boolean; // dropped from the monster? drops should be rendered after corpses, so zombie corpse will not obscure ammo container, for example
46 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
80 type
86 var
92 implementation
94 uses
95 {$IFDEF ENABLE_GFX}
96 g_gfx,
97 {$ENDIF}
98 Math,
103 ;
105 // ////////////////////////////////////////////////////////////////////////// //
106 var
110 // ////////////////////////////////////////////////////////////////////////// //
112 begin
121 begin
122 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
124 if not result.slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
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');
136 // ////////////////////////////////////////////////////////////////////////// //
138 begin
143 begin
151 begin
153 begin
160 // ////////////////////////////////////////////////////////////////////////// //
161 const
205 begin
218 begin
232 var
234 begin
235 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('releaseItem: invalid item id');
236 if not freeIds.hasAlloced[LongWord(idx)] then raise Exception.Create('releaseItem: trying to release unallocated item (0)');
238 if not it.slotIsUsed then raise Exception.Create('releaseItem: trying to release unallocated item (1)');
242 begin
255 var
258 begin
260 // no free slots
264 begin
274 //if not freeIds.hasFree[LongWord(i)] then raise Exception.Create('internal error in item idx manager');
280 begin
283 if (Integer(result) > High(ggItems)) then raise Exception.Create('allocItem: freeid list corrupted');
284 if (ggItems[result].arrIdx <> Integer(result)) then raise Exception.Create('allocItem: arrIdx inconsistency');
288 // it will be slow if the slot is free (we have to rebuild the heap)
290 var
293 begin
294 if (slot < 0) or (slot > $0fffffff) then raise Exception.Create('wantItemSlot: bad item slot request');
295 // do we need to grow item storate?
301 begin
303 end
304 else
305 begin
306 if not freeIds.hasAlloced[slot] then raise Exception.Create('wantItemSlot: internal error in item idx manager');
314 // ////////////////////////////////////////////////////////////////////////// //
316 var
318 begin
319 if gMapInfo.Height > gPlayerScreenSize.Y then a := gMapInfo.Height-gPlayerScreenSize.Y else a := gMapInfo.Height;
320 if gMapInfo.Width > gPlayerScreenSize.X then b := gMapInfo.Width-gPlayerScreenSize.X else b := gMapInfo.Width;
326 var
328 begin
330 begin
340 var
343 begin
346 //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
350 if (it.arrIdx <> Integer(find_id)) then raise Exception.Create('g_Items_Create: arrIdx inconsistency');
351 //it.arrIdx := find_id;
374 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà
376 begin
378 begin
389 // Óñòàíîâêà àíèìàöèè
408 var
410 begin
414 begin
421 var
425 begin
428 // respawn items in 15 seconds regardless of settings during warmup
432 begin
437 begin
441 begin
443 begin
447 // Ñîïðîòèâëåíèå âîçäóõà
450 // Åñëè âûïàë çà êàðòó
452 begin
454 begin
456 end
457 else
458 begin
462 continue;
466 // Åñëè èãðîêè ïîáëèçîñòè
468 begin
472 begin
477 begin
484 {
485 Doom 2D: Original:
486 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
487 +2. I_MEGA,I_INVL,I_SUPER
488 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
489 }
492 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì
494 begin
497 else
501 break;
511 begin
514 begin
516 {$IFDEF ENABLE_GFX}
518 R_GFX_ITEM_RESPAWN,
521 );
522 {$ENDIF}
546 begin
548 begin
555 begin
557 begin
561 ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36;
567 var
570 begin
572 begin
573 //writeln('g_Items_Remove: invalid item id: ', ID);
575 //exit;
592 var
595 begin
596 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ
598 for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then Inc(count);
600 // Êîëè÷åñòâî ïðåäìåòîâ
605 begin
607 begin
608 // Ñèãíàòóðà ïðåäìåòà
611 // Òèï ïðåäìåòà
615 // Åñòü ëè ðåñïàóí
617 // Êîîðäèíàòû ðåñïóíà
620 // Âðåìÿ äî ðåñïàóíà
622 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
624 // Ìîæåò ëè îí ïàäàòü
626 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
628 // Îáúåêò ïðåäìåòà
636 var
639 begin
644 // Êîëè÷åñòâî ïðåäìåòîâ
647 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid number of items');
650 begin
651 // Ñèãíàòóðà ïðåäìåòà
654 // Òèï ïðåäìåòà
656 // Ñîçäàåì ïðåäìåò
659 // Åñòü ëè ðåñïàóí
661 // Êîîðäèíàòû ðåñïóíà
664 // Âðåìÿ äî ðåñïàóíà
666 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
668 // Ìîæåò ëè îí ïàäàòü
670 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
672 // Îáúåêò ïðåäìåòà
679 var
682 begin
684 begin
690 begin
693 end
694 else
695 begin
704 var
706 begin
711 begin
713 begin
715 begin
720 end
721 else
722 begin
724 begin
726 begin
735 var
737 begin
742 begin
744 exit;
748 // ////////////////////////////////////////////////////////////////////////// //
750 var
752 begin
759 var
761 begin
766 begin
769 begin
771 end
772 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
776 begin
778 end
779 else
780 begin
783 end
784 else
785 begin
788 begin
790 end
791 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
794 begin
796 end
797 else
798 begin
806 var
809 begin
811 begin
815 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);
816 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);
817 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);
818 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);
819 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);
820 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);
821 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);
822 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);
823 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);
824 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);
825 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);
826 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);