1 //**************************************************************************
3 //** ## ## ## ## ## #### #### ### ###
4 //** ## ## ## ## ## ## ## ## ## ## #### ####
5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ##
6 //** ## ## ######## ## ## ## ## ## ## ## ### ##
7 //** ### ## ## ### ## ## ## ## ## ##
8 //** # ## ## # #### #### ## ##
10 //** Copyright (C) 1999-2006 Jānis Legzdiņš
11 //** Copyright (C) 2018-2023 Ketmar Dark
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.
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.
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/>.
25 //**************************************************************************
26 class MorphedMonster : Actor;
30 class!Actor UnmorphFlash;
34 //==========================================================================
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;
59 //==========================================================================
63 //==========================================================================
64 override int UnmorphActor (Entity Activator, int Force) {
66 class!EntityEx originalClass;
73 originalClass = SpecialCID;
74 if (originalClass.default.bStayMorphed) return false; // these must remain morphed
77 oldAngle = Angles.yaw;
87 mo = Spawn(originalClass, Origin, AllowReplace:false); //k8:dunno
89 if (!mo.TestLocation() && !Force) {
92 LinkToWorld(properFloorCheck:true);
93 UnmorphTime = XLevel.Time+5.0; // next try in 5 seconds
96 LinkToWorld(properFloorCheck:true);
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];
106 mo.CopyFriendliness(self, true);
107 mo.bShadow = bShadow;
109 SetState(FindState('FreeTargMobj'));
111 Spawn(UnmorphFlash ? UnmorphFlash : class!Actor(TeleportFog),
112 oldOrigin+vector(0.0, 0.0, LineSpecialGameInfo(Level.Game).TeleFogHeight));
117 //==========================================================================
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;