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 const
27 Type
30 private
31 //treeNode: Integer;
35 public
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!
82 type
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 begin
314 begin
323 var
326 begin
329 //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
333 if (it.arrIdx <> Integer(find_id)) then raise Exception.Create('g_Items_Create: arrIdx inconsistency');
334 //it.arrIdx := find_id;
356 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà
358 begin
360 begin
377 var
379 begin
383 begin
390 var
394 begin
397 // respawn items in 15 seconds regardless of settings during warmup
401 begin
406 begin
410 begin
412 begin
416 // Ñîïðîòèâëåíèå âîçäóõà
419 // Åñëè âûïàë çà êàðòó
421 begin
423 begin
425 end
426 else
427 begin
431 continue;
435 // Åñëè èãðîêè ïîáëèçîñòè
437 begin
441 begin
446 begin
453 {
454 Doom 2D: Original:
455 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
456 +2. I_MEGA,I_INVL,I_SUPER
457 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
458 }
461 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì
463 begin
466 else
470 break;
480 begin
483 begin
485 {$IFDEF ENABLE_GFX}
487 R_GFX_ITEM_RESPAWN,
490 );
491 {$ENDIF}
513 begin
515 begin
522 begin
524 begin
528 ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36;
534 var
537 begin
539 begin
540 //writeln('g_Items_Remove: invalid item id: ', ID);
542 //exit;
559 var
562 begin
563 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ
565 for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then Inc(count);
567 // Êîëè÷åñòâî ïðåäìåòîâ
572 begin
574 begin
575 // Ñèãíàòóðà ïðåäìåòà
578 // Òèï ïðåäìåòà
582 // Åñòü ëè ðåñïàóí
584 // Êîîðäèíàòû ðåñïóíà
587 // Âðåìÿ äî ðåñïàóíà
589 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
591 // Ìîæåò ëè îí ïàäàòü
593 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
595 // Îáúåêò ïðåäìåòà
603 var
606 begin
611 // Êîëè÷åñòâî ïðåäìåòîâ
614 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid number of items');
617 begin
618 // Ñèãíàòóðà ïðåäìåòà
621 // Òèï ïðåäìåòà
623 // Ñîçäàåì ïðåäìåò
626 // Åñòü ëè ðåñïàóí
628 // Êîîðäèíàòû ðåñïóíà
631 // Âðåìÿ äî ðåñïàóíà
633 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
635 // Ìîæåò ëè îí ïàäàòü
637 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
639 // Îáúåêò ïðåäìåòà
646 var
649 begin
651 begin
657 begin
660 end
661 else
662 begin
671 var
673 begin
678 begin
680 begin
682 begin
687 end
688 else
689 begin
691 begin
693 begin
702 var
704 begin
709 begin
711 exit;
715 // ////////////////////////////////////////////////////////////////////////// //
717 var
719 begin
726 var
728 begin
733 begin
736 begin
738 end
739 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
743 begin
745 end
746 else
747 begin
750 end
751 else
752 begin
755 begin
757 end
758 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
761 begin
763 end
764 else
765 begin
773 var
776 begin
778 begin
782 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);
783 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);
784 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);
785 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);
786 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);
787 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);
788 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);
789 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);
790 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);
791 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);
792 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);
793 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);