OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Speeder on 03 Apr 2007, 09:29:05
-
Okay - I'm having some trouble getting this to work.
I've made a addaction to the medics init linie calling a sqs file.
MakeMedicten.sqs:
tent = createVehicle MASH... bla bla..
My problem lies within deleting the MASH again.
Could anyone please write a working code which checks nearest building, checks if building is a MASH if it's a MASH or even the same MASH that the Medic has just setup, the Medic should get an action to delete/destroy it. It needs to be MP compatible.
I tried to get it to work for 4 hours last night, and it sort of did, but not every time.
Please help me with it.
Thank you so much in advange
----------------------------------------------------------------------------------------
THE SCRIPT.
----------------------------------------------------------------------------------------
setupmash.sqf
_unit = _this select 0;
_id = _this select 2;
_unit removeAction _id;
_unit playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 1;
_mash = createVehicle ["MASH",[0,0,0], [], 0, "NONE"];
_mash setDir ((direction _unit) -180);
_mash setdammage 0.8;
sleep 1;
_mash setPos (_unit modelToWorld [0,6,((position _unit) select 2)]);
_mash setdammage 0.5;
_unit playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 2;
_mash setdammage 0.2;
sleep 2;
_mash setdammage 0;
sleep 2;
_unit addAction ["Dismantle MASH","takedownmash.sqf",_mash,1,false];
takedownmash.sqf
if (!local server) exitWith {true};
_unit = _this select 0;
_id = _this select 2;
_mash = _this select 3;
_unit removeAction _id;
_unit playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 1;
_mash setdammage 0.2;
sleep 2;
_mash setdammage 0.5;
_unit playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 2;
_mash setdammage 0.8;
sleep 2;
_mash setdammage 1;
sleep 2;
deleteVehicle _mash;
sleep 2;
_unit addAction ["Deploy MASH", "setupmash.sqf","",1,false];
INIT line og My medic:
this addAction ["Deploy MASH", "setupmash.sqf","",1,false]
-
I did this using sqf, but that's just because I'm now so used to it I can't even write sqs anymore...
First, add the action in the init field
this addAction ["Deploy MASH", "setupmash.sqf","",1,false]Those extra bits are the new things available in ArmA, the false for example prevents the action from showing up on the center of the screen all the time..
setupmash.sqf
_unit = _this select 0;
_id = _this select 2;
_unit removeAction _id;
_mash = "MASH" createVehicleLocal [0,0,0];
_mash setDir ((direction _unit) -180);
_mash setPos (_unit modelToWorld [0,6,((position _unit) select 2)]);
sleep 1;
_unit addAction ["Dismantle MASH","takedownmash.sqf",_mash,1,false];In ArmA you can now pass custom arguments into the script executed by the action which makes this easier..
And don't be confused by the modelToWorld command there, it just easier to 'misuse' the command like that instead of using the sin/cos stuff to get the MASH deployed in front of the medic..
takedownmash.sqf
_unit = _this select 0;
_id = _this select 2;
_mash = _this select 3;
_unit removeAction _id;
deleteVehicle _mash;
sleep 1;
_unit addAction ["Deploy MASH", "setupmash.sqf","",1,false];
Now, I'm not at all sure this would work in MP 'out fo the box' but that's a start I think :dunno:
-
I'm gonna test this the minut I get home. It looks great, and just might work. But could it be made so it only ran on the server.
I'm sending a lot of good karma your way if this works.
-
But could it be made so it only ran on the server.
I'm not at all familiar with MP scripting, but I guess if you have a gamelogic called 'server' in the mission and add something like
if (!local server) exitWith {true};in the beginning of each script that might work..
You can also try adding scopes in the scripts and use the breakOut (http://www.ofpec.com/COMREF/ArmAOnly/index.php?action=list&game=All&letter=a#breakOut) command for exiting sqf script
if (!local server) exitWith {true};
_unit = _this select 0;
_id = _this select 2;
_unit removeAction _id;
_mash = "MASH" createVehicleLocal [0,0,0];
_mash setDir ((direction _unit) -180);
_mash setPos (_unit modelToWorld [0,6,((position _unit) select 2)]);
sleep 1;
_unit addAction ["Dismantle MASH","takedownmash.sqf",_mash,1,false];
or
scopeName "setupmash";
if (!local server)
then {breakOut "setupmash"};
_unit = _this select 0;
_id = _this select 2;
_unit removeAction _id;
_mash = "MASH" createVehicleLocal [0,0,0];
_mash setDir ((direction _unit) -180);
_mash setPos (_unit modelToWorld [0,6,((position _unit) select 2)]);
sleep 1;
_unit addAction ["Dismantle MASH","takedownmash.sqf",_mash,1,false];
Dunno how the createVehicleLocal works in situation like this though, but that remains to be seen I guess..
-
If I was not to use createvehiclelocal what should I then use? Because the MASH isn't being made atm
-
so I got it working - The createvehiclelocal did not work, so I just found away around that.
However - is it possible to make sure that no other players gets the medics actions when they are close to him??
That's my setupmash.sqf
_unit = _this select 0;
_id = _this select 2;
_unit removeAction _id;
_unit playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 1;
_mash = createVehicle ["MASH",[0,0,0], [], 0, "NONE"];
_mash setDir ((direction _unit) -180);
_mash setdammage 0.8;
sleep 1;
_mash setPos (_unit modelToWorld [0,6,((position _unit) select 2)]);
_mash setdammage 0.5;
_unit playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 1;
_mash setdammage 0.2;
sleep 1;
_mash setdammage 0;
sleep 1;
_unit addAction ["Dismantle MASH","takedownmash.sqf",_mash,1,false];
Medics INIT
this addAction ["Deploy MASH", "setupmash.sqf","",1,false]
Would it be possible to make a check in the script to see if the unit using the script is of the medic class?
-
First: Please, do not double post. Edit your previous post if you have someting to add.
Would it be possible to make a check in the script to see if the unit using the script is of the medic class?
Yes.
However that would not prevent the action being available to other players, which is a shame really..
Anyways, you can do it in the same vein as the server check, by using exitWith (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=d#exitWith) or naming the scope and using breakOut (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=a#breakOut)..
if (!_unit in ["SoldierWMedic","SoldierEMedic","SoldierGMedic]) exitWith {true}
Btw, I would add a longer sleep before adding the dismantle action because currently the medic is still building the mash when he/she gets the dismantle action :scratch:
-
So now it builds the mash, and I tried addind the scope af descrieped, but that just crashed the server. I tried running it witout, but the createvehicle is not carried over the network, so no other players can see the mash..
-
The action added to the medic will not be visible to other players if the addAction is executed only on the medic's machine. If this is done your setup script itself will not need a locality check.
In the medic unit's init you could put this:
If (local this) Then {this addAction ["Deploy MASH", "setupmash.sqf","",1,false]}
Make sure you remove the locality check from "setupmash.sqf". The createVehicle command should propagate the tent across all nodes. Put longer pauses in between the mash setDamage lines.
-
Speeder, when you get it worked out, could you post a sample mission? I would like to see this in action. :)
TCM
-
Do you mean like this? (see top post.)
-
okay -. now my script won't run at all. Any chance one of you great guys could make one for me that works, and works in MP too please
-
okay - I got it running again, but with the code in post 1 the other players on the server still can't see the mash created.
Would someone be so kind to give my script the finishing touch.
thank you so very much
-
I hate to repeat myself
Please, do not double post. Edit your previous post if you have someting to add.
Did you try what Peanut suggested?
Remove the server check from the script and change
this addAction ["Deploy MASH", "setupmash.sqf","",1,false]to
If (local this) Then {this addAction ["Deploy MASH", "setupmash.sqf","",1,false]}
:dunno:
-
but by editing the topic will not be shown as new to the readers right? - Well - nevermind.
-
Yes it will, it just won't be 'bumped' :scratch:
But look, this our site policy, there is no reason to start getting into trouble for something as minor as this..