Home   Help Search Login Register  

Author Topic: transfer or change locality of units  (Read 1732 times)

0 Members and 1 Guest are viewing this topic.

Offline takbal

  • Members
  • *
transfer or change locality of units
« on: 08 Aug 2009, 02:32:57 »
I am struggling with a problem where I should execute a script on some of the player's AI team members. The script works correctly only on objects which are local to the (dedicated) server. It is possible to remove the units from the player group temporarily, but they should be added back later when the script finishes (it is actually BIS's arty module).

Is there a way to directly change locality between clients and the server?

What I tried is to use "join", as the BIS wiki explicitly says that join can change the locality. The wiki also states that AI teams with a server-running AI leader are local to the server. So I tried to

1. create a group on the server,
2. add a "dummy" leader to it which was created on the server,
3. pass the group to the client which executes the join on the members of the team (BIS wiki says join should be executed on the machine where the objects are local),
4. pass the control back to the server which is then executes the script,
5. after finish, issue join to player's group on the server to give them back,
6. cleanup (delete dummy leader and group).

Although it executes without errors, the client's join does not look like to move the team members out of its own group, and they stay remote on the server.

Variations:

- If I issue createGroup on the client, "join" removes units from the player's team. (Shouldn't createGroup's effect be global?) However, the leader is the first added unit, so the group stays remote when I pass it to the server.
- Tried to move out - readd team members (empty vehicles should be local to the server) but did not work.
- Tried to use attachTo to change locality, but it did not work.

Have not gone through all the options I have in mind yet, but maybe somebody can speed up this search... and the answer can be useful for others as well.

///////////////////////////////////////////////

UPDATE: I had a bug in my code, forgot to PV back the group ID to the client. Now it works, so I can confirm that join can be used in this way to directly change the locality. However, if the AI is inside a vehicle, join looks like to have on effect only if issued on the *vehicle* the AI is sitting in, and for some reason even that time it does not transfer the driver, only the gunner. But if I join the driver separately after the vehicle was transferred, it works fine. I dod not tried with vehicles of more crew than 2.
« Last Edit: 10 Aug 2009, 02:33:03 by takbal »

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: transfer or change locality of units
« Reply #1 on: 08 Aug 2009, 18:42:21 »
Uhm, how about running the script where the unit is local?
try { return true; } finally { return false; }

Offline takbal

  • Members
  • *
Re: transfer or change locality of units
« Reply #2 on: 09 Aug 2009, 01:12:53 »
It is BIS's ARTY_ExecuteMission.sqf which starts with ExitWith{} if not server. I can remove that but most probably there is a reason for this. I did not follow through why it is important.

///// Join works; updated the initial post.
« Last Edit: 10 Aug 2009, 02:33:39 by takbal »

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re: transfer or change locality of units
« Reply #3 on: 12 Aug 2009, 11:48:58 »
I think I see your point here. The mortars (or whatever you are using) cannot conduct a scripted fire mission if they stay under player control, right?

Have you tried to join them to the Arty module itself? It has a SIDE and since it's been present on the map since mission start it's bound to be recognized by the server. Untested but maybe worth trying.

Forgive me if I misunderstood your problem.
OFPEC | Intel Depot
RETARDED Ooops... Retired!