Jump to content
Sign in to follow this  
copper2010

Trouble with Triggers (mutiplayer mission troubles and questions)

Recommended Posts

Hello there fellow mission creators!

My current project is something similar to missions like Invade and Annex and Insurgency, players make there way through the island capturing enemy AI sectors, although it has quite a few twists to make it unique. So far, everything has been going pretty smoothly...with the exception of AI spawning triggers. To save FPS enemy AI doesn't spawn in sectors until players get within a few kilometers of the sector. I have run into a few problems with this, however.

1) The script is set up to spawn 4 enemy fireteams in the town, plus one enemy MHQ the players have to destroy to stop the enemies from getting reinforcements. This works fine with one player, however when mutiple players enter the area, the script will run for every player, meaning instead of 4 enemy fireteams and 1 MHQ, a group of 4 players will have to deal with 64 enemies and 4 MHQs. This is bad for obvious reasons (although it could be an interesting concept for scaling difficulty in future projects). What is a way (if there is any) around this?

Trigger Properties

Name- trge
Activation- BLUFOR Present Repeating
Condition- this
On Act.- _x = execVM "defenseeasy.sqf";
On DeAct. _x = execVM "cleanup.sqf";

defenseeasy.sqf (if any of you coding geniuses out there are also willing to make this script better somehow, that would be much appreciated ;) )

//This is the script that spawns the initial defenses, I spawn the group leader at the marker GrpM that will hopefully eventully use the nearest gamelogic instead of the named one, question on that later. I also use Urban Patrol Script to have dynamic patrols

_markerstr = createMarker ["Alpha", position gamelogiceasy]; //Marker that UPS uses
_markerstr setMarkerShape "RECTANGLE";
"Alpha" setMarkerBrush "DIAGGRID";
"Alpha" setMarkerColor "ColorBlack";
"Alpha" setMarkerSize [250, 250];

_markergrp = createMarker ["GrpM", position gamelogiceasy]; //Marker that enemy groups spawn around
_markergrp setMarkerShape "ICON";
_markergrp setMarkerType "hd_start";

_markergrp = createMarker ["spawn1", position gamelogiceasy]; //Marker that reinforcements spawn in on
_markergrp setMarkerShape "ICON";
_markergrp setMarkerType "hd_ambush";

sleep 0.1;

minRadius = 500;
maxRadius = 500;
"spawn1" setMarkerPos [
    (getMarkerPos "GrpM" select 0) + ((minRadius + (maxRadius - minRadius))*(1 - random 2)),
    (getMarkerPos "GrpM" select 1) + ((minRadius + (maxRadius - minRadius))*(1 - random 2))
]; 

sleep 0.1;

Grp1 = Creategroup EAST;
_Leader="O_G_Soldier_TL_F" createUnit [getMarkerPos "GrpM", Grp1, "LGrp1=this; nul=[this,'Alpha'] execVM 'UPS.sqf'; this addAction ['Search for Intel', 'script5.sqf', nil, 6, True, True, '', '(_target distance _this) < 1']", 0.5, "Sergeant "];

minRadius = 0;
maxRadius = 250;
LGrp1 setpos [
    (getMarkerPos "GrpM" select 0) + ((minRadius + (maxRadius - minRadius))*(1 - random 2)),
    (getMarkerPos "GrpM" select 1) + ((minRadius + (maxRadius - minRadius))*(1 - random 2))
]; 

_Unit2="O_G_Soldier_AR_F" createUnit [getPos LGrp1, Grp1, "", 0.5, "Corporal"];
_Unit3="O_G_Soldier_GL_F" createUnit [getPos LGrp1, Grp1, "", 0.5, "Private"];
_Unit4="O_G_Soldier_F" createUnit [getPos LGrp1, Grp1, "", 0.5, "Private"];

sleep 0.1;

Grp2 = Creategroup EAST;
_Leader="O_G_Soldier_TL_F" createUnit [getMarkerPos "GrpM", Grp2, "LGrp2=this; nul=[this,'Alpha'] execVM 'UPS.sqf'; this addAction ['Search for Intel', 'script5.sqf', nil, 6, True, True, '', '(_target distance _this) < 1']", 0.5, "Sergeant "];

minRadius = 0;
maxRadius = 250;
LGrp2 setpos [
    (getMarkerPos "GrpM" select 0) + ((minRadius + (maxRadius - minRadius))*(1 - random 2)),
    (getMarkerPos "GrpM" select 1) + ((minRadius + (maxRadius - minRadius))*(1 - random 2))
]; 

_Unit2="O_G_Soldier_AR_F" createUnit [getPos LGrp2, Grp2, "", 0.5, "Corporal"];
_Unit3="O_G_Soldier_GL_F" createUnit [getPos LGrp2, Grp2, "", 0.5, "Private"];
_Unit4="O_G_Soldier_F" createUnit [getPos LGrp2, Grp2, "", 0.5, "Private"];

sleep 0.1;

Grp3 = Creategroup EAST;
_Leader="O_G_Soldier_TL_F" createUnit [getMarkerPos "GrpM", Grp3, "LGrp3=this; nul=[this,'Alpha'] execVM 'UPS.sqf'; this addAction ['Search for Intel', 'script5.sqf', nil, 6, True, True, '', '(_target distance _this) < 1']", 0.5, "Sergeant "];

minRadius = 0;
maxRadius = 250;
LGrp3 setpos [
    (getMarkerPos "GrpM" select 0) + ((minRadius + (maxRadius - minRadius))*(1 - random 2)),
    (getMarkerPos "GrpM" select 1) + ((minRadius + (maxRadius - minRadius))*(1 - random 2))
]; 

_Unit2="O_G_Soldier_AR_F" createUnit [getPos LGrp3, Grp3, "", 0.5, "Corporal"];
_Unit3="O_G_Soldier_GL_F" createUnit [getPos LGrp3, Grp3, "", 0.5, "Private"];
_Unit4="O_G_Soldier_F" createUnit [getPos LGrp3, Grp3, "", 0.5, "Private"];

sleep 0.1;

Grp4 = Creategroup EAST;
_Leader="O_G_Soldier_TL_F" createUnit [getMarkerPos "GrpM", Grp4, "LGrp4=this; nul=[this,'Alpha'] execVM 'UPS.sqf'; this addAction ['Search for Intel', 'script5.sqf', nil, 6, True, True, '', '(_target distance _this) < 1']", 0.5, "Sergeant "];

minRadius = 0;
maxRadius = 250;
LGrp4 setpos [
    (getMarkerPos "GrpM" select 0) + ((minRadius + (maxRadius - minRadius))*(1 - random 2)),
    (getMarkerPos "GrpM" select 1) + ((minRadius + (maxRadius - minRadius))*(1 - random 2))
]; 

_Unit2="O_G_Soldier_AR_F" createUnit [getPos LGrp4, Grp4, "", 0.5, "Corporal"];
_Unit3="O_G_Soldier_GL_F" createUnit [getPos LGrp4, Grp4, "", 0.5, "Private"];
_Unit4="O_G_Soldier_F" createUnit [getPos LGrp4, Grp4, "", 0.5, "Private"];

sleep 0.1;

Grp5 = Creategroup EAST;
_Leader="O_G_officer_F" createUnit [getMarkerPos "GrpM", Grp5, "LGrp5=this;", 0.5, "Major"];

minRadius = 0;
maxRadius = 250;
LGrp5 setpos [
    (getMarkerPos "GrpM" select 0) + ((minRadius + (maxRadius - minRadius))*(1 - random 2)),
    (getMarkerPos "GrpM" select 1) + ((minRadius + (maxRadius - minRadius))*(1 - random 2))
]; 

_Unit4="O_G_Soldier_F" createUnit [getPos LGrp5, Grp5, "", 0.5, "Corporal"];

target1 = "I_Truck_02_covered_F" createVehicle getPos LGrp5;

dtrg = createTrigger ["EmptyDetector", getMarkerPos "Alpha"];
dtrg setTriggerArea [2500, 2500, 0, false];
dtrg setTriggerActivation ["WEST", "EAST D", false];
dtrg setTriggerStatements ["this", "_script = execVM 'reinforcementssmall.sqf'; 
hint 'Attention all units, the enemy has spotted you. They will now call in reinforcements until you destory thier MHQ!';", ""];
dtrg setSoundEffect ["Alarm_Independent", "", "", ""];

cleanup.sqf

//This is the script that cleans up enemies and markers after BLUFOR has left the area, the gun1 and gun2 are static defenses that only appear on harder sectors

{deleteVehicle _x;}forEach crew gun1;
{deleteVehicle _x;}forEach crew gun2;


trg = createTrigger ["EmptyDetector", getMarkerPos "GrpM"];
trg setTriggerArea [500, 500, 0, false];
trg setTriggerActivation ["EAST", "PRESENT", true];
trg setTriggerStatements ["this", "{deleteVehicle _x} forEach list trg", ""];

trg2 = createTrigger ["EmptyDetector", getMarkerPos "GrpM"];
trg2 setTriggerArea [500, 500, 0, false];
trg2 setTriggerActivation ["CIV", "PRESENT", true];
trg2 setTriggerStatements ["this", "{deleteVehicle _x} forEach list trg2", ""];

deleteVehicle target1;

terminate _script;

deleteMarker "Alpha";

deleteMarker "GrpM";

deleteMarker "spawn1";

deleteVehicle dtrg;

sleep 5;

deleteVehicle trg;

deleteVehicle trg2;

2) You might notice that I currently spawn all the markers on a game logic named "gamelogiceasy". This is intended to only be temporary, and I intend to create multiple gamelogics and place them in every sector, then when the player triggers the AI spawner, it gets the nearest gamelogic and spawns the markers necessary to make the AI patrol (among other things) right on top of it. I've tried messing around with getNearest but haven't had any luck with it, can anyone help me out here?

3) Last one I swear! Even after the sector has been captured by BLUFOR, the defenseeasy script with still run whenever players enter the area. I can't simply delete the trigger when the area is captured since it is it's deactivation that runs the cleanup.sqf script. Be aware I am using the Sector module that BI provides (I like the little icons in the corner and the fact that it isn't 100% based on if all enemies are dead). I also don't want to simply delete the enemy AI once the sector is captured since oftentimes BLUFOR will still be fighting OPFOR when this happens. Is there any way around this? Also if it can be avoided I would love to avoid giving all the spawn triggers individual names.

Thanks to anyone who tries to help me out with this! Your assistance is appreciated!

Share this post


Link to post
Share on other sites

Have you tried this to stop multiple spawns

cond this and Isserver

Share this post


Link to post
Share on other sites
Have you tried this to stop multiple spawns

cond this and Isserver

Not yet, I'll try it and see if that works when I test the mission tonight with my friend.

Share this post


Link to post
Share on other sites

Not to take away from your scripting fun.

But for these I would consider using EOS (script designed to do what you want, configured somewhat by your preferences and caches the units after AO is player empty to save resources)or bis_fn_spawngroup.

http://forums.bistudio.com/showthread.php?153100-Enemy-occupation-system-%28eos%29

https://community.bistudio.com/wiki/BIS_fnc_spawnGroup

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  

×