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 Math,
101 // ////////////////////////////////////////////////////////////////////////// //
102 var
106 // ////////////////////////////////////////////////////////////////////////// //
108 begin
117 begin
118 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
120 if not result.slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
125 begin
126 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
127 if not ggItems[idx].slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
132 // ////////////////////////////////////////////////////////////////////////// //
134 begin
139 begin
147 begin
149 begin
156 // ////////////////////////////////////////////////////////////////////////// //
157 const
201 begin
214 begin
228 var
230 begin
231 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('releaseItem: invalid item id');
232 if not freeIds.hasAlloced[LongWord(idx)] then raise Exception.Create('releaseItem: trying to release unallocated item (0)');
234 if not it.slotIsUsed then raise Exception.Create('releaseItem: trying to release unallocated item (1)');
238 begin
251 var
254 begin
256 // no free slots
260 begin
270 //if not freeIds.hasFree[LongWord(i)] then raise Exception.Create('internal error in item idx manager');
276 begin
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)
286 var
289 begin
290 if (slot < 0) or (slot > $0fffffff) then raise Exception.Create('wantItemSlot: bad item slot request');
291 // do we need to grow item storate?
297 begin
299 end
300 else
301 begin
302 if not freeIds.hasAlloced[slot] then raise Exception.Create('wantItemSlot: internal error in item idx manager');
310 // ////////////////////////////////////////////////////////////////////////// //
312 var
314 begin
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;
322 var
324 begin
326 begin
336 var
339 begin
342 //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
346 if (it.arrIdx <> Integer(find_id)) then raise Exception.Create('g_Items_Create: arrIdx inconsistency');
347 //it.arrIdx := find_id;
370 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà
372 begin
374 begin
385 // Óñòàíîâêà àíèìàöèè
404 var
406 begin
410 begin
417 var
421 begin
424 // respawn items in 15 seconds regardless of settings during warmup
428 begin
433 begin
437 begin
439 begin
443 // Ñîïðîòèâëåíèå âîçäóõà
446 // Åñëè âûïàë çà êàðòó
448 begin
450 begin
452 end
453 else
454 begin
458 continue;
462 // Åñëè èãðîêè ïîáëèçîñòè
464 begin
468 begin
473 begin
480 {
481 Doom 2D: Original:
482 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
483 +2. I_MEGA,I_INVL,I_SUPER
484 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
485 }
488 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì
490 begin
493 else
497 break;
507 begin
510 begin
512 g_GFX_QueueEffect(R_GFX_ITEM_RESPAWN, InitX + (Obj.Rect.Width div 2) - 16, InitY + (Obj.Rect.Height div 2) - 16);
536 begin
538 begin
545 begin
547 begin
551 ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36;
557 var
560 begin
562 begin
563 //writeln('g_Items_Remove: invalid item id: ', ID);
565 //exit;
582 var
585 begin
586 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ
588 for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then Inc(count);
590 // Êîëè÷åñòâî ïðåäìåòîâ
595 begin
597 begin
598 // Ñèãíàòóðà ïðåäìåòà
601 // Òèï ïðåäìåòà
605 // Åñòü ëè ðåñïàóí
607 // Êîîðäèíàòû ðåñïóíà
610 // Âðåìÿ äî ðåñïàóíà
612 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
614 // Ìîæåò ëè îí ïàäàòü
616 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
618 // Îáúåêò ïðåäìåòà
626 var
629 begin
634 // Êîëè÷åñòâî ïðåäìåòîâ
637 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid number of items');
640 begin
641 // Ñèãíàòóðà ïðåäìåòà
644 // Òèï ïðåäìåòà
646 // Ñîçäàåì ïðåäìåò
649 // Åñòü ëè ðåñïàóí
651 // Êîîðäèíàòû ðåñïóíà
654 // Âðåìÿ äî ðåñïàóíà
656 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
658 // Ìîæåò ëè îí ïàäàòü
660 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
662 // Îáúåêò ïðåäìåòà
669 var
672 begin
674 begin
680 begin
683 end
684 else
685 begin
694 var
696 begin
701 begin
703 begin
705 begin
710 end
711 else
712 begin
714 begin
716 begin
725 var
727 begin
732 begin
734 exit;
738 // ////////////////////////////////////////////////////////////////////////// //
740 var
742 begin
749 var
751 begin
756 begin
759 begin
761 end
762 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
766 begin
768 end
769 else
770 begin
773 end
774 else
775 begin
778 begin
780 end
781 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
784 begin
786 end
787 else
788 begin
796 var
799 begin
801 begin
805 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);
806 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);
807 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);
808 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);
809 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);
810 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);
811 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);
812 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);
813 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);
814 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);
815 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);
816 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);