Jump to content
Sign in to follow this  
molotov_billy

Making trenches work in the editor

Recommended Posts

Trying to put some quick missions together in the editor, I'm trying to get teams of men to use trenches in defense. Is there some trick here? I carefully place them, turn special formation to 'none' or whatever.. they start in the right spots, but immediately wander off, even if they do not have a waypoint.

Share this post


Link to post
Share on other sites

That doesn't work for me. Don't you have to name the trench something? I tried naming it "ATL" (I think that script is talking about a trench named ATL) in the but it still did nothing.

Share this post


Link to post
Share on other sites

Yeah It says nothing about how to actually get the units inside the trench, it's just a script to get them to act properly.

Share this post


Link to post
Share on other sites

Has anyone actually managed to get trenches working? If so, how do we do it?

Share this post


Link to post
Share on other sites

SaOk has something for that, its a script so the credits for this script goes to him.

There is building positions for trenches. I have already functions to populate trenches with wanted life. Here is example if someone like to try my scripts:

Create trigger with 600 radius, player side activation, repeatedly setting, 2 on min/mid/max, condition this and in on act:

_nul = [5,["LIB_SOV_sergeant","LIB_SOV_smgunner","LIB_SOV_smgunner","LIB_SOV_LC_rifleman","LIB_SOV_mgunner","LIB_SOV_medic","LIB_SOV_AT_grenadier"],EAST, 1, (position thisTrigger),30] execVM "RandomBuilding.sqf";
or 
_nul = [6,["LIB_GER_unterofficer","LIB_GER_mgunner","LIB_GER_medic","LIB_GER_scout_ober_rifleman","LIB_GER_ober_rifleman","LIB_GER_AT_soldier"],WEST, 1, (position thisTrigger),30] execVM "RandomBuilding.sqf";

The first number is how many unit the script spawns and the class array is where the it picks randomly classes to units.

The needed scripts (You also need to have functions module placed on map):

RandomBuilding.sqf:

private ["_buildings", "_mencount", "_unitclasses", "_side", "_del", "_pos", "_dis", "_t", "_units", "_used", "_building", "_waypoints", "_c", "_array", "_c2", "_start", "_class", "_g1", "_unit", "_nul", "_found"];
//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: SaOk
//////////////////////////////////////////////////////////////////
//thanks for tips Rejen Orst, xenogf and Celery
//_buildings = _this select 0; 
_mencount = _this select 0; 
_unitclasses = _this select 1; 
_side = _this select 2; 
_del = _this select 3;
_pos = _this select 4;
_dis = _this select 5;
_buildings = nearestObjects [_pos,["Static"], _dis];
_t = 0 - _mencount;
_units = [];
_used = [];
while {_mencount > 0 && _t < 50} do {
_building = _buildings call BIS_fnc_selectRandom;
if (_side == civilian && typeof _building in ["Land_fortified_nest_big_EP1","Land_fortified_nest_big","Land_fortified_nest_small_EP1","Land_fortified_nest_small","Land_Fort_Watchtower_EP1","Land_Fort_Watchtower"]) then {
_v = 0;
while {typeof _building in ["Land_fortified_nest_big_EP1","Land_fortified_nest_big","Land_fortified_nest_small_EP1","Land_fortified_nest_small","Land_Fort_Watchtower_EP1","Land_Fort_Watchtower"] && _v < 20} do {_building = _buildings call BIS_fnc_selectRandom; _v = _v + 1;};
};
_waypoints = [];
_c = 0;
_array = _building buildingPos _c;
while {str(_array) != "[0,0,0]"} do {	
_waypoints set [count _waypoints,_c];
_c = _c + 1;
_array = _building buildingPos _c;
};
_c = count _waypoints;
_c2 = {_x ==_building} count _used;
if (_c2 + 1 > _c) then {_waypoints = [];} else {_used set [count _used,_building];};
if (count _waypoints > 0) then {
_start = _waypoints call BIS_fnc_selectRandom;
_class = _unitclasses call BIS_fnc_selectRandom;
_g1 = [position _building, _side, [_class],[],[],[0.5,0.8]] call BIS_fnc_spawnGroup;
_unit = leader _g1;
_unit setpos (_building buildingPos _start);
_nul = [_unit,_building,_waypoints,_start] execVM "BuildingAI.sqf";
_mencount = _mencount - 1;
_units set [count _units,_unit];
};
_t = _t + 1;
};
if (_del == 1) then {
waituntil {sleep 5; player distance _pos > 600};
{deletevehicle _x;} foreach _units;
};

BuildingAI.sqf:

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: SaOk
//////////////////////////////////////////////////////////////////
private ["_unit", "_building", "_wps", "_start", "_count", "_picked", "_pos"];
_unit = _this select 0; 
_building = _this select 1; 
_wps = _this select 2; 
_start = _this select 3; 
if (_start != -1) then {_unit setpos (_building buildingPos _start)};
_unit setunitpos "UP";
_unit setbehaviour "SAFE";
_unit setspeedmode "LIMITED";
sleep (random 15);
_count = count _wps;
while {!isNull _unit && alive _unit && (_count > 0)} do {
 _picked = _wps call BIS_fnc_selectRandom;
 _pos = _building buildingPos (_wps select _picked); 
 _unit domove _pos;
 sleep (25 +(random 15));
};

Place the trigger over trench or any building with building positions. You can set the radius from what distance the script select random buildings for the script (default). In the example the units are spawn when player in less than 600m away from trigger and deleted when more far. If you dont want the script to delete the units never make the trigger activate once and set the zero to one in script launch (...EAST, 0...). To make the script MP compatible add isServer to the condition (this and isServer). Then just copy paste triggers to populate whole map. ;) Let me know if there is any problems.

For more performance friendly method you can add this to init.sqf:

FUNKTIO_LIIKUTALOSSA=compile preprocessfileLineNumbers "BuildingAI.sqf";

And change this code:

_nul = [_unit,_building,_waypoints,_start] execVM "BuildingAI.sqf";

to this:

_nul = [_unit,_building,_waypoints,_start] SPAWN FUNKTIO_LIIKUTALOSSA;

Kind regards

---------- Post added at 02:32 PM ---------- Previous post was at 02:29 PM ----------

That doesn't work for me. Don't you have to name the trench something? I tried naming it "ATL" (I think that script is talking about a trench named ATL) in the but it still did nothing.

no you don't need to name the trenches, the code that needs to go in the trigger has a radius count for 30 meters standard, you can narrow it down to 10 if you have more trenches or other buildings in that area. Also be sure that you place the trigger on the middle of the trench you are using "By this I mean where the trench name pops up" to narrow the radius down change the part

(position thisTrigger),30] execVM

Example:

_nul = [5,["LIB_SOV_sergeant","LIB_SOV_smgunner","LIB_SOV_smgunner","LIB_SOV_LC_rifleman","LIB_SOV_mgunner","LIB_SOV_medic","LIB_SOV_AT_grenadier"],EAST, 1, (position thisTrigger),[b]10[/b]] execVM "RandomBuilding.sqf";

kind regards

Edited by KBourne

Share this post


Link to post
Share on other sites

Cheers KBourne, I'll give that a go :)

Share this post


Link to post
Share on other sites

I created a trench template if anyones interested - each trench of the game filled in with units & appropriate weapons (squad trench, MG trenches, etc..)

Share this post


Link to post
Share on other sites

Majoris: yes, I am interested in all templates to use in the editor, Thanks

Oksman: I wish there was docs explaining how to do it all like your video.

Share this post


Link to post
Share on other sites

If you make a mission with trenches in the editor, the best way for the soldiers inside the trenches to act properly, is to write in the initialization of the commander of the trench group this:

{_x setUnitPos "UP"; doStop _x; _x allowFleeing 0; _x forceSpeed 0; _x setPosATL [getPosATL _x select 0, getPosATL _x select 1, 0.23];} foreach units this;

The getPosATL_x select 1, 0.23 is the altitude of the units, for various trenches are suitable a different altitude, you can test in the editor with various trenches.

For example, to set an anti-tank gun in the anti-tank trench, it needs this setPosATL [getPosATL this select 0, getPosATL this select 1, 0.75]; in the initialization of the unit, where the 0.75 is the altitude.

Share this post


Link to post
Share on other sites
I created a trench template if anyones interested - each trench of the game filled in with units & appropriate weapons (squad trench, MG trenches, etc..)

I'd really appreciate if you could send it to me or post it here as an attachment.

Share this post


Link to post
Share on other sites

I have all the ground troops & vehicles working fairly well.

Now I want to get some aircraft flying so I can be attacked

and bombed from the air. Got the flak guns ready to fight them.

Anybody know how that can be done with the editor???

Share this post


Link to post
Share on other sites

Just place the aircraft and chose "flying" instead of "in formation" etc. in the unit options. This way they are in the air and don't need to start first. Then set normal waypoints to your position, etc.

Share this post


Link to post
Share on other sites

Hey everybody, I created a quick trench template for those who need it. Right now I only have the German trenches/foxholes filled in, but I'll post a full version with both armies soon.

Very basic, but it should give you a good idea how the trenches work, and might save you some time. :)

PS. I forgot to change the tanks fuel to 0 so it doesn't move - oops!

previewfqj.jpg

German Trench Template

http://www.filedropper.com/germantrenchtemplatepanovo

Edited by majoris

Share this post


Link to post
Share on other sites

majoris, your template contains a "mission.sqm" file only.

Where do you put this file? I see no .sqm files anywhere

in the game files...

Share this post


Link to post
Share on other sites
majoris, your template contains a "mission.sqm" file only.

Where do you put this file? I see no .sqm files anywhere

in the game files...

You have to put the folder in the .rar (German_Trench_Template.Panovo) in your My Docs/Iron Front/Missions folder :)

Share this post


Link to post
Share on other sites

Ok, thanks

A readme file for us editor newbies with

info like that is always appreciated....

New Question: In making SP, Co-op or MP editor missions, can they all be combined?

I have 1 player unit for SP & maybe other playable units as well. (tried this, works OK)

In Co-Op, do I put in multiple "playable units" with no player unit on 1 side?

In MP, do I put in "playable units" both sides with no player units?

Edited by FAdmiral
New Question

Share this post


Link to post
Share on other sites

There always is at least one player. For coop, you only have to add more playable units. If you add them on both faction sides, both can be played in multiplayer. Also, if you add more playable units for coop and play alone, you can jump to these units with the T button, so you can control them all by yourself.

Share this post


Link to post
Share on other sites
If you make a mission with trenches in the editor, the best way for the soldiers inside the trenches to act properly, is to write in the initialization of the commander of the trench group this:

{_x setUnitPos "UP"; doStop _x; _x allowFleeing 0; _x forceSpeed 0; _x setPosATL [getPosATL _x select 0, getPosATL _x select 1, 0.23];} foreach units this;

The getPosATL_x select 1, 0.23 is the altitude of the units, for various trenches are suitable a different altitude, you can test in the editor with various trenches.

For example, to set an anti-tank gun in the anti-tank trench, it needs this setPosATL [getPosATL this select 0, getPosATL this select 1, 0.75]; in the initialization of the unit, where the 0.75 is the altitude.

Thanks for sharing. Quite useful so far. I figured for lone AI heavy machine gunners, the following to be sufficient. It´s not grouped with other units and works quite well.

Mounted Weapons, machine gun "Maxim" (trench)

in single foxhole object. Positioning is a bit fiddly, but at last I figured the correct position to be the foxhole objects pivot point.

this setPos [getPos this select 0, getPos this select 1, 1.05]; dostop this

Also tried with the group commanders initialization field, but tend more now to use:

{_x setUnitPos "Middle"; doStop _x; _x allowFleeing 0; _x disableai "target";_x forceSpeed 0; _x setPosATL [getPosATL _x select 0, getPosATL _x select 1, 0.23];} foreach units this;

setUnitPos "Middle" more helps to use the aperture, thus providing more allround cover for trench/FH inhabitants, although limiting field of fire more to 90°.

According to Biki, disableai "target" looks like a good alternative to disableai "move", as I suspect disableai "move" prevents a unit from turning around on the spot, which causes the situation, that units can´t react to threats from the rear.

Biki quote: "The "TARGET" section of the AI is likely different than what you would think. Normally, when an AI group is standing still and sees an enemy, the group will break formation and start moving towards the enemy. If you disable the "TARGET" AI, then the AI units will stay where they are at. Even if you disable the "MOVE" AI, the units will still move out to attack the enemy, unless you disable the "TARGET" AI. Disabling both these AI sections is useful when placing units in defensive positions. This way, you can have them stay behind their cover, and not run out into the open."

http://community.bistudio.com/wiki/disableAI

ironfrontfoxhole1.jpg

ironfrontfoxhole2.jpg

ironfrontfoxhole3.jpg

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  

×