Weapon and "Offhand" Magic

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!)
Post Reply
Praecant
Posts: 2
Joined: Fri Apr 24, 2020 9:08 pm

Weapon and "Offhand" Magic

Post by Praecant »

I'm trying to build a new WAD where the character works similar to VTM: Bloodlines. For those that don't know, you can have a weapon equipped which is changed with the top number keys and can cycle through various abilities and spells using the mouse wheel without changing your weapon. These abilities differ based on your Clan and range from temporary increased speed, a projectile attack, temporary invisibility, a damage shield, forced placation, etc. and all of them can be used while a weapon is drawn.

Does anyone know of a WAD that allows for a similar system which I can study or use as a base?
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Weapon and "Offhand" Magic

Post by Jarewill »

I don't know if there's a way to detect if the player is changing weapons via the mouse wheel, (ZScript might have a way) but the way I did it is this:
In a weapon parent class, I put User1 and User2 states, which work as a switch between various spells, which give dummy inventory items.
And also a Zoom state which casts the spell based on the amount of those inventory items.

Of course it could have been done smoother with ZScript and weapon variables, but there would be too much converting at this point.
Here's a slightly edited example:
Spoiler:
Praecant
Posts: 2
Joined: Fri Apr 24, 2020 9:08 pm

Re: Weapon and "Offhand" Magic

Post by Praecant »

Oh changing via mousewheel isn't really necessary, having them bound to a hotkey like [ and ] to shift through and R to cast, etc. or mapping each one to a different Numpad button for quick use once unlocked would be fine as well.

My design doc has only 4 ATM for conceptual reasons (Projectile, temporary buff, toggle that drains secondary resource over time, toggle that drains secondary resource when weapon is fired), so the example actually works really well.
User avatar
kodi
 
 
Posts: 1361
Joined: Mon May 06, 2013 8:02 am

Re: Weapon and "Offhand" Magic

Post by kodi »

What you'll probably want to do is to initiate an A_Overlay through an item inheriting from customInventory. It'll run like a second weapon along with the real weapon. In this overlay, you'd make it jump to a next spell state, a previous spell state, or the use spell state depending on input. Presumably you'd want to use the User_1/2/3/4 inputs only, rather than the normal secondary or primary fire inputs that the weapons will be using.
Post Reply

Return to “Scripting”