It is currently 25 May 2013, 17:19

Post new topic Reply to topic  Page 1 of 1
 [ 1 post ] 

[APPROVED] Alternate Fire/Reload/Zoom/Whatever States on Weapons


Author Message
 Post subject: Alternate Fire/Reload/Zoom/Whatever States on Weapons
PostPosted: 20 Oct 2011, 14:57 
Offline
Commander Keen  A rather ghastly dragon
User avatar
Joined: 11 Dec 2009, 20:01
Posts: 2661
Thanks to WildWeasel for teaching me a non-ACS way of doing this. I've been meaning to write this for ages, but never got around to it.

One of the more obscure tricks with weapons is the ability to add a new firing state (a state that can be activated aside from primary and alternate fire). This is usually used to have a key that specifically zooms or reloads. However, this is actually quite a simple trick.

For reference, here are three wiki pages:

I'll put it in basic terms, then explain each part further. Essentially, you have a dummy inventory item as a flag for the weapon to check for in the Ready state, and this item is given and taken away by a pair of CustomInventory items which are bound to a key.

I'll use a third Fire state as an example. To explain further, we start with our fake inventory item; an item that literally has
no use besides A_JumpIfInventory to check for:

All this will do is sit in your inventory. Now we have an alternate pistol checking for this:

There! Our pistol is checking for that item, and has a new firing state. Now we just need those two CustomInventory items:

When Action_Fire is used, it will give the fake item, but when Action_FireCancel is used, it will take it away again. Thus, using one will make the pistol fire, and the other will make it stop. It is important that both of these are given to the player at the start with Player.StartItem, or this will not work.

Now to bind these two items to a key:

Check the wiki link above about adding keysections for explanations of what these do. Now, when the key is pressed it will give the item (activating AltAltFire), and when the key is released, it will take the item away (making it stop firing).

And it's that simple! If you want to test it out, here's a full Decorate and KeyConf:


Keep in mind, by the way, Fire and AltFire have some special behavior that alerts monsters, and A_Refire only works for Fire/Hold and AltFire/AltHold. Here's another AltAltFire that emulates that behavior:
Currently reading: Blood Ravens, The Dawn of War Omnibus
_________________
Total approved submissions: 78
Total approved updates: 21
Total rejected: 2


Top
 Profile  
 
Display posts from previous:  Sort by  
Moderators: Ghastly, NeuralStunner

Post new topic Reply to topic  Page 1 of 1
 [ 1 post ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron