1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Detecting new commands through code

Discussion in 'Programming' started by Unrar, Dec 8, 2001.

  1. Unrar

    Unrar New Member

    Joined:
    Dec 8, 2001
    Messages:
    7
    Likes Received:
    0
    Hello:
    I wanted to add a new command to a single player style game.
    For example I want to use a "P" to represent my custom command which is supposed to enable some type of magic.

    Basically I wanted to make a new command bind it to a key and be able to capture it in my source.

    I was looking at PlayerInput in PlayerPawn.uc but based on the parameter that is passed in it doesn't look like a good place.

    My best alternative looks like
    ProcessKeyEvent( int Key, int Action, FLOAT Delta ) but for some reason I can't seem to get it called even when I inherited from the HUD.

    Anyway. Before I spend a lot of time going in circles what is the best way of doing this? Should I keep playing with ProcessKeyEvent or is it more convenient to try this a different way.
    Thanks
     
  2. eXoR

    eXoR Lead coder

    Joined:
    Oct 22, 2001
    Messages:
    36
    Likes Received:
    0
    If you are making a mutator, use mutate. For example, if you the name of your command is DoSomeStuff, then add this function Mutate to your mutator:

    function Mutate(string MutateString, PlayerPawn Sender)
    {
    if (MutateString ~= "DoSomeStuff")
    DoSomeStuff(); // Your own function where you do your things.

    Super.Mutate(MutateString, Sender);
    }

    if you are making a gametype, you could consider making a default mutator that is used with it, or you could use exec functions like this:

    exec function DoSomeStuff()
    {
    // Your stuff here.
    }

    Then, if you are using a mutate function, bind the command to the key using this console command:
    set input <keyname> mutate DoSomeStuff
    or if you are using an exec function:
    set input <keyname> DoSomeStuff

    That's all. Hope this clears things up for you,

    eXoR.
     
  3. Papapishu

    Papapishu 我是康

    Joined:
    Jun 18, 2001
    Messages:
    2,043
    Likes Received:
    0
  4. Eater1

    Eater1 Coder

    Joined:
    Oct 22, 2000
    Messages:
    176
    Likes Received:
    0
    Oh, and... I don't think anyone mentioned this: you can also place exec functions in PlayerPawns. This may be better for you since you're making a single player game.

    Eater.
     
  5. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,913
    Likes Received:
    36
    You can also place exec functions in weapons. Then they are only executed when you have the weapon selected.
     
  6. eXoR

    eXoR Lead coder

    Joined:
    Oct 22, 2001
    Messages:
    36
    Likes Received:
    0
    In my mutator I spawn pickups for players when they spawn, the exec functions are in those pickups. Works fine, altough since my mutie is offline only I don't know if it'll work online.
     
  7. Unrar

    Unrar New Member

    Joined:
    Dec 8, 2001
    Messages:
    7
    Likes Received:
    0
    Thanks Everybody for the information.
    This is great!!!!
    There is so much information on Unreal but it is so hard to filter out what you want. In fact I was unclear on what to research. When I asked the question I didn't even know what I should have been asking.
    Thanks Again. This is all very helpful.
     

Share This Page