Permalink
Browse files

- scriptified A_SelectWeapon

  • Loading branch information...
coelckers committed Dec 4, 2018
1 parent 9348bae commit 44e43c48b5144215b8531970aca1eb20786cf05f
Showing with 58 additions and 66 deletions.
  1. +1 −48 src/p_actionfunctions.cpp
  2. +1 −1 wadsrc/static/zscript/actor.txt
  3. +56 −17 wadsrc/static/zscript/actor_inventory.txt
@@ -1529,54 +1529,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Recoil)
}
//===========================================================================
//
// A_SelectWeapon
//
//===========================================================================
enum SW_Flags
{
SWF_SELECTPRIORITY = 1,
};
DEFINE_ACTION_FUNCTION(AActor, A_SelectWeapon)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS(cls, AActor);
PARAM_INT(flags);
bool selectPriority = !!(flags & SWF_SELECTPRIORITY);
if ((!selectPriority && cls == NULL) || self->player == NULL)
{
ACTION_RETURN_BOOL(false);
}
auto weaponitem = self->FindInventory(cls);
if (weaponitem != NULL && weaponitem->IsKindOf(NAME_Weapon))
{
if (self->player->ReadyWeapon != weaponitem)
{
self->player->PendingWeapon = weaponitem;
}
ACTION_RETURN_BOOL(true);
}
else if (selectPriority)
{
// [XA] if the named weapon cannot be found (or is a dummy like 'None'),
// select the next highest priority weapon. This is basically
// the same as A_CheckReload minus the ammo check. Handy.
self->player->mo->PickNewWeapon(NULL);
ACTION_RETURN_BOOL(true);
}
else
{
ACTION_RETURN_BOOL(false);
}
}
//===========================================================================
///===========================================================================
//
// A_Print
//
@@ -1067,7 +1067,7 @@ class Actor : Thinker native
native void A_QueueCorpse();
native void A_DeQueueCorpse();
native void A_ClearLastHeard();
native bool A_SelectWeapon(class<Weapon> whichweapon, int flags = 0);
native void A_ClassBossHealth();
native void A_SetAngle(double angle = 0, int flags = 0, int ptr = AAPTR_DEFAULT);
native void A_SetPitch(double pitch, int flags = 0, int ptr = AAPTR_DEFAULT);
@@ -58,7 +58,7 @@ extend class Actor
// AActor :: GiveInventory
//
//============================================================================
bool GiveInventory(Class<Inventory> type, int amount, bool givecheat = false)
{
bool result = true;
@@ -193,7 +193,7 @@ extend class Actor
if (item != null)
{
// A_SetInventory sets the absolute amount.
// A_SetInventory sets the absolute amount.
// Subtract or set the appropriate amount as necessary.
if (amount == item.Amount)
@@ -264,12 +264,12 @@ extend class Actor
return false;
}
if (!item.Use(false))
if (!item.Use(false))
{
return false;
}
if (sv_infiniteinventory)
if (sv_infiniteinventory)
{
return true;
}
@@ -355,7 +355,7 @@ extend class Actor
}
}
//============================================================================
//
// AActor :: GiveAmmo
@@ -413,7 +413,7 @@ extend class Actor
{
amount = 1;
}
if (mi)
if (mi)
{
let item = Inventory(Spawn(mi));
if (item == NULL)
@@ -446,7 +446,7 @@ extend class Actor
bool A_GiveInventory(class<Inventory> itemtype, int amount = 0, int giveto = AAPTR_DEFAULT)
{
return DoGiveInventory(self, false, itemtype, amount, giveto);
}
}
bool A_GiveToTarget(class<Inventory> itemtype, int amount = 0, int giveto = AAPTR_DEFAULT)
{
@@ -497,7 +497,7 @@ extend class Actor
bool DoTakeInventory(Actor receiver, bool orresult, class<Inventory> itemtype, int amount, int flags, int setreceiver = AAPTR_DEFAULT)
{
int paramnum = 0;
if (itemtype == NULL)
{
return false;
@@ -517,12 +517,12 @@ extend class Actor
bool A_TakeInventory(class<Inventory> itemtype, int amount = 0, int flags = 0, int giveto = AAPTR_DEFAULT)
{
return DoTakeInventory(self, false, itemtype, amount, flags, giveto);
}
}
bool A_TakeFromTarget(class<Inventory> itemtype, int amount = 0, int flags = 0, int giveto = AAPTR_DEFAULT)
{
return DoTakeInventory(target, false, itemtype, amount, flags, giveto);
}
}
int A_TakeFromChildren(class<Inventory> itemtype, int amount = 0)
{
@@ -564,7 +564,7 @@ extend class Actor
// A_SetInventory
//
//===========================================================================
bool A_SetInventory(class<Inventory> itemtype, int amount, int ptr = AAPTR_DEFAULT, bool beyondMax = false)
{
bool res = false;
@@ -600,7 +600,7 @@ extend class Actor
{
int style = sv_dropstyle;
if (style==0) style = gameinfo.defaultdropstyle;
if (style==2)
{
Vel.X += random2[DropItem](7);
@@ -614,7 +614,7 @@ extend class Actor
}
}
//---------------------------------------------------------------------------
//
// PROC A_DropItem
@@ -730,8 +730,47 @@ extend class Actor
return false;
}
}
//===========================================================================
//
// A_SelectWeapon
//
//===========================================================================
bool A_SelectWeapon(class<Weapon> whichweapon, int flags = 0)
{
bool selectPriority = !!(flags & SWF_SELECTPRIORITY);
let player = self.player;
if ((!selectPriority && whichweapon == NULL) || player == NULL)
{
return false;
}
let weaponitem = Weapon(FindInventory(whichweapon));
if (weaponitem != NULL)
{
if (player.ReadyWeapon != weaponitem)
{
player.PendingWeapon = weaponitem;
}
return true;
}
else if (selectPriority)
{
// [XA] if the named weapon cannot be found (or is a dummy like 'None'),
// select the next highest priority weapon. This is basically
// the same as A_CheckReload minus the ammo check. Handy.
player.mo.PickNewWeapon(NULL);
return true;
}
else
{
return false;
}
}
}

0 comments on commit 44e43c4

Please sign in to comment.