Home   Help Search Login Register  

Author Topic: Tracking script problems ?  (Read 1566 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Tracking script problems ?
« on: 12 Oct 2009, 23:58:44 »
I have a script that should make a "hunting group" track units from a certain group (players group).

An editor placed trigger is setup that is counting the units in the players group.

Any group member present, Repeatedly - grouped with the leader of players group.
Condition: this
on Activation: preylist = thislist


Then this script (run from leader of hunting group):
Code: [Select]
? ! isServer : exit

_trackleader = _this select 0
_trackers = group _trackleader

#choice

_preyNum =  count preyList
_preyChoice = floor random _preyNum
_chosenPrey = preyList select _preyChoice


#trackloop

_trackers move getpos _chosenPrey

@ unitReady leader _trackers

~ 1

if (! (alive _chosenPrey)) then {goto "choice"} else {goto "trackloop"}

The script is supposed to choose a random member from the group (preylist), hunt it down, and when that unit is dead choose another random (still alive) group member to hunt, and so on.

Problem: At least on a dedi the tracking group sometimes stops and don't continue tracking.

Can anyone find the mistake?

I have doubts about the trigger and how the scripts chooses a prey.

Any better solutions to choose a random and alive group member, that you know?

Cheers all of you,

Laggy
« Last Edit: 13 Oct 2009, 00:02:47 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Tracking script problems ?
« Reply #1 on: 13 Oct 2009, 02:46:26 »
The @ checks for the condition every frame so I assume that it would time-out while they are moving about. I don't know how that affects the script.

Here's my my version of your script (sry I'm not comfortable with sqs):

Code: (tracking.sqf) [Select]
if(!isServer) exitWith{};
private ["_trackleader", "_trackers", "_dist", "_chosenPrey", "_waypoint1"];
_trackleader = _this select 0;
_trackers = group _trackleader;

_dist=0;
{if((side _x == west) && (alive _x)) then {if((_x distance _trackleader) > _dist) then {_chosenPrey=_x; dist=(_x distance _trackleader);};};} forEach playableUnits;

_waypoint1 = _trackers addwaypoint[getpos _chosenPrey,0];
_waypoint1 setwaypointtype "MOVE";
_waypoint1 setWaypointBehaviour "AWARE";
_waypoint1 setWaypointFormation "LINE";
call compile format["_waypoint1 setWaypointStatements ['true', 'Nul = %1 execVM ""tracking.sqf""'];",_trackleader];
« Last Edit: 13 Oct 2009, 03:27:47 by tcp »

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Tracking script problems ?
« Reply #2 on: 13 Oct 2009, 17:05:02 »
Thanks mate  :good:

I'm still way too comfortable with .sqs  :-[

A couple of questions:

In your script the _trackers move to the playable unit that is the furthest away, right?
Code: [Select]
{if((side _x == west) && (alive _x)) then {if((_x distance _trackleader) > _dist) then {_chosenPrey=_x; dist=(_x distance _trackleader);};};} forEach playableUnits;
If I want the _trackers to hunt the nearest:
Code: [Select]
{if((side _x == west) && (alive _x)) then {if((_x distance _trackleader) < _dist) then {_chosenPrey=_x; dist=(_x distance _trackleader);};};} forEach playableUnits;

Or am I wrong about this?

I like how this script doesn't incorporate a trigger (my preylist), and I guess I could just exchange "forEach playableUnits" with "forEach heroes" (heroes is the name of my hunted group).

Have you tried this on a dedi?

Cheers and thanks again, really appreciate your help.

Laggy

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Tracking script problems ?
« Reply #3 on: 13 Oct 2009, 18:17:11 »
You're right, I just wrote the code without checking it too much.
If you send me a test version, I can try it out on my dedicated server.
If you go to my website listed in my profile, there's Development forums where you can post and attach your mission and get some help testing it.

Also, make it: forEach units heroes;
« Last Edit: 13 Oct 2009, 19:15:26 by tcp »