- Added Gez's patch for A_TakeInventory flag for taking ammo, with TIF_AMMO renamed to TIF_NOTAKEINFINITE.

SVN r2306 (trunk)
This commit is contained in:
Randy Heit 2010-04-26 02:05:11 +00:00
parent 36c4b39688
commit d070e04ff6
3 changed files with 21 additions and 4 deletions

View file

@ -1314,11 +1314,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToTarget)
// //
//=========================================================================== //===========================================================================
enum
{
TIF_NOTAKEINFINITE = 1,
};
void DoTakeInventory(AActor * receiver, DECLARE_PARAMINFO) void DoTakeInventory(AActor * receiver, DECLARE_PARAMINFO)
{ {
ACTION_PARAM_START(2); ACTION_PARAM_START(3);
ACTION_PARAM_CLASS(item, 0); ACTION_PARAM_CLASS(item, 0);
ACTION_PARAM_INT(amount, 1); ACTION_PARAM_INT(amount, 1);
ACTION_PARAM_INT(flags, 2);
if (item == NULL || receiver == NULL) return; if (item == NULL || receiver == NULL) return;
@ -1332,7 +1338,15 @@ void DoTakeInventory(AActor * receiver, DECLARE_PARAMINFO)
{ {
res = true; res = true;
} }
if (!amount || amount>=inv->Amount) // Do not take ammo if the "no take infinite/take as ammo depletion" flag is set
// and infinite ammo is on
if (flags & TIF_NOTAKEINFINITE &&
((dmflags & DF_INFINITE_AMMO) || (receiver->player->cheats & CF_INFINITEAMMO)) &&
inv->IsKindOf(RUNTIME_CLASS(AAmmo)))
{
// Nothing to do here, except maybe res = false;? Would it make sense?
}
else if (!amount || amount>=inv->Amount)
{ {
if (inv->ItemFlags&IF_KEEPDEPLETED) inv->Amount=0; if (inv->ItemFlags&IF_KEEPDEPLETED) inv->Amount=0;
else inv->Destroy(); else inv->Destroy();

View file

@ -191,7 +191,7 @@ ACTOR Actor native //: Thinker
action native A_JumpIfInventory(class<Inventory> itemtype, int itemamount, state label); action native A_JumpIfInventory(class<Inventory> itemtype, int itemamount, state label);
action native A_JumpIfArmorType(string Type, state label, int amount = 1); action native A_JumpIfArmorType(string Type, state label, int amount = 1);
action native A_GiveInventory(class<Inventory> itemtype, int amount = 0); action native A_GiveInventory(class<Inventory> itemtype, int amount = 0);
action native A_TakeInventory(class<Inventory> itemtype, int amount = 0); action native A_TakeInventory(class<Inventory> itemtype, int amount = 0, int flags = 0);
action native A_SpawnItem(class<Actor> itemtype = "Unknown", float distance = 0, float zheight = 0, bool useammo = true, bool transfer_translation = false); action native A_SpawnItem(class<Actor> itemtype = "Unknown", float distance = 0, float zheight = 0, bool useammo = true, bool transfer_translation = false);
action native A_SpawnItemEx(class<Actor> itemtype, float xofs = 0, float yofs = 0, float zofs = 0, float xvel = 0, float yvel = 0, float zvel = 0, float angle = 0, int flags = 0, int failchance = 0); action native A_SpawnItemEx(class<Actor> itemtype, float xofs = 0, float yofs = 0, float zofs = 0, float xvel = 0, float yvel = 0, float zvel = 0, float angle = 0, int flags = 0, int failchance = 0);
action native A_Print(string whattoprint, float time = 0, string fontname = ""); action native A_Print(string whattoprint, float time = 0, string fontname = "");
@ -228,7 +228,7 @@ ACTOR Actor native //: Thinker
action native A_Recoil(float xyvel); action native A_Recoil(float xyvel);
action native A_JumpIfInTargetInventory(class<Inventory> itemtype, int amount, state label); action native A_JumpIfInTargetInventory(class<Inventory> itemtype, int amount, state label);
action native A_GiveToTarget(class<Inventory> itemtype, int amount = 0); action native A_GiveToTarget(class<Inventory> itemtype, int amount = 0);
action native A_TakeFromTarget(class<Inventory> itemtype, int amount = 0); action native A_TakeFromTarget(class<Inventory> itemtype, int amount = 0, int flags = 0);
action native A_CountdownArg(int argnum, state targstate = ""); action native A_CountdownArg(int argnum, state targstate = "");
action native A_CustomMeleeAttack(int damage = 0, sound meleesound = "", sound misssound = "", name damagetype = "none", bool bleed = true); action native A_CustomMeleeAttack(int damage = 0, sound meleesound = "", sound misssound = "", name damagetype = "none", bool bleed = true);
action native A_CustomComboAttack(class<Actor> missiletype, float spawnheight, int damage, sound meleesound = "", name damagetype = "none", bool bleed = true); action native A_CustomComboAttack(class<Actor> missiletype, float spawnheight, int damage, sound meleesound = "", name damagetype = "none", bool bleed = true);

View file

@ -105,6 +105,9 @@ const int AF_ClearSpecial = 32;
const int AF_NoDeathSpecial = 64; const int AF_NoDeathSpecial = 64;
const int AF_TriggerActs = 128; const int AF_TriggerActs = 128;
// Flags for A_TakeInventory and A_TakeFromTarget
const int TIF_NOTAKEINFINITE = 1;
// constants for A_PlaySound // constants for A_PlaySound
enum enum
{ {