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
42 dropped: Boolean; // dropped from the monster? drops should be rendered after corpses, so zombie corpse will not obscure ammo container, for example
45 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
79 type
85 var
91 implementation
93 uses
94 {$IFDEF ENABLE_GFX}
95 g_gfx,
96 {$ENDIF}
97 Math,
102 ;
104 // ////////////////////////////////////////////////////////////////////////// //
105 var
109 // ////////////////////////////////////////////////////////////////////////// //
111 begin
120 begin
121 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
123 if not result.slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
128 begin
129 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
130 if not ggItems[idx].slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
135 // ////////////////////////////////////////////////////////////////////////// //
137 begin
142 begin
150 begin
152 begin
159 // ////////////////////////////////////////////////////////////////////////// //
160 const
204 begin
217 begin
231 var
233 begin
234 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('releaseItem: invalid item id');
235 if not freeIds.hasAlloced[LongWord(idx)] then raise Exception.Create('releaseItem: trying to release unallocated item (0)');
237 if not it.slotIsUsed then raise Exception.Create('releaseItem: trying to release unallocated item (1)');
249 var
252 begin
254 // no free slots
258 begin
267 //if not freeIds.hasFree[LongWord(i)] then raise Exception.Create('internal error in item idx manager');
273 begin
276 if (Integer(result) > High(ggItems)) then raise Exception.Create('allocItem: freeid list corrupted');
277 if (ggItems[result].arrIdx <> Integer(result)) then raise Exception.Create('allocItem: arrIdx inconsistency');
281 // it will be slow if the slot is free (we have to rebuild the heap)
283 var
286 begin
287 if (slot < 0) or (slot > $0fffffff) then raise Exception.Create('wantItemSlot: bad item slot request');
288 // do we need to grow item storate?
294 begin
296 end
297 else
298 begin
299 if not freeIds.hasAlloced[slot] then raise Exception.Create('wantItemSlot: internal error in item idx manager');
307 // ////////////////////////////////////////////////////////////////////////// //
309 var
311 begin
312 if gMapInfo.Height > gPlayerScreenSize.Y then a := gMapInfo.Height-gPlayerScreenSize.Y else a := gMapInfo.Height;
313 if gMapInfo.Width > gPlayerScreenSize.X then b := gMapInfo.Width-gPlayerScreenSize.X else b := gMapInfo.Width;
319 begin
328 var
331 begin
334 //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
338 if (it.arrIdx <> Integer(find_id)) then raise Exception.Create('g_Items_Create: arrIdx inconsistency');
339 //it.arrIdx := find_id;
361 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà
363 begin
365 begin
382 var
384 begin
388 begin
395 var
399 begin
402 // respawn items in 15 seconds regardless of settings during warmup
406 begin
411 begin
415 begin
417 begin
421 // Ñîïðîòèâëåíèå âîçäóõà
424 // Åñëè âûïàë çà êàðòó
426 begin
428 begin
430 end
431 else
432 begin
436 continue;
440 // Åñëè èãðîêè ïîáëèçîñòè
442 begin
446 begin
451 begin
458 {
459 Doom 2D: Original:
460 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
461 +2. I_MEGA,I_INVL,I_SUPER
462 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
463 }
466 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì
468 begin
471 else
475 break;
485 begin
488 begin
490 {$IFDEF ENABLE_GFX}
492 R_GFX_ITEM_RESPAWN,
495 );
496 {$ENDIF}
518 begin
520 begin
527 begin
529 begin
533 ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36;
539 var
542 begin
544 begin
545 //writeln('g_Items_Remove: invalid item id: ', ID);
547 //exit;
564 var
567 begin
568 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ
570 for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then Inc(count);
572 // Êîëè÷åñòâî ïðåäìåòîâ
577 begin
579 begin
580 // Ñèãíàòóðà ïðåäìåòà
583 // Òèï ïðåäìåòà
587 // Åñòü ëè ðåñïàóí
589 // Êîîðäèíàòû ðåñïóíà
592 // Âðåìÿ äî ðåñïàóíà
594 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
596 // Ìîæåò ëè îí ïàäàòü
598 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
600 // Îáúåêò ïðåäìåòà
608 var
611 begin
616 // Êîëè÷åñòâî ïðåäìåòîâ
619 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid number of items');
622 begin
623 // Ñèãíàòóðà ïðåäìåòà
626 // Òèï ïðåäìåòà
628 // Ñîçäàåì ïðåäìåò
631 // Åñòü ëè ðåñïàóí
633 // Êîîðäèíàòû ðåñïóíà
636 // Âðåìÿ äî ðåñïàóíà
638 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
640 // Ìîæåò ëè îí ïàäàòü
642 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
644 // Îáúåêò ïðåäìåòà
651 var
654 begin
656 begin
662 begin
665 end
666 else
667 begin
676 var
678 begin
683 begin
685 begin
687 begin
692 end
693 else
694 begin
696 begin
698 begin
707 var
709 begin
714 begin
716 exit;
720 // ////////////////////////////////////////////////////////////////////////// //
722 var
724 begin
731 var
733 begin
738 begin
741 begin
743 end
744 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
748 begin
750 end
751 else
752 begin
755 end
756 else
757 begin
760 begin
762 end
763 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
778 var
781 begin
783 begin
787 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);
788 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);
789 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);
790 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);
791 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);
792 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);
793 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);
794 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);
795 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);
796 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);
797 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);
798 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);