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
45 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
77 type
83 var
89 implementation
91 uses
92 {$IFDEF ENABLE_GFX}
93 g_gfx,
94 {$ENDIF}
95 Math,
100 ;
102 // ////////////////////////////////////////////////////////////////////////// //
103 var
107 // ////////////////////////////////////////////////////////////////////////// //
109 begin
118 begin
119 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
121 if not result.slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
126 begin
127 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
128 if not ggItems[idx].slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
133 // ////////////////////////////////////////////////////////////////////////// //
135 begin
139 // ////////////////////////////////////////////////////////////////////////// //
140 const
184 begin
197 begin
211 var
213 begin
214 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('releaseItem: invalid item id');
215 if not freeIds.hasAlloced[LongWord(idx)] then raise Exception.Create('releaseItem: trying to release unallocated item (0)');
217 if not it.slotIsUsed then raise Exception.Create('releaseItem: trying to release unallocated item (1)');
221 begin
233 var
236 begin
238 // no free slots
242 begin
251 //if not freeIds.hasFree[LongWord(i)] then raise Exception.Create('internal error in item idx manager');
257 begin
260 if (Integer(result) > High(ggItems)) then raise Exception.Create('allocItem: freeid list corrupted');
261 if (ggItems[result].arrIdx <> Integer(result)) then raise Exception.Create('allocItem: arrIdx inconsistency');
265 // it will be slow if the slot is free (we have to rebuild the heap)
267 var
270 begin
271 if (slot < 0) or (slot > $0fffffff) then raise Exception.Create('wantItemSlot: bad item slot request');
272 // do we need to grow item storate?
278 begin
280 end
281 else
282 begin
283 if not freeIds.hasAlloced[slot] then raise Exception.Create('wantItemSlot: internal error in item idx manager');
291 // ////////////////////////////////////////////////////////////////////////// //
293 var
295 begin
296 if gMapInfo.Height > gPlayerScreenSize.Y then a := gMapInfo.Height-gPlayerScreenSize.Y else a := gMapInfo.Height;
297 if gMapInfo.Width > gPlayerScreenSize.X then b := gMapInfo.Width-gPlayerScreenSize.X else b := gMapInfo.Width;
303 var
305 begin
307 begin
317 var
320 begin
323 //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
327 if (it.arrIdx <> Integer(find_id)) then raise Exception.Create('g_Items_Create: arrIdx inconsistency');
328 //it.arrIdx := find_id;
350 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà
352 begin
354 begin
365 // Óñòàíîâêà àíèìàöèè
384 var
386 begin
390 begin
397 var
401 begin
404 // respawn items in 15 seconds regardless of settings during warmup
408 begin
413 begin
417 begin
419 begin
423 // Ñîïðîòèâëåíèå âîçäóõà
426 // Åñëè âûïàë çà êàðòó
428 begin
430 begin
432 end
433 else
434 begin
438 continue;
442 // Åñëè èãðîêè ïîáëèçîñòè
444 begin
448 begin
453 begin
460 {
461 Doom 2D: Original:
462 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
463 +2. I_MEGA,I_INVL,I_SUPER
464 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
465 }
468 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì
470 begin
473 else
477 break;
487 begin
490 begin
492 {$IFDEF ENABLE_GFX}
494 R_GFX_ITEM_RESPAWN,
497 );
498 {$ENDIF}
522 begin
524 begin
531 begin
533 begin
537 ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36;
543 var
546 begin
548 begin
549 //writeln('g_Items_Remove: invalid item id: ', ID);
551 //exit;
568 var
571 begin
572 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ
574 for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then Inc(count);
576 // Êîëè÷åñòâî ïðåäìåòîâ
581 begin
583 begin
584 // Ñèãíàòóðà ïðåäìåòà
587 // Òèï ïðåäìåòà
591 // Åñòü ëè ðåñïàóí
593 // Êîîðäèíàòû ðåñïóíà
596 // Âðåìÿ äî ðåñïàóíà
598 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
600 // Ìîæåò ëè îí ïàäàòü
602 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
604 // Îáúåêò ïðåäìåòà
612 var
615 begin
620 // Êîëè÷åñòâî ïðåäìåòîâ
623 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid number of items');
626 begin
627 // Ñèãíàòóðà ïðåäìåòà
630 // Òèï ïðåäìåòà
632 // Ñîçäàåì ïðåäìåò
635 // Åñòü ëè ðåñïàóí
637 // Êîîðäèíàòû ðåñïóíà
640 // Âðåìÿ äî ðåñïàóíà
642 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
644 // Ìîæåò ëè îí ïàäàòü
646 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
648 // Îáúåêò ïðåäìåòà
655 var
658 begin
660 begin
666 begin
669 end
670 else
671 begin
680 var
682 begin
687 begin
689 begin
691 begin
696 end
697 else
698 begin
700 begin
702 begin
711 // ////////////////////////////////////////////////////////////////////////// //
713 var
715 begin
722 var
724 begin
729 begin
732 begin
734 end
735 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
739 begin
741 end
742 else
743 begin
746 end
747 else
748 begin
751 begin
753 end
754 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
757 begin
759 end
760 else
761 begin
769 var
772 begin
774 begin
778 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);
779 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);
780 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);
781 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);
782 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);
783 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);
784 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);
785 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);
786 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);
787 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);
788 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);
789 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);