(Solved) [ZScript] Multi-Ammo Grenade Launcher

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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!)

(Solved) [ZScript] Multi-Ammo Grenade Launcher

Postby Ac!d » Tue Nov 23, 2021 5:16 am

I reworked the Resident Evil 2 M79 Grenade Launcher made by jdredalert with a few changes :

- The ability to change between 4 ammo types (HE, Incendiary, Acid and Cryogenic 40 mm grenade rounds) by pressing Alt-Fire.
- Inventory items used for ammo are replaced by ammo classes which replaces rocketammo and rocketbox.
- I also made a custom hud where you can select the presentation of one or all ammo types of the M79 via a CVar.


But I encounter some issues (for now) :

- If I want to see the ammo selected for the M79 (Server Int AllAmmoTypesOnHud = 0;) and, for exemple, I have only HE rounds, I can't see the icons and the 0 of the other ammo types.
- If I don't have ammo for a selected ammo type, I can't pickup an other M79.


NeoTerraNova send me some PMs with some help in Decorate, and I edited his solutions in ZScript.
Code: Select allExpand view
// Add in the files

// MapInfo
    AddEventHandlers = "M79Handler"

// ZScript
//Giving the item to the player
Class M79Handler : EventHandler
    Override void WorldThingSpawned(WorldEvent e)
        If(e.Thing is "PlayerPawn" && !e.Thing.FindInventory("RE2_WeaponBase"))
User avatar
Perfection is a way, not an end. - Korean Proverb
Joined: 02 Apr 2019
Location: France
Discord: Ac!d#2732

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests