mapinfo: ignore some more fields in "UMAPINFO"
[k8vavoom.git] / progs / common / linespec / MorphedMonster.vc
blob0c20aee15dc04e3a5490327918370fe2c6f7d6b7
1 //**************************************************************************
2 //**
3 //**    ##   ##    ##    ##   ##   ####     ####   ###     ###
4 //**    ##   ##  ##  ##  ##   ##  ##  ##   ##  ##  ####   ####
5 //**     ## ##  ##    ##  ## ##  ##    ## ##    ## ## ## ## ##
6 //**     ## ##  ########  ## ##  ##    ## ##    ## ##  ###  ##
7 //**      ###   ##    ##   ###    ##  ##   ##  ##  ##       ##
8 //**       #    ##    ##    #      ####     ####   ##       ##
9 //**
10 //**  Copyright (C) 1999-2006 Jānis Legzdiņš
11 //**  Copyright (C) 2018-2023 Ketmar Dark
12 //**
13 //**  This program is free software: you can redistribute it and/or modify
14 //**  it under the terms of the GNU General Public License as published by
15 //**  the Free Software Foundation, version 3 of the License ONLY.
16 //**
17 //**  This program is distributed in the hope that it will be useful,
18 //**  but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 //**  GNU General Public License for more details.
21 //**
22 //**  You should have received a copy of the GNU General Public License
23 //**  along with this program.  If not, see <http://www.gnu.org/licenses/>.
24 //**
25 //**************************************************************************
26 class MorphedMonster : Actor;
28 int MorphStyle;
29 float UnmorphTime;
30 class!Actor UnmorphFlash;
31 EntityEx UnmorphedMo;
34 //==========================================================================
36 //  Tick
38 //==========================================================================
39 override void Tick (float DeltaTime) {
40   if (!UpdateMorphedMonster()) ::Tick(DeltaTime);
44 //==========================================================================
46 //  UpdateMorphedMonster
48 //  Returns true if the pig morphs.
50 //==========================================================================
51 bool UpdateMorphedMonster () {
52   if (Health <= 0) return false;
53   if (UnmorphTime > XLevel.Time) return false;
54   if (!UnmorphActor(none, false)) return false;
55   return true;
59 //==========================================================================
61 //  UnmorphActor
63 //==========================================================================
64 override int UnmorphActor (Entity Activator, int Force) {
65   TVec oldOrigin;
66   class!EntityEx originalClass;
67   float oldAngle;
68   int oldSpecial;
69   int oldTID;
70   int[5] oldArgs;
71   EntityEx mo;
73   originalClass = SpecialCID;
74   if (originalClass.default.bStayMorphed) return false; // these must remain morphed
76   oldOrigin = Origin;
77   oldAngle = Angles.yaw;
78   oldSpecial = Special;
79   oldTID = TID;
80   oldArgs[0] = Args[0];
81   oldArgs[1] = Args[1];
82   oldArgs[2] = Args[2];
83   oldArgs[3] = Args[3];
84   oldArgs[4] = Args[4];
86   UnlinkFromWorld();
87   mo = Spawn(originalClass, Origin, AllowReplace:false); //k8:dunno
89   if (!mo.TestLocation() && !Force) {
90     // didn't fit
91     mo.Destroy();
92     LinkToWorld(properFloorCheck:true);
93     UnmorphTime = XLevel.Time+5.0; // next try in 5 seconds
94     return false;
95   }
96   LinkToWorld(properFloorCheck:true);
97   SetTID(0);
98   mo.Angles.yaw = oldAngle;
99   mo.Special = oldSpecial;
100   mo.Args[0] = oldArgs[0];
101   mo.Args[1] = oldArgs[1];
102   mo.Args[2] = oldArgs[2];
103   mo.Args[3] = oldArgs[3];
104   mo.Args[4] = oldArgs[4];
105   mo.SetTID(oldTID);
106   mo.CopyFriendliness(self, true);
107   mo.bShadow = bShadow;
108   mo.bGhost = bGhost;
109   SetState(FindState('FreeTargMobj'));
110   UnmorphedMo = mo;
111   Spawn(UnmorphFlash ? UnmorphFlash : class!Actor(TeleportFog),
112         oldOrigin+vector(0.0, 0.0, LineSpecialGameInfo(Level.Game).TeleFogHeight));
113   return true;
117 //==========================================================================
119 //  MorphedDeath
121 //==========================================================================
122 override bool MorphedDeath (out EntityEx Morphed, out int MorphedStyle, out int MorphedHealth) {
123   if (UnmorphTime && (MorphStyle&MORPH_UNDOBYDEATH)) {
124     int RealStyle = MorphStyle;
125     int RealHealth = Health;
126     if (UnmorphActor(none, MorphStyle&MORPH_UNDOBYDEATHFORCED)) {
127       Morphed = UnmorphedMo;
128       MorphedStyle = RealStyle;
129       MorphedHealth = RealHealth;
130       return true;
131     }
132   }
133   bStayMorphed = true;
134   return false;
138 defaultproperties {
139   bAlwaysTick = true;