Jump to content
Sign in to follow this  
ShinShin

How to create a marker when a trigger was activated?

Recommended Posts

Heyy!

I've this Script Idea...

But, I'm Not Sure how to Go about Starting it off. :confused: :banghead:

Any Pointers to Set me on the Right track would be Very Nice.

( Already made an Attempt... Trashed it Now :pistols: :dead: )

So...

I Want to use a trigger Ingame to Execute a Script, Which will in return... Create a Marker with (Name, Shape, Type, Color, & Size) anywhere within the triggers Area (Random Pos Within Say... 400M).

With this Newly Created marker at it's Random new Position. Another Script will Be used & Will Call for the Position of this Marker & at this Markers Location... Will Create a Crate/Ammo Box with a Designated Selection of Gear/Equipment/Ammunition & Weapons in it.

Please, Please, Please ...Help me Start this or Give me an Idea atleast of how It Should be.

Thanks in Return for your Effort to Help :)

Edited by Foxhound
Please make descriptive topic titles!

Share this post


Link to post
Share on other sites

You've got everything you need to make the script already. :) You just need to use the right commands, which you can find in the COMREF.

So you know you'll need a trigger. You'll want to look up how to create a marker and set it's properties. Then you'll want to look up how to create an ammo box (you'll need the classname of the ammo box to create it in a script) and add weapons to it.

There's a few more commands you'll need to look up but it's all possible. Like you'll want to set the marker color for your marker, so you'd check the COMREF for something similar to that.

Now that you know where to find the commands give it another shot and see if you can't get a better result. :)

Share this post


Link to post
Share on other sites

Okay, Thanks for the Reference :) :thumbsup:

Now... Here's What i've Sofar for the Creation of the Marker & What not.

I took Abit of a Different Route from What I'd wanted. But You'd Get the Idea... I Hope.

But i'm Still looking to get the Same effect...

e.g. Marker Spawns at a Random Position Within the Triggers 400m Size.

Scripts...

CreateTrigger.sqf

[spoiler]//CALL || nul = execVM "Kays_Scripts\CreateTrigger.sqf";


_Pos = position _myLocation;

//	Create City Center	//
_myLocation = createLocation ["NameCity", [4129.1313,16.812166,4156.957], 50, 50];
_myLocation setText "Zargabad City";
Sleep 0.5

//	Create Trigger	//
_trigger = createTrigger ["EmptyDetector", position _Pos];
_trigger setTriggerArea [400, 400, 0, false];
_trigger setTriggerActivation ["NONE", "PRESENT", false];
_trigger setTriggerStatements ["true", "'nul = execVM "Kays_Scripts\tCreateMarker.sqf";'", ""];

hint "CreateTrigger.sqf Loaded... Done!";
Sleep 1.0;[/spoiler]

tCreateMarker.sqf

[spoiler]
_myLocation = _this Select 0;

//[b][color="#FF0000"][size=3]EDIT: My Bad... this Isn't an [/size][/color][size=4][Array][/size][color="#FF0000"][size=3] BUT... I DID Have one here Before I Changed the Code around.[/size][/color][/b] // <--Disregard this Line Please...
private ["_Options","_gPos", "_sPos", "_gMarker"];

_Options = _this select _myLocation;

_gPos = getPos _Options;
_sPos = getPos _Options;
_gPos = [ _gPos, 0, 15, 10, 0, 50 * (pi / 180), 0, [], [_sPos]] call BIS_fnc_findSafePos;
_gMarker = createMarker [format ["MarkerPos", random 400], _sPos];
_gMarker setMarkerType "DOT";
_gMarker setMarkerColor "ColorOrange";
_gMarker setMarkerSize [0.5, 0.5];

hint "tCreateMarker.sqf Loaded... Done!";
Sleep 1.0;[/spoiler]

Thanks in Return for Helping :)

Correct Me Please... as Ive tried Multiple Solutions and Still Error.

Edited by ShinShin

Share this post


Link to post
Share on other sites

A few comments in red:

Don't need spoiler tags, CODE is enough.

//CALL || nul = execVM "Kays_Scripts\CreateTrigger.sqf";

[color="#FF0000"]// You set this before you declare _myLocation so you're not getting the value you expect.[/color]
_Pos = position _myLocation;

[color="#FF0000"]// Why do you need this at all?  The coords are more than enough.  You're also using the wrong type of coords.  Those are 3D editor coords, not the 2D one.  The whole location thing isn't needed for this.[/color]
//	Create City Center	//
_myLocation = createLocation ["NameCity", [4129.1313,16.812166,4156.957], 50, 50];
_myLocation setText "Zargabad City";
Sleep 0.5  [color="#FF0000"]// missing a ; here[/color]

//	Create Trigger	//
_trigger = createTrigger ["EmptyDetector", position _Pos];  [color="#FF0000"]// _pos is already a position, so you don't need "position" here.[/color]
_trigger setTriggerArea [400, 400, 0, false];
_trigger setTriggerActivation ["NONE", "PRESENT", false];
_trigger setTriggerStatements ["true", "'nul = execVM "Kays_Scripts\tCreateMarker.sqf";'", ""];

[color="#FF0000"]// Don't really need to run the create marker from the trigger... in fact you don't really need the trigger at all.
// If you had preplaced the trigger it would be OK to refer to it, but creating a trigger in order to simply
// find a spot 400m from it doesn't make sense. :)  Just use distance from your coords.[/color]

hint "CreateTrigger.sqf Loaded... Done!";
Sleep 1.0;

[color="#FF0000"]// You don't send any arguments to this script, so what is this checking?[/color]
_myLocation = _this Select 0;

private ["_Options","_gPos", "_sPos", "_gMarker"];

[color="#FF0000"]// Erm, what?[/color]
_Options = _this select _myLocation;

_gPos = getPos _Options;
_sPos = getPos _Options;
[color="#FF0000"]// BIS_fnc_findSafePos takes 7 arguments, so what are the [], [_sPos] things doing there?  Also what isArray
// the intetion of the 50 * (pi / 180) there?  That's the terrain gradient field.[/color]
_gPos = [ _gPos, 0, 15, 10, 0, 50 * (pi / 180), 0, [], [_sPos]] call BIS_fnc_findSafePos;
_gMarker = createMarker [format ["MarkerPos", random 400], _sPos];  [color="#FF0000"]// Why is there format and a random in there?[/color]
_gMarker setMarkerType "DOT";
_gMarker setMarkerColor "ColorOrange";
_gMarker setMarkerSize [0.5, 0.5];

hint "tCreateMarker.sqf Loaded... Done!";
Sleep 1.0; [color="#FF0000"] // Why a trailing sleep?[/color]

Here's one way of doing what you're after. There's a demo mission available as well.

// Call via:  _null = [4107, 3960, 0] execVM "spawnMyAmmo.sqf";

private ["_myPos","_myDistance","_myTerrainGradient","_myMinDistanceFromObjects","_myAmmoBoxType","_myMarkerPos","_myMarker","_myAmmoBox"];

// Center point of area.
_myPos = _this;

// Variables
_myDistance = 40; // distance from center point that the marker can be created.
_myTerrainGradient = 20;  // how steep a hill it can be spawned on.
_myMinDistanceFromObjects = 5; // how far away from other objects it can spawn.
_myAmmoBoxType = "USBasicAmmunitionBox_EP1"; // classname of the ammo box to use.
_myMarkAmmoWithSmoke = true; // T/F to mark the ammo crate with smoke.

// See BOXLOADOUT to change box contents

// Make sure you have the functions module on the map!

// Find a safe spot.
_myMarkerPos = [_myPos, 0, _myDistance, _myMinDistanceFromObjects, 0, _myTerrainGradient, 0] call BIS_fnc_findSafePos;  // No water spots.

// Create a marker on the spot.
_myMarker = createMarker ["AmmoSpawnMarker", _myMarkerPos];
_myMarker setMarkerColor "ColorOrange";
_myMarker setMarkerType "DOT";
_myMarker setMarkerSize [0.5, 0.5];

// Create an ammo crate on the marker.
_myAmmoBox = _myAmmoBoxType createVehicle getMarkerPos _myMarker;

// BOXLOADOUT

// Empty the box
clearWeaponCargoGlobal _myAmmoBox;
clearMagazineCargoGlobal _myAmmoBox;

// Add in what we want:  2x SAW, 4x M4A3, 5 boxes of SAW ammo, 20 magazines of STANAG, 1x MAAWS and 1x rangefinder
// Add weapons.
_myAmmoBox addWeaponCargoGlobal ["M249_EP1", 2];
_myAmmoBox addWeaponCargoGlobal ["M4A3_CCO_EP1", 4];
_myAmmoBox addWeaponCargoGlobal ["MAAWS", 1];
_myAmmoBox addWeaponCargoGlobal ["Binocular_Vector", 1];

// Add ammo.
_myAmmoBox addMagazineCargoGlobal ["200Rnd_556x45_M249", 5];
_myAmmoBox addMagazineCargoGlobal ["30Rnd_556x45_Stanag", 20];
_myAmmoBox addMagazineCargoGlobal ["MAAWS_HEDP", 2];

if (_myMarkAmmoWithSmoke) then {
_myAmmoSmoke = "SmokeShellOrange" createVehicle getPos _myAmmoBox;	
};

Share this post


Link to post
Share on other sites

Wow... Holyshit... I Didn't know it'd be Soo Simple.

(Because I Can Read everything you Wrote Better & it DOES Sound alot more Logical)

Once again though... I'm still a Noob in this ARMA 2 Scripting World :D

But Thank you Very Much Kylania :yay:

I'm Very Greatfull of this :bounce3: :)

EDIT: Where is this Coming from... _null = [4107, 3960, 0] execVM "spawnMyAmmo.sqf";

Because I Can't seem to find the Second two Numbers in EachFour Digits on the 2D Editor Gridding.

Edited by ShinShin

Share this post


Link to post
Share on other sites

It's an X (North to South), Y (West to East) and Z (up and down) coordinate. Best way to find it is simply make a trigger, radio Alpha repeatable with this as it's onAct:

hint str(position player)

Then 001 in game and you'll get an hint with something like [4107.232, 3960.343, 0.1291919] which is your position (an array of three numbers, the [x,y,z] of where you player is at. I was going to set it up so you could feed it an object or coords but ran out of time. I'll try to do that tonight so you can see how it would work.

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  

×