Coolinator 10 Posted November 21, 2014 i want to add an ambush scene in my mission, but i don't know how to do it :( How to put IED's on the road hidden, and how to create a basic infantry ambush?(that also works well when playing in dedicated server). Share this post Link to post Share on other sites
jshock 513 Posted November 21, 2014 Here is a 100% hidden IED: http://i.imgur.com/ZXMDY1t.jpg (116 kB) Share this post Link to post Share on other sites
Coolinator 10 Posted November 21, 2014 Here is a 100% hidden IED:http://i.imgur.com/ZXMDY1t.jpg (116 kB) when i put the code it says: "missing )"? Share this post Link to post Share on other sites
jshock 513 Posted November 21, 2014 Sorry try it minus the "bomb=": "M_Mo_82mm_AT_LG" createVehicle (getPos thisTrigger); ---------- Post added at 05:44 ---------- Previous post was at 04:07 ---------- Just some fun for the ambush group. In the trigger's onAct after the IED created vehicle: nul = [thisTrigger, 50] execVM "ambushGroup.sqf"; In the ambushGroup.sqf file: _area = (_this select 0); _distance = (_this select 1); _center = createCenter EAST; _rndConfig = ["OIA_InfTeam", "OIA_InfSquad", "OIA_InfTeam_AT"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _grp = [_pos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_rndConfig))] call BIS_fnc_spawnGroup; [_grp, (getPos _area)] call BIS_fnc_taskAttack; It will spawn a random group of a fireteam (4 men), squad (8, if I remember correctly), or an AT team (4 men), in a relative defined distance away from the trigger (exampled as 50m), in a random direction in relation to the trigger (ambush could come from any direction), they will then attack the trigger position (where the IED went off). *Untested Share this post Link to post Share on other sites
Coolinator 10 Posted November 21, 2014 (edited) [/color] Sorry try it minus the "bomb=": "M_Mo_82mm_AT_LG" createVehicle (getPos thisTrigger); ---------- Post added at 05:44 ---------- Previous post was at 04:07 ---------- Just some fun for the ambush group. In the trigger's onAct after the IED created vehicle: nul = [thisTrigger, 50] execVM "ambushGroup.sqf"; In the ambushGroup.sqf file: _area = (_this select 0); _distance = (_this select 1); _center = createCenter EAST; _rndConfig = ["OIA_InfTeam", "OIA_InfSquad", "OIA_InfTeam_AT"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _grp = [_pos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_rndConfig))] call BIS_fnc_spawnGroup; [_grp, (getPos _area)] call BIS_fnc_taskAttack; It will spawn a random group of a fireteam (4 men), squad (8, if I remember correctly), or an AT team (4 men), in a relative defined distance away from the trigger (exampled as 50m), in a random direction in relation to the trigger (ambush could come from any direction), they will then attack the trigger position (where the IED went off). *Untested Thanks!! i actually just found a tutorial on how to make ambush and ieds on youtube. Still thanks for your help, really appreciate it :) I will try ur method sounds so cool!!! by the way does this ambush works in dedicated server? I just tested it works!!! really cool!!! but i haven't tested it in dedicated server yet. Edited November 21, 2014 by Coolinator Share this post Link to post Share on other sites
jshock 513 Posted November 21, 2014 I will try ur method sounds so cool!!! by the way does this ambush works in dedicated server? There isn't a reason for it not too, unless I'm just too tired atm to see any possible issues with that :p. Share this post Link to post Share on other sites
cuel 25 Posted November 21, 2014 add "&& isServer" to the condition on the triggers or you will have a lot of bombs and a lot of ambush groups. Assuming that it's a MP mission since you mentioned dedicated. Share this post Link to post Share on other sites
Coolinator 10 Posted November 21, 2014 add "&& isServer" to the condition on the triggers or you will have a lot of bombs and a lot of ambush groups. Assuming that it's a MP mission since you mentioned dedicated. ooo thank you!! i didnt know about that!! Quick question, do i still need to add "&& isServer" for a trigger i made that grouped with a truck? For example When the truck goes into the trigger the mission will end. So do i still need to put "&& isServer" in the condition because i play my mission on dedicated server? or it doesn't really matter i can just use "this"? Share this post Link to post Share on other sites
cuel 25 Posted November 21, 2014 It matters mostly when you're creating stuff. Ending the mission has local effect, so no. Everyone should run that. An important thing to remember is that when you put down triggers in mission, they are in no sense "global" or synchronized on every machine. Every trigger will exist locally on every machine, and conditions can be true on one machine but no the other. For example using player in thisList Would only be true on the machine where the player object is inside the trigger. Share this post Link to post Share on other sites
Coolinator 10 Posted November 21, 2014 (edited) It matters mostly when you're creating stuff.Ending the mission has local effect, so no. Everyone should run that. An important thing to remember is that when you put down triggers in mission, they are in no sense "global" or synchronized on every machine. Every trigger will exist locally on every machine, and conditions can be true on one machine but no the other. For example using player in thisList Would only be true on the machine where the player object is inside the trigger. okay i misread sorry lol>_< , i actually get the idea what u just said lol okay thank you so much!! i really appreacite it :) Edited November 21, 2014 by Coolinator Share this post Link to post Share on other sites
jshock 513 Posted November 21, 2014 add "&& isServer" to the condition on the triggers or you will have a lot of bombs and a lot of ambush groups. Assuming that it's a MP mission since you mentioned dedicated. You know, I thought the same right after I went to bed :p. Share this post Link to post Share on other sites
jshock 513 Posted November 21, 2014 (edited) Easy to forget :) Yea I made that mistake with a mortar script that I made up for an operation for my old unit months back, started with ~400 objects on the map (editor placed), after that script ran there were more than 3000 objects (by the time it became unplayable), all of which were being created on each of the clients (which was 25+), it got ugly fast, lol. Edited November 21, 2014 by JShock Share this post Link to post Share on other sites
Coolinator 10 Posted November 22, 2014 Sorry try it minus the "bomb=": "M_Mo_82mm_AT_LG" createVehicle (getPos thisTrigger); ---------- Post added at 05:44 ---------- Previous post was at 04:07 ---------- Just some fun for the ambush group. In the trigger's onAct after the IED created vehicle: nul = [thisTrigger, 50] execVM "ambushGroup.sqf"; In the ambushGroup.sqf file: _area = (_this select 0); _distance = (_this select 1); _center = createCenter EAST; _rndConfig = ["OIA_InfTeam", "OIA_InfSquad", "OIA_InfTeam_AT"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _grp = [_pos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_rndConfig))] call BIS_fnc_spawnGroup; [_grp, (getPos _area)] call BIS_fnc_taskAttack; It will spawn a random group of a fireteam (4 men), squad (8, if I remember correctly), or an AT team (4 men), in a relative defined distance away from the trigger (exampled as 50m), in a random direction in relation to the trigger (ambush could come from any direction), they will then attack the trigger position (where the IED went off). *Untested Is there a way i can increase the number opfor units? i wanna use this as enemy reinforments :) Share this post Link to post Share on other sites
jshock 513 Posted November 22, 2014 Call line: nul = [thisTrigger, 50, 5] execVM "ambushGroup.sqf"; _area = (_this select 0); _distance = (_this select 1); _numGrps = (_this select 2); _center = createCenter EAST; for "_i" from 0 to (_numGrps) step 1 do { _rndConfig = ["OIA_InfTeam", "OIA_InfSquad", "OIA_InfTeam_AT"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _grp = [_pos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_rndConfig))] call BIS_fnc_spawnGroup; [_grp, (getPos _area)] call BIS_fnc_taskAttack; }; Third parameter in call line is now the number of groups you want to come in, it randomizes the group each time, and still randomizes the position they spawn each time (take it out of the for loop if you don't want that), then are tasked to attack the central position. Share this post Link to post Share on other sites
Coolinator 10 Posted November 22, 2014 Call line: nul = [thisTrigger, 50, 5] execVM "ambushGroup.sqf"; _area = (_this select 0); _distance = (_this select 1); _numGrps = (_this select 2); _center = createCenter EAST; for "_i" from 0 to (_numGrps) step 1 do { _rndConfig = ["OIA_InfTeam", "OIA_InfSquad", "OIA_InfTeam_AT"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _grp = [_pos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_rndConfig))] call BIS_fnc_spawnGroup; [_grp, (getPos _area)] call BIS_fnc_taskAttack; }; Third parameter in call line is now the number of groups you want to come in, it randomizes the group each time, and still randomizes the position they spawn each time (take it out of the for loop if you don't want that), then are tasked to attack the central position. Thank you so much Jshock!!!!! :) Share this post Link to post Share on other sites
Coolinator 10 Posted December 1, 2014 Call line: nul = [thisTrigger, 50, 5] execVM "ambushGroup.sqf"; _area = (_this select 0); _distance = (_this select 1); _numGrps = (_this select 2); _center = createCenter EAST; for "_i" from 0 to (_numGrps) step 1 do { _rndConfig = ["OIA_InfTeam", "OIA_InfSquad", "OIA_InfTeam_AT"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _grp = [_pos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_rndConfig))] call BIS_fnc_spawnGroup; [_grp, (getPos _area)] call BIS_fnc_taskAttack; }; Third parameter in call line is now the number of groups you want to come in, it randomizes the group each time, and still randomizes the position they spawn each time (take it out of the for loop if you don't want that), then are tasked to attack the central position. Hey Jshock, I'm loving your script :) it's really fun using it as enemy reinforcements and ambush :) but how do I add vehicles? Like heli,tanks, ifrits? Not on random though, I don't want to spawn 3 Helis, 5 tanks at same time,you know what I mean? I just want to spawn 1 for each type of vehicle? Or at least can control how many to spawn like a parameter? Share this post Link to post Share on other sites
jshock 513 Posted December 1, 2014 Hey Jshock, I'm loving your script :) it's really fun using it as enemy reinforcements and ambush :) but how do I add vehicles? Like heli,tanks, ifrits? Not on random though, I don't want to spawn 3 Helis, 5 tanks at same time,you know what I mean? I just want to spawn 1 for each type of vehicle? Or at least can control how many to spawn like a parameter? Well, do you want to spawn each vehicle in a group on the same position, or just spawn "x" number of defined vehicles in random positions around the center position? Share this post Link to post Share on other sites
Coolinator 10 Posted December 1, 2014 (edited) Well, do you want to spawn each vehicle in a group on the same position, or just spawn "x" number of defined vehicles in random positions around the center position? kinda of both lol :) but either way is fine :) Edited December 1, 2014 by Coolinator Share this post Link to post Share on other sites
jshock 513 Posted December 1, 2014 Three more parameters added, the first being # of tanks, second being # of helicopters, third # of ifrits: nul = [thisTrigger, 50, 5, 2, 2, 2] execVM "ambushGroup.sqf"; The ifrits are randomized to give you a chance of both HMG and GMG. _area = (_this select 0); _distance = (_this select 1); _numGrps = (_this select 2); _numTanks = (_this select 3); _numHelis = (_this select 4); _numIfrits = (_this select 5); _center = createCenter EAST; if (_numGrps > 0) then { for "_i" from 0 to (_numGrps) step 1 do { _rndConfig = ["OIA_InfTeam", "OIA_InfSquad", "OIA_InfTeam_AT"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _grp = [_pos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_rndConfig))] call BIS_fnc_spawnGroup; [_grp, (getPos _area)] call BIS_fnc_taskAttack; }; }; if (_numTanks > 0) then { for "_a" from 0 to (_numTanks) step 1 do { _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _veh = [_pos,0,"O_MBT_02_cannon_F",_center] call BIS_fnc_spawnVehicle; [_veh, (getPos _area)] call BIS_fnc_taskAttack; }; }; if (_numHelis > 0) then { for "_b" from 0 to (_numHelis) step 1 do { _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _veh = [_pos,0,"O_Heli_Attack_02_black_F",_center] call BIS_fnc_spawnVehicle; [_veh, (getPos _area)] call BIS_fnc_taskAttack; }; }; if (_numIfrits > 0) then { for "_c" from 0 to (_numIfrits) step 1 do { _typeVeh = ["O_MRAP_02_hmg_F","O_MRAP_02_gmg_F"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _veh = [_pos,0,_typeVeh,_center] call BIS_fnc_spawnVehicle; [_veh, (getPos _area)] call BIS_fnc_taskAttack; }; }; Share this post Link to post Share on other sites
Coolinator 10 Posted December 1, 2014 Three more parameters added, the first being # of tanks, second being # of helicopters, third # of ifrits: nul = [thisTrigger, 50, 5, 2, 2, 2] execVM "ambushGroup.sqf"; The ifrits are randomized to give you a chance of both HMG and GMG. _area = (_this select 0); _distance = (_this select 1); _numGrps = (_this select 2); _numTanks = (_this select 3); _numHelis = (_this select 4); _numIfrits = (_this select 5); _center = createCenter EAST; if (_numGrps > 0) then { for "_i" from 0 to (_numGrps) step 1 do { _rndConfig = ["OIA_InfTeam", "OIA_InfSquad", "OIA_InfTeam_AT"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _grp = [_pos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_rndConfig))] call BIS_fnc_spawnGroup; [_grp, (getPos _area)] call BIS_fnc_taskAttack; }; }; if (_numTanks > 0) then { for "_a" from 0 to (_numTanks) step 1 do { _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _veh = [_pos,0,"O_MBT_02_cannon_F",_center] call BIS_fnc_spawnVehicle; [_veh, (getPos _area)] call BIS_fnc_taskAttack; }; }; if (_numHelis > 0) then { for "_b" from 0 to (_numHelis) step 1 do { _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _veh = [_pos,0,"O_Heli_Attack_02_black_F",_center] call BIS_fnc_spawnVehicle; [_veh, (getPos _area)] call BIS_fnc_taskAttack; }; }; if (_numIfrits > 0) then { for "_c" from 0 to (_numIfrits) step 1 do { _typeVeh = ["O_MRAP_02_hmg_F","O_MRAP_02_gmg_F"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _veh = [_pos,0,_typeVeh,_center] call BIS_fnc_spawnVehicle; [_veh, (getPos _area)] call BIS_fnc_taskAttack; }; }; Thank you so much man!!!!!!! :) I really appreciate it!!! :) ---------- Post added at 03:15 ---------- Previous post was at 03:03 ---------- By the way quick question, What do i put in parameter, if u want no helis to spawn? do i put 0, or do leave it blank like nothing at all? So if i dont want heli to spawn i put this? nul = [thisTrigger, 50, 5, 0, 2, 2] execVM "ambushGroup.sqf";[ or nul = [thisTrigger, 50, 5, 2, 2] execVM "ambushGroup.sqf";[ Share this post Link to post Share on other sites
jshock 513 Posted December 1, 2014 By the way quick question, What do i put in parameter, if u want no helis to spawn? do i put 0, or do leave it blank like nothing at all? Yep, just input 0, that's what the if statements are for. Share this post Link to post Share on other sites
Coolinator 10 Posted December 1, 2014 Yep, just input 0, that's what the if statements are for. ahh kk, thank you so much :)!!! Share this post Link to post Share on other sites
jshock 513 Posted December 1, 2014 So if i dont want heli to spawn i put this? nul = [thisTrigger, 50, 5, 0, 2, 2] execVM "ambushGroup.sqf";[ or nul = [thisTrigger, 50, 5, 2, 2] execVM "ambushGroup.sqf";[ And just to help you understand why the above won't work, as soon as you remove an argument from the script call the indicies of the arguments (see below) will be off by one, and leave the last argument undefined, therefore, leaving you with a broken script. //for example, taking out the "number of tanks" argument from the script call //call line: nul = [thisTrigger, 50, 5, 2, 2] execVM "ambushGroup.sqf"; _area = (_this select 0); // = thisTrigger _distance = (_this select 1); // = 50 _numGrps = (_this select 2); // = 5 _numTanks = (_this select 3); // = 2 _numHelis = (_this select 4); // = 2 _numIfrits = (_this select 5); //will be undefined Reading through the BIKI page on ARRAYS, may help you understand this concept. Share this post Link to post Share on other sites
Coolinator 10 Posted December 1, 2014 (edited) And just to help you understand why the above won't work, as soon as you remove an argument from the script call the indicies of the arguments (see below) will be off by one, and leave the last argument undefined, therefore, leaving you with a broken script. //for example, taking out the "number of tanks" argument from the script call //call line: nul = [thisTrigger, 50, 5, 2, 2] execVM "ambushGroup.sqf"; _area = (_this select 0); // = thisTrigger _distance = (_this select 1); // = 50 _numGrps = (_this select 2); // = 5 _numTanks = (_this select 3); // = 2 _numHelis = (_this select 4); // = 2 _numIfrits = (_this select 5); //will be undefined Reading through the BIKI page on ARRAYS, may help you understand this concept. ahh okay, i kinda get the concept now. By the way i want to add apc i tried doing this: _area = (_this select 0); _distance = (_this select 1); _numGrps = (_this select 2); _numTanks = (_this select 3); _numHelis = (_this select 4); _numIfrits = (_this select 5); _numApcs = (_this select 6); _center = createCenter EAST; if (_numGrps > 0) then { for "_i" from 0 to (_numGrps) step 1 do { _rndConfig = ["OIA_InfTeam", "OIA_InfSquad", "OIA_InfTeam_AT"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _grp = [_pos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_rndConfig))] call BIS_fnc_spawnGroup; [_grp, (getPos _area)] call BIS_fnc_taskAttack; }; }; if (_numTanks > 0) then { for "_a" from 0 to (_numTanks) step 1 do { _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _veh = [_pos,0,"O_MBT_02_cannon_F",_center] call BIS_fnc_spawnVehicle; [_veh, (getPos _area)] call BIS_fnc_taskAttack; }; }; if (_numHelis > 0) then { for "_b" from 0 to (_numHelis) step 1 do { _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _veh = [_pos,0,"O_Heli_Attack_02_black_F",_center] call BIS_fnc_spawnVehicle; [_veh, (getPos _area)] call BIS_fnc_taskAttack; }; }; if (_numIfrits > 0) then { for "_c" from 0 to (_numIfrits) step 1 do { _typeVeh = ["O_MRAP_02_hmg_F","O_MRAP_02_gmg_F"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _veh = [_pos,0,_typeVeh,_center] call BIS_fnc_spawnVehicle; [_veh, (getPos _area)] call BIS_fnc_taskAttack; }; }; if (_numApcs > 0) then { for "_d" from 0 to (_numApcs) step 1 do { _typeVeh = ["O_APC_Tracked_02_cannon_F","O_APC_Wheeled_02_rcws_F"] call BIS_fnc_selectRandom; _pos = [(getPos _area), _distance, random(359)] call BIS_fnc_relPos; _veh = [_pos,0,_typeVeh,_center] call BIS_fnc_spawnVehicle; [_veh, (getPos _area)] call BIS_fnc_taskAttack; }; }; did i do it right? then parameter would be like this: nul = [thisTrigger, 50, 5, 2, 2, 2, 2] execVM "ambushGroup.sqf"; Edited December 1, 2014 by Coolinator Share this post Link to post Share on other sites