Jump to content

Photo
- - - - -

How to use call compile format?


  • Please log in to reply
15 replies to this topic
Thread Starter
jakkob4682
jakkob4682

    Sergeant

  • Members
  • 188 posts

#1

Posted 05 February 2013 - 15:47

I'm trying to wrap my head around creating dynamic objects using call compile format, more specifically I'm trying to create my ied setup in a small town.
in triggerStatements i have
for [{i=0},{i=i<3},{i=i+1}] do {iedPos = [getMarkerPos "TC1",random 250,random 360] call BIS_fnc_relPos;iedBPos = getPos(nearestBuilding iedPos);call compile format ["ied%1 = 'BAF_IED_V1' createVehicle iedBPos"];iedList = nearestObjects [getMarkerPos "TC1",["LAND_IED_V1_PMC"],1000];player sideChat format ["%1",count iedList]};

the debug returns 0, so how can I create three ied's w/o having to do ied1-ied3 in a trigger?

blackmamb
blackmamb

    Master Sergeant

  • Members
  • 640 posts

#2

Posted 05 February 2013 - 19:30

The syntax for format seems messed up. Try and put that on separate lines to see it better. Any reason you don't use the same calssname for what you dreate and what youtry to find?

galzohar
galzohar

    First Lieutenant

  • Members
  • 5575 posts

#3

Posted 05 February 2013 - 20:23

Try not to use call compile format as there is almost always a better way to get things done. For example:

iedList = [];
for [{_i=0}, {_i < 3}, {_i = _i + 1}] do
{
	_iedPos = [getMarkerPos "TC1",250 * (sqrt (random 1)),random 360];
	// This will give area to have equal chance for IED.
	// Your randomization makes it so areas around the center are much more likely to have an IED.

	_iedBPos = getPos (nearestBuilding _iedPos);
	_ied = createVehicle ["BAF_IED_V1", _iedBPos, [], 0, "NONE"];
	iedList set [_i, _ied]; // Create array with IEDs we have created
};

// Now if you already placed some PMC IEDs and want to make a list of them as well...
iedListPMC = nearestObjects [getMarkerPos "TC1", ["LAND_IED_V1_PMC"],1000];

You don't mess with the Zohar!
YouTube channel: http://www.youtube.com/user/galzohar
Steam: http://steamcommunity.com/id/galzohar
ArmA Israel: http://www.arma-il.info
Check out and support upcoming Ground Branch: http://www.groundbranch.com/

ceeeb
ceeeb

    Staff Sergeant

  • Members
  • 392 posts

#4

Posted 05 February 2013 - 21:04

Example syntax:

for "_i" from 1 to 3 do
{
call compile format ["ied%1 = 'BAF_IED_V1' createVehicle iedBPos", _i];
};


Thread Starter
jakkob4682
jakkob4682

    Sergeant

  • Members
  • 188 posts

#5

Posted 05 February 2013 - 22:22

@BlackMamb - As far as I can tell the actual class name is "LAND_IED_V1_PMC" when I use the empty IED's in the editor and use typeOf it returns that.
@Galv - I like that snippet, but I'm trying not to have to create a seperate script for it, although I might have to anyways because I'm using the createTrigger from CBA to script the explosions
@Ceeeb - Thats exactly what I was looking for thank you.

Thread Starter
jakkob4682
jakkob4682

    Sergeant

  • Members
  • 188 posts

#6

Posted 06 February 2013 - 08:33

ok so another question.... how then would I create a trigger on each of those ied's in a script?

galzohar
galzohar

    First Lieutenant

  • Members
  • 5575 posts

#7

Posted 06 February 2013 - 11:02

https://community.bi...i/createTrigger

After creating, use the "See Also" section for how to set the trigger's parameters.

Keep in mind the trigger is only created on the machine that runs the command and its condition is only checked on said machine, unlike triggers placed in the editor. This can actually make certain things easier, though, as for example in the case of an IED only the server needs to decide if/when to detonate it.
You don't mess with the Zohar!
YouTube channel: http://www.youtube.com/user/galzohar
Steam: http://steamcommunity.com/id/galzohar
ArmA Israel: http://www.arma-il.info
Check out and support upcoming Ground Branch: http://www.groundbranch.com/

Thread Starter
jakkob4682
jakkob4682

    Sergeant

  • Members
  • 188 posts

#8

Posted 06 February 2013 - 13:50

I know how to create a generic trigger in a script the question was more about how to I create a trigger for each of the ied's created in the original for-from loop? i.e. what variable name do I use to represent each ied?

---------- Post added at 13:50 ---------- Previous post was at 13:42 ----------

The concept of this script is multi-layered, and I'm playing around with different idea's, but at the moment I'm trying to figure out how to:
Create dynamic IED's(I've tried reezo's module and it doesn't function 100% of the time, sometimes it doesn't work it all)
Create a trigger on those IED's(west present only activation)
Spawn a group at the nearest building of the ied location and have them ambush.
More to come... as I add more idea's.

Only wish I was a well versed scripter :(

cuel
cuel

    Sergeant Major

  • Members
  • 1557 posts

#9

Posted 06 February 2013 - 15:06

I've never had to use call compile format to be honest. There are many other solutions.


for "_i" from 0 to 2 do
{
_iedpos = [getMarkerPos "TC1",250 * (sqrt (random 1)),random 360] call BIS_fnc_relPos;
_ied = createVehicle ["LAND_IED_V1_PMC",_iedpos, [], 0, "NONE"] ;
_trig = ([getPosATL _ied, "AREA:", [5, 5, 0, false], "ACT:", ["WEST", "PRESENT", true],"STATE:",["this","deleteVehicle (thisTrigger getVariable ['ied',objNull]); createVehicle ['Sh_125_HE',getPosATL thisTrigger, [], 0, 'NONE']",""]] call CBA_fnc_createTrigger) select 0;
_trig setVariable ["ied",_ied];
_mrk = createMarker[format ["ied_%1",random 1000],_iedpos];
_mrk setMarkerShape "ICON";
_mrk setMarkerType "DOT";
};


You're going to have to work on the nearestBuilding since it requires an object but that's a start.

Edited by cuel, 06 February 2013 - 15:12.


Thread Starter
jakkob4682
jakkob4682

    Sergeant

  • Members
  • 188 posts

#10

Posted 06 February 2013 - 15:32

thank you so much, going to give it a test and see what happens

Thread Starter
jakkob4682
jakkob4682

    Sergeant

  • Members
  • 188 posts

#11

Posted 07 February 2013 - 19:24

Cuel I'm using you're little snippett and it works fine, but how would I go about spawning a group nearby the ied after its detonated? As for the nearestBuilding question couldn't I just use nearestBuilding _ied? And thank you for the help, I'm trying to learn by doing, but the extent of what I can learn is limited to my understanding lol.

cuel
cuel

    Sergeant Major

  • Members
  • 1557 posts

#12

Posted 07 February 2013 - 20:52

I'm sure you can find a lot of examples on how to spawn groups :). A lot of people prefer using BIS_fnc_spawnGroup. You need the functions module placed.
Indeed you could just use the nearestBuilding on the ied object. However you won't know if it's an enterable house and you can't place it 'inside' the house in a buildingPos without some more code. I also don't see the appeal of a house blowing up as soon as you get close to it ;)

Thread Starter
jakkob4682
jakkob4682

    Sergeant

  • Members
  • 188 posts

#13

Posted 07 February 2013 - 21:00

It's just to add suspense to a mission I'm working on lol, and possibly some frustration with rng. Thought I saw somewhere a function to find the nearest enterable building will have to do some more looking into it. Originally I was going to make a secondary explosion nearby the original, so that when the support group/unit gets within range it detonates(IRA style bombing), and then spawn the group nearby to do the ambush. Might have to give up on spawning the group using nearestBuilding.

I know how to spawn a group, but how would I reference the trigger that activated to spawn the group?

cuel
cuel

    Sergeant Major

  • Members
  • 1557 posts

#14

Posted 07 February 2013 - 21:06

You could just execute a script in the statement of the trigger and pass the trigger.


for "_i" from 0 to 2 do
{
_iedpos = [getMarkerPos "TC1",250 * (sqrt (random 1)),random 360] call BIS_fnc_relPos;
_ied = createVehicle ["LAND_IED_V1_PMC",_iedpos, [], 0, "NONE"] ;
_trig = ([getPosATL _ied, "AREA:", [5, 5, 0, false], "ACT:", ["WEST", "PRESENT", true],"STATE:",["this","deleteVehicle (thisTrigger getVariable ['ied',objNull]); createVehicle ['Sh_125_HE',getPosATL thisTrigger, [], 0, 'NONE']; 0 = [thisTrigger] execVM 'spawnGroup.sqf';",""]] call CBA_fnc_createTrigger) select 0;
_trig setVariable ["ied",_ied];
_mrk = createMarker[format ["ied_%1",random 1000],_iedpos];
_mrk setMarkerShape "ICON";
_mrk setMarkerType "DOT";
};


//spawnGroup.sqf
_pos = getPosATL (_this select 0);
//spaw some groups


Thread Starter
jakkob4682
jakkob4682

    Sergeant

  • Members
  • 188 posts

#15

Posted 07 February 2013 - 21:07

/facepalm - such an easy solution thanks again cuel

Thread Starter
jakkob4682
jakkob4682

    Sergeant

  • Members
  • 188 posts

#16

Posted 11 February 2013 - 05:28

So new problem, I can get the function to work properly with a loop(meaning that the positions update when used with a sleep command), however if the unit remain in the same area the function continues to fire. So could I just use a for "_i" from 0 to 1 command when the script executes to call the function? i.e. if (condition) then {for-from}