Nielsen 10 Posted July 12, 2010 (edited) I've been browsing the forums for a "follow solution" that suit my needs, but to no avail. I hope some of you will share some insight. What I am trying to accomplish is this: I want to spawn a group of hostile civilians within a certain radius, and have them follow the playergroup within a certain area, at a set distance, while throwing rocks at them. I spawn the civilians in an 'east' group, and give them 'throw-weapon' and rocks. This works. They throw rocks en masse. They cant hit for sh!t, but I can live with that :p. The problem is, that I want them to follow BLUEFOR. Idealy they would follow whatever player was closest to them, but my scripting skills limit me to have them follow 'player1' atm. The problem is: I need them to follow but keep their distance. If i use 'doFollow' or just make them attack, they rush to my position - getting right up in my face - but not throwing rocks as they are too close. For some reason I'm having a really hard time figuring out a solution that works. I thought I had it figured out. I made the script (look below) such that the group is given a waypoint that never completes, and then do a loop that moves the waypointPos to my position +20m on the x-axis, and then sleeps 15, so they have time to throw some rocks. This kinda worked. If I stood still until the group was fully spawned and had reached their waypoint, they would continue to follow me at 20m. But if I was in motion while the script ran, then they would gather at the first waypoint, and never move from there. This is obviously not a viable solution. In addition, now it suddenly does not work. They dont follow me at all, even though I havent changed anything I can think of. This is my script: angryCivTest.sqf: //Virker kun ordentligt hvis man venter på at gruppen får samlet sig før man løber. hint "script started"; sleep 2; //sleep (240 + (random 120)); if (DangerZone) then { [nil,nil,rHINT,"Some of the locals are getting agitated. Stay alert."] call RE; } else { if(true) exitWith {}; }; sleep 2; //sleep (120 + (random 120)); if (DangerZone) then { _grp = createGroup east;sleep 0.05; _unit = _grp createUnit ["TK_INS_Soldier_5_EP1", getPos player1, [], 50, "NONE"];sleep 0.05; [_unit] join _grp; _unit2 = _grp createUnit ["TK_CIV_Takistani04_EP1", getPos player1, [], 50, "NONE"];sleep 0.05; [_unit2] join _grp; _unit3 = _grp createUnit ["TK_CIV_Takistani04_EP1", getPos player1, [], 50, "NONE"];sleep 0.05; [_unit3] join _grp; _unit4 = _grp createUnit ["TK_CIV_Takistani02_EP1", getPos player1, [], 50, "NONE"];sleep 0.05; [_unit4] join _grp; _unit5 = _grp createUnit ["TK_CIV_Takistani05_EP1", getPos player1, [], 50, "NONE"];sleep 0.05; [_unit5] join _grp; _unit6 = _grp createUnit ["TK_CIV_Takistani01_EP1", getPos player1, [], 50, "NONE"];sleep 0.05; [_unit6] join _grp; _unit7 = _grp createUnit ["TK_CIV_Takistani06_EP1", getPos player1, [], 50, "NONE"];sleep 0.05; [_unit7] join _grp; _unit8 = _grp createUnit ["TK_CIV_Worker02_EP1", getPos player1, [], 50, "NONE"];sleep 0.05; [_unit8] join _grp; _unit9 = _grp createUnit ["TK_CIV_Worker01_EP1", getPos player1, [], 50, "NONE"];sleep 0.05; [_unit9] join _grp; hint format ["group is: %1",_grp]; { _x setVehicleInit "this addEventHandler [""killed"", {civkilled = civkilled + 1; PublicVariable ""civkilled"";}];"; removeAllWeapons _x; _x addWeapon "throw"; _x addMagazine "HandGrenade_Stone"; _x addMagazine "HandGrenade_Stone"; _x addMagazine "HandGrenade_Stone"; _x addMagazine "HandGrenade_Stone"; _x addMagazine "HandGrenade_Stone"; _x setMimic "Angry"; _x setUnitPos "UP"; } forEach units _grp; sleep 0.05; processInitCommands; _grp setBehaviour "COMBAT"; _grp setCombatMode "RED"; _grp setSpeedMode "FULL"; _waypoint = _grp addWaypoint [[((getpos player1 select 0) + 10),((getpos player1 select 1) + 10),2], 0];sleep 0.05; [_grp, 1] setWaypointType "SAD"; //[_grp, 1] setWaypointFormation "LINE"; [_grp, 1] setWaypointStatements ["targetcheck", ""]; while {DangerZone} do { [_grp, 1] setWaypointPosition [[((getpos player1 select 0) + 20),getpos player1 select 1,2], 0]; //_waypoint = _grp addWaypoint [[((getpos player1 select 0) + 20),getpos player1 select 1,2], 0];sleep 0.05; //nul = _grp addWaypoint [[((getpos player1 select 0) + 20),getpos player1 select 1,2], 0]; { _x addMagazine "HandGrenade_Stone"; _x addMagazine "HandGrenade_Stone"; _x addMagazine "HandGrenade_Stone"; _x doTarget player1; _x doFire player1; } forEach units _grp; sleep 15; }; } else { if(true) exitWith {}; }; hint "script done"; Note: The 'DangerZone' variable is set to true/false in a repeated trigger. The 'targetcheck' condition in the waypoint is just to block it from completing, so I dont have to create new waypoints but can just move the active one. I have tried a solution I found in another thread with a 'doFollow.sqf' function. But that does not seem to work for me. Also, as mentioned, I dont want them to rush my position, but stay at a distance. A couple of things. Firstly the OPFOR groupleader does not seem to appear. I do not know why, but apperantly he does not spawn. The civilians spawn though, and they are indeed hostile, as they are throwing rocks at me, which is why I spawned an OPFOR leader in the first place, so I'd rather keep it that way. I dont know why he does not appear though. Secondly, the '_x setUnitPos "UP";' does not seem to work either. But that is also not a great concern. I've played around with various combat/behaviour modes with no effect. I put in a hint to check the WPPos, and it seems that the waypoint do get updated on every loop, the civilians just dont move to the waypoint. Also, they seem a little shaky, almost as if they want to move but cant. They kinda twitch (for lack of a better word) around. I would really appreciate any thougts on the matter. Regards, Nielsen Edited July 12, 2010 by Nielsen addition Share this post Link to post Share on other sites
kylania 568 Posted July 12, 2010 Just use attachTo! heh Share this post Link to post Share on other sites
Nielsen 10 Posted July 12, 2010 I would prefer something a little more aesthetic ;) Share this post Link to post Share on other sites