Jump to content

Recommended Posts

Hi I'm making this 3 man Coop mission for me and some friends to be played on a LAN server. and I have a problem that I cant find a answer too i have searced both Google and the forum but no luck :(. I have reached a point in the mission where our FOB is going to be attacked by insurgents and i want the anttack to start with a barrage of 8 -10 morter rounds fired by the AI. how do i set that op nice and easy. please help

Share this post


Link to post
Share on other sites

maybe i'm not smart enough to figure out how to use the FO observer mod, but i dosent look like what i'm looking for. I was thinking more like a code i could write in a triggers act to simulate 6 to 8 mortar round hitting my base

Share this post


Link to post
Share on other sites

Well the easiest way would be creating the explosives of your choice and drop them around your base using setPosATL :D

This would be without the action of any AI or any animation which could possibly show the trajectory of the explosive - it would just fall off of some height and explode while touching the ground.

_detonationPosition set [2, 20]; // set height to 20meter
_explosive = createVehicle ["EXPLOSIVE_CLASSNAME", _detonationPosition, [], 0, "NONE"];

// You could also do some simple trig calculation and place it around your base with a set radius
_explosive setPosATL _detonationPosition;  

Unfortunately I don't know the classnames of the explosives but I think other ppl can help you out finding the one you're looking for.

Share this post


Link to post
Share on other sites

The problem is that just spawning a bomb above the target results in a bomb that slowly floats to the ground, often drifting away from the target (with the wind? not sure). Getting it to "fly in" with any real velocity and accuracy takes some doing. One of these days I'm going to dig into a few scripts (like MCC) to see how others have accomplished it.

*edit* - Just realized that, since I always use ACE, this may not be true for vanilla Arma.

Share this post


Link to post
Share on other sites
Well the easiest way would be creating the explosives of your choice and drop them around your base using setPosATL :D

This would be without the action of any AI or any animation which could possibly show the trajectory of the explosive - it would just fall off of some height and explode while touching the ground.

_detonationPosition set [2, 20]; // set height to 20meter
_explosive = createVehicle ["EXPLOSIVE_CLASSNAME", _detonationPosition, [], 0, "NONE"];

// You could also do some simple trig calculation and place it around your base with a set radius
_explosive setPosATL _detonationPosition;  

Unfortunately I don't know the classnames of the explosives but I think other ppl can help you out finding the one you're looking for.

thanks for the reply. this might be a noob question. but what is php code. i might know the answer whitout realizing it :-).

I have tried with the firesky way. but i can only make it to drop one round

Share this post


Link to post
Share on other sites

now I have worked on my own problem for a While, and found a way to make it work :-) it might not be the easiest way to do it, but it Works.

On my map i placed 6 emty game logics named Shell1 to Shell6 to be the targets. then i placed 6 triggers named tr1 to tr6. in the first triggers con i put in "this and triggeractivated trig6" (trig6 is the name of the trigger that starts the attack) in the other triggers i used tr1 to tr5

on act i put in fireSky = "ARTY_Sh_82_HE" createVehicle (shell3 modelToWorld [0,0,100])

i set all the triggers to 5x5 radius and to activated by opfor.

to set of the triggers i put a single opfor rifleman beside the triggers.

but i would stil like to hear for others WHO have an easier way to do the same.

Share this post


Link to post
Share on other sites

Well using triggers to do this kind of work is... kinda strange :D

A trigger is for detecting presence or other detection types and to react to those "events".

Okay, my fingers were itching so I wrote some code for you


_explosives 	= _this select 0;   // the classname of the explosives to use
_markers 		= _this select 1;   // the array containing the markers names
_rounds		= 1;
_delay		= 0;

if (count _this > 2) then
{
	_rounds     = _this select 2;	// number of explosives to place over every marker
	if (_rounds < 1) then
	{
		_rounds = 1;
	};

	if (count _this > 3) then
	{
		_delay= _this select 3;   // maximum delay in seconds between each strike (randomly set)
		if (_delay < 0) then
		{
			_delay = 0;
		};
	};
};

_detonationArea		= [];
_detonationRadius 	= 0;
{
	_detonationRadius = (markerSize _x) select 0;
	_detonationArea = getMarkerPos _x;
	_detonationArea set [2, 100];	// set to 100m height

	for "_mortarRound" from 1 to _rounds do
	{
		createVehicle [_explosives, _detonationArea, [], _detonationRadius, "NONE"];

		if (_delay > 0) then
		{
			sleep (random _delay);
		};
	};

} forEach _markers;

Put this into your init.sqf or into another sqf and compile it beforehand.

Now you have to place markers around your base and give them an unique name.

If you want to start the bombardment, execute this line of code:

["ARTY_Sh_82_HE", ["mortarTarget_1", "mortarTarget_2", "mortarTarget_3"], 3, 0.8] call startBombardment;

Okay the above code will start the bombardment with the following settings:

ARTY_Sh_82_HE shells will be used and placed above the markers mortarTarget_1-3.

3 Shots will be fired at every markers with a maximum of 0.8 seconds delay between each shot.

You wouldn't call this easier, but it's more versatile and doesn't depend on numerous triggers (yeah, they're replaced with markers but markers are "stupid" so its okay anyway :D).

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

I pretty dumb when it comes to this code stuff :p. so if it not to much trouble would you mind making a step by step instruktion on how to implement this in my mission. you know like

step 1 copy code to notapad and save it as blabla.sqf etc

it would be grately appreciated :)

Share this post


Link to post
Share on other sites

Well, here you go:

  1. Copy the content of the codeblock from my post (the big one) and put it into a sqf-file, name it like you see fit (just for this example we're gonna use bombardment.sqf).
  2. Put this newly created sqf-file into your missions folder (the one where your mission.sqm/init.sqf resides).
  3. In your init.sqf (if your mission doesn't have one, create it!) insert this somewhere:
    startBombardment = {};
    if (isServer) then {
       startBombardment = compile preprocessFileLineNumbers "bombardment.sqf";
    };


    This means that just the server will be able to execute the bombardment and will spare us to check if we defined the function before using it.

  4. Now you would execute it whenever you need it, but as you already have knowledge using triggers, you can use the onAct-field of any trigger and put this code into it:
    nil = ["ARTY_Sh_82_HE", ["mortarTarget_1", "mortarTarget_2", "mortarTarget_3"], 3, 0.8] spawn startBombardment;


    The above code will be executed on every client but remember - just the server has the actual code so it will run once on the server.

Don't forget to place your markers in the editor and supplying the names to the function call above.

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

I followed your instructions to the letter but there is something wrong. when i type this in the triggers on act. ["ARTY_Sh_82_HE", ["mortarTarget_1", "mortarTarget_2", "mortarTarget_3"], 3, 0.8] spawn startBombardment; i get this error Type Script. expected Nothing

just i tought. I'm not using ACE. I dont know if that has anything to go with the problem

Edited by Lars-the-dane

Share this post


Link to post
Share on other sites

argh I hate it.... triggers Y_Y

Yeah, add a "nil = " in front of the code, I edited my post so you can just copy it.

Share this post


Link to post
Share on other sites

now i got this error message " warning: nil varibel overriden; please fix mission or loaded addon scripts" whats wrong ?? now :confused:

Share this post


Link to post
Share on other sites

I'm no coder but I'm pretty sure you can't use nil - try using nul instead?

Share this post


Link to post
Share on other sites

Are you sure we'Re talking about ArmA2 here?

adding

nil = ["ARTY_Sh_82_HE", ["mortarTarget_1", "mortarTarget_2", "mortarTarget_3"], 3, 0.8] spawn startBombardment;

into the onAct-field of any trigger works for me without any problems.

Share this post


Link to post
Share on other sites

I'm running Arma 2 CO whit cba and the latest betapatch and a lots of other addons. but no ace

Share this post


Link to post
Share on other sites

Well that's strange, using the vanilla ArmA2 CO and the latest beta patch I don't get these problems, is the code to start the bombardment the only text in your onAct-field?

I don't know if any addons could cause these problems, or my arma is just something "special" :D

Could someone recreate this? Just put something like

nil = [] spawn {hint "YAY!";};

into any trigger's onAct-Field and hit OK.

Does this work without any error messages? Yes? Please report back asap! :D

// PS: try to use any other name than "nil" and try out if it works, if not, somethings wrong on the other end of the rope :D

Share this post


Link to post
Share on other sites

that line Works

---------- Post added at 18:48 ---------- Previous post was at 18:40 ----------

that line Works, and yes the borbart starting line is the only one in the on act field :-(

Share this post


Link to post
Share on other sites

Okay, I know this is stupid and I'm clutchting at straws here but could you post your content of the onAct-field?

All of it, with all of the spaces and such, put a PHP-Tag around it and show it to us.

I really can't fathom why this isn't working for you :<

Share this post


Link to post
Share on other sites

this is what I put in the On act of the trigger

nil = ["ARTY_Sh_82_HE", ["mortarTarget_1", "mortarTarget_2", "mortarTarget_3"], 3, 0.8] spawn startBombardment; 

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  

×