Jump to content
Sign in to follow this  
rcmw

Battlefield clearance

Recommended Posts

OK, I am trying to make a battlefield clearance script that will able to move a dead units. I know there are a few medical scripts that allow you to move wounded units, but I only need/want to be able to move dead units.

The problem I have is that the attach unit command ether dose not work or somehow stops the player from moving. It works fine with ammo crates and things like that but not dead units.

I have tried two scripts, one made myself and one taken from bons medic scripts in a hope that would solve the problem, both don’t work on dead units. Can anyone give me any ideas as to why this dose not work? Or a better way of doing it?

I think it may be something to do with them being dead or maybe its the physics system?

Mine

sleep 1;


unit1 attachTo [playerr, [0, 1, 0.08]];
unit1 setDir 180;

unit1 switchMove "AinjPpneMrunSnonWnonDb";
player playAction "grabDrag";
sleep 1;

Bon

private["_injuredperson","_dragger"];
_injuredperson = unit1;
_dragger = player;


_injuredperson setVariable ["dragger",_dragger,true];
_injuredperson attachTo [_dragger, [0, 1, 0.08]];
_injuredperson setDir 180;

_injuredperson switchMove "AinjPpneMrunSnonWnonDb";
_dragger playAction "grabDrag";
sleep 1;

dropaction = _dragger addAction [format["<t color='#FC9512'>Drop %1</t>",name _injuredperson], {_this spawn tcb_fnc_drop},_injuredperson, 0, false, true];
//carryaction = _dragger addAction [format["<t color='#FC9512'>Carry %1</t>",name _injuredperson], {_this spawn tcb_fnc_carry},_injuredperson, 0, false, true];

Share this post


Link to post
Share on other sites

A really horrible way to do it....every killed unit - replace with a new one - but place him in the dead position and cancel his ability to move. then once youve finished kill that unit

Share this post


Link to post
Share on other sites

I was looking at your post and got interested in seeing if we could do something. It seems that for whatever reason, attachTo doesn't work on corpses. (I tried lots of things but couldn't get the corpse to attach either).

You can work around that by using onEachFrame. Here is some sample code that adds an action to unit1 when he is killed, so you can drag him. When you are dragging, there is the option to drop him. Then you can drag again etc.

Limitations:

1 - Only works for a unit called unit1 at the moment - we can get around this for multiple units by writing variables to the missionNameSpace

2 - Uses onEachFrame. This is bad as it will break any other scripts you may be using that use onEachFrame as well. (and they will break this). If this is a problem for you, then we can look at using:

stackedEventhandlers or using CBA per frame handler.

Anyway, that stuff might not be an issue so let me know if this is the sort of thing you wanted:

In your init.sqf:

horde_fnc_attach_dead_man = compileFinal preProcessFileLineNumbers "grabbed.sqf";
horde_fnc_detach_dead_man = compileFinal preProcessFileLineNumbers "dropped.sqf";

unit1 addEventHandler ["killed", {grabDeadManHandle = unit1 addAction ["Drag corpse", "call horde_fnc_attach_dead_man"]}];

Grabbed.sqf:

player playAction "grabDrag";

unit1 removeAction grabDeadManHandle;

dropDeadManHandle = player addAction ["Drop corpse", "call horde_fnc_detach_dead_man"];

onEachFrame
{
_pos = player modelToWorld [0,1,0];
_pos set [2,0];
unit1 setPos _pos;
_dir = getDir player;
_dir = _dir + 180;	
if (_dir > 360) then {_dir = _dir - 360};
unit1 setDir _dir;
unit1 switchMove "AinjPpneMrunSnonWnonDb";
};

Dropped.sqf:

player switchMove "";

player removeAction dropDeadManHandle;

grabDeadManHandle = unit1 addAction ["Drag corpse", "call horde_fnc_attach_dead_man"];

onEachFrame {};

It may look a bit clunky as I am pretty poor at doing animation timing and I've had a few drinks tonight as well. Let me know how you get on :)

Share this post


Link to post
Share on other sites
It may look a bit clunky as I am pretty poor at doing animation timing and I've had a few drinks tonight as well. Let me know how you get on :)
Haven't you ever heard "Don't drink & code"? ;)

Share this post


Link to post
Share on other sites

I'll give it a look and a try. I only used unit1 as a test to try and get the simple attach and drag bit working 1st but I like your method of getting it on every unit.

Will let you know soon how it works :)

O and

http://xkcd.com/323/

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  

×