diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 7d22f11d7..8b09a2c10 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1314,11 +1314,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToTarget) // //=========================================================================== +enum +{ + TIF_NOTAKEINFINITE = 1, +}; + void DoTakeInventory(AActor * receiver, DECLARE_PARAMINFO) { - ACTION_PARAM_START(2); + ACTION_PARAM_START(3); ACTION_PARAM_CLASS(item, 0); ACTION_PARAM_INT(amount, 1); + ACTION_PARAM_INT(flags, 2); if (item == NULL || receiver == NULL) return; @@ -1332,7 +1338,15 @@ void DoTakeInventory(AActor * receiver, DECLARE_PARAMINFO) { 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; else inv->Destroy(); diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 50d7369d2..1b9719463 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -191,7 +191,7 @@ ACTOR Actor native //: Thinker action native A_JumpIfInventory(class itemtype, int itemamount, state label); action native A_JumpIfArmorType(string Type, state label, int amount = 1); action native A_GiveInventory(class itemtype, int amount = 0); - action native A_TakeInventory(class itemtype, int amount = 0); + action native A_TakeInventory(class itemtype, int amount = 0, int flags = 0); action native A_SpawnItem(class itemtype = "Unknown", float distance = 0, float zheight = 0, bool useammo = true, bool transfer_translation = false); action native A_SpawnItemEx(class 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 = ""); @@ -228,7 +228,7 @@ ACTOR Actor native //: Thinker action native A_Recoil(float xyvel); action native A_JumpIfInTargetInventory(class itemtype, int amount, state label); action native A_GiveToTarget(class itemtype, int amount = 0); - action native A_TakeFromTarget(class itemtype, int amount = 0); + action native A_TakeFromTarget(class itemtype, int amount = 0, int flags = 0); 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_CustomComboAttack(class missiletype, float spawnheight, int damage, sound meleesound = "", name damagetype = "none", bool bleed = true); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 0fd613a72..71fb3d511 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -105,6 +105,9 @@ const int AF_ClearSpecial = 32; const int AF_NoDeathSpecial = 64; const int AF_TriggerActs = 128; +// Flags for A_TakeInventory and A_TakeFromTarget +const int TIF_NOTAKEINFINITE = 1; + // constants for A_PlaySound enum {