Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a working omnipanel and omnitool system
ghoststeam217 Offline
Junior Member

Posts: 7
Threads: 2
Joined: Apr 2016
Reputation: 0
#1
Question  Creating a working omnipanel and omnitool system

If you haven't already noticed I am using the hpl3 engine for this. I am trying to make a map where the player needs to collect an omnitool and cortex chip (or whatever it is that gives the omnitool higher access privileges) and combine them to access a door which can only be opened through an omnipanel.

My problem is I have no idea how to get the panel to work with the omnitool and I can't find anything on the wiki to help me. First of all, the omnipanel doesn't appear to be active and when I equip an omnitool it doesn't allow me to interact with the omnipanel to open the door. Could someone provide a script or small tutorial to describe how to setup an omnitool - omnipanel system to open a door. I know it has something to do with the OmnitoolGui function or something. Thanks.
(This post was last modified: 04-12-2016, 12:52 AM by ghoststeam217.)
04-12-2016, 12:36 AM
Find
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#2
RE: Creating a working omnipanel and omnitool system

The thing about the omnitool is that every stage where you are upgrading the tool with a chip of some kind, in the game it is actually two different omnitools, each with their own set of interaction callbacks. For example, in Upsilon, the first omnitool that you pick up (that doesn't have the tool-chip) is one omnitool, and its OnUse function is set to automatically decline use with everything. When you insert the tool-chip, the game switches it out with a different omnitool (that already has the chip equipped), and its OnUse function is set to open the door.

The first step to using the omnitool is to learn about the OnUse callback. This callback is fired whenever the omnitool is used on something like, say, a door panel. One of the parameters of this callback is the name of the entity it is being used on, so you use this to determine what door panel (and from there what door) should be opened. An example of this callback might look like this:

bool omnitool_OnUse(const tString &in asTool, const tString &in asEntity)
{
    if (asEntity == "door_lab_panel")
    {
        CathTool_UseOnPanel("omnitool", asEntity);
    }

    return true;
}

The CathTool_UseOnPanel function is part of a family of CathTool helper functions in "helper_custom_depth.hps" that make using the omnitool much easier. This function in particular automates all the interaction between the omnitool and the door panel.

The next omnitool callback to know about is the CanBeUsed callback. This callback triggers whenever the player looks at an entity while the omnitool is equipped. If the callback returns true, then the omnitool is primed for action on the panel. (Without this callback, the OnUse callback would never happen.)

bool omnitool_CanBeUsed(const tString &in asTool, const tString &in asEntity)
{
    if (CathTool_CanUse("omnitool", asEntity))
    {
        return true;
    }
    
    return false;
}

The CathTool_CanBeUsed function automatically checks various things about the entity the player is looking at, such as if it is an omnitool-enabled panel or a socket where an omnitool can be placed.

Detecting when the omnitool has been used on a door panel is a job for the panel itself. In the panel's config is a callback called ConnectionStateChangeCallback. This callback gets fired whenever the state of the panel changes, or in other words, when the panel is set to locked, unlocked, or activated.

void door_lab_panel_OnConnectionStateChange(const tString &in asEntity, int alState)
{
    if (alState != 1)
        return;
        
    SlideDoor_SetClosed("door_lab", false, false);
}

The parameter alState contains what state the panel is currently in. If the state is 1, that means the panel has been successfully activated. And since we don't care when the panel changes to any other state, if alState is not equal to 1 then we ignore it.

SlideDoor_SetClosed is a helper function for programmatically setting doors to open or close. The first parameter is the name of the door we want to affect, the second parameter sets whether we want the door to be closed or not (false for open), and the third parameter sets if we want the door to instantly open (set to false because we want it to open gradually while playing its animations).

That's pretty much all of the interaction code sorted, but we need one more thing before we can call it good. By default, the omnitool isn't equipped all the time. It's put away after it is picked up. Before the omnitool can interact with the panel, we need to make sure it is equipped. The easiest way to do this is to put a tool area in the space around the door panel that equips the omnitool when the player enters it and unequips it when the player leaves.

[Image: Z1lAMpT.png]

That's everything for when you have one omnitool and one panel. If you have multiple door panels, you will need to handle them properly in the OnUse callback of your omnitool, as well as having a ConnectionStateChangedCallback for each door panel. If you have parts of the game that require an "upgraded" omnitool, then like I said before, you just need to have a second omnitool object that you switch with the first, and has its own set of callbacks.
04-12-2016, 03:09 AM
Find
ghoststeam217 Offline
Junior Member

Posts: 7
Threads: 2
Joined: Apr 2016
Reputation: 0
#3
RE: Creating a working omnipanel and omnitool system

So I used the omnitool, but then my arm disappeared. Here are the debug messages. Why didn't it play the animation?


Attached Files
.png   omnierror.png (Size: 210.25 KB / Downloads: 155)
(This post was last modified: 04-12-2016, 06:18 AM by ghoststeam217.)
04-12-2016, 06:01 AM
Find
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#4
RE: Creating a working omnipanel and omnitool system

This happened to me as well, and what I suspect is that the base omnitool model doesn't have a panel-interaction animation because, in the game, that particular entity never actually interacts with a panel. The only time it could is in the first Upsilon level, after you get the omnitool but before you equip it with a tool chip, where you can interact with the door panel that leads to the observation tube. At that point, though, the omnitool instead is supposed to deny access to the door. So in that sense, the animation never happens because it has never needed to happen.

There's probably a way to use the existing animation from the tool-chipped omnitool with the plain one. I'm not in a place where I could easily check, though, so if you haven't figured it out I can look into it tomorrow. A workaround for the time being would be to use the tool-chipped omnitool rather than the normal one.
04-12-2016, 10:21 AM
Find
ghoststeam217 Offline
Junior Member

Posts: 7
Threads: 2
Joined: Apr 2016
Reputation: 0
#5
RE: Creating a working omnipanel and omnitool system

Still having this problem if anyone could help me.
04-14-2016, 09:04 PM
Find
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#6
RE: Creating a working omnipanel and omnitool system

Alright, I've been looking into this, and I'm having trouble figuring out what is going on. It's not the animation thing that I guessed at before, since the FG Demo Map on the Steam Workshop uses the default omnitool and it works fine.
04-16-2016, 09:15 AM
Find




Users browsing this thread: 1 Guest(s)