Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Lippeth

Reloading weapons that switch when empty (Decorate)

Recommended Posts

I've been having a blast learning how to make custom weapons with Decorate. I decided to make a shotgun that reloads after five shells, like an old WWII trench gun. Reloading takes ammo from type 1 like normal, but when I'm out of ammo, the alt ammo takes inventory from nothing, giving unlimited ammo, in a sense. I would much rather automatically switch to another weapon. This is probably a simple fix, and I created this while looking at countless tutorials and other people's decorate lines, so the code takes a little bit from all of them, and I've experimented with a million things that I thought would be logical, but in the end, I have a cheating shotgun.

I've spent all day and night trying to figure this out, so help is appreciated. Here's a link to download the weapons and see the decorate file, but I can post the Decorate code if requested, I'd rather not initially muck up a thread with a wall of code.

Share this post


Link to post

That was the first place I looked. I may have a mental block, but I followed step by step and while it's close, I'm still having minor issues.

Share this post


Link to post

In the ReloadWork state, you need to check on the reserve ammo (which in this case, the shells) to see if you've run out, and if so, "abort" the reload process. Otherwise, it'll continue to load shells into the weapon until it's full, even if you don't have reserve ammo for it.

Share this post


Link to post

You also need to specify the AmmoUse1 property so that the weapon uses ammo when you normally fire it.

Share this post


Link to post

Well, if I set it to 1, it doesn't even fire after initially loading shells. It's fine at zero and without the line at all but it still keeps reloading from nothing and I don't know how to tell it to switch to the next best weapon when it's out. The problem is in my reloadwork state, and I've experimented to the point that I have to give it a rest and wait until it either hits me all of a sudden, or someone with more experience knows what action function I can use to switch to the next best weapon if out of ammo instead of reloading. Jumping back to ready doesn't work, and the NoReload state basically goes back to ready. Using Stop doesn't seem to do anything at all. I've torn down the whole code and started from scratch and I get the same thing, there's got to be something simple that I'm missing or didn't define correctly.

Initially I figured it would be something like,

A_JumpIfInventory("Shell", 0, "Deselect") but that doesn't work. It makes sense to me, but there could be something else in my code that prevents this from happening, or my logic is wrong. It could be anything with my experience.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×