Weapons Dropped by Monsters
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
- Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
- Contact:
Weapons Dropped by Monsters
I have a question about weapons that have been dropped by downed monsters. When a monster drops an item upon death, such as when Shotgun Guy is killed and drops a Shotgun, the weapon will have half the standard ammo in it. For instance, Shotgun Guy's dropped Shotgun will give 4 rounds of ammo, when the weapon is defined to give 8 upon pickup.
My question is, what is the determining factor here? How does the engine label the weapon as having come from a monster so it knows to give the player half the ammo? I suppose this question can also be applied to ammo items, such as ZombieMan dropping a Clip -- unless an amount is defined in the actor's DropItem field, it'll be half the usual.
I'd like to know what makes these dropped variants special. Is there a special actor flag being attached? Is its "special" value being set to something specific? I'd like to be able to manually set/check whatever this value is so that I can apply the halving effect to my items -- they're placed by special spawning actors, and thus whatever the 'x-factor' is won't be carried down, as things are right now.
My question is, what is the determining factor here? How does the engine label the weapon as having come from a monster so it knows to give the player half the ammo? I suppose this question can also be applied to ammo items, such as ZombieMan dropping a Clip -- unless an amount is defined in the actor's DropItem field, it'll be half the usual.
I'd like to know what makes these dropped variants special. Is there a special actor flag being attached? Is its "special" value being set to something specific? I'd like to be able to manually set/check whatever this value is so that I can apply the halving effect to my items -- they're placed by special spawning actors, and thus whatever the 'x-factor' is won't be carried down, as things are right now.
Re: Weapons Dropped by Monsters
I wonder if the DROPPED flag has anything to do with it.
The wiki only says...
The wiki only says...
but I wonder if the flag may also affect the pickup ammo valueDROPPED
Actor always acts as if it was dropped. Dropped items have two properties: They never respawn, and they will be crushed by doors and moving sectors.
- NeuralStunner
-
- Posts: 12326
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Weapons Dropped by Monsters
Weapons and ammo have a value that's set on the actor. If you provide a value to DropItem for Ammo items, it'll apply that. (100-shot Clips for example. Or the 1-shot deals when dropped through console.)
Weapons use different properties to determine what and how much ammo they provide. Supplying an amount other than 0 will result in "full" weapon pickups.
Weapons use different properties to determine what and how much ammo they provide. Supplying an amount other than 0 will result in "full" weapon pickups.
- Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
- Contact:
Re: Weapons Dropped by Monsters
Any item that isn't placed by the map (such as an item created with ACS commands like Spawn, or Decorate commands like A_SpawnItem) will have the +DROPPED flag, but only weapons dropped by monsters will have their ammo halved.
But if a weapon or ammo item does not have an explicitly set Drop amount, like pretty much all of them (with exceptions in Strife), then the drop will be halved.
To refer back to my previous example of the Shotgun Guy:
The Shotgun is set to give 8 rounds of ammo when picked up off the floor.
Shotgun Guy is given the property: DropItem "Shotgun", with no explicit number on it, meaning it will be half of the Shotgun's standard -- four rounds.
What I'm trying to determine is, where on the item is this property being set?
But if a weapon or ammo item does not have an explicitly set Drop amount, like pretty much all of them (with exceptions in Strife), then the drop will be halved.
To refer back to my previous example of the Shotgun Guy:
Code: Select all
ACTOR Shotgun : DoomWeapon 2001
{
Game Doom
SpawnID 27
Weapon.SelectionOrder 1300
Weapon.AmmoUse 1
Weapon.AmmoGive 8
Weapon.AmmoType "Shell"
Inventory.PickupMessage "$GOTSHOTGUN"
Obituary "$OB_MPSHOTGUN"
Tag "$TAG_SHOTGUN"
States
{
Ready:
SHTG A 1 A_WeaponReady
Loop
Deselect:
SHTG A 1 A_Lower
Loop
Select:
SHTG A 1 A_Raise
Loop
Fire:
SHTG A 3
SHTG A 7 A_FireShotgun
SHTG BC 5
SHTG D 4
SHTG CB 5
SHTG A 3
SHTG A 7 A_ReFire
Goto Ready
Flash:
SHTF A 4 Bright A_Light1
SHTF B 3 Bright A_Light2
Goto LightDone
Spawn:
SHOT A -1
Stop
}
}
Code: Select all
ACTOR ShotgunGuy 9
{
Game Doom
SpawnID 1
Health 30
Radius 20
Height 56
Mass 100
Speed 8
PainChance 170
Monster
+FLOORCLIP
SeeSound "shotguy/sight"
AttackSound "shotguy/attack"
PainSound "shotguy/pain"
DeathSound "shotguy/death"
ActiveSound "shotguy/active"
Obituary "$OB_SHOTGUY"
DropItem "Shotgun"
States
{
Spawn:
SPOS AB 10 A_Look
Loop
See:
SPOS AABBCCDD 3 A_Chase
Loop
Missile:
SPOS E 10 A_FaceTarget
SPOS F 10 BRIGHT A_SposAttackUseAtkSound
SPOS E 10
Goto See
Pain:
SPOS G 3
SPOS G 3 A_Pain
Goto See
Death:
SPOS H 5
SPOS I 5 A_Scream
SPOS J 5 A_NoBlocking
SPOS K 5
SPOS L -1
Stop
XDeath:
SPOS M 5
SPOS N 5 A_XScream
SPOS O 5 A_NoBlocking
SPOS PQRST 5
SPOS U -1
Stop
Raise:
SPOS L 5
SPOS KJIH 5
Goto See
}
}
What I'm trying to determine is, where on the item is this property being set?
Re: Weapons Dropped by Monsters
actually that's a third property the +DROPPED flag has - it halves the amount of ammunition weapon and item pickups give. It only applies to Weapon and Ammo pickups however.
Last edited by Kate on Tue Jul 31, 2012 6:31 pm, edited 1 time in total.
- Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
- Contact:
Re: Weapons Dropped by Monsters
That's not true. If it were, my weapons would already be giving me half their ammo because they have that flag. The flag only makes them never respawn and get crushed by doors.Kate wrote:actually that's a third property the +DROPPED flag has - it halves the amount of ammunition weapon and item pickups give.
Re: Weapons Dropped by Monsters
Last time I tested, setting the flag did make them alter their amounts, but this was a while ago and I guess it may have changed since then.
...Actually wait, I remember now, I'm pretty sure ZDoom alters AmmoGive1/AmmoGive2 and Inventory.Amount somewhere when being spawned via DropItem. There's a very specific place it does this, let's see if I can find it..
...Actually wait, I remember now, I'm pretty sure ZDoom alters AmmoGive1/AmmoGive2 and Inventory.Amount somewhere when being spawned via DropItem. There's a very specific place it does this, let's see if I can find it..
- Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
- Contact:
Re: Weapons Dropped by Monsters
That would be absolutely fantastic. I'm looking for where the engine makes that happen so I can try to replicate it. My weapons all get placed indirectly, via spawners which call ACS to run some conditional checks and then use the Spawn command (via which, with HUGE thanks to input from you and FDARI, I can handily control the DROPPED flag to work alongside item respawning) to put the item in play, but this means that even if it comes from a dead monster, it will have the full ammo value unconditionally. This makes things easier for the player, so it's not a tremendous deal, but I'd really like to streamline things to make them more in-line with the classic game mechanics.Kate wrote:There's a very specific place it does this, let's see if I can find it..
Re: Weapons Dropped by Monsters
Ah, here it is.
p_enemy.cpp:2973
This gets called on actors when they're dropped immediately when they're spawned via a monster's DropItem field. You can see that it checks to see if the object inherits from Weapon or Ammo, and if it does, multiplies the amount by half, 0.5 (which is FRACUNIT/2), assuming there's no skill [wiki=Skill_definition]DropAmmoFactor[/wiki] defined.
In your case though, all I can suggest is to use a [wiki=Classes:WeaponGiver]WeaponGiver[/wiki] to create weapon pickups that have half of their usual ammo amounts defined in their AmmoGive1/2 fields, and alternative ammo pickups for the monsters to spawn. Currently unfortunately there's no way to alter the Inventory.Amount or AmmoGive1/2 fields from ACS, unless you want to wind up playing with GiveInventory and CustomInventory items that run scripts.
p_enemy.cpp:2973
Code: Select all
//---------------------------------------------------------------------------
//
// Modifies the drop amount of this item according to the current skill's
// settings (also called by ADehackedPickup::TryPickup)
//
//---------------------------------------------------------------------------
void ModifyDropAmount(AInventory *inv, int dropamount)
{
int flagmask = IF_IGNORESKILL;
fixed_t dropammofactor = G_SkillProperty(SKILLP_DropAmmoFactor);
// Default drop amount is half of regular amount * regular ammo multiplication
if (dropammofactor == -1)
{
dropammofactor = FRACUNIT/2;
flagmask = 0;
}
if (dropamount > 0)
{
if (flagmask != 0 && inv->IsKindOf(RUNTIME_CLASS(AAmmo)))
{
inv->Amount = FixedMul(dropamount, dropammofactor);
inv->ItemFlags |= IF_IGNORESKILL;
}
else
{
inv->Amount = dropamount;
}
}
else if (inv->IsKindOf (RUNTIME_CLASS(AAmmo)))
{
// Half ammo when dropped by bad guys.
inv->Amount = inv->GetClass()->Meta.GetMetaInt (AIMETA_DropAmount, MAX(1, FixedMul(inv->Amount, dropammofactor)));
inv->ItemFlags|=flagmask;
}
else if (inv->IsKindOf (RUNTIME_CLASS(AWeapon)))
{
// The same goes for ammo from a weapon.
static_cast<AWeapon *>(inv)->AmmoGive1 = FixedMul(static_cast<AWeapon *>(inv)->AmmoGive1, dropammofactor);
static_cast<AWeapon *>(inv)->AmmoGive2 = FixedMul(static_cast<AWeapon *>(inv)->AmmoGive2, dropammofactor);
inv->ItemFlags|=flagmask;
}
else if (inv->IsKindOf (RUNTIME_CLASS(ADehackedPickup)))
{
// For weapons and ammo modified by Dehacked we need to flag the item.
static_cast<ADehackedPickup *>(inv)->droppedbymonster = true;
}
}
In your case though, all I can suggest is to use a [wiki=Classes:WeaponGiver]WeaponGiver[/wiki] to create weapon pickups that have half of their usual ammo amounts defined in their AmmoGive1/2 fields, and alternative ammo pickups for the monsters to spawn. Currently unfortunately there's no way to alter the Inventory.Amount or AmmoGive1/2 fields from ACS, unless you want to wind up playing with GiveInventory and CustomInventory items that run scripts.
- Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
- Contact:
Re: Weapons Dropped by Monsters
Mmm, I see... That's sorta what I was afraid of. I actually made some huge leaps in my work just to get away from having givers for each weapon and ammo (literally doubling the selection of items...), so I'm thinking it wouldn't be worth it for me to go through all that again. I guess I was just crossing my fingers that the ammo-halving was based on a special value set in one of the actor Args, or an unseen flag, or something. But, such is life sometimes.
I don't think it'll be the end of the world if I just let the monsters drop fully-loaded weapons. Who'd complain, right? Anyhow, thanks so much for your help with investigating this.
I don't think it'll be the end of the world if I just let the monsters drop fully-loaded weapons. Who'd complain, right? Anyhow, thanks so much for your help with investigating this.