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
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)');
250 var
253 begin
255 // no free slots
259 begin
268 //if not freeIds.hasFree[LongWord(i)] then raise Exception.Create('internal error in item idx manager');
274 begin
277 if (Integer(result) > High(ggItems)) then raise Exception.Create('allocItem: freeid list corrupted');
278 if (ggItems[result].arrIdx <> Integer(result)) then raise Exception.Create('allocItem: arrIdx inconsistency');
282 // it will be slow if the slot is free (we have to rebuild the heap)
284 var
287 begin
288 if (slot < 0) or (slot > $0fffffff) then raise Exception.Create('wantItemSlot: bad item slot request');
289 // do we need to grow item storate?
295 begin
297 end
298 else
299 begin
300 if not freeIds.hasAlloced[slot] then raise Exception.Create('wantItemSlot: internal error in item idx manager');
308 // ////////////////////////////////////////////////////////////////////////// //
310 begin
315 begin
324 var
327 begin
330 //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
334 if (it.arrIdx <> Integer(find_id)) then raise Exception.Create('g_Items_Create: arrIdx inconsistency');
335 //it.arrIdx := find_id;
357 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà
359 begin
361 begin
378 var
380 begin
384 begin
391 var
395 begin
398 // respawn items in 15 seconds regardless of settings during warmup
402 begin
407 begin
411 begin
413 begin
417 // Ñîïðîòèâëåíèå âîçäóõà
420 // Åñëè âûïàë çà êàðòó
422 begin
424 begin
426 end
427 else
428 begin
432 continue;
436 // Åñëè èãðîêè ïîáëèçîñòè
438 begin
442 begin
447 begin
454 {
455 Doom 2D: Original:
456 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
457 +2. I_MEGA,I_INVL,I_SUPER
458 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
459 }
462 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì
464 begin
467 else
471 break;
481 begin
484 begin
486 {$IFDEF ENABLE_GFX}
488 R_GFX_ITEM_RESPAWN,
491 );
492 {$ENDIF}
514 begin
516 begin
523 begin
525 begin
529 ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36;
535 var
538 begin
540 begin
541 //writeln('g_Items_Remove: invalid item id: ', ID);
543 //exit;
560 var
563 begin
564 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ
566 for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then Inc(count);
568 // Êîëè÷åñòâî ïðåäìåòîâ
573 begin
575 begin
576 // Ñèãíàòóðà ïðåäìåòà
579 // Òèï ïðåäìåòà
583 // Åñòü ëè ðåñïàóí
585 // Êîîðäèíàòû ðåñïóíà
588 // Âðåìÿ äî ðåñïàóíà
590 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
592 // Ìîæåò ëè îí ïàäàòü
594 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
596 // Îáúåêò ïðåäìåòà
604 var
607 begin
612 // Êîëè÷åñòâî ïðåäìåòîâ
615 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid number of items');
618 begin
619 // Ñèãíàòóðà ïðåäìåòà
622 // Òèï ïðåäìåòà
624 // Ñîçäàåì ïðåäìåò
627 // Åñòü ëè ðåñïàóí
629 // Êîîðäèíàòû ðåñïóíà
632 // Âðåìÿ äî ðåñïàóíà
634 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
636 // Ìîæåò ëè îí ïàäàòü
638 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
640 // Îáúåêò ïðåäìåòà
647 var
650 begin
652 begin
658 begin
661 end
662 else
663 begin
672 var
674 begin
679 begin
681 begin
683 begin
688 end
689 else
690 begin
692 begin
694 begin
703 var
705 begin
710 begin
712 exit;
716 // ////////////////////////////////////////////////////////////////////////// //
718 var
720 begin
727 var
729 begin
734 begin
737 begin
739 end
740 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
744 begin
746 end
747 else
748 begin
751 end
752 else
753 begin
756 begin
758 end
759 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
762 begin
764 end
765 else
766 begin
774 var
777 begin
779 begin
783 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);
784 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);
785 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);
786 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);
787 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);
788 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);
789 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);
790 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);
791 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);
792 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);
793 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);
794 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);