New weapon that replaces weapon in players inventory?
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
New weapon that replaces weapon in players inventory?
So I was wondering in my project you will aquire a weapon that is semi only. later if you find it there is a modded version of this weapon that is converted to fire in full-auto. I was wondering how it would be possible to replace the old semi weapon with this new modded weapon? (No sense in having both, I'm looking at this in a realistic point of view.)
Re: New weapon that replaces weapon in players inventory?
How about using a CustomInventory actor that takes away the old weapon and gives the new one?
For example:
For example:
Spoiler:
- wildweasel
- Posts: 21706
- Joined: Tue Jul 15, 2003 7:33 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): A lot of them
- Graphics Processor: Not Listed
- Contact:
Re: New weapon that replaces weapon in players inventory?
Bear in mind that if you find another of the original weapon, it will be added back to your inventory - you will probably want to do a similar CustomInventory for the weapon that is being replaced, that detects the upgraded version and gives only the ammo.
Re: New weapon that replaces weapon in players inventory?
Sorry for the bump, I am just now working on this particular issue. And I've been taking a break from building my mod. I set up an additional pickup I would put ontop of the upgraded weapon in doom builder, it works for me. Now how would I make the older weapon act as somekind of ammo pickup once the player aqcuired this upgraded weapon? I played around a bit and couldn't really figure this one out.
Again, sorry for the bump Didn't feel like making a new topic about something I've asked before.
Again, sorry for the bump Didn't feel like making a new topic about something I've asked before.
Re: New weapon that replaces weapon in players inventory?
Something to keep in mind aswell is that this upgraded weapon is a secret weapon, so depending on the players exploration not all players will acquire this weapon, but will definitely acquire the older weapon.
- Player701
-

- Posts: 1710
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: New weapon that replaces weapon in players inventory?
If you can use ZScript, here is a way that does not require any extra classes:
Note that it is not required for UpgradedWeapon to derive from NormalWeapon, they only have to use the same types of ammo (which I guess is true in your scenario).
Code: Select all
class NormalWeapon : Weapon
{
// TODO: Your normal weapon code here
}
class UpgradedWeapon : NormalWeapon
{
override bool TryPickup(in out Actor toucher)
{
bool result = Super.TryPickup(toucher);
if (result)
{
// If picked up successfully, remove the normal weapon
toucher.TakeInventory('NormalWeapon', 1);
}
return result;
}
override bool HandlePickup(Inventory item)
{
// If picking up a NormalWeapon, only attempt to pick it up for ammo.
if (item.GetClass() == 'NormalWeapon')
{
item.bPickupGood = Weapon(item).PickupForAmmo(self);
return true;
}
return Super.HandlePickup(item);
}
}