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
88 var
94 implementation
96 uses
97 {$IFDEF ENABLE_GFX}
98 g_gfx,
99 {$ENDIF}
100 Math,
105 ;
107 // ////////////////////////////////////////////////////////////////////////// //
108 var
112 // ////////////////////////////////////////////////////////////////////////// //
114 begin
123 begin
124 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
126 if not result.slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
131 begin
132 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
133 if not ggItems[idx].slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
138 // ////////////////////////////////////////////////////////////////////////// //
140 begin
145 begin
153 begin
155 begin
162 // ////////////////////////////////////////////////////////////////////////// //
163 const
207 begin
220 begin
234 var
236 begin
237 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('releaseItem: invalid item id');
238 if not freeIds.hasAlloced[LongWord(idx)] then raise Exception.Create('releaseItem: trying to release unallocated item (0)');
240 if not it.slotIsUsed then raise Exception.Create('releaseItem: trying to release unallocated item (1)');
252 var
255 begin
257 // no free slots
261 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 begin
331 var
334 begin
337 //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
341 if (it.arrIdx <> Integer(find_id)) then raise Exception.Create('g_Items_Create: arrIdx inconsistency');
342 //it.arrIdx := find_id;
364 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà
366 begin
368 begin
385 var
387 begin
391 begin
398 var
402 begin
405 // respawn items in 15 seconds regardless of settings during warmup
409 begin
414 begin
418 begin
420 begin
424 // Ñîïðîòèâëåíèå âîçäóõà
427 // Åñëè âûïàë çà êàðòó
429 begin
431 begin
433 end
434 else
435 begin
439 continue;
443 // Åñëè èãðîêè ïîáëèçîñòè
445 begin
449 begin
454 begin
461 {
462 Doom 2D: Original:
463 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
464 +2. I_MEGA,I_INVL,I_SUPER
465 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
466 }
469 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì
471 begin
474 else
478 break;
488 begin
491 begin
493 {$IFDEF ENABLE_GFX}
495 R_GFX_ITEM_RESPAWN,
498 );
499 {$ENDIF}
521 begin
523 begin
530 begin
532 begin
536 ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36;
542 var
545 begin
547 begin
548 //writeln('g_Items_Remove: invalid item id: ', ID);
550 //exit;
567 var
570 begin
571 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ
573 for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then Inc(count);
575 // Êîëè÷åñòâî ïðåäìåòîâ
580 begin
582 begin
583 // Ñèãíàòóðà ïðåäìåòà
586 // Òèï ïðåäìåòà
590 // Åñòü ëè ðåñïàóí
592 // Êîîðäèíàòû ðåñïóíà
595 // Âðåìÿ äî ðåñïàóíà
597 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
599 // Ìîæåò ëè îí ïàäàòü
601 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
603 // Îáúåêò ïðåäìåòà
611 var
614 begin
619 // Êîëè÷åñòâî ïðåäìåòîâ
622 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid number of items');
625 begin
626 // Ñèãíàòóðà ïðåäìåòà
629 // Òèï ïðåäìåòà
631 // Ñîçäàåì ïðåäìåò
634 // Åñòü ëè ðåñïàóí
636 // Êîîðäèíàòû ðåñïóíà
639 // Âðåìÿ äî ðåñïàóíà
641 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
643 // Ìîæåò ëè îí ïàäàòü
645 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
647 // Îáúåêò ïðåäìåòà
654 var
657 begin
659 begin
665 begin
668 end
669 else
670 begin
679 var
681 begin
686 begin
688 begin
690 begin
695 end
696 else
697 begin
699 begin
701 begin
710 var
712 begin
717 begin
719 exit;
723 // ////////////////////////////////////////////////////////////////////////// //
725 var
727 begin
734 var
736 begin
741 begin
744 begin
746 end
747 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
751 begin
753 end
754 else
755 begin
758 end
759 else
760 begin
763 begin
765 end
766 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
769 begin
771 end
772 else
773 begin
781 var
784 begin
786 begin
790 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);
791 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);
792 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);
793 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);
794 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);
795 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);
796 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);
797 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);
798 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);
799 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);
800 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);
801 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);