Key Binding Actions -1 reply

Please wait...

Guest

I didn't make it!

0 XP

 
#1 11 years ago

Hello I am looking around to develop a mod for custom key bindings (like antirads, vodka, endrinks), but i'm having some difficulties creating actions for them. Every key action has a hardcoded function in the xrGame.dll file, for example kb_use_medkit is having the action "use_medkit". I wonder if there is a way to add more actions via scripts or something. I know how to create a key, and how to make a fuction which makes the player "consume" an object (like antirad), but i can't connect these. For now my efforts are in vain. I wonder if someone have more experience with the key bindings in STALKER, or just a way to make a scripted function get executed when a particular key is pressed. Or just a way to make anything custom written get executed if any key is pressed. I'll gladly accept any help in this manner Thank you




Shibbywrd

all yur stalker r belong 2 me

50 XP

30th June 2005

0 Uploads

167 Posts

0 Threads

#2 11 years ago

well the only input I have is this sounds like a good idea, let us know how things work out for you. Ill defintally use this is it comes though. GL




Guest

I didn't make it!

0 XP

 
#3 11 years ago

I've comed to an intermediate solution. Please read the readme TXT file that comes with this mod for all the important information. http://www.heer0.qhoster.net/files/STALKER_Keys_MOD_by_HeEr0_v01.zip Some testing will be a good idea. Tell me if you have ideas for suggestions/fixes or found any bugs.




Guest

I didn't make it!

0 XP

 
#4 11 years ago

I have downloaded the mod, but have no idea how to connect a game action to a key. For example if I right click on the bread and highlight eat, and hit 'Ctrl B' will your program allow Ctrl B to have my character eat some bread? I need better details for how to use your mod, not just how it works. Thank you.




Guest

I didn't make it!

0 XP

 
#5 11 years ago

Ok i will explain a bit, but you must have a decent ammount of modding experience. After you install the mod, you'll need to configure your own keyactions, as i only supplied an example of a function to use antirad with [J] key. You can use this function to write your own. First, you need the keyboard codes of the keys you want to use to activate the specific action. You have to look in the URL shortcut i provided (these are standard Win32 virtual keycodes). In our case, you need to look for CTRL+B. You look for CTRL key and B key seperately, their codes are: CTRL = 17, B = 66. Note these down. Then you have to edit the stalker_keys.script file (found in gamedata\scripts\). Open it with wordpad. Now you need to write your own function to handle the use of bread (eating it =p). Copy the example function "function use_antirad(keydown)" and all it's body (including the variable "local antiradused = false"). Then change it's name and variable to something unique, like: [html] local breadused = false function use_bread(keydown) ... [/html] Then in the function body, change the name of the used item from "antirad" to "bread", also change every instance of variable "antiradused" to "breadused" [html] ... db.actor:eat(db.actor:object("bread")) ... [/html] So in the end you'll have something like this: [html] ----------------------------------------------- local breadused = false function use_bread(keydown) if keydown == true then if breadused == false then db.actor:eat(db.actor:object("bread")) breadused = true end else breadused = false end end [/html] Now, the function is ready, we need to hook it up with the keys. Look in the body of the "keyproc()" function. There is a line there "use_antirad(iskeydown(74))" Which executes the antirad usage function when [J] key is pressed or released. We'll write our hook right under this line. It should look something like this: [html] if iskeydown(17) == true and iskeydown(66) == true then use_bread(true) else use_bread(false) end [/html] translated: "if both keys 17 and 66 are down, execute use_bread(true), else, execute use_bread(false)" The scripting language of STALKER is a strange mix of BASIC, C, and PASCAL programming languages. When i started modding i had some difficulties getting used to it, and my game crashed so many times because of syntax errors :lol: First, you start stalkerkeys.exe and leave it running (pressing any key in the console window will stop it) then you run the game, or use the start.BAT file to do this for you. The stalkerkeys.exe captures the codes of the pressed keys and writes them in the keys.ltx file, which is then read by the stalker_keys.script. The stalkerkeys.exe closes automaticaly when you exit STALKER. Hope i was helpful enough. If your game crashes on loading, this means you have made syntax mistake in the scripts, you'll just need to trace it down and correct it. Have fun experimenting ;)