Jump to content
Sign in to follow this  
AndroidSpawn

Question about moving markers around

Recommended Posts

Hello!

I have run into a problem, this is my first attempt trying to randomize spawn positions.

I get a Zero Divisor error in this script.

Could a kind soul point me in the right direction on how to solve this, feel free to point out any errors you find. :)

I can move objects around just fine, and I can move around the editor placed "active area" marker without any problems.

I know a bit of basic C++ if that helps someone to explain my error.

Thanks!

// nul = execVM "scripts\AndroidSpawn\grpSpawnRNDmrk.sqf";

if(!isServer) exitWith {};

// an array containing spawn markers
_spawnMark = ["mrk1", "mrk2", "mrk3", "mrk4", "mrk5", "mrk6", "mrk7", "mrk8"] call BIS_fnc_selectRandom;

_resetMarkPos = [getMarkerPos _spawnMark select 0, getMarkerPos _spawnMark select 1];  


// moves the spawn marker a bit for a more random position
_newSpawnPos = [(getMarkerPos _spawnMark select 0 + (random (round 200))), (getMarkerPos _spawnMark select 1 + (random (round 200))), 0];
_spawnMark setPos _newSpawnPos;

// creation of militia group at spawn marker
_taki1 = [getMarkerPos _spawnMark, EAST, (configFile >> "CfgGroups" >> "East" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Group")] call BIS_fnc_spawnGroup;
_taki1 join grpNull;
_takiGrp1 = creategroup EAST;
_taki1 join _takiGrp1;

// makes the group defend their spot
[group _takiGrp1, getPos _takiGrp1] call bis_fnc_taskDefend;

// moves the active area marker to a close random position
"Active area" setpos [getMarkerPos _spawnMark select 0 + (random (round 120)), getMarkerPos _spawnMark select 1 + (random (round 120)), 0];


sleep 0.1;

spawnMarker = _spawnMark;

// returns the spawnmarker to original position
_spawnMark setpos [getMarkerPos _resetMarkPos select 0, getMarkerPos _resetMarkPos select 1, 0];
sleep 0.1;

// creates a trigger that runs this script again when the previous group has been destroyed
_trg = createTrigger["EmptyDetector",getMarkerPos _spawnMark];
_trg setTriggerArea[2000,2000,0,false];
_trg setTriggerActivation["EAST","NOT PRESENT",false];
_trg setTriggerStatements["this", "hint 'Area Clear'; nul = execVM "scripts\AndroidSpawn\grpSpawnRNDmrk.sqf";", "deleteGroup _takiGrp1;"];



if(true) exitWith{};

Edited by AndroidSpawn

Share this post


Link to post
Share on other sites

Not sure if this is your problem, but try this...

_trg setTriggerStatements["this", "hint 'Area Clear'; nul = execVM 'scripts\AndroidSpawn\grpSpawnRNDmrk.sqf';", "deleteGroup _takiGrp1;"];

And you really shouldn`t use names of variables with empty spaces.. so rename "Active area" to "ActiveArea"...

;)

Share this post


Link to post
Share on other sites

// moves the spawn marker a bit for a more random position
_newSpawnPos = [(getMarkerPos _spawnMark select 0 + (random (round 200))), (getMarkerPos _spawnMark select 1 + (random (round 200))), 0];
_spawnMark [color="Red"]setPos[/color] _newSpawnPos;

You must use setMarkerPos to change the position of markers.

Share this post


Link to post
Share on other sites

Thank you both, the marker issue seems to be resolved.

Ok, I got it to work a few extra () and a few other changes did it.

// nul = execVM "scripts\AndroidSpawn\grpSpawnRNDmrk.sqf";

if(!isServer) exitWith {};

// an array containing spawn markers
_spawnMark = ["mrk1", "mrk2", "mrk3", "mrk4", "mrk5", "mrk6", "mrk7", "mrk8"] call BIS_fnc_selectRandom;

_resetMarkPos = [getMarkerPos _spawnMark select 0, getMarkerPos _spawnMark select 1];  


// moves the spawn marker a bit for a more random position


_newSpawnPos = [((getMarkerPos _spawnMark select 0) + (random 200)), ((getMarkerPos _spawnMark select 1) + (random 200)), 0];
_spawnMark setMarkerPos [ _newSpawnPos select 0, _newSpawnPos select 1, 0];

// creation of militia group at spawn marker
_taki1 = [getMarkerPos _spawnMark, EAST, (configFile >> "CfgGroups" >> "East" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Group")] call BIS_fnc_spawnGroup;


// makes the group defend their spot
[_taki1, getMarkerPos _spawnMark] call bis_fnc_taskDefend;

// moves the active area marker to a close random position
"ActiveArea" setMarkerPos [(_newSpawnPos select 0) + (random (round 120)), (_newSpawnpos select 1) + (random (round 120)), 0];


sleep 0.1;

spawnMarker = _spawnMark;

// returns the spawnmarker to original position
_spawnMark setMarkerPos [_resetMarkPos select 0, _resetMarkPos select 1, 0];
sleep 0.1;

// creates a trigger that runs this script again when the previous group has been destroyed
_trg = createTrigger["EmptyDetector",getMarkerPos _spawnMark];
_trg setTriggerArea[2000,2000,0,false];
_trg setTriggerActivation["EAST","NOT PRESENT",false];
_trg setTriggerStatements["this", "hint 'Area Clear'; nul = execVM 'scripts\AndroidSpawn\grpSpawnRNDmrk.sqf';", "deleteGroup _taki1;"];



if(true) exitWith{};

Edited by AndroidSpawn
Added the code that seems to 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  

×