diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index c96ae683b..07771702d 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -561,7 +561,7 @@ FString cht_Morph(player_t *player, PClassActor *morphclass, bool quickundo) void cht_SetInv(player_t *player, const char *string, int amount, bool beyond) { - IFVIRTUALPTR(player->mo, APlayerPawn, CheatSetInv) + IFVIRTUALPTR(player->mo, APlayerPawn, CheatTakeInv) { FString message = string; VMValue params[] = { player->mo, &message, amount, beyond }; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 8d7a92740..286cca925 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -856,6 +856,7 @@ bool AActor::UseInventory (AInventory *item) VMCall(func, params, 2, &ret, 1); return !!retval; } + return false; } //=========================================================================== @@ -868,38 +869,15 @@ bool AActor::UseInventory (AInventory *item) AInventory *AActor::DropInventory (AInventory *item, int amt) { - AInventory *drop = nullptr; - IFVIRTUALPTR(item, AInventory, CreateTossable) + IFVM(Actor, DropInventory) { - VMValue params[] = { (DObject*)item, amt }; - VMReturn ret((void**)&drop); - VMCall(func, params, countof(params), &ret, 1); + VMValue params[] = { this, item, amt }; + AInventory *retval = 0; + VMReturn ret((void**)&retval); + VMCall(func, params, 3, &ret, 1); + return retval; } - if (drop == nullptr) return NULL; - drop->SetOrigin(PosPlusZ(10.), false); - drop->Angles.Yaw = Angles.Yaw; - drop->VelFromAngle(5.); - drop->Vel.Z = 1.; - drop->Vel += Vel; - drop->flags &= ~MF_NOGRAVITY; // Don't float - drop->ClearCounters(); // do not count for statistics again - { - // [MK] call OnDrop so item can change its drop behaviour - IFVIRTUALPTR(drop, AInventory, OnDrop) - { - VMValue params[] = { drop, this }; - VMCall(func, params, 2, nullptr, 0); - } - } - return drop; -} - -DEFINE_ACTION_FUNCTION(AActor, DropInventory) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_OBJECT_NOT_NULL(item, AInventory); - PARAM_INT(amt); - ACTION_RETURN_OBJECT(self->DropInventory(item, amt)); + return nullptr; } //============================================================================ diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 689e6563b..e0626a3e9 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -743,7 +743,6 @@ class Actor : Thinker native protected native void DestroyAllInventory(); // This is not supposed to be called by user code! native clearscope Inventory FindInventory(class itemtype, bool subclass = false) const; native Inventory GiveInventoryType(class itemtype); - native Inventory DropInventory (Inventory item, int amt = -1); native void ObtainInventory(Actor other); native bool GiveAmmo (Class type, int amount); native bool UsePuzzleItem(int PuzzleItemType); diff --git a/wadsrc/static/zscript/actor_inventory.txt b/wadsrc/static/zscript/actor_inventory.txt index f8c486578..c0b5b52c8 100644 --- a/wadsrc/static/zscript/actor_inventory.txt +++ b/wadsrc/static/zscript/actor_inventory.txt @@ -259,6 +259,29 @@ extend class Actor return true; } + //=========================================================================== + // + // AActor :: DropInventory + // + // Removes a single copy of an item and throws it out in front of the actor. + // + //=========================================================================== + + Inventory DropInventory (Inventory item, int amt = 1) + { + Inventory drop = item.CreateTossable(amt); + if (drop == null) return NULL; + drop.SetOrigin(Pos + (0, 0, 10.), false); + drop.Angle = Angle; + drop.VelFromAngle(5.); + drop.Vel.Z = 1.; + drop.Vel += Vel; + drop.bNoGravity = false; // Don't float + drop.ClearCounters(); // do not count for statistics again + drop.OnDrop(self); + return drop; + } + //=========================================================================== //