Jump to content
Sign in to follow this  
goliath86

(TBS) Touch Buddy Script

Recommended Posts

Hi guys!

This is a little little script made for me and mine friends for play coop mission.

It will add the player to 'touch' other players in MP by passing them very near. It represent the real touch at your buddies in real life when you or an other squad members are watching the enemy and/or suppress them and have no possibility to watch if you (or other) pass behind him.

It works in this way:

1. Put playable units in a mission

2. Add the following files (script.sqf and touched.sqf) in your mission folder

script.sqf

//*************************************************************************
// script.sqf by goliath86
// touch your mates when near them
//*************************************************************************

//variable declaration and initialization 
private ["_unit", "_vectorup", "_array"];

TOUCHEDVAR = 0;
SPONGE = nil;

_nul0 = [] execVM "touched.sqf";

//reveal the unit 
_unit = _this;

while{true} do{

waitUntil{
			_array = ((position _unit) nearObjects ["SoldierWB", 1.3]);
			_array = _array - [_unit];
			count _array >= 1;
};

{
	if(cursorTarget == _x) then{
		SPONGE = _x;
		publicVariable "SPONGE";
		TOUCHEDVAR = 1;
		publicVariable "TOUCHEDVAR";
	};		

} forEach _array;

sleep 1;

};

touched.sqf

//*************************************************************************
// touched.sqf by goliath86
// stamp a hint message - works with script.sqf
//*************************************************************************
private ["_spong", "_a1", "_b1", "_c1", "_a", "_b", "_c", "_a2", "_b2", "_c2", "_i"];

while{true} do{
waitUntil{TOUCHEDVAR == 1};
_spong = SPONGE;
if(_spong == player) then{
	hintSilent "A soldier touched you";

	for "_i" from 1 to 2 do
	    {
			_vectorup = vectorup player;
			_a1 = _vectorup select 0;
			_b1 = _vectorup select 1;
			_c1 = _vectorup select 2;

			//tweak the following three valors to make more or less shacking (all zeroes = no shacking)
			_a = 0;
			_b = 0.02;
			_c = 0;

			player setvectorup [_a1 + _a, _b1 + _b, _c1 + _c];

			sleep 0.08;

			//returning to primary position
			_vectorup = vectorup player;
			_a2 = _vectorup select 0;
			_b2 = _vectorup select 1;
			_c2 = _vectorup select 2;
			player setvectorup [_a2 - _a, _b2 - _b, _c2 - _c];
		};

	sleep 1;
	hint "";

};
TOUCHEDVAR = 0;
};

3. Write in each activation field of all the playable units this line:

null0 = this execVM "script.sqf";

that's it.

Now if you pass nearby a your teammates (very near!) then it will experience a little shake of the camera (representing the touching) and a hint message inform it that you have passed behind him.

It's a simple (very simple script) but for us it is very useful.

You're free to add it in your mission and/or modify it.

Here's the download link for the Module version:

Touch Module

You can find the module in the editor (F7), name: "Touch module".

Simply put the module in your mission (don't synchronize it!) and it will start!

goliath86

Edited by goliath86

Share this post


Link to post
Share on other sites
Nice script, thanks for sharing :cool:

Thank you very much! ;)

Share this post


Link to post
Share on other sites

Great. So now TRexian can come up behind me and "touch" me.

*shudder*

;) :D

Nice idea. Looks like you're creating quite a suite of handy little addons :)

Share this post


Link to post
Share on other sites

muhwawaawah

*touch*

DM: "Don't touch me."

*touch*

DM: "Don't touch me."

*touch*

DM: "Don't touch me."

*touch*

DM: "Don't touch me."

*touch*

DM: "MOM - T's touching me again!"

:D

Share this post


Link to post
Share on other sites

Hi guys!

If anyone's interested I've made a module for this little script so you don't have to write, for every mission, the two files (script.sqf and touched.sqf) and then put them in the mission's folder but you only have to put the module in the mission's editor and the script will start automatically :cool:

Share this post


Link to post
Share on other sites

Yes, bring it please. I will be very happy to use it as module...

Share this post


Link to post
Share on other sites

Ohhh... Awesome! Got to try this out! If it is as good as it sounds it'll become mission-standard for me!

Share this post


Link to post
Share on other sites

Ok guys!

Heres the download link:

@Touch.7z

You can find the module in the editor (F7), name: "Touch module".

Simply put the module in your mission (don't synchronize it!) and it will start!

I'haven't tested for now the module in MP but it should works ;)

If you have any problems post here ;)

Edited by goliath86

Share this post


Link to post
Share on other sites

OK I downloaded it. I don't do MP that often and even less so in a test environment, but I'll be sure & test it out when I can :)

Share this post


Link to post
Share on other sites
OK I downloaded it. I don't do MP that often and even less so in a test environment, but I'll be sure & test it out when I can :)

Thank you very much DMarwick! Yoi're help is very precious for me! :D

Share this post


Link to post
Share on other sites
Thank you very much DMarwick! Yoi're help is very precious for me! :D

LOL, you won't be saying that after I keep updating the medevac thread with bug reports :D

Share this post


Link to post
Share on other sites
LOL, you won't be saying that after I keep updating the medevac thread with bug reports :D

:D bug reports it VERY important for me...so...more bug report more fun for me!! :D

Share this post


Link to post
Share on other sites

Is this meant to fix something like this?

*You're watching down an alleyway for enemy movement, covering the rest of your squad as you move from block to block, suddenly you realize it's too quiet. You turn around and realize your squad is down on the next block...*

So it's basically simulating the tap of the shoulder each person gives to the one behind him?

Share this post


Link to post
Share on other sites
Is this meant to fix something like this?

*You're watching down an alleyway for enemy movement, covering the rest of your squad as you move from block to block, suddenly you realize it's too quiet. You turn around and realize your squad is down on the next block...*

So it's basically simulating the tap of the shoulder each person gives to the one behind him?

Exactly Darkhorse. Me and my friends use this little addon in every coop. In some cases it is very useful for us! ;)

Share this post


Link to post
Share on other sites

goliath86,

I instantly fell in love with this idea. :bounce3:

Rewrote it so that the message that has to go over the network (in your script its the whole bunch of broadcasting a publicvariable) firstly shrank to one small statement via setVehicleInit and secondly cannot interfere anymore with each other.

Furthermore the "touching" doesn't happen by passing another player closely but by pressing a key button (i.e. Left CTRL, can be easily changed) for about half a second when standing close to this player.

Hope you don't mind that I published the new code here:

http://10th-community.com/index.php?site=files&file=52

mentioned your participation both in the description as well as in the enclosed readme file.

Thx for that,

hf.

Share this post


Link to post
Share on other sites
goliath86,

I instantly fell in love with this idea. :bounce3:

Rewrote it so that the message that has to go over the network (in your script its the whole bunch of broadcasting a publicvariable) firstly shrank to one small statement via setVehicleInit and secondly cannot interfere anymore with each other.

Furthermore the "touching" doesn't happen by passing another player closely but by pressing a key button (i.e. Left CTRL, can be easily changed) for about half a second when standing close to this player.

Hope you don't mind that I published the new code here:

http://10th-community.com/index.php?site=files&file=52

mentioned your participation both in the description as well as in the enclosed readme file.

Thx for that,

hf.

Great work Bon!! It's only a little addon but very useful!! Thanks again for the improvements!!! :D

Share this post


Link to post
Share on other sites
I only see the American soldiers in that script, don't forget the other factions :)

my "regeneration" of this code considers any kind of man.

goliath, just replace "SoldierWB" with "Man". Thats all.

Share this post


Link to post
Share on other sites

With this, is it possible to change the button pressed client-side or does it have to be the one button for everyone in the mission it's used. Reason being, with Ace there are alot of keys taken up and different people have them all set differently, is it possible for the user to change it to his preference?

Cheers, Morts

Share this post


Link to post
Share on other sites
With this, is it possible to change the button pressed client-side or does it have to be the one button for everyone in the mission it's used. Reason being, with Ace there are alot of keys taken up and different people have them all set differently, is it possible for the user to change it to his preference?

Cheers, Morts

currently not, however, it's not hard to change it: in the func_touch_keyspressed.sqf, func_touch_keysreleased.sqf respectively, you can find this piece of code:

if(_button == bon_touch_key ...
...

You can change that to:

if(_button in actionKeys "here goes the key you want" ...
...

Check out here: actionKeys, and here: CfgDefaultKeysMapping.

One example for having the key assigned to the Teamswitch action that is on default assigned to "T" and not available in MP:

if(_button in actionKeys "teamSwitch" ...

How the actionkeys are named in ACE2, you have to ask one of their codemonkeys, don't know them (I assume they are named the same way they are defined in your ace_keys.hpp).

Share this post


Link to post
Share on other sites
How the actionkeys are named in ACE2, you have to ask one of their codemonkeys, don't know them (I assume they are named the same way they are defined in your ace_keys.hpp).

You should really google up a word before writing it... no, we are no "codemonkeys".

His question was if it is possible to make something like it is available in ACE or other mods, change keys via some userconfig or whatever file.

Xeno

Share this post


Link to post
Share on other sites
You should really google up a word before writing it... no, we are no "codemonkeys".

His question was if it is possible to make something like it is available in ACE or other mods, change keys via some userconfig or whatever file.

Xeno

Precisely, It saves squabbles in units over who wants it to be programmed to what key.

Share this post


Link to post
Share on other sites

Somehow it doesn't work for me. I wrote it to

if(_button in actionKeys "user4" && not bon_touch_active) then{

bon_touch_active = true;

but nothing happens. Any ideas? I also deleted

bon_touch_key = "57";

from the bon_touch_init.sqf. I'd like my mates to assign the key themselves within the user actions.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×