Jump to content
cooked auto

[SOLVED] Weird interactions between script and attachto

Recommended Posts

I'm working on a mission where the player has to intercept a motorcade of three cars in order to capture an HVT.

But an odd interaction between the method I use to disable the engine and the convoy script I'm using is causing some frustration.

 

So in order to intercept the vehicles in the convoy, the players have to disable the engine of either the lead car, or the car carrying th HVT. The way I accomplished this was to attachto a balloon to the hood to the car that is tied to a trigger that will disable the engine once shot.  (The Balloons later hidden by removing their textures while they're still considered  there.)

That works without issue.

 

The motorcade itself uses Tova's Simple Convoy Script to get from point A to B.

That works without issue.

 

In this case using the line 

"convoyScript = [group this, 70, 20, false] spawn TOV_fnc_SimpleConvoy;"

on the lead vehicle to call the script. In this case following the video tutorial found in the thread.

The script itself present in the mission in a game logic file.

 

But the problem arises when I combine these two parts.

When I add a variable name to the cars for the attachto, the convoy script doesn't want to fire. The cars reverting back to the way the AI usually drives, ie poorly.

Adding the cars variable name to the group doesn't work, neither does giving the group a variable name and using that. 

 

The thread for the script has another way of implementing the script, but using that doesn't seem to do much other than the AI marking off all the waypoints as completed without moving from the spot during testing.
Even when trying on a LAN server I get a similar results.

 

So what am I missing in this case?
As far as I can deduce it out has something to do with how the convoy script is called, and how it doesn't seem to like the cars in it having names.

I don't think I can use the attachto without using a variable name for the cars.

Edited by cooked auto
Problem solved. :)

Share this post


Link to post
Share on other sites

Unlikely it has anything to do with variable names, and everything to do with attachTo.

 

Easy to check, with this in your car's init:

balloon attachTo [this,[0,0,0]];

 

Though I'm not sure I understand what the balloon is about. You could use an event handler to disable the engine. How exactly do you want it to work, though? Does the engine actually need to be damaged for it to trigger, or just any damage to the vehicle?

 

To disable the engine when the engine takes any damage, place this in the car's init:

this addEventHandler ["Dammaged", {
	params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
	if (_hitpoint isEqualTo "hitengine") then {
		_unit setHitPointDamage ["hitEngine",1];
	};
}];

 

  • Like 1

Share this post


Link to post
Share on other sites

Oh. I probably should've elaborated on that. 

In this case the balloon was the best way I could figure out how to execute disabling the engine, as the cars were rather bullet resistant.

 

In this case they're attached to the cars hoods, and then upscale them slightly to make them easier to hit (when shooting from above in a helicopter).
 

init="g1 attachTo [car1, [0, 2, -0.5]];" \n "g1 setObjectScale 2.3;";


Then there's a trigger that checks if the balloons are killed or not.

condition="call{{alive _x} count [g1] < 1}";

Which then takes out the engine.

onActivation="car1 setHitPointDamage[""hitengine"",1];";

 

I tried finding some way to use event handlers for it, but couldn't find a clear enough instructions for it.
Essentially one shot through the engine block.

Share this post


Link to post
Share on other sites

Easy. In the balloon's init:

this addEventHandler ["Killed", {
	params ["_unit", "_killer", "_instigator", "_useEffects"];
	car1 setHitPointDamage ["hitEngine",1];
}];

No need for a trigger.

  • Like 2

Share this post


Link to post
Share on other sites

Well that's good to know at least. I'll give the attachto method and that a try then.

 

Share this post


Link to post
Share on other sites

Okay, after testing it's the attachto that is causing the issue. Because attaching it that way created the same issue with them not moving.

In one instance, with the event handler not firing properly due to a missing variable name for the car, they started driving off.

 

Edit:
Okay, the eventhandler does make the convoy script working.
The only downside is that one of the objective triggers were dependant on the balloons getting destroyed for completion. Which I figure can be solved by the trigger checking for if the engine is alive or not.

 

Not sure what command I should use for the trigger condition though. Checking if EngineOn False doesn't work as the cars start with their engines off, which automatically activates the trigger.

Share this post


Link to post
Share on other sites

In my example, the balloon being "killed" is the event, so you can either add your trigger's code to the EH, or check for the balloon's status in the trigger as you were before.

Share this post


Link to post
Share on other sites

Ah, due to the attachto being the problem in this case I swapped from the balloons to the EH you mentioned before. 
That made the convoy script work without a hitch, and shooting the hood of the car disabling the engine as well.

Share this post


Link to post
Share on other sites

In that case you can use getHitPointDamage to check that the engine is destroyed. Your trigger condition:

car1 getHitPointDamage "hitengine" == 1

 

  • Like 1

Share this post


Link to post
Share on other sites

That worked just perfect.


Can definitely called that issue nipped in the bud. 
Much appreciated. :)

  • Like 1

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

×