RSS

Interaction Tutorial.

25 Jul

There are many ways to address the topic of having the user control something( specificity script code).

User Input / Interaction Methods

  • Methods
    – Replication
    – Binding keys
    – Chat scanning
    – Checking keystrokes
    – Pick-up Activation/Deactivation
    – Triggers
    – Fake Weapons

Some of these methods have advantages and disadvantages , and different usage scenarios.
Like most things in unreal script Not every method is ideal for each application , most anything can be made to work.

Replication
The most common method for interaction in uscript is using replication – Role<ROLE_Authority to replicate exec functions,
This is what is used for most of the commands in unreal such as FLY , SUMMON , etc. This allows you to catch things typed into the console.

Example Code
—————–
class commandsthing expands pickup;

Replication(
reliable if( Role<ROLE_Authority )
dothat;
}

exec function dothat(){PlayerPawn(Owner).ClientMessage(” some action”);}
—————-

This method requires your code class to be placed on a client package / actor ,
Mostly always thats a pickup/item/weapon (or declared in the playerpawn)
in the case of playerpawn , It’s self replicated without Replication declaration.
it isn’t usually usable in any other classes , and this method has the advantage that you can have required arguments
so for instance dothat( int mynumber) will only accept a # and that argument will be passed straight to your functions,
Without having to phrase anything yourself.

The downsides are that the client has to have downloaded this class. it cant be “hidden” like server side code, also replicating
tons of commands probably isnt good for the server ( you can get RPC overflows – But you would have to replicate hundreds of things for that to happen)
also your code is executed on the pickup or class , Or course you can pass instruction elsewhere or obfuscate ( for instance for login commands),Using blind dummy dynamicloads and child classes.
In general this is the accepted method for adding commands to a game.

Additional you can use mods to rebind the clients keys to call one of these replicated commands.FE how voting handler overides or amends your X key.

Chat Scanning
Chat scanning is sort or common function of modern games – whether your notice it or not. mine craft and gtaSA and many games use it,
As far as unreal227 is concerned , its a passive method – A simple mutator can sit and wait for chat callbacks.
all chat goes tho the system as usual – If a magic string such as “/” or “/togglechat” is seen in a chat message the chat is phrased and you can execute a action based on that.

If your sever/game version is < 227 you can use a dummy pawn actor to listen for chat strings , but you wont be able to not show them in the chat,Its possible but alot more inconvenient to get who chated what.

The main advantage to this is that is entirely serverside , So you can put security related stuff ,
and link/references to other packages that are linked to dlls etc , The client never has to download it.
so you can be clever and unload/rebuild/update the commands mod without shuttingdown/restarting your server.
The downsides to this method is that you need to phrase the chat yourself if you want more then a simple executed action.
If you want arguments you need to intelligently process the data , Breaking up space delimited text and converting strings to numbers etc ,also you need to do alot of idiot checking for spaces , bad args, or args out of sequence.

The other downside is that everyone was trained to NOT type commands into chat , but the console!
So unless you explain how it works , most people wont understant why is doent work.

Some example code here:
http://www.oldunreal.com/cgi-bin/yabb2/YaBB.pl?num=1409617108/0#0

Checking keystrokes
While I cant give a elaborate example , Ill point out that 227 has the ability to detect key presses.
Is is necessary to do this ON THE CLIENTSIDE. and you must check if a button is pressed/held , In some tick/timer etc.
You must create your own debouncing scheme and then or course execute your functions.
A check like this would work good in HUD classes inside postrender etc.

use a table like this http://www.dakmm.com/?p=272 ,

you can make a uscript comparison table array if your clever. think array(KEYCODE) = array.charstring to mass check keys.

if (PlayerPawn(Owner).IsPressing(32))
{

}
If your clever you can check for every possible key clientside , and pass that data blindly back to the server for post processing
in a single sting FE “a6-=” etc then phrase it sever side.
I also may suggest that is possible to write a crude keylogger this way(Viewport keystokes only , Dont get excited!).

Pick-up Activation/Deactivation/use
For some simple action (fly mods/skin swaps etc), You could toggle on/off by the states of a pickup, of even be creative and foreach/item and
detect active states as a easteregg. This type of thing is intuitive and easy to understand for any player.
You can even set up multiple pickups to build a navigation system menu type thing – Think 5 items (up / down/ left/right/enter) Thats sort of insane tho.
But if your already doing this why dont you just go ahead and replicate some functions to get calls from the console?????

 Triggers-
This is a convoluted method. mostly for map makers. You build a room in the map that has triggers that execute your code. You can use this method
in a server context by spawning visible sprite triggers with a serverside mod, FE triggers at the beginging of level that change your model or affect
the player , execute some scripted code etc.

Fake Weapons
You use a fake weapon to interact with the players fire/altfire binds ,
Prehaps even use/ overide next/prev weapon actions. The bonus here is that you have callbacks easily available to the hud to draw stuff.
Think right click shuffles , left click selects.

(to be continued … maybe?)

Advertisements
 
3 Comments

Posted by on July 25, 2015 in Uncategorized

 

3 responses to “Interaction Tutorial.

  1. Kelly Davis

    July 26, 2015 at 2:45 am

    Thanks for this Bob. There’s not a lot of great discussion on this since most mod authors tend to hide this part of their code.

     
    • bobisunreal

      July 26, 2015 at 3:08 am

      i probably wouldn’t have wrote this at all , But i was in bad mood all day and decided to put my energy into something helpful and creative, that’s why it all shitty

       
  2. Kelly Davis

    July 26, 2015 at 5:03 am

    This is fantastic stuff. You should link in your code examples from http://www.oldunreal.com/cgi-bin/yabb2/YaBB.pl?num=1409617108/0#4 I’ve been playing with this all evening 😀

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s