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
397 begin
400 // respawn items in 15 seconds regardless of settings during warmup
404 begin
409 begin
413 begin
415 begin
419 // Ñîïðîòèâëåíèå âîçäóõà
422 // Åñëè âûïàë çà êàðòó
424 begin
426 begin
428 end
429 else
430 begin
434 continue;
438 // Åñëè èãðîêè ïîáëèçîñòè
440 begin
444 begin
449 begin
456 {
457 Doom 2D: Original:
458 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
459 +2. I_MEGA,I_INVL,I_SUPER
460 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
461 }
464 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì
466 begin
469 else
473 break;
483 begin
486 begin
488 r_GFX_OnceAnim(R_GFX_ITEM_RESPAWN, InitX + (Obj.Rect.Width div 2) - 16, InitY + (Obj.Rect.Height div 2) - 16);
512 begin
514 begin
521 begin
523 begin
527 ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36;
533 var
536 begin
538 begin
539 //writeln('g_Items_Remove: invalid item id: ', ID);
541 //exit;
558 var
561 begin
562 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ
564 for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then Inc(count);
566 // Êîëè÷åñòâî ïðåäìåòîâ
571 begin
573 begin
574 // Ñèãíàòóðà ïðåäìåòà
577 // Òèï ïðåäìåòà
581 // Åñòü ëè ðåñïàóí
583 // Êîîðäèíàòû ðåñïóíà
586 // Âðåìÿ äî ðåñïàóíà
588 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
590 // Ìîæåò ëè îí ïàäàòü
592 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
594 // Îáúåêò ïðåäìåòà
602 var
605 begin
610 // Êîëè÷åñòâî ïðåäìåòîâ
613 if (count < 0) or (count > 1024*1024) then raise XStreamError.Create('invalid number of items');
616 begin
617 // Ñèãíàòóðà ïðåäìåòà
620 // Òèï ïðåäìåòà
622 // Ñîçäàåì ïðåäìåò
625 // Åñòü ëè ðåñïàóí
627 // Êîîðäèíàòû ðåñïóíà
630 // Âðåìÿ äî ðåñïàóíà
632 // Ñóùåñòâóåò ëè ýòîò ïðåäìåò
634 // Ìîæåò ëè îí ïàäàòü
636 // Èíäåêñ òðèããåðà, ñîçäàâøåãî ïðåäìåò
638 // Îáúåêò ïðåäìåòà
645 var
648 begin
650 begin
656 begin
659 end
660 else
661 begin
670 var
672 begin
677 begin
679 begin
681 begin
686 end
687 else
688 begin
690 begin
692 begin
701 // ////////////////////////////////////////////////////////////////////////// //
703 var
705 begin
712 var
714 begin
719 begin
722 begin
724 end
725 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
729 begin
731 end
732 else
733 begin
736 end
737 else
738 begin
741 begin
743 end
744 else if it.ItemType in [ITEM_WEAPON_SAW, ITEM_WEAPON_PISTOL, ITEM_WEAPON_SHOTGUN1, ITEM_WEAPON_SHOTGUN2,
747 begin
749 end
750 else
751 begin
759 var
762 begin
764 begin
768 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);
769 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);
770 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);
771 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);
772 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);
773 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);
774 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);
775 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);
776 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);
777 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);
778 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);
779 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);