Forum Jump :

Author Message


Posts: 59
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2013-06-23 05:38        
     
Alright, I've looked everywhere... I can't seem to find anything for speed scripts except the Nitro script.

On armAII I can get my vehicle to go up to 220 on Chernarus Life(with upgrades) without mods, So how do they do that?

Any help on this??

This post was edited by Noxious (2013-06-24 22:44, ago)


Author Message


Posts: 250
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name: austinXmedic

 
#2 Posted at 2013-06-23 21:56        
     
From what i've looked into it... i think the speed upgrades in chernarus life use

vehicle player setvelocity [3,2,1];



x = horzontal velocity
y = verticle velocity
z = angle velocity??

Some of my work:
http://steamcommunity.com/sharedfiles/filedetails/?id=287343671 -- Unit Play/ Unit Capture Functions Guide
http://steamcommunity.com/sharedfiles/filedetails/?id=265454265 -- Zeus Guide
add me on steam: austin_medic

Advertisement


Author Message


Posts: 59
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2013-06-24 03:33        
     
# austin(medic) : From what i've looked into it... i think the speed upgrades in chernarus life use

vehicle player setvelocity [3,2,1];



x = horzontal velocity
y = verticle velocity
z = angle velocity??


I put in
vehicle1 player1 setvelocity [3,2,1];
and it keeps saying " missing ; "



Couple minutes later
Okay I figured it out. But when I increase any of the numbers, it makes the car going flying somewhere.

It also doesn't make the car go much faster.



Another couple of minutes later

Ok, I figured out how to do with a addaction but not like a normal car yet.

Nevermind about that... It just keeps teleporting me and killing me



After playing around a bit
Ok I did
car1 setVelocity [200, 0, 0]
It did make it go faster, but it only stay at 200 for half a second. And it only went 200 in the X position.



Would also like to figure out how to do this as well

ArmA 3 - setVelocity is fun

After playing around again

All right, I made the vehicle go 200. But it only works when I spawn the vehicle facing the X position.

It also only works if I get in and don't start the vehicle up, After that it does not work again.

This post was edited by Noxious (2013-06-24 04:41, ago)


Author Message


Posts: 166
Rank:


Level: Member

Country: fi
Location:
Occupation:
Age: 32
In-game name: SPUn

 
#4 Posted at 2013-06-24 05:04        
     
setVelocity <- Check out Example 2

Need web sites & apps or video effects? I'll make 'em; http://kaartomedia.com/ || https://www.facebook.com/kaartomedia

Author Message


Posts: 59
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2013-06-24 05:11        
     
# spunFIN : setVelocity <- Check out Example 2

I did.. No idea how to use it.

Can you set a example with the numbers and names? I have no idea where to place them.

This post was edited by Noxious (2013-06-24 05:25, ago)


Author Message


Posts: 166
Rank:


Level: Member

Country: fi
Location:
Occupation:
Age: 32
In-game name: SPUn

 
#6 Posted at 2013-06-24 09:40        
     
If your vehicle is named as car1, then:
_vehicle = car1; //your vehicle
_vel = velocity _vehicle; //current velocity of car1
_dir = direction _vehicle; //current direction of car1
_speed = 10; //how much you want to add speed for the vehicle
_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];

_speed is meters per second, so 10 = 36kmh (1 km/h = 0.2778 m/s)

You dont need to be afraid of the 'sin & cos _dir -stuff', it just proportionates the _speed value to the direction of your vehicle (since setVelocity separates x & y -values).
And it checks the current velocity of your vehicle becouse it needs to add the "boost" on it, otherwise it would just slow down your vehicle to the speed of 10m/s.

Not probably the best explanation, but hopefully you'll understand! :) You can test it for example with radio trigger as external script.

How did you want to use this functionality?

This post was edited by spunFIN (2013-06-24 15:46, ago)

Need web sites & apps or video effects? I'll make 'em; http://kaartomedia.com/ || https://www.facebook.com/kaartomedia

Author Message


Posts: 59
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#7 Posted at 2013-06-24 17:44        
     
# spunFIN : If your vehicle is named as car1, then:
_vehicle = car1; //your vehicle
_vel = velocity _vehicle; //current velocity of car1
_dir = direction _vehicle; //current direction of car1
_speed = 10; //how much you want to add speed for the vehicle
_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];

_speed is meters per second, so 10 = 36kmh (1 km/h = 0.2778 m/s)

You dont need to be afraid of the 'sin & cos _dir -stuff', it just proportionates the _speed value to the direction of your vehicle (since setVelocity separates x & y -values).
And it checks the current velocity of your vehicle becouse it needs to add the "boost" on it, otherwise it would just slow down your vehicle to the speed of 10m/s.

Not probably the best explanation, but hopefully you'll understand! :) You can test it for example with radio trigger as external script.

How did you want to use this functionality?

Well, It worked just fine.

Expect that it only works once only if I don't start or move my vehicle when I first spawn.

After that, it dose not work.

"How did you want to use this functionality?"

I would like to use it like in the video, and like a normal car like on ArmAII Chernarus Life.(It goes faster onroad and offroad)



Edit:

This may help or not.

Here is what I am doing,

I am putting this in the init of the vehicle
car1 addAction ["speed", "speed.sqf"]

And putting this in the speed.sqf :

_vehicle = car3; //your vehicle
_vel = velocity _vehicle; //current velocity of car1
_dir = direction _vehicle; //current direction of car1
_speed = 100; //how much you want to add speed for the vehicle
_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];

This post was edited by Noxious (2013-06-24 17:57, ago)


Author Message


Posts: 166
Rank:


Level: Member

Country: fi
Location:
Occupation:
Age: 32
In-game name: SPUn

 
#8 Posted at 2013-06-24 18:13        
     
I tried only in arma3, but it worked with a trigger (remember to set Activation to REPEATEDLY), and now in my current project I use it this way:

Every vehicle I want to have a boost has this in its init field:
nul = [this,10] execVM "addToPlayerVehicles.sqf";

init.sqf
[] execVM "boost.sqf";

addToPlayerVehicles.sqf
_veh = _this select 0;
_Boost = _this select 1;
_veh setVariable ["Boost", _Boost, true];

boost.sqf
ARGT_BOOST = {
	if(vehicle player != player)then{
		
		_vehicle = vehicle player;
		_speed = _vehicle getVariable "Boost";

		_vel = velocity _vehicle;
		_dir = direction _vehicle;

		_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];
	};
};

ARGT_KEYDOWN = {
  private ["_dikcode"];
  _dikcode = _this select 1;
  switch ( true ) do
  {
    case ( _dikcode == 0x2A ) : {call ARGT_BOOST}; // Left Shift
    default {false};
  };    
};

while { true } do {
  waituntil { ! isnull finddisplay 46 };
  finddisplay 46 displayaddeventhandler ["KeyDown", "_this call ARGT_KEYDOWN"];
  waituntil { isnull finddisplay 46 };
};  

EDIT:
In your addAction example you set the addaction to car1 but in speed.sqf you use car3, is it typo in here or in your script?

EDIT 2:
Set first line of your speed.sqf to:
_vehicle = _this select 0;
and it should select the target of addaction as _vehicle.

This post was edited by spunFIN (2013-06-24 18:23, ago)

Need web sites & apps or video effects? I'll make 'em; http://kaartomedia.com/ || https://www.facebook.com/kaartomedia

Author Message


Posts: 59
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#9 Posted at 2013-06-24 18:28        
     
# spunFIN : I tried only in arma3, but it worked with a trigger (remember to set Activation to REPEATEDLY), and now in my current project I use it this way:

Every vehicle I want to have a boost has this in its init field:
nul = [this,10] execVM "addToPlayerVehicles.sqf";

init.sqf
[] execVM "boost.sqf";

addToPlayerVehicles.sqf
_veh = _this select 0;
_Boost = _this select 1;
_veh setVariable ["Boost", _Boost, true];

boost.sqf
ARGT_BOOST = {
	if(vehicle player != player)then{
		
		_vehicle = vehicle player;
		_speed = _vehicle getVariable "Boost";

		_vel = velocity _vehicle;
		_dir = direction _vehicle;

		_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];
	};
};

ARGT_KEYDOWN = {
  private ["_dikcode"];
  _dikcode = _this select 1;
  switch ( true ) do
  {
    case ( _dikcode == 0x2A ) : {call ARGT_BOOST}; // Left Shift
    default {false};
  };    
};

while { true } do {
  waituntil { ! isnull finddisplay 46 };
  finddisplay 46 displayaddeventhandler ["KeyDown", "_this call ARGT_KEYDOWN"];
  waituntil { isnull finddisplay 46 };
};  

EDIT:
In your addAction example you set the addaction to car1 but in speed.sqf you use car3, is it typo in here or in your script?

EDIT 2:
Set first line of your speed.sqf to:
_vehicle = _this select 0;
and it should select the target of addaction as _vehicle.

Yea they were both car3. I just forgot to set the other one to car1 for example


After trying the script

Well, It's very buggy.. It's kinda of jerks my car alot of times. I tried it for another car and I pushed shift and it just stopped it.

And changing _vehicle = _this select 0; still only makes the car work once

Edit:

I'm not using any triggers BTW. I don't know what to do with them in this script

This post was edited by Noxious (2013-06-24 18:40, ago)


Author Message


Posts: 166
Rank:


Level: Member

Country: fi
Location:
Occupation:
Age: 32
In-game name: SPUn

 
#10 Posted at 2013-06-24 19:07        
     
Yeah, my bad. Seems like it doesnt work in Arma2 as good as in Arma3. Now I tried in A2 and it kinda worked but only occasionally and not very constantly and smoothly. :/

Need web sites & apps or video effects? I'll make 'em; http://kaartomedia.com/ || https://www.facebook.com/kaartomedia

Author Message


Posts: 59
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#11 Posted at 2013-06-24 19:16        
     
# spunFIN : Yeah, my bad. Seems like it doesnt work in Arma2 as good as in Arma3. Now I tried in A2 and it kinda worked but only occasionally and not very constantly and smoothly. :/

Oh? I've seen many videos of it working... I can't finding the videos at the moment.

Thanks for the help! :)


Author Message


Posts: 1470
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#12 Posted at 2013-06-24 22:10        
     
This is what I made using bits from several posts some time back.

save as init.sqf
disableSerialization;
sleep 1;
player setvariable ["brake",0];
_display = (findDisplay 46);
_display displayAddEventHandler ["KeyDown","if ((_this select 1) == 31) then {player setvariable ['brake',1]} else {player setvariable ['brake',0]}"];


save as boost.sqf
_speedX = 0.1;
_max = 150;

quit_this = true;

while {quit_this} do {
	sleep 0.001;
	if (vehicle player != player) then {
		_veh = vehicle player;
            if (!isOnRoad (position player)) then {_speedX = 0.2} else {_speedX = 0.1};; 
		if (speed _veh > 20 and speed _veh < _max and (player getvariable "brake" == 0)) then {
		
			_vel = velocity _veh;
			_dir = getdir _veh;
			_veh setvelocity [
				(_vel select 0) + _speedX * (sin _dir),
				(_vel select 1) + _speedX * (cos _dir),
				(_vel select 2) - _speedX
			];
		};
			
	};
};


enable by placing this in game logic or unit init.
null=[] execvm "boost.sqf"


And to boost AI you can use this.

save as boostAI.sqf
_vehicle = _this select 0;
while {true} do {
_vel = velocity _vehicle;
_dir = direction _vehicle;
_speed = 0.2;
_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+(cos _dir*_speed),(_vel select 2)];
sleep 0.001;
};

called by placing in vehicles init line
 null=[this] ececvm "boostAI.sqf"

This post was edited by F2kSel (2013-06-24 22:35, ago)


Author Message


Posts: 59
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#13 Posted at 2013-06-24 22:31        
     
# F2kSel : This is what I made using bits from several posts some time back.

save as init.sqf
disableSerialization;
sleep 1;
player setvariable ["brake",0];
_display = (findDisplay 46);
_display displayAddEventHandler ["KeyDown","if ((_this select 1) == 31) then {player setvariable ['brake',1]} else {player setvariable ['brake',0]}"];


save as boos.sqf
_speedX = 0.1;
_max = 150;

quit_this = true;

while {quit_this} do {
	sleep 0.001;
	if (vehicle player != player) then {
		_veh = vehicle player;
            if (!isOnRoad (position player)) then {_speedX = 0.2} else {_speedX = 0.1};; 
		if (speed _veh > 20 and speed _veh < _max and (player getvariable "brake" == 0)) then {
		
			_vel = velocity _veh;
			_dir = getdir _veh;
			_veh setvelocity [
				(_vel select 0) + _speedX * (sin _dir),
				(_vel select 1) + _speedX * (cos _dir),
				(_vel select 2) - _speedX
			];
		};
			
	};
};


enable by placing this in game logic or unit init.
null=[] execvm "boost.sqf"


And to boost AI you can use this.

save as boostAI.sqf
_vehicle = _this select 0;
while {true} do {
_vel = velocity _vehicle;
_dir = direction _vehicle;
_speed = 0.2;
_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+(cos _dir*_speed),(_vel select 2)];
sleep 0.001;
};

called by placing in vehicles init line
 null=[this] ececvm "boostAI.sqf"


THANK YOU!!!! It worked awesome!

Do you know how to do the thing like in the video too?

Do you know how to change the max speed?


Author Message


Posts: 1470
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#14 Posted at 2013-06-24 22:39        
     
if you look in the script boost.sqf it says _max = 150; change that.

for boostAI.sqf try changing _speed = 0.2; or reduce the sleep 0.001;

As for the video I don't think it's possible as A2/OA has limited physics.


Author Message


Posts: 59
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#15 Posted at 2013-06-24 22:44        
     
# F2kSel : if you look in the script boost.sqf it says _max = 150; change that.

for boostAI.sqf try changing _speed = 0.2; or reduce the sleep 0.001;

As for the video I don't think it's possible as A2/OA has limited physics.

Ok, thanks a bunch man