Jump to content
Sign in to follow this  
Taurus

M1A1 Abrams Issues + General Tank issues

Recommended Posts

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_args = _this select 0; //Started with: this addEventHandler ["fired", {[_this] execVM "belowScript.sqf"}]

_unit = _args select 0;

_wepn = _args select 1;

_mzle = _args select 2;

_mode = _args select 3;

_ammo = _args select 4;

//Treat as Object ID

_aObj1 = (getPos _unit) nearestObject _ammo;

//Position and class type

_aObj2 =  nearestObject [(getPos _unit), _ammo];

//Object and class type

_aObj3 =  nearestObject [_unit, _ammo];

player groupChat format ["1=%1 2=%2 3=%3",_aObj1,_aObj2,_aObj3];

Tested with M1A1 Abrams

All three returns object id's with the machinegun(both gunner and commander)

But the main gun(Sabot) doesn't return any id.

Hence I can not do a follow cam on that object.

Bug or working as intended, how to fetch the fired shell?

I've tried with the M119 , The tripod mounted Grenade launcher and TOW.

All of them returns object ID's.

and for my next issue.

Why doesn't the gunner in the Abrams engage armored targets with the Sabot?

Instead it's wasting ammo using the MG until I switch to the gunner seat and back to the commander.

Thanks in advance

Share this post


Link to post
Share on other sites

There is probably too long a delay when called from a script. Either call the nearest object straight from the init field like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">This AddEventHandler ["fired",{Hint Format ["Ammo %1",NearestObject [_This Select 0,_This Select 4]]}]

Or call it from a function.

If the above works ok for you, you can pass the vehicle and ammo as parameters to your cam script:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">This AddEventHandler ["fired",{[_This Select 0,NearestObject [_This Select 0,_This Select 4]] ExecVM "belowScript.sqf"}]

belowScript.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vehicle=_This Select 0;

_Round=_This Select 1;

...

Share this post


Link to post
Share on other sites

Thanks Unn!

However the script is started from the init line of the tank.

I'll try calling a function to see if it differs.

And the code example in the init line too.

Share this post


Link to post
Share on other sites
Quote[/b] ]However the script is started from the init line of the tank.

Sorry I didn't make myself very clear. You should be ok from either the config event or script event. As long as you call NearestObject as quickly as possible.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fired="[_This Select 0,NearestObject [_This Select 0,_This Select 4]] ExecVM ""belowScript.sqf""";

Or

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fired="_This Call UNN_GetRound";

UNN_GetRound.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_Vehicle","_Ammo","_Round"];

_vehicle=_This Select 0;

_Ammo=_This Select 4;

_Round=nearestObject [_Vehicle,_Ammo];

If !(IsNull _Round) Then

       {

       [_Vehicle,_Round] ExecVM "belowScript.sqf";

       };

Share this post


Link to post
Share on other sites

In your first reply, was the second code example there to begin with?

Because if it was I do feel ashamed.

You gave me the answer and I didn't see it.

I have now tried the hint thingy from the first reply, this indeed returned shell objects.

Odd I must say.

But Unn, with your second reply I became somewhat confused.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fired="[_This Select 0,NearestObject [_This Select 0,_This Select 4]] ExecVM ""belowScript.sqf""";

Or

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fired="_This Call UNN_GetRound";

I'm sorry but I don't understand.

Where would I put one of theses two code blocks?

I tried with putting the "execVM"-example in my init.sqf

Then in the init line of the vehicle itself:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["fired", {fired}];

But nothing happens.

However I've got

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">This AddEventHandler ["fired",{[_This Select 0,NearestObject [_This Select 0,_This Select 4]] ExecVM "belowScript.sqf"}]

to work so I'll stick with this.

I'm pretty sure this "used" to work as I described in my first post tho'

(one year ago or so)

I be back soon with my reworked camFollow thingy script

Thanks for your help Unn.

Share this post


Link to post
Share on other sites
Quote[/b] ]In your first reply, was the second code example there to begin with?

I can't remember off hand, I may well have.

Quote[/b] ]I have now tried the hint thingy from the first reply, this indeed returned shell objects.

Odd I must say.

It's because there is a slight delay when you load and launch a script with ExecVM. With a high muzzle velocity or increased lag, it can sometimes miss the round being fired.

Quote[/b] ]I'm sorry but I don't understand.

Where would I put one of theses two code blocks?

I wasn't sure how you wanted to add the event, so I added those for the config.cpp to.

Glad to hear you have it working ok now.

Share this post


Link to post
Share on other sites
I can't remember off hand, I may well have.

Ok I do apologize.

Quote[/b] ]It's because there is a slight delay when you load and launch a script with ExecVM. With a high muzzle velocity or increased lag, it can sometimes miss the round being fired.

Ok, but I'm pretty sure it worked before, one year ago as this script worked back then hehe! smile_o.gif

Quote[/b] ]I wasn't sure how you wanted to add the event, so I added those for the config.cpp to.

Oh I see, that's appreciated!

Quote[/b] ]Glad to hear you have it working ok now.

Thanks!

Still haven't had time to update the script. Been working on my mission(scripting)

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  

×