Jump to content
Sign in to follow this  
epicgoldenwarrior

Request - Carry Script

Recommended Posts

Hey guys, I don't necessarily have the time to write this atm so I'm hoping someone could pull it together for me, plus theres a portion I don't completely understand.

I want a simple carry script so I can go up to a unit (already switchmoving 'injured' for example) and carry them via addaction.

carry = this addaction ["Carry","carry.sqf"];

I guess I can supply the outline somewhat.

carry.sqf

_target = this select 0;
_unit = this select 1;  // I never really understood how to use these actually, so fix them if they're used wrong. _unit should be player, _target is a unit being picked up

_target attachTo [_unit[0,0,1]];
sleep 0.5;
_target removeAction carry;
_target switchMove "AinjPfalMstpSnonWrflDnon_carried_Up";
_unit switchMove "AcinPknlMstpSrasWrflDnon_AcinPercMrunSrasWrflDnon";
drop = _target addAction ["Drop","drop.sqf"];

if (!alive _unit) then {
_target switchMove "AinjPfalMstpSnonWnonDf_carried_fall";
_target removeAction drop;
carry = _target addaction ["Carry","carry.sqf"];

Make sure I'm not missing anything there please (physically too, ex. if I missed removeaction or something we'd see in game)

Drop.sqf

_target switchMove "AinjPfalMstpSnonWnonDnon_carried_Down";
_target removeAction drop;
_unit switchMove "AcinPercMrunSnonWnonDf_AmovPercMstpSnonWnonDnon";

Dammit I wrote half the damn thing already.

Please finish.

Share this post


Link to post
Share on other sites

You talking SP or MP, because I've got a drag/carry script in SP sorted, if you need a proper system it won't do because I seem to break the AI when I do it, but if you just need it for a specific segment I can post it up.

Share this post


Link to post
Share on other sites
Multiplayer, I guess you could post most of it to help others out but that's all I've got for now.

Never mind then, there's really not that much more there than yours. Wasn't there a script called ARMA III Wounding system or something that had carrying? Might be able to use that.

Share this post


Link to post
Share on other sites

Here is an explanation about addAction and _this select 0;

If you call a script via addAction, the addAction forwards 3 entities in an array. The first on is the unit the addAction is/was attached to.

[color="#FF8040"][color="#1874CD"]_unit[/color] 	[color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color][/color]

The second one is the caller, who used the addAction

[color="#FF8040"][color="#1874CD"]_caller[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color][/color]

the third one is the action itself.

[color="#FF8040"][color="#1874CD"]_action[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]2[/color][color="#8B3E2F"][b];[/b][/color][/color]

So the array would look like this: [_unit,_caller,_action]

If you now want to point a variable to the units in the script the addAction called you can simply put _unit = _this select 0; To define the _caller you would put _caller = _this select 1; And _action = _this select 2; for the action itself.

So all in all you actually got it completely right, exept that the _this must be local.

Okay, I fiddled a little bit with the script and that's what I got now:

carry.sqf

[color="#FF8040"]injuredTarget [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_caller[/color] 	  [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_action[/color] 	  [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]2[/color][color="#8B3E2F"][b];[/b][/color] 

injuredTarget [color="#191970"][b]attachTo[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#1874CD"]_caller[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#FF0000"]-0.5[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0.2[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]0[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]sleep[/b][/color] [color="#FF0000"]0.01[/color][color="#8B3E2F"][b];[/b][/color]
injuredTarget [color="#191970"][b]switchMove[/b][/color] [color="#7A7A7A"]"AinjPfalMstpSnonWrflDnon_carried_Up"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_caller[/color] 	  [color="#191970"][b]switchMove[/b][/color] [color="#7A7A7A"]"AcinPknlMstpSrasWrflDnon_AcinPercMrunSrasWrflDnon"[/color][color="#8B3E2F"][b];[/b][/color]
injuredTarget [color="#191970"][b]removeAction[/b][/color] [color="#1874CD"]_action[/color][color="#8B3E2F"][b];[/b][/color]
injuredTarget [color="#191970"][b]switchMove[/b][/color] [color="#7A7A7A"]"AinjPfalMstpSnonWrflDnon_carried_Up"[/color][color="#8B3E2F"][b];[/b][/color]

[color="#1874CD"]_caller[/color] [color="#191970"][b]switchMove[/b][/color] [color="#7A7A7A"]"AcinPknlMstpSrasWrflDnon_AcinPercMrunSrasWrflDnon"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_caller[/color] [color="#191970"][b]addAction[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"Drop"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"scripts\carryScript\drop.sqf"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]

[color="#8B3E2F"][b]/[/b][/color][color="#8B3E2F"][b]*[/b][/color]
[color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#8B3E2F"][b]![/b][/color][color="#191970"][b]alive[/b][/color] [color="#1874CD"]_caller[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
[color="#1874CD"]_caller[/color] [color="#191970"][b]switchMove[/b][/color] [color="#7A7A7A"]"AinjPfalMstpSnonWnonDf_carried_fall"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_caller[/color] [color="#191970"][b]removeAction[/b][/color] [color="#191970"][b]drop[/b][/color][color="#8B3E2F"][b];[/b][/color]
carry [color="#8B3E2F"][b]=[/b][/color] injuredTarget [color="#191970"][b]addAction[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"Carry"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"carry.sqf"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

drop.sqf

[color="#FF8040"][color="#1874CD"]_caller[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_action[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]2[/color][color="#8B3E2F"][b];[/b][/color]

injuredTarget [color="#191970"][b]switchMove[/b][/color] [color="#7A7A7A"]"AinjPfalMstpSnonWnonDnon_carried_Down"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]detach[/b][/color] injuredTarget[color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_caller[/color] [color="#191970"][b]removeAction[/b][/color] [color="#1874CD"]_action[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_caller[/color] [color="#191970"][b]switchMove[/b][/color] [color="#7A7A7A"]"AcinPercMrunSnonWnonDf_AmovPercMstpSnonWnonDnon"[/color][color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

There were some issues, but nothing serious. The problem I've got now is, that the player is stuck and can't move after puting the patient down on the ground agian.

This could be an issue with the animation itself.

Edited by R3vo

Share this post


Link to post
Share on other sites

I suppose I could add

sleep 10;
_caller switchMove "";

at the end.

I would assume that could at least reset it fine.

Thanks for your help, will test it out in a bit.

Share this post


Link to post
Share on other sites
I suppose I could add

sleep 10;
_caller switchMove "";

at the end.

I would assume that could at least reset it fine.

Thanks for your help, will test it out in a bit.

That could actually work, just wondering why it doesn't end the animation properly in the first place.

Share this post


Link to post
Share on other sites

Um, for some reason the target isnt playing anim...so, it looks weird.

EDIT: The guy's height was 100m so he was dead when I got there, and dead units cant switchmove. So it works now.

Only issue I have (which this is actually working better than revive scripts) is that they arent ...synced together.

Ex. I face opposite direction lifting him, yet when he is on my back it works perfect. When I take him off, he floats off other direction.

By the way, my idea fixed the walk problem :)

Edited by EpicGoldenWarrior

Share this post


Link to post
Share on other sites
Um, for some reason the target isnt playing anim...so, it looks weird.

EDIT: The guy's height was 100m so he was dead when I got there, and dead units cant switchmove. So it works now.

Only issue I have (which this is actually working better than revive scripts) is that they arent ...synced together.

Ex. I face opposite direction lifting him, yet when he is on my back it works perfect. When I take him off, he floats off other direction.

By the way, my idea fixed the walk problem :)

Great that you fixed that walking problem. I'm also thinkin about a way to "sync" both units to make it look better.

Share this post


Link to post
Share on other sites
Um, for some reason the target isnt playing anim...so, it looks weird.

Only issue I have (which this is actually working better than revive scripts) is that they arent ...synced together.

It isn't playing anim likely because you're using switchMove which is local code and not fit for MP on its own. Will have to use a method to broadcast the anim states over network, BIS_fnc_MP, public variable, etc.

They aren't synced together because it's incomplete functionality which as you can see there is good reason why its not in the default game :)

You're always going to have issues syncing the anims, especially in MP when you'll be subject to latency and sync delay. There's no way to accelerate the animations to stay in sync.

Share this post


Link to post
Share on other sites

Actually he wasnt playing anim because he was dead *_* but, shouldnt setdir and attachto make it perfect? The actions are timed perfectly, but it looks like I'm doing a raindance until he is on my back.

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  

×