mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- scriptified DropInventory.
This commit is contained in:
parent
09129e0113
commit
2c59172c42
4 changed files with 32 additions and 32 deletions
|
@ -549,7 +549,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 };
|
||||
|
|
|
@ -842,6 +842,7 @@ bool AActor::UseInventory (AInventory *item)
|
|||
VMCall(func, params, 2, &ret, 1);
|
||||
return !!retval;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -854,38 +855,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;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
|
|
@ -745,7 +745,6 @@ class Actor : Thinker native
|
|||
protected native void DestroyAllInventory(); // This is not supposed to be called by user code!
|
||||
native clearscope Inventory FindInventory(class<Inventory> itemtype, bool subclass = false) const;
|
||||
native Inventory GiveInventoryType(class<Inventory> itemtype);
|
||||
native Inventory DropInventory (Inventory item, int amt = -1);
|
||||
native void ObtainInventory(Actor other);
|
||||
native bool GiveAmmo (Class<Ammo> type, int amount);
|
||||
native bool UsePuzzleItem(int PuzzleItemType);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue