OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Barbolani on 06 Feb 2008, 21:10:28
-
Hi all,
Im trying to make a script that allows to control various squads just controlling only the squad leaders (having them on the players group). The objective is:
- Have updated info of enemies to call support (thats why the leader of the other squads is on the players group)
- non-controlled-squads follow the controlled-squad-leader (DONE with a domove from time to time)
- controlled-squad-leader shares info with the non-controlled-squad (PROBLEM)
- when controlled-squad-leader dies, the non-controlled-squad leader joins my group, and the non-controlled-squad follows him from that moment (DONE)
- when all the non-controlled-squad die they respawn (I HAVENT DONDE THIS YET, BUT SEEMS EASY)
- IMPORTANT: The enemies will respawn, so Im trying to make the infoshare without triggers
Well. This is what i have now:
_ctrleader = _this select 0
_noctrlgroup = _this select 1
_noctrleader = leader _noctrlgroup
#Update0
_enemigos = _ctrleader neartargets 500
_noctrlgroup move getpos _ctrleader
_noctrlgroup reveal _enemigos
? not (alive (_ctrleader)) : goto "Update2"
? west countSide (units _noctrlgroup) < 1 : goto "Update1"
~5
goto "Update0"
#Update1
hint "group dead, here should be the respawn script"
~5
#Update2
hint "leader died"
[_noctrleader] join group player
_ctrleader = _noctrleader
_noctrleader = leader _noctrlgroup
goto "Update0"
I think the problem is my use o the "reveal" command, but as far as i see, this forum and the COMREF doesent use the reval command in this sense..
Plz scripting gurus, help me
Thnx in advance.
-
A problem spotted with the reveal command:
Reveal works only between two units (unit1 reveal unit2), so having one group reveal another array won't work. However, if the leader of a group is aware of any unit, the whole group is, so using ((leader _group) reveal _unit2) should work.
Problem with nearTargets is more complicated:
If you check the array you get out of nearTargets (using a hint format for instance) will give you something like this: [[[2555.33,2535.33,1.32708],"SoldierEB",EAST,214222,EAST 1-1-A:1],[[2550.39,2482.5,1.32696],"SoldierWB",WEST,0,WEST 1-1-A:2]]
What these different parts mean is explained in the comref, but basically the command return is considerably more complicated than just a list of units. Furthermore, it returns both empty and static targets, as well as friendly or neutral ones. So not even solely enemies. What you need to do is filter the information you want (=the unfriendly units themselves) from the nested arrays, which will require a bit of setting up. Apparently, the "object" itself is the 5th element of the nested array. So, let's see:
(untested example)
//get list of targets
_list = _unit nearTargets 500;
//count initial array
_count1 = count _list;
_list2 = [];
//create new array which picks out the 5th element (_list select 4) of _list
for "_i" from 0 to (_count1 - 1) do
{
_cursel = _list select _i;
_list2 = _list2 + [_cursel select 4];
};
//reveal entire content of _list2 to _unit & give hint as to list's contents
{_unit reveal _x} forEach _list2;
hint format ["List 2: %1", _list2];
The above is in .sqf of course, and would pick up friendly and neutral and semi-unknown objects as well (i.e., you know how sometimes your men cry out "man, at, 6 o'clock!" and it turns out to just be some random farmer/a guy from the other team. Or how targets pop up as "Unknown" when in a chopper turn out to be "Shilka" once you get closer - those would all now be revealed).
Might work, might not. Food for thought though!
Wolfrug out.
-
aaaagggggg... sqf!!! Im allergic....
As allways Wolfrug is there to help.
Ok, so, Neartargets discarded... too messy... the next thing could be a moveable trigger.... agggggggg .... createtrigger... ok, let me guess:
_ctrleader = _this select 0
_noctrlgroup = _this select 1
_noctrleader = leader _noctrlgroup
_trigger = createTrigger ["EmptyDetector", getPos _ctrleader]
_trigger setTriggerActivation ["EAST", "PRESENT", true]
_trigger setTriggerArea [500, 500, 0, false]
_trigger setTriggerType "NONE"
_trigger setTriggerStatements ["this", "", ""]
_trigger setTriggerTimeout [0, 0, 0, false ]
#Update0
_noctrlgroup move getpos _ctrleader
_trigger setPos getPos _ctrleader
~1
{_ctrleader reveal _x} forEach list _trigger
? not (alive (_ctrleader)) : goto "Update2"
? west countSide (units _noctrlgroup) < 1 : goto "Update1"
~4
goto "Update0"
#Update1
hint "group dead, here should be the respawn script"
~5
#Update2
hint "leader died"
[_noctrleader] join group player
_ctrleader = _noctrleader
_noctrleader = leader _noctrlgroup
goto "Update0"
exit
AAAAGGGGG doesent work... I havent any error msg, but the units are not revealed....
P.D: Maybe changing "_trigger setTriggerStatements ["this", "", ""]" by "_trigger setTriggerStatements ["thislist", "", ""]"??????
-
I looked at your trigger-creation code and, frankly, I see no reason why that wouldn't work. :dunno: Triggers need about a second or so after being created before their lists work, but you've got that going for you. :(
How about you remove all the unnecessary parts though, since you won't be needing those (and they might for some reason confuse it...I don't know). The only ones you'll need, IMHO, are: createTrigger, setTriggerArea, setTriggerActivation and possible setTriggerStatements.
Also, I suggest you put in some hints that checks if the trigger has actually been activated: say, in the statements, write something like
_trigger setTriggerStatements ["this", "hint format [""Units in trigger area: %1"", thisList]", ""]
And see if you get a hint with a "thisList" in it. :) If not, there might be something wrong with your calling of the script, or...something else. Usually, most script-problems can be solved simply by adding hints everywhere and checking to see if your variables are actually working :D
Try it!
Wolfrug out.
-
Why not move an existing trigger to the correct location and see if that works?
-
Hiya, good morning for all!
Wolfrug, tested that, effectively the trigger detects tha units, and the hint reports it, but the enemy units still doesent get revealed.
Anyway, after lots of testing Ive spotted another problem with the domove command. Sometimes the units get stucked far far away of the controlled-squad-commander, and they tend to move like "walk 5 meters-stop-walk 5 meters".... I donno why.
Im starting to think on changing the way to do this: Maybe I`ll just move the non-controlled-groups with a radio command and a domove on map single click.... The spotting enemies issue could be solved creating markers....