diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 0af7cd95a..394322f4c 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,7 @@ +March 13, 2007 +- Fixed: Morphed players did not regain their innate armor when unmorphing. + (Only Hexen has players with innate armor.) + March 12, 2007 - Changed the default player.startitem amount from 0 to 1. diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index ae38333df..a1ce4902c 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -88,7 +88,25 @@ bool P_MorphPlayer (player_t *p, const PClass *spawntype) AInventory *next = item->Inventory; if (item->IsKindOf (RUNTIME_CLASS(AArmor))) { - item->Destroy (); + if (item->IsKindOf (RUNTIME_CLASS(AHexenArmor))) + { + // Set the HexenArmor slots to 0, except the class slot. + AHexenArmor *hxarmor = static_cast(item); + hxarmor->Slots[0] = 0; + hxarmor->Slots[1] = 0; + hxarmor->Slots[2] = 0; + hxarmor->Slots[3] = 0; + hxarmor->Slots[4] = spawntype->Meta.GetMetaFixed (APMETA_Hexenarmor0); + } + else if (item->ItemFlags & IF_KEEPDEPLETED) + { + // Set depletable armor to 0 (this includes BasicArmor). + item->Amount = 0; + } + else + { + item->Destroy (); + } } item = next; } @@ -186,6 +204,12 @@ bool P_UndoPlayerMorph (player_t *player, bool force) } pmo->tracer = NULL; pmo->Destroy (); + // Restore playerclass armor to its normal amount. + AHexenArmor *hxarmor = mo->FindInventory(); + if (hxarmor != NULL) + { + hxarmor->Slots[4] = mo->GetClass()->Meta.GetMetaFixed (APMETA_Hexenarmor0); + } return true; } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 8b7ff60db..6c97683c2 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -883,6 +883,8 @@ void AActor::CopyFriendliness (const AActor *other, bool changeTarget) void AActor::ObtainInventory (AActor *other) { + assert (Inventory == NULL); + Inventory = other->Inventory; InventoryID = other->InventoryID; other->Inventory = NULL;