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

New configurable keys, interaction with actor states (weapons)

Recommended Posts

I want to have new configurable keys (on the keyboard) and have them be able to call certain actor states of certain actors (weapons).


I want to have more functions in my weapons (states, Decorate) and activate these with new freely selectable keys, and possibly configurate these in the options (Options/Customize controls)(GZdoom).
I don't mean to just use Altfire, this state is already occupied in my weapons.


For example, Brutal Doom has this with its kicking, taunting etc.


(To be specific I'm trying to create a shoulder lamp.)


----
How can I do this? Thanks for any advice or links.

Share this post


Link to post

Try looking up the DECORATE lump in the documentation of your favorite source port, if it supports it.
For ZDoom, look here: http://zdoom.org/wiki/DECORATE
Specifically, try the Creating new weapons page.

I don't know exactly how to do this since I'm pretty new to editing and I am working with creating plain old DOOM maps right now, but the above should be a start.

Share this post


Link to post

If we're talking about doing something in ZDoom, then yeah, there are tutorials on how to do it. As for other source ports, I wouldn't know. The way most mods do it is through what are commonly called " inventory hacks" and the ability to assign aliases (actions) to keys in a KEYCONF lump.

Here's an example. Keep in mind this is somewhat involved and may be above your modding ability if you haven't done much before.

DECORATE:

ACTOR PlayerHasLampOn : Inventory
{
 -INVBAR
 +INVENTORY.UNDROPPABLE
 Inventory.Amount 1
 Inventory.MaxAmount 1
}

The above is the item that will be checking for in player inventory by another actor to see if its going to go to the appropriate state. It inherits from Inventory, so that the player can hold it. It has the -INVBAR flag (so that we'll never see it in the inventory bar, even though it is in the player's inventory), and +INVENTORY.UNDROPPABLE (so that the player can't drop it, unsuprisingly). In addition, it has its MaxAmount property set to 1, so that the player will never have more than 1.

I'll continue in the next post.

Share this post


Link to post

Next, comes the CustomInventory item. It will serve as the "switch", so to speak.

ACTOR ShoulderLampOnOff : CustomInventory
{
 -INVBAR
 +INVENTORY.UNDRAPPABLE
 Inventory.Amount 1
 Inventory.MaxAmount 1
 States
 {
 Use:
  TNT1 A 0 A_JumpIfInventory("PlayerHasLampOn",1,"SwitchOff")
 SwitchOn:
  TNT1 A 0 A_GiveInventory("PlayerHasLampOn")
  Fail
 SwitchOff:
  TNT1 A 0 A_TakeInventory("PlayerHasLampOff")
  Fail
 }
}

CustomInventory actors are incredibly flexible, having access to action functions that Inventory actors don't. Lets look at the actor. First we have the -INVBAR & +INVENTORY.UNDROPPABLE flags & MaxAmount property set as before, because we don't need to see the item, don't want the player dropping it, and don't want him to have more than 1.

Now, the Use state. Normally, this would be entered when you selected the item from the bar and pressed the "use inventory" key, but we're going to use the item through a KEYCONF alias. The first thing we do is heve it call A_JumpIfInventory. This will check the player's inventory for the specified amount. Here, we're checking to see if the player already has the PlayerHasLampOn item; we're checking to see if he has the lamp active. If the player has 1, it will jump to the SwitchOff state, where it will take it away. If false (the player doesn't have it), it will "fall through" to the SwitchOn state, giveing the player the item. Both the SwitchOff & SwitchOn states end with Fail instead of Stop, because we don't want this item being used in the normal way, where it would disappear from inventory. We want to keep on using it.

Continued in next post.

Share this post


Link to post

Thank you very much for your effort so far.
---

I took a look at Custominventory in the wiki, and I believe I understand the logic behind your explaination.

Let me try to do a synopsis of your logic to see if I got this right:
----

There obviously needs to be a conditional dummy actor (:Inventory) that will be checked by the weapons (A_jumpifInventory) and thus activates/deactivates the desired Actor states with the desired functions.

The :CustomInventory dummy actor has a use state than can be called by an alias from KEYCONF and this use state will put the actual conditional dummy actor into the inventory (A_giveinventory), or if it is already present, take the conditional actor out of the inventory (A_jumpifInventory,A_takeInventory).

The weapons have all their states cloned with the desired functionality built into the clones (lamp turned on), and the clones will be seperated from the originals (that don't have said functionality == lamp turned off, standard) by the presence/non-presence of the conditional :inventory-dummy-actor (A_JumpifInventory).

Thus the condition will the set with the push of a button.


Correct?
----

In any case, my problem is also that I don't know what to do in KEYCONF; that I don't how to create aliases and connect them with the USE state.
----

Thanks for the help so far, looking forward to feedback and more insights.

Share this post


Link to post
Servastal said:

...In any case, my problem is also that I don't know what to do in KEYCONF; that I don't how to create aliases and connect them with the USE state.

Here's what you'll need to add to KEYCONF:

addkeysection <name> <identifier>
This, as its name implies, adds a new section for any keys you're going to add, at the bottom of the Configure Controls menu. <Name> will be what the name of the section is called in the menu. It should be in quotes. <Identifier> is just sort of an internal name for the section, and will not normally be seen ingame by the player. Here's an example:

addkeysection "LampMod Keys" lampmod_keys

addmenukey <description> <command>
This will add a key into your new keysection. <Description> will appear in the menu, and should be in quotes. <Command> is what will actually occur; we're using it to call an alias. Here's an example of a command:

addmenukey "Toggle Shoulder Lamp" lampmod_lamponoff

What will happen when this command is executed will be defined in the next property: Alias.

alias <name> <command string>
With alias, we're giving a name to a macro and defining what it actually does. <Name> is the same as what we put in its companion addmenukey property, and <Command String> is what will happen. Here's an example:

alias lampmod_lampmodonoff "Use ShoulderLampOnOff"


There are actually two more things that need to be in your KEYCONF, and they tie into something I forgot to mention earlier: You need to start your player off with the CustomInventory item that does the switching. Simplest way to do this is to replace the playerclass with a slightly modified one.

DECORATE:

ACTOR LampModPlayer : DoomPlayer
{
 Player.StartItem "ShoulderLampOnOff"
}

You'll notice that while we are inheriting from DoomPlayer, we aren't using "replaces" to replace it. That's because replaces doesn't work with playerclasses. We use KEYCONF to accomplish it instead. At the start of your KEYCONF, put (using the above replaced playerclass as example):

clearplayerclasses
addplayerclass LampModPlayer

Thanks for the help so far, looking forward to feedback and more insights.

You're welcome!

Share this post


Link to post

I did as instucted.

It works perfectly. It uses KEYCONF and Decorate.

New Alias ----> calls CostumInventory actors Use-state ----> activates/deactivates Inventory actor ----> weapons check the Inventory ----> Lampfunction is on/off with the weapons

Great. Thank you very much.

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
×