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 Math,
98 // ////////////////////////////////////////////////////////////////////////// //
99 var
103 // ////////////////////////////////////////////////////////////////////////// //
105 begin
114 begin
115 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
117 if not result.slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
122 begin
123 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('g_ItemObjByIdx: invalid index');
124 if not ggItems[idx].slotIsUsed then raise Exception.Create('g_ItemObjByIdx: requested inexistent item');
129 // ////////////////////////////////////////////////////////////////////////// //
131 begin
135 // ////////////////////////////////////////////////////////////////////////// //
136 const
180 begin
193 begin
207 var
209 begin
210 if (idx < 0) or (idx > High(ggItems)) then raise Exception.Create('releaseItem: invalid item id');
211 if not freeIds.hasAlloced[LongWord(idx)] then raise Exception.Create('releaseItem: trying to release unallocated item (0)');
213 if not it.slotIsUsed then raise Exception.Create('releaseItem: trying to release unallocated item (1)');
217 begin
229 var
232 begin
234 // no free slots
238 begin
247 //if not freeIds.hasFree[LongWord(i)] then raise Exception.Create('internal error in item idx manager');
253 begin
256 if (Integer(result) > High(ggItems)) then raise Exception.Create('allocItem: freeid list corrupted');
257 if (ggItems[result].arrIdx <> Integer(result)) then raise Exception.Create('allocItem: arrIdx inconsistency');
261 // it will be slow if the slot is free (we have to rebuild the heap)
263 var
266 begin
267 if (slot < 0) or (slot > $0fffffff) then raise Exception.Create('wantItemSlot: bad item slot request');
268 // do we need to grow item storate?
274 begin
276 end
277 else
278 begin
279 if not freeIds.hasAlloced[slot] then raise Exception.Create('wantItemSlot: internal error in item idx manager');
287 // ////////////////////////////////////////////////////////////////////////// //
289 var
291 begin
292 if gMapInfo.Height > gPlayerScreenSize.Y then a := gMapInfo.Height-gPlayerScreenSize.Y else a := gMapInfo.Height;
293 if gMapInfo.Width > gPlayerScreenSize.X then b := gMapInfo.Width-gPlayerScreenSize.X else b := gMapInfo.Width;
299 var
301 begin
303 begin
313 var
316 begin
319 //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
323 if (it.arrIdx <> Integer(find_id)) then raise Exception.Create('g_Items_Create: arrIdx inconsistency');
324 //it.arrIdx := find_id;
346 // Êîîðäèíàòû îòíîñèòåëüíî öåíòðà íèæíåãî ðåáðà
348 begin
350 begin
361 // Óñòàíîâêà àíèìàöèè
380 var
382 begin
386 begin
393 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
492 begin
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 // ////////////////////////////////////////////////////////////////////////// //
712 var
714 begin
721 var
723 begin
728 begin
731 begin
733 end
734 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
738 begin
740 end
741 else
742 begin
745 end
746 else
747 begin
750 begin
752 end
753 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
756 begin
758 end
759 else
760 begin
768 var
771 begin
773 begin
777 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);
778 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);
779 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);
780 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);
781 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);
782 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);
783 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);
784 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);
785 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);
786 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);
787 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);
788 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);