Jump to content
Sign in to follow this  
Gekkibi

Script: Cross-Com (Units shows in map)

Recommended Posts

Cross-Com Positioning System is part of bigger script (Other "modules" are even more WIP than this one).

CCPS creates marker that moves and rotates with the unit, thus allowing players to see their positions by using a map or GPS (Right CTRL + M). Marker color changes its color between base color (Makes it easier to recognize different groups if you use unique color for every group) and the condition of the unit: Green is healthy/undamaged, yellow is injured/damaged, orange is if the unit is in agony (And first aid module is activated) and red is dead/destroyed.

There are lots of more features, which you can learn by reading the comment lines in the script.

As always, bug reports / feedback / suggestions are more than welcome. And remember: I am not doing this for myself. I am doing this for the community! Use it freely. Modify it freely. I don't care even if you stuff it up your a--... :)

Copypasta it to your favorite text editor and save it to cross-com.sqs (Put it into \missions\mission.island\cross-com -folder).

; Cross-Com Positioning System (CCPS) by Gekkibi
; Version 1.06
;
; Copying and distributing this script is under EVVKTVH/ICCLEIYSIUYA license:
; http://evvk.com/evvktvh.html
;
; Features:
; - Units and vehicles visible in map via map markers.
;   - Marker moves and rotates with the unit (Markers disappears if the unit is in a vehicle).
;   - Group leaders easily recognizable by the markers size, which is bigger than others (Adjustable).
;   - Empty vehicles are shown black.
;   - Selectable marker base colors to make it easier to distinguish different groups from each other (Optional).
;   - Marker color changes between the selected marker base color (And black if it is an empty vehicle) and the condition of the unit (Optional).
;     - Healthy/undamaged (Green).
;     - Wounded/damaged (Yelow).
;     - In agony. Only if first-aid module is in use (Orange).
;     - Dead/destroyed (Red).
;   - Marker position and direction updates only if the unit has actually moved, and the marker isn't dot or cross (No point to turn them).
;     - The difference between coordinates in the same axis must be 1 meter (Adjustable).
;     - The difference between directions must be 10 degrees (Adjustable).
;
; "Optional" means it can be changed by editing the arguments of the exec-command.
; "Adjustable" means it can be changed by editing the script.
;
; Updates:
; - More features:
;   - If unit is in agony, his marker color is orange (If marker condition -feature is switched on).
; - More userfriendly:
;   - Changed some of the arguments to local variables, such as marker size, changeable in the initialization stage of the script. Thus requiring
;     less arguments when the script is executed.
;   - Use debug-mode to check marker and unit positions, directions and color.
; - Decreased the workload:
;   - Multiplayer desync went from over 9000 to less than 300. :) I would appreciate if you give me feedback how much desync you have.
;   - Marker positions, directions, colors and visibility updates only when there is need (Unit has moved, color isn't what it supposed to be etc).
; - More flexible:
;   - Possible to choose when map markers are visible and when not. Adds more possibilites to mission makers.
;   - The unit marker is now named as "(unit name)_CCPS_Marker", thus preventing problems with other scripts that uses marker names that are using
;     unit name as part of the marker name ("(unit name)Marker").
; - More tweaking allowed:
;   - Users can more easily modify the script to allow different map markers to be used.
;   - All constant numbers are now variables, which are easily changeable in the initialization stage (Instead of changing the numbers directly
;     to the code).
; - Bugs fixed:
;   - Minor:
;     - Marker direction were calculated even if the unit were in a vehicle.
;     - Marker direction were changed even if the difference between unit direction and marker direction were less than defined update difference.
;       This happened if other were slightly less than 0 and other slightly more than 0, even if the difference weren't enough to update the direction.
;     - Marker type was changed to empty every cycle if the unit were in a vehicle.
;     - Marker color were changed even if the unit were in a vehicle.
;     - Marker size were changed to 0 every cycle in idle even it already was 0.
;   - Moderate:
;     - If condition feature were turned on, dead markers blinked between red and the base color.
;     - If unit were alone, his marker was the size of a group leader.
;     - If unit died while marker color was the condition color, unit color didn't blink in the next cycle even it was supposed to.
;     - Dead crew members inside a vehicle prevented the marker to blink black. Destroyed vehicles never blink back, because a bug causes infantry
;       to blink black if dead. To prevent this, added condition that the unit must be alive to blink black.
;   - Major:
;     - Bug prevented markers from disappearing after death if the condition feature was switched off.
;     - Bug prevented lonely units markers from reappearing when run condition was turned on.
;
; Known bugs:
; - Minor:
;   - When group leader dies, the marker size of next in charge don't change instantly (Is it possible to fix this, as leader _unit changes
;     only when someone in the group realizes his leader have been killed?).
;   - After awhile markers aren't refreshed exactly at the same time. (How to fix: Global counter with waitUntil. Unfortunately waituntil isn't
;     working in SQS-scripts. Tried to convert this script to SQF, but had too many questions how to do it, so at the moment can't do this feature).
; - Moderate:
;   - Script is still executable if the first argument (_unit) doesn't exist (Possibility to launch scripts what doesn't do anything other than
;     eats resources). Any way to fix this? Maybe it doesn't sound to you it is important feature, but I like that users gets feedback if he has
;     executed the script with wrong arguments (For example, if user tries to use marker type 5 (Which isn't defined) the script will inform that
;     the arguments were incorrect. Same should be with unit names).
; - Major:
;   - ...None since I removed the unit line -feature... :)
;
; TO-DO:
; - Change markers to local so players can switch the visibility on and off via communications interface. Help needed how, because I have little
;   experience with multiplayer scripting. Something to do with setMarkerTypeLocal.
; - Remake markerline -feature. Make it work better if someone is in a vehicle...
; - Marker line starts to blink when the unit is far away from his leader. If the distance increases, the line turns invisible.
; - Add marker to the average position of the unit, and draw unit lines to this marker from each unit. Whatever the community wants.
; - No point to show the condition of a unit if he/it is undamaged (Green) and the marker color has been selected.
; - Prevent certain base colors if the unit is using condition feature. Yellow marker blinks as yellow when damaged? Makes no sense.
; - Change this script to do multitasking: One script execution per group. What problems does this cause, other than all group members must
;   have the same icon (For example, vehicles).
; - Automatic definition of marker type: Infantry uses "2" and vehicles uses "3". Possible?
; - Color changes independent to the refresh rate.
;
; How to use:
; - Some features are changeable by editing the script:
;   - _markerUpdatePos: How much must be the difference between unit and marker coordinates in the same axis until the marker updates its position.
;   - _markerUpdateDir: How much must be the difference between unit and marker directions until the marker updates its direction.
;   - _markerSize: What is the size of the marker if the unit isn't a group leader (Or is alone).
;   - _markerSizeLeader: What is the size of the marker if the unit is a group leader.
;   - _markerRemovalTime: How many cycles (Refresh rate) needed to remove a dead marker, if marker removal -feature is switched on.
;   - _conditionDamage: How much damage is needed to change the condition from undamaged to damaged.
;   - _conditionColorUndamaged: What is the condition color of healthy/undamaged unit.
;   - _conditionColorDamaged: What is the condition color of injured/damaged unit.
;   - _conditionColorAgony: What is the condition color of a unit in agony (If first aid module is used).
;   - _conditionColorDestroyed: What is the condition color of dead/destroyed unit.
; - Syntax: [unit, marker type, marker color, marker condition, marker removal, refresh rate, run condition, debug] exec "cross-com\ccps.sqs";
;   - Where:
;     - Unit is the name of the unit (Object).
;     - Marker type is the shape of the marker (Number).
;       - 1: Small dot (Doesn't rotate).
;       - 2: Small circle with an arrow pointing the direction.
;       - 3: Triangle.
;       - 4: Cross (Doesn't rotate).
;     - Marker color is the color of the marker (Number).
;       - 0: No designated marker color (Color is the condition. Marker condition must be turned on, or the script won't run!)
;       - 1: Black.
;       - 2: Green.
;       - 3: Red.
;       - 4: Blue.
;       - 5: Orange.
;       - 6: Yellow.
;     - Marker condition states if the color of the marker changes by condition (Boolean).
;     - Marker removal states if the markers are deleted after couple of seconds if the unit is killed (Boolean).
;     - Refresh rate is the time in seconds how often markers are updated (Both position and color) (Number).
;     - Run condition states when to update the markers and when not to. This argument must return boolean value. If the argument is inside
;       quotation marks the condition is checked every cycle. Without quotation marks the condition is checked only when script is executed
;       (If true it will function indefinitely, and if false it will never update marker positions). Note that you can't use word "this" to
;       define the unit if it is written in the initialization field. Instead, use _unit. You can also use _leader to define the leader of
;       the unit.
;     - Debug states whether or not display additional information. It is recommended that only one execution uses debug, if debug is needed.
;       Due to the fact that this is only temporary argument, the script doesn't check if it is valid (True or false) (Boolean).
;
;     Note that all arguments must have a value, and all values must be valid, or else the script will exit itself.
;
;   - Example: [natosotamise, 2, 4, true, false, 0.5, "_unit distance _leader < 1000", false] exec "cross-com\ccps.sqs";
;       - Unit natosotamise is shown as a blue circle with an arrow which color changes depending of the health of the unit.
;       - The marker stays in the map even after the unit is killed. The marker position and angle is recalculated every 500 ms.
;       - Marker shows in the map when natosotamise is closer than 1000 meters from his current group leader, and is invisible
;         when further. Debug-mode is turned off.

#INITIALIZATION
 ?(!isServer): exit;
 _unit = _this select 0;
 _markerType = _this select 1;
 _markerColor = _this select 2;
 _markerCondition = _this select 3;
 _markerRemoval = _this select 4;
 _refreshRate = _this select 5;
 _runCondition = _this select 6;
 _debug = _this select 7;

 _markerUpdatePos = 1;
 _markerUpdateDir = 10;
 _markerSize = 1;
 _markerSizeLeader = 1.5;
 _markerRemovalTime = 10;
 _conditionDamage = 0.1;
 _conditionColorUndamaged = "ColorGreen";
 _conditionColorDamaged = "ColorYellow";
 _conditionColorAgony = "ColorOrange";
 _conditionColorDestroyed = "ColorRed";

 _counter = 0;
 _markerRemovalCounter = 0;
 _vehicleCrewCounter = 0;

#CHECKING ARGUMENTS
 ?((_markerCondition || !_markerCondition) && (_markerRemoval || !_markerRemoval)): goto "CREATING MARKER";
 goto "EXIT ERROR";

#CREATING MARKER
 _marker = str(_unit) + "_CCPS_Marker";
 createMarker [_marker, getPos _unit];
 _marker setMarkerShape "ICON";
 _marker setMarkerSize [_markerSize, _markerSize];
 _marker setMarkerDir getDir _unit;

#CREATING MARKER TYPE
 ?(_markerType == 1): _marker setMarkerType "x_art"; _markerRotation = false; goto "CREATING MARKER COLOR";
 ?(_markerType == 2): _marker setMarkerType "x_mortar"; _markerRotation = true; goto "CREATING MARKER COLOR";
 ?(_markerType == 3): _marker setMarkerType "mil_triangle"; _markerRotation = true; goto "CREATING MARKER COLOR";
 ?(_markerType == 4): _marker setMarkerType "waypoint"; _markerRotation = false; goto "CREATING MARKER COLOR";
 goto "EXIT ERROR";

#CREATING MARKER COLOR
 ?(_markerColor == 0 && _markerCondition): goto "PROGRAM";
 ?(_markerColor == 1): _marker setMarkerColor "ColorBlack"; goto "CREATING _MARKERCOLORSTRING";
 ?(_markerColor == 2): _marker setMarkerColor "ColorGreen"; goto "CREATING _MARKERCOLORSTRING";
 ?(_markerColor == 3): _marker setMarkerColor "ColorRed"; goto "CREATING _MARKERCOLORSTRING";
 ?(_markerColor == 4): _marker setMarkerColor "ColorBlue"; goto "CREATING _MARKERCOLORSTRING";
 ?(_markerColor == 5): _marker setMarkerColor "ColorOrange"; goto "CREATING _MARKERCOLORSTRING";
 ?(_markerColor == 6): _marker setMarkerColor "ColorYelloW"; goto "CREATING _MARKERCOLORSTRING";
 goto "EXIT ERROR";

#CREATING _MARKERCOLORSTRING
 _markerColorString = markerColor _marker;

#PROGRAM
 #IDLE
   ~_refreshRate
   _counter = _counter + 1;
   ?(_counter > 3): _counter = 1;
   _leader = leader _unit;
   _crew = 0;

   #UNIT AGONY
     _inAgony = _unit getVariable "BIS_IS_inAgony";
     ?(isNil "_inAgony"): _inAgony = false;

   #VEHICLE CREW ITERATION
     ?(_vehicleCrewCounter >= count crew _unit): _vehicleCrewCounter = 0; goto "MARKER REMOVAL";
     ?(alive (crew _unit select _vehicleCrewCounter)): _crew = _crew + 1;
     _vehicleCrewCounter = _vehicleCrewCounter + 1;
     goto "VEHICLE CREW ITERATION";

   #MARKER REMOVAL
     ?(_markerRemoval && !alive _unit): _markerRemovalCounter = _markerRemovalCounter + 1;
     ?(_markerRemovalCounter >= _markerRemovalTime): goto "EXIT";

   ?(call compile format ["%1", _runCondition]): goto "MARKER POSITION";
   ?(markerSize _marker select 0 != 0): _marker setMarkerSize [0, 0];
   goto "IDLE";

 #MARKER POSITION
   ?(vehicle _unit == _unit && (markerPos _marker select 0 < ((getPos _unit select 0) - _markerUpdatePos) || markerPos _marker select 0 > ((getPos _unit select 0) + _markerUpdatePos))): _marker setMarkerPos [getPos _unit select 0, markerPos _marker select 1];
   ?(vehicle _unit == _unit && (markerPos _marker select 1 < ((getPos _unit select 1) - _markerUpdatePos) || markerPos _marker select 1 > ((getPos _unit select 1) + _markerUpdatePos))): _marker setMarkerPos [markerPos _marker select 0, getPos _unit select 1];

 #MARKER DIRECTION
   ?(_markerRotation && vehicle _unit == _unit && abs (markerDir _marker - getDir _unit) > _markerUpdateDir && markerDir _marker max getDir _unit < markerDir _marker min getDir _unit + 360 - _markerUpdateDir): _marker setMarkerDir getDir _unit;

 #MARKER SIZE
   ?(markerSize _marker select 0 != 0 && vehicle _unit != _unit): _marker setMarkerSize [0, 0];
   ?(markerSize _marker select 0 != _markerSize && vehicle _unit == _unit && (_unit != _leader || (_unit == _leader && count units _unit == 1))): _marker setMarkerSize [_markerSize, _markerSize];
   ?(markerSize _marker select 0 != _markerSizeLeader && vehicle _unit == _unit && _unit == _leader && count units _unit != 1): _marker setMarkerSize [_markerSizeLeader, _markerSizeLeader];

 #MARKER COLOR
   ?(_counter == 1 && _markerColor != 0 && markerColor _marker != _markerColorString && (!alive _unit && markerColor _marker != _conditionColorDestroyed || alive _unit))): _marker setMarkerColor _markerColorString;
   ?(_counter == 2 && _crew == 0 && alive _unit): _marker setMarkerColor "ColorBlack";

 #MARKER CONDITION
   ?(_counter == 3 && _markerCondition && vehicle _unit == _unit && markerColor _marker != _conditionColorDestroyed && !alive _unit): _marker setMarkerColor _conditionColorDestroyed;
   ?(_counter == 3 && _markerCondition && vehicle _unit == _unit && markerColor _marker != _conditionColorAgony && alive _unit && _inAgony): _marker setMarkerColor _conditionColorAgony;
   ?(_counter == 3 && _markerCondition && vehicle _unit == _unit && markerColor _marker != _conditionColorDamaged && alive _unit && !_inAgony && damage _unit >= _conditionDamage): _marker setMarkerColor _conditionColorDamaged;
   ?(_counter == 3 && _markerCondition && vehicle _unit == _unit && markerColor _marker != _conditionColorUndamaged && alive _unit && !_inAgony && damage _unit < _conditionDamage): _marker setMarkerColor _conditionColorUndamaged;

 #DEBUG
   ?(_debug): hintSilent format ["Marker:\nColor: %1\nSize: %2\nPosition: %3 %4\nDirection: %5\n\nUnit:\nPosition: %6 %7\nDirection: %8\nCrew count: %9", markerColor _marker, markerSize _marker select 0, markerPos _marker select 0, markerPos _marker select 1, markerDir _marker, getPos _unit select 0, getPos _unit select 1, getDir _unit, _crew];

 goto "PROGRAM";

#EXIT ERROR
 hint "CCPS.sqs: Arguments incorrect!";
   #EXIT
     deleteMarker _marker;
     exit;

For now, CCGM (Cross-Com Group Marker) isn't included in this script. Here is the script for that feature. Copypasta it to the same direction as CCPS.sqs. It doesn't require CCPS to run.

CCGM shows the average position of certain units, and draws lines from each unit to the average position.

; Cross-Com Group Marker (CCGM) by Gekkibi
; Version 0.01
;
; Copying and distributing this script is under EVVKTVH/ICCLEIYSIUYA license:
; http://evvk.com/evvktvh.html
;
; Features:
; - Marker shows the average position of a group.
; - Line is drawn from each alive unit in a group to the marker.
;
; Updates:
; - None. ;)
;
; Known bugs:
; - Minor:
;   - None so far...
; - Moderate:
;   - None so far...
; - Major:
;   - None so far...
;
; TO-DO:
; - Include this feature to the CCPS -script.
; - Marker and markerlines only updates if the position have been changed.
; - Add group size marker to show how big is the group.
;
; How to use:
; - Syntax: [group, marker type] exec "cross-com\ccgm.sqs";
;   - Where:
;     - Group is the array of all the units in a group (Array).
;     - Marker type is the shape of the marker (Number).
;       - 1: Infantry.
;       - 2: Recon.
;       - 3: Motorized infantry.
;       - 4: Mechanized infantry.
;       - 5: Armor.
;       - 6: Artillery.
;       - 7: Mortar.
;       - 8: Helicopter.
;       - 9: Aircraft.
;       - 10: UAV.
;       - 11: HQ.
;       - 12: Medical.
;       - 13: Support.
;       - 14: Maintenance.
;       - 15: Service.
;
;   - Example: [[unit1, unit2, unit3, unit4], 1] exec "cross-com\ccgm.sqs";

#INITIALIZATION
 ?(!isServer): exit;
 _group = _this select 0;
 _markerType = _this select 1;

 _markerLineWidth = 0.25;
 _refreshRate = 0.5;

 _markerLine = [];
 _counter = 0;



 _marker = str(_group select 0) + "_CCGM_Marker";
 createMarker [_marker, getPos (_group select 0)];
 _marker setMarkerShape "ICON";

 ?(_markerType == 1): _marker setMarkerType "b_inf"; goto "CREATE MARKER LINES";
 ?(_markerType == 2): _marker setMarkerType "b_recon"; goto "CREATE MARKER LINES";
 ?(_markerType == 3): _marker setMarkerType "b_motor_inf"; goto "CREATE MARKER LINES";
 ?(_markerType == 4): _marker setMarkerType "b_mech_inf"; goto "CREATE MARKER LINES";
 ?(_markerType == 5): _marker setMarkerType "b_armor"; goto "CREATE MARKER LINES";
 ?(_markerType == 6): _marker setMarkerType "b_art"; goto "CREATE MARKER LINES";
 ?(_markerType == 7): _marker setMarkerType "b_mortar"; goto "CREATE MARKER LINES";
 ?(_markerType == 8): _marker setMarkerType "b_air"; goto "CREATE MARKER LINES";
 ?(_markerType == 9): _marker setMarkerType "b_plane"; goto "CREATE MARKER LINES";
 ?(_markerType == 10): _marker setMarkerType "b_uav"; goto "CREATE MARKER LINES";
 ?(_markerType == 11): _marker setMarkerType "b_hq"; goto "CREATE MARKER LINES";
 ?(_markerType == 12): _marker setMarkerType "b_med"; goto "CREATE MARKER LINES";
 ?(_markerType == 13): _marker setMarkerType "b_support"; goto "CREATE MARKER LINES";
 ?(_markerType == 14): _marker setMarkerType "b_maint"; goto "CREATE MARKER LINES";
 ?(_markerType == 15): _marker setMarkerType "b_service"; goto "CREATE MARKER LINES";

#CREATE MARKER LINES
 ?(_counter >= count _group): _counter = 0; goto "INITIALIZE VARIABLES";
 _unit = _group select _counter;
 _markerLine set [_counter, str(_unit) + "_CCGM_Marker_Line"];
 createMarker [_markerLine select _counter, getPos _unit];
 _markerLine select _counter setMarkerShape "RECTANGLE";
 _counter = _counter + 1;
 goto "CREATE MARKER LINES";

#INITIALIZE VARIABLES
 ~_refreshRate
 _markerPos_x = 0;
 _markerPos_y = 0;

#ITERATE ARRAYS
 ?(_counter >= count _group): _counter = 0; goto "ITERATE MARKER POSITION";
 ?(!alive (_group select _counter)): deleteMarker (_markerLine select _counter); _group = _group - [_group select _counter]; _markerLine = _markerLine - [_markerLine select _counter];
 _counter = _counter + 1;
 goto "ITERATE ARRAYS";

#ITERATE MARKER POSITION
 ?(_counter >= count _group): _counter = 0; goto "UPDATE MARKER POSITION";
 _markerPos_x = _markerPos_x + (getPos (_group select _counter) select 0);
 _markerPos_y = _markerPos_y + (getPos (_group select _counter) select 1);
 _counter = _counter + 1;
 goto "ITERATE MARKER POSITION";

#UPDATE MARKER POSITION
 _marker setMarkerPos [_markerPos_x / count _group, _markerPos_y / count _group];

#UPDATE MARKER LINES
 ?(_counter >= count _group): _counter = 0; goto "INITIALIZE VARIABLES";
 _unit = _group select _counter;
 _markerLine select _counter setMarkerPos [((markerPos _marker select 0) + (getPos _unit select 0)) / 2, ((markerPos _marker select 1) + (getPos _unit select 1)) / 2];
 _markerLine select _counter setMarkerDir ((markerPos _marker select 0) - (getPos _unit select 0)) atan2 ((markerPos _marker select 1) - (getPos _unit select 1));
 _markerLine select _counter setMarkerSize [_markerLineWidth, (markerPos _marker distance _unit) / 2];
 _counter = _counter + 1;
 goto "UPDATE MARKER LINES";

You can download example mission (Scripts included) here:

http://oh3tr.ele.tut.fi/~oh3gkb/CCPS.utes.rar

Edited by Gekkibi
New version

Share this post


Link to post
Share on other sites

Nice script :) The visibility of a unit to pursue increases.

0 division error is caused in script starting.

Share this post


Link to post
Share on other sites
Nice script :) The visibility of a unit to pursue increases.

0 division error is caused in script starting.

It is because unit and its leader posesses the same y-coordinates.

Cyclometric function of tangent is opposing cathetus divided by adjacent cathetus. Because the length of adjacent cathetus is zero (Anything subtracted by itself is always zero) script tries to divide using zero.

Quick solving: Don't use 0 degree azimut with formation line in initialization. :)

Slow solving: I fix it next time I improve the script. The problem is that if I use other trigonometric functions I will get another "features". The problem is that the cycle of sin and cos is pi/2 radians, and full circle is 2 pi radians. So I'll have to make a little more than just fix the mathematic equation.

I thank you for this bug report. Didn't found it when I bug-tested the script.

Share this post


Link to post
Share on other sites
It may be improved if atan2 is used instead of atan. atan2 protects 0 division.

...Now I wonder why on earth I started to use atan in the first place... Must been too tired to think about that (After all, this isn't the first time I am coding... And atan2 was created for coding purposes...).

However, I don't get any kind of error message when using atan (Read: Dividing by zero). I made a small script that does the following equations:

1) (a - b) / (c - d)

2) atan (a - b) / (c - d)

3) (a - b) atan2 (c - d)

Here it is (Under the spoiler):

_variable1 = 1;

_variable2 = 1;

_variable3 = 2;

_variable4 = 2;

_equation1 = (_variable1 - _variable2) / (_variable3 - _variable4);

_equation2 = atan ((_variable1 - _variable2) / (_variable3 - _variable4));

_equation3 = (_variable1 - _variable2) atan2 (_variable3 - _variable4);

hint format ["%1 minus %2 divided by %3 minus %4 is %5\n\natan between %1 minus %2 and %3 minus %4 is %6\n\natan2 between %1 minus %2 and %3 minus %3 is %7", _variable1, _variable2, _variable3, _variable4, _equation1, _equation2, _equation3];

When a and b are any numbers and c = d, then solutions are:

1) 0

2) 0

3) 90

Okay, so atan2 fixed the problem, not going to argue with that (Thanks, by the way for the hint). However, I am confused, because I don't get any kind of error, even I divide by zero (As I do in this equation script... Two times). It seems ArmA 2 decides that division of zero is zero...

I give a virtual hug if someone can explain this to me. :)

Share this post


Link to post
Share on other sites

If it's just about a unit which is a leader why not use this check:

if {_unit == leader group _blah} then ( dont draw line etc etc )

Share this post


Link to post
Share on other sites
)rStrangelove;1481575']If it's just about a unit which is a leader why not use this check:

if {_unit == leader group _blah} then ( dont draw line etc etc )

It is not just about that. It is also if two unit posesses exactly the samy Y-coordinates (Azimut is 0 or 180 degrees) and was placed to line formation in editor (Or 90 and 270 degrees and in staggered column' date=' or just about anything else what causes them to be in the same y-coordinates).

PS. What is the correct forum to put finished scripts (No, this is far from finished. But I have couple of other WIP-scripts what I plan to publish when they are finished)?

EDIT: Found a problem I can't solve. Hopefully someone can point me into the right direction. I am trying to put all variables into specific arrays, so I don't have to run multiple scripts for every unit.

Here is the code with comments:

_objects = _this select 0; (Array. For example [unit1, unit2, unit3'])

_errormargin = _this select 1; (Number)

_counter_1 = 0;

#_ERRORS

_errors set [_counter_1, random _errormargin - random _errormargin];

_counter_1 = _counter_1 + 1;

?(_counter_1 == count _objects): _counter_1 = 0; goto "_ERRORS DONE";

goto "_ERRORS";

#_ERRORS DONE

(This generates an array what is as big as _objects. For example [0.5, 0.2, -0.9]. Everything is ok)

#_TRIANGULATION_LINE

_triangulation_line set [_counter_1, str(_objects select _counter_1) + "_triangulation_line"];

_counter_1 = _counter_1 +1;

?(_counter_1 == count _objects): _counter_1 = 0; goto "_TRIANGULATION_LINE DONE";

goto "_TRIANGULATION_LINE";

#_TRIANGULATION_LINE DONE

(This generates an array what is also as big as _objects. For example [unit1_triangulation_line, unit2_triangulation_line, unit3_triangulation_line]. Markers must have names)

#CREATE MARKERS

createMarker [_triangulation_line select _counter_1, getPos _objects select _counter_1];

_triangulation_line select _counter_1 setMarkerShape "RECTANGLE";

_triangulation_line select _counter_1 setMarkerColor "ColorBlack";

_triangulation_line select _counter_1 setMarkerSize [0, 0];

_counter_1 = _counter_1 +1;

?(_counter_1 == count _objects): counter_1 = 0; goto "CREATE MARKERS DONE";

goto "CREATE MARKERS";

#CREATE MARKERS DONE

(Now this just isn't working! Tried to use hint format ["%1", getMarkerColor _triangulation_line select _counter_1 ]; and it doesn't hint anything (No box, no sound)!

What am I doing wrong? And should I really start learning SQF-scripting? :)

Edited by Gekkibi

Share this post


Link to post
Share on other sites

BUMP.

New version available (Read the 1st post). Now it is much neater code, and shouldn't stress the server so much if used in MP (Haven't tested that yet, 'tho).

Edited by Gekkibi

Share this post


Link to post
Share on other sites

However, I don't get any kind of error message when using atan (Read: Dividing by zero). I made a small script that does the following equations:

1) (a - b) / (c - d)

2) atan (a - b) / (c - d)

3) (a - b) atan2 (c - d)

Here it is (Under the spoiler):

_variable1 = 1;

_variable2 = 1;

_variable3 = 2;

_variable4 = 2;

_equation1 = (_variable1 - _variable2) / (_variable3 - _variable4);

_equation2 = atan ((_variable1 - _variable2) / (_variable3 - _variable4));

_equation3 = (_variable1 - _variable2) atan2 (_variable3 - _variable4);

hint format ["%1 minus %2 divided by %3 minus %4 is %5\n\natan between %1 minus %2 and %3 minus %4 is %6\n\natan2 between %1 minus %2 and %3 minus %3 is %7", _variable1, _variable2, _variable3, _variable4, _equation1, _equation2, _equation3];

When a and b are any numbers and c = d, then solutions are:

1) 0

2) 0

3) 90

zeroerror.th.jpg

An error is shown by the test. This error is based on 1) and 2). It does not come out in 3).

Also, the error is not displayed in new script :)

PS: Since I only offered a small idea to you, my description is unnecessary ;)

Share this post


Link to post
Share on other sites

PS: Since I only offered a small idea to you, my description is unnecessary ;)

Still, I am grateful to you. ;)

I am struggling with couple of annoying bugs atm. I made it that markers don't change their position & directions if the unit haven't moved / turned couple of degrees / feets, and this is causing massive amount of headache with those lines between unit and his leader (Because units in a vehicle don't update markerpos), and that is why I am asking now that should I keep trying to fix them, or should I remove the whole markerline feature?

In other words: Do you want that you have an option to see the lines between unit and his leader or not? It makes the map view alot more messy, and because I included the possibility to choose a "team color", it kind of makes the lines pointless (Marker color reveals if someone belongs to a certain group)...

Suggestions & feedback are welcome, as always.

And if you think my script sucks in any way (Poor programming or you don't need certain features, or the script at all [For example if there is better script made by someone else out there somewhere]), tell me. Otherwise I can't improve this script.

I am not making this script for myself. I am making this for the community... I wouldn't publish it under EVVKTVH/ICCLEIYSIUYA otherwise (If you are lazy to find out what it means, it means: "Ei Voisi Vähempää Kiinnostaa, Tunge Vaikka Hanuriisi" for finnish, and for english it is "I Couldn't Care Less Even If You Stuff It Up Your A--". Meaining: Use it, modify it, distribute it freely).

EDIT:

Quickly made a version without marker lines. In addition, fixed couple of (really silly) bugs (More like typos...). Here is the code (Edit: 10.11. Made new version):

; Cross-Com Positioning System (CCPS) by Gekkibi

; Version 1.02

;

; Copying and distributing this script is under EVVKTVH/ICCLEIYSIUYA license:

; http://evvk.com/evvktvh.html

;

; Features:

; "Optional" means it can be changed by editing the arguments of the exec-command.

; "Adjustable" means it can be changed by editing the script.

; - Units and vehicles visible in map via map markers.

; - Marker moves with the unit.

; - Marker rotates to the units bearing.

; - Group leaders marker is bigger than others (Adjustable).

; - Marker disappears if the unit is in a vehicle.

; - Empty vehicles are shown black.

; - Selectable marker colors to make it easier to distinguish two groups from each other (Optional).

; - Marker color changes between the selected marker color (And black if it is an empty vehicle) and the condition of the unit (Optional).

; - Healthy/undamaged (Green).

; - Wounded/damaged (Orange).

; - Dead/destroyed (Red).

; - Marker position and direction updates only if the unit has actually moved, and the marker isn't dot or cross (No point to turn them).

; - The difference between coordinates in the same axis must be 1 meter (Adjustable).

; - The difference between directions must be 10 degrees (Adjustable).

;

; Updates:

; - Decreased the workload:

; - Multiplayer desync went from over 9000 to less than 300. :)

; - Marker positions, directions, colors and visibility updates only when there is need (Unit has moved, color isn't what it supposed to be etc).

; - More critical calculations are done more often than less critical (Position is calculated every cycle, when condition color isn't).

; - More tweaking allowed:

; - Users can more easily modify the script to allow more map markers to be used.

; - All constant numbers are now variables, which are easily changeable in the initialization stage (Instead of changing the numbers directly

; to the code).

; - Bugs fixed:

; - Bug prevented markers from disappearing after death if the condition -feature was switched off.

; - If condition feature were turned on, dead markers blinked between red and the group color (Not a bug, it's a feature...).

; - Marker direction were calculated even if the unit were in a vehicle.

; - Marker type was changed to empty every cycle if the unit were in a vehicle (Not sure if this actually causes desync, but still fixed it).

; - Destroyed vehicles with dead crew inside didn't blink black, so changed that destroyed vehicles never blink black (After all, destroyed

; vehicle is still a destroyed vehicle. Nobody is interested if there are dead crew men inside...).

;

; Known bugs:

; - Minor:

; - If markers direction is less than 5 degrees and units more than 355, marker is updated, even if the difference in degrees is less than 10.

; - If unit is alone, his marker is the size of a leader. Script should check if the unit is a leader and he isn't alone in the group.

; - Moderate:

; - Script is still executable if the first argument (_unit) doesn't exist (Possibility to launch scripts what doesn't do anything other than

eats resources).

; - Major:

; - ...None since I removed the unit line -feature... :)

;

; TO-DO:

; - Add yet another argument: Condition. It states when map markers are shown.

; - Change markers to local so players can switch the visibility on and off via communications interface.

; - Remake markerline -feature. Make it work better if someone is in a vehicle... If community so desires...

; - Marker line starts to blink when the unit is far away from his leader. If the distance increases, the line turns invisible.

; - Remove markerSize from arguments and create it as a local variable, so its operand can be changed by editing the script (Simplifies the execution).

; - No point to show the condition of a unit if he/it is undamaged (Green) and the marker color has been selected.

; - Prevent certain team colors if the unit is using condition feature. Orange marker blinks as orange when damaged? Makes no sense.

; - When unit enters a vehicle, his marker type doesn't change. Instead, his marker size changes to [0, 0]. This way we can include shaped

; unit markers (Ellipse and rectangle). Those have one advantage over icons: Their size doesn't change when the map is zoomed.

;

; How to use:

; - Syntax: [unit, marker type, marker size, marker color, marker condition, marker removal, refresh rate] exec "cross-com\ccps.sqs";

; - Where:

; - Unit is the name of the unit (Object).

; - Marker type is the shape of the marker (Number).

; - 1: Small dot (Doesn't rotate).

; - 2: Small circle with an arrow pointing the direction.

; - 3: Triangle.

; - 4: Cross (Doesn't rotate).

; - Marker size is the size of the marker (Number).

; - Marker color is the color of the marker (Number).

; - 0: No designated marker color (Color is the condition. Marker condition must be turned on, or the script won't run!)

; - 1: Black.

; - 2: Green.

; - 3: Red.

; - 4: Blue.

; - 5: Orange.

; - 6: Yellow.

; - Marker condition states if the color of the marker changes by condition (Boolean).

; - Marker removal states if the markers are deleted after couple of seconds if the unit is killed (Boolean).

; - Refresh rate is the time in seconds how often markers are updated (Both position and color) (Number).

;

; Note that all arguments must have a value, and all values must be valid, or else the script will exit itself.

;

; - Example: [natosotamise, 2, 1, 4, true, false, 0.5] exec "cross-com\ccps.sqs";

; - Unit natosotamise is shown as a small blue circle with an arrow which color changes depending of the health of the unit.

; - The marker stays in the map even after the unit is killed. The marker position and angle is recalculated every 500 ms.

#INITIALIZATION

?(!isServer): exit;

_unit = _this select 0;

_markerType = _this select 1;

_markerSize = _this select 2;

_markerColor = _this select 3;

_markerCondition = _this select 4;

_markerRemoval = _this select 5;

_refreshRate = _this select 6;

; _runCondition = _this select 7;

; How much must be the difference between unit and marker coordinates in the same axis until the marker updates its position.

_markerUpdatePos = 1;

; How much must be the difference between unit and marker directions until the marker updates its direction.

_markerUpdateDir = 10;

; How much bigger is the marker of group leader than other units.

_markerSizeLeader = 1.5;

; How many cycles needed to remova a dead marker, if marker removal -feature is turned on.

_markerRemovalTime = 10;

; How much damage needed to change the condition from undamaged to damaged.

_conditionDamage = 0.1;

; What is the condition color of undamaged object:

_conditionColorUndamaged = "ColorGreen";

; What is the condition color of damaged object:

_conditionColorDamaged = "ColorOrange";

; What is the condition color of destroyed object:

_conditionColorDestroyed = "ColorRed";

; Initializing counter-variables. You shouldn't change these...

_counter = 0;

_markerRemovalCounter = 0;

#CHECKING ARGUMENTS

; HELP NEEDED HERE! How to check if _unit is a valid (existing) unit? isNull doesn't work...

?((_markerCondition || !_markerCondition) && (_markerRemoval || !_markerRemoval)): goto "CREATING MARKER";

goto "EXIT ERROR";

#CREATING MARKER

_marker = str(_unit) + "Marker";

createMarker [_marker, position _unit];

_marker setMarkerShape "ICON";

_marker setMarkerSize [_markerSize, _markerSize];

_marker setMarkerDir getDir _unit;

#CREATING MARKER TYPE

?(_markerType == 1): _marker setMarkerType "x_art"; _markerRotation = false; goto "CREATING _MARKERTYPESTRING";

?(_markerType == 2): _marker setMarkerType "x_mortar"; _markerRotation = true; goto "CREATING _MARKERTYPESTRING";

?(_markerType == 3): _marker setMarkerType "mil_triangle"; _markerRotation = true; goto "CREATING _MARKERTYPESTRING";

?(_markerType == 4): _marker setMarkerType "waypoint"; _markerRotation = false; goto "CREATING _MARKERTYPESTRING";

goto "EXIT ERROR";

#CREATING _MARKERTYPESTRING

_markerTypeString = markerType _marker;

#CREATING MARKER COLOR

?(_markerColor == 0 && _markerCondition): goto "PROGRAM";

?(_markerColor == 1): _marker setMarkerColor "ColorBlack"; goto "CREATING _MARKERCOLORSTRING";

?(_markerColor == 2): _marker setMarkerColor "ColorGreen"; goto "CREATING _MARKERCOLORSTRING";

?(_markerColor == 3): _marker setMarkerColor "ColorRed"; goto "CREATING _MARKERCOLORSTRING";

?(_markerColor == 4): _marker setMarkerColor "ColorBlue"; goto "CREATING _MARKERCOLORSTRING";

?(_markerColor == 5): _marker setMarkerColor "ColorOrange"; goto "CREATING _MARKERCOLORSTRING";

?(_markerColor == 6): _marker setMarkerColor "ColorYelloW"; goto "CREATING _MARKERCOLORSTRING";

goto "EXIT ERROR";

#CREATING _MARKERCOLORSTRING

_markerColorString = markerColor _marker;

#PROGRAM

; HELP NEEDED HERE! How can I temporarily halt the updating marker pos & dir if certain condition is false (6th argument. For example when

; "unit1 distance base < 1000". If I put it to exec without "'s, it will check instantly if the condition is true or false, and send boolean

; value to the script. I want that it sends it as a string, and changes it to logical operator. That way the marker pos & dir will only update

; when the player is closer than 1000 meters from object "base", and stops to update them until player comes closer than 1000 meters)?

; #LOOP

; ?(_runCondition): goto "LOOP EXIT";

; ~_refreshRate

; goto "LOOP";

; #LOOP EXIT

~_refreshRate

_counter = _counter + 1;

?(_counter > 3): _counter = 1;

_leader = leader _unit;

#MARKER POSITION

?(vehicle _unit == _unit && (markerPos _marker select 0 < ((getPos _unit select 0) - _markerUpdatePos) || markerPos _marker select 0 > ((getPos _unit select 0) + _markerUpdatePos))): _marker setMarkerPos [getPos _unit select 0, markerPos _marker select 1];

?(vehicle _unit == _unit && (markerPos _marker select 1 < ((getPos _unit select 1) - _markerUpdatePos) || markerPos _marker select 1 > ((getPos _unit select 1) + _markerUpdatePos))): _marker setMarkerPos [markerPos _marker select 0, getPos _unit select 1];

#MARKER DIRECTION

?(_markerRotation && vehicle _unit == _unit && (markerDir _marker < getDir _unit - _markerUpdateDir || markerDir _marker > getDir _unit + _markerUpdateDir)): _marker setMarkerDir getDir _unit;

#MARKER TYPE

?(vehicle _unit != _unit && markerType _marker != "Empty"): _marker setMarkerType "Empty";

?(vehicle _unit == _unit && markerType _marker != _markerTypeString): _marker setMarkerType _markerTypeString;

#MARKER SIZE

?(markerSize _marker select 0 == _markerSize && _unit == _leader): _marker setMarkerSize [_markerSize * _markerSizeLeader, _markerSize * _markerSizeLeader];

?(markerSize _marker select 0 != _markerSize && _unit != _leader): _marker setMarkerSize [_markerSize, _markerSize];

#MARKER COLOR

?(_counter == 1 && _markerColor != 0 && alive _unit && markerColor _marker != _markerColorString)): _marker setMarkerColor _markerColorString;

?(_counter == 2 && count crew _unit == 0 && alive _unit): _marker setMarkerColor "ColorBlack";

#MARKER CONDITION

?(_counter == 3 && _markerCondition && !alive _unit && markerColor _marker != _conditionColorDestroyed): _marker setMarkerColor _conditionColorDestroyed; deleteMarker _markerLine;

?(_counter == 3 && _markerCondition && alive _unit && damage _unit >= _conditionDamage && markerColor _marker != _conditionColorDamaged): _marker setMarkerColor _conditionColorDamaged;

?(_counter == 3 && _markerCondition && damage _unit < _conditionDamage && markerColor _marker != _conditionColorUndamaged): _marker setMarkerColor _conditionColorUndamaged;

#MARKER REMOVAL

?(_markerRemoval && !alive _unit): _markerRemovalCounter = _markerRemovalCounter + 1;

?(_markerRemovalCounter == _markerRemovalTime): goto "EXIT";

goto "PROGRAM";

#EXIT ERROR

hint "CCPS.sqs: Arguments incorrect!";

#EXIT

deleteMarker _marker;

; HELP NEEDED HERE! Does local variables get deleted if the script is exited?

_conditionDamage = nil;

_conditionColorDamaged = nil;

_conditionColorDestroyed = nil;

_conditionColorUnDamaged = nil;

_counter = nil;

_leader = nil;

_marker = nil;

_markerColor = nil;

_markerColorString = nil;

_markerCondition = nil;

_markerRemoval = nil;

_markerRemovalCounter = nil;

_markerRemovalTime = nil;

_markerRotation = nil;

-markerUpdateDir = nil;

_markerUpdatePos = nil;

_markerSize = nil;

_markerSizeLeader = nil;

_markerType = nil;

_markerTypeString = nil;

_refreshRate = nil;

_unit = nil;

exit;

EDIT 2:

I have couple of questions without answers:

1) Is it possible to add custom markers without addons (Imported to the mission when exported via editor)? In-game markers kind of sucks. I would like to use the markers shown in the editor (Squad leader, AT, medic, etc).

2) Does local variables get nulled after script exits (Or should I "_variable = nul" every variable to optimize the workload)?

3) How to check if _unit is a valid (existing) unit? isNull doesn't work (Something like "?(isNull _unit): exit;"). For example, if the first argument of exec is asdasdasd, and there is no unit named asdasdasd.

4) I am planning to put yet another argument to the exec: Condition. It exits the idle-loop (#LOOP // ?(_condition): goto #PROGRAM // ~1 // goto "LOOP";) when this condition is met and goes back to the idle-loop when the condition isn't met. The problem is that if I put player distance base < 1000 it checks the condition right away and sends true or false to the script. I have tried to send it as a string, but failed to get it working. Any ideas?

5) I try to minimize desync in MP. What causes more desync: "Constantly updating marker positions" or "doing lots of math calculations and using great amount of variables"?

Edited by Gekkibi
New version

Share this post


Link to post
Share on other sites

Nice one, more customizable :)

I like that there was a line between units. When there is no it, group color forces the setup upon a user.

I have couple of questions without answers:

1) Is it possible to add custom markers without addons (Imported to the mission when exported via editor)? In-game markers kind of sucks. I would like to use the markers shown in the editor (Squad leader, AT, medic, etc).

2) Does local variables get nulled after script exits (Or should I "_variable = nul" every variable to optimize the workload)?

3) How to check if _unit is a valid (existing) unit? isNull doesn't work (Something like "?(isNull _unit): exit;"). For example, if the first argument of exec is asdasdasd, and there is no unit named asdasdasd.

4) I am planning to put yet another argument to the exec: Condition. It exits the idle-loop (#LOOP // ?(_condition): goto #PROGRAM // ~1 // goto "LOOP" when this condition is met and goes back to the idle-loop when the condition isn't met. The problem is that if I put player distance base < 1000 it checks the condition right away and sends true or false to the script. I have tried to send it as a string, but failed to get it working. Any ideas?

5) I try to minimize desync in MP. What causes more desync: "Constantly updating marker positions" or "doing lots of math calculations and using great amount of variables"?

1) I think impossible. It seems to be unable to define a marker class in Description.ext.

2) I think that the necessity does not exist. Although it seems to a global variable that it is better to carry out, if a lot of variables are not treated, the influence which it has on performance is small.

3) Probably, there must be a variable specified as isnull at an object type. At the time, it cannot be judged whether "asdasdasd" is an object type. Supposing it uses correctly, In advance, it may be necessary to assign a object type null value. "asdasdasd = objnull".

4) I can't read question intention.

5) It may be good, if the unit movement speed is acquired and you make it reflected in a marker. But, since it will occupy the execution resource of a script more, it may not be so good when moving amount scripts simultaneously.

Share this post


Link to post
Share on other sites
4) I can't read question intention.

Made an example code:

; [this, 2, 1, 0, true, true, 0.5, this distance base < 1000] exec "cross-com\ccps.sqs";

#INITIALIZATION

?(!isServer): exit;

_unit = _this select 0;

_markerType = _this select 1;

_markerSize = _this select 2;

_markerColor = _this select 3;

_markerCondition = _this select 4;

_markerRemoval = _this select 5;

_refreshRate = _this select 6;

_runCondition = _this select 7;

_markerUpdatePos = 1;

_markerUpdateDir = 10;

_markerSizeLeader = 1.5;

_markerRemovalTime = 10;

_conditionDamage = 0.1;

_conditionColorUndamaged = "ColorGreen";

_conditionColorDamaged = "ColorOrange";

_conditionColorDestroyed = "ColorRed";

_counter = 0;

_markerRemovalCounter = 0;

_marker = str(_unit) + "Marker";

createMarker [_marker, position _unit];

_marker setMarkerShape "ICON";

_marker setMarkerSize [_markerSize, _markerSize];

_marker setMarkerDir getDir _unit;

?(_markerType == 2): _marker setMarkerType "x_mortar"; _markerRotation = true;

_markerTypeString = markerType _marker;

#PROGRAM

#LOOP

?(_runCondition): goto "LOOP EXIT";

~_refreshRate

goto "LOOP";

#LOOP EXIT

~_refreshRate

_counter = _counter + 1;

?(_counter > 3): _counter = 1;

_leader = leader _unit;

#MARKER POSITION

?(vehicle _unit == _unit && (markerPos _marker select 0 < ((getPos _unit select 0) - _markerUpdatePos) || markerPos _marker select 0 > ((getPos _unit select 0) + _markerUpdatePos))): _marker setMarkerPos [getPos _unit select 0, markerPos _marker select 1];

?(vehicle _unit == _unit && (markerPos _marker select 1 < ((getPos _unit select 1) - _markerUpdatePos) || markerPos _marker select 1 > ((getPos _unit select 1) + _markerUpdatePos))): _marker setMarkerPos [markerPos _marker select 0, getPos _unit select 1];

#MARKER DIRECTION

?(_markerRotation && vehicle _unit == _unit && (markerDir _marker < getDir _unit - _markerUpdateDir || markerDir _marker > getDir _unit + _markerUpdateDir)): _marker setMarkerDir getDir _unit;

#MARKER TYPE

?(vehicle _unit != _unit && markerType _marker != "Empty"): _marker setMarkerType "Empty";

?(vehicle _unit == _unit && markerType _marker != _markerTypeString): _marker setMarkerType _markerTypeString;

#MARKER SIZE

?(markerSize _marker select 0 == _markerSize && _unit == _leader): _marker setMarkerSize [_markerSize * _markerSizeLeader, _markerSize * _markerSizeLeader];

?(markerSize _marker select 0 != _markerSize && _unit != _leader): _marker setMarkerSize [_markerSize, _markerSize];

#MARKER COLOR

?(_counter == 1 && _markerColor != 0 && alive _unit && markerColor _marker != _markerColorString)): _marker setMarkerColor _markerColorString;

?(_counter == 2 && count crew _unit == 0 && alive _unit): _marker setMarkerColor "ColorBlack";

#MARKER CONDITION

?(_counter == 3 && _markerCondition && !alive _unit && markerColor _marker != _conditionColorDestroyed): _marker setMarkerColor _conditionColorDestroyed; deleteMarker _markerLine;

?(_counter == 3 && _markerCondition && alive _unit && damage _unit >= _conditionDamage && markerColor _marker != _conditionColorDamaged): _marker setMarkerColor _conditionColorDamaged;

?(_counter == 3 && _markerCondition && damage _unit < _conditionDamage && markerColor _marker != _conditionColorUndamaged): _marker setMarkerColor _conditionColorUndamaged;

#MARKER REMOVAL

?(_markerRemoval && !alive _unit): _markerRemovalCounter = _markerRemovalCounter + 1;

?(_markerRemovalCounter == _markerRemovalTime): goto "EXIT";

goto "PROGRAM";

#EXIT ERROR

hint "CCPS.sqs: Arguments incorrect!";

#EXIT

deleteMarker _marker;

exit;

(Removed everything that were not essential).

_runCondition argument is true when player is closer than 1000 meters from object named "base". However, this is checked instantly when the sqs is executed. It means that if the player is further than 1000 meters, script will loop "LOOP" indefinitely, because _runCondition is false. And vice verse: If player was closer than 1000 meters from base it will always update the markers, even if player goes further than 1000 from base. I have planned that it loops until player is closer than 1000 meters from "base", and then starts to update the markers, until player is further than 1000 meters from "base" (And it goes back to loop "LOOP" until player is closer once again). Other uses for this is that if I place radio alpha trigger and put asdasd = true to activation field and asdasd to the last argument of exec, it will loop until radio alpha is activated).

I am poor at describing anything. In paper, in text, in real life. :D

Share this post


Link to post
Share on other sites

It seems that you are making the recognition mistake for a while about script execution :)

The value of an argument is passed only when a script is executed. Those values can be used only as initial value to a script.

Also, "_runCondition" is a local variable. The value of "_runCondition" can be changed only within the script.

A global variable must be used within a script and the value of the variable must be changed by a trigger to change a state from the trigger on mission.

As the example which uses a global variable:

"runCondition" is used instead of "_runCondition".

In the trigger on mission, "runCondition" is used instead of "asdasd".

As a fault , when a script uses a global variable, the flexibility of the script will be lowered.

Edited by Gigan

Share this post


Link to post
Share on other sites

Found a workaround! Man, it took couple of beers and lots of testing different alternatives. :)

_runCondition = _this select 7;

?(call compile format ["%1", _runCondition]): hint "It works!";

[this, 2, 1, 4, true, true, 0.5, "koira distance kissa > 10"] exec "cross-com\ccps.sqs";

When koira is further than 10 meters from kissa, I get message "It works!" (When the if-statement is in program-loop, naturally. Otherwise it will only check the statement once).

Going to publish next version with this feature when I am sober (And fixed all the bugs I have made while being drunk :) ).

EDIT: New version. Edited the first post.

Edited by Gekkibi

Share this post


Link to post
Share on other sites

New version available.

Couple of new features, such as if you use first aid module the marker is blinking orange (if condition feature is switched on) if the unit is in agony.

More features always means more bugs, so keep reporting if the script does/doesn't do something which it is not supposed to do.

The latest version is in the first post. Enjoy.

Share this post


Link to post
Share on other sites

Once again new version is available (Read 1st post).

Added debug-feature and fixed all the bugs I have found (And know how to fix them).

Due to the changes, the execution arguments has been changed. Read the comments to find out how to execute the script this time.

I try my best that unit line -feature is in the next version. Lets hope I can get it to work properly...

Share this post


Link to post
Share on other sites

Included completely new script to the first post.

It creates additional marker to the average position of certain units, and draws a line from each unit to the marker.

In my opinion this is better solution than older marker line -feature. Comments?

Download the test mission and try it out.

Share this post


Link to post
Share on other sites

Question about this script.

Is there a way so I can set this up in this way.

In a mission I'm making the player and group(BLUFOR) have to find a civilian in a build and when they walk up to the civilian there's an action menu option to "Talk to Informant". Then a script runs that gives enemy positions for a certain period of time, then they disappear. But the player can ask for the info as many times as they want.

Can I use this script for that action? I would just like the enemy positions(Just certain groups) to pop up once the action is selected and then the positions would disappear or not be refreshed.

I've tried to implement this but I can't figure out a few things:

- How can I get just the OPFOR positions to display and after a set time not be visible any more? Until you walk back up to the civilian and select the action again.

- Is it possible to get this script to run inside a script? How would this be done, syntax?

I basically have an addaction command added to a trigger that give the "Talk to Informant" action. I want this script that is activated to set an objective to succeed(which I have done) and then show the enemy positions and have the civilian give a little speech. I'm just not sure if it's possible to use this script in that manner.

And help would be appreciated, thanks in advance.

This is a great script pack by the way. Thanks!

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  

×