Forum Jump :

Author Message


Posts: 4
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2015-10-28 09:10        
     
As is the norm with people who are new to the more advanced side of editing "I have an issue and have looked everywhere to solve it, blah, blah, blah...".

(I apologise if any of my terminology is incorrect but I hope you understand what I mean).

I am trying to create a small 4-player COOP mission for my first attempt at making a high-quality mission. Everything is running smoothly so far. My current problem is that I want to have conversations between the players and the friendly AI Command unit (named "Archway").

I am looking at BIKB way of doing chat because it seems simpler in the long term however it requires a named unit to be referenced in the script which is as simple as naming the unit. My problem is that there are 4 playable slots, not all may be occupied, I don't want AI group members, and if the current group leader (named "Kobold") is killed or is an unfilled player slot at launch how can the new group leader inherit the unit name to allow AI radio messages to the group?

I am extremely new to this but I have been doing my homework. Possible ideas I've had to solve it include:

Placing an AI group member, naming it "Kobold", set the probability of presence to 0 OR set condition of presence to False. (I don't know if scripting will reference non-existent units or whether only the non-existent unit will receive radio messages)

Placing a game logic named "Kobold", grouping all playable group members to the game logic unit. (I don't know if game logic counts a a placeable unit in the traditional sense)

Creating a script to somehow rename the current group leader and, if killed or not present at mission launch, rename the newly elected team leader as "Kobold". (Only have a basic knowledge of scripting and I am unsure what commands will allow me to do this. setUnitName? How will the script know what group I want to rename the leader of without setGroupId?

Setting a GroupId as "Kobold" but am unsure how to reference it in place of a unit name in the script. (setGroupId wants to reference a named unit withing the group [ *playableUnit* setGroupId "Kobold" ] but I can't guarantee that the unit I have given the INIT to will even be present at mission launch)

Some other external script... (But I still need to reference in-game named units for that to work)


I don't know if I'm barking up the wrong tree or how to even implement my ideas if I am correct. I just need a way of getting radio messages to all of the playable group with any player slot possibly not being occupied.

Thank you for any help or links to similar forum threads.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#2 Posted at 2015-10-28 09:37        
     
My current problem is that I want to have conversations between the players and the friendly AI Command unit (named "Archway").
You can set a callsign Archway to your HQ with a module in editor. Simple and efficient. But you can't have true "conversation" with players and AI HQ. You can only trigger sentences (with little variant if you want) when a player reaches a condition. Player's name are their profile ones. You can setname AI https://community.bistudio.com/wiki/setName in SP mission but in MP you must broadcast this with a remoteExec command. If you don't know what it is, have a look at: https://community.bistudio.com/wiki/remoteExec . You can't script MP mission if you don't understand locality in MP, owners and other fabulous stuffs. After that, you could globalChat, sideChat and so on.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 4
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2015-10-28 10:31        
     
Thank you Pierre MGI, I'll give it another try when I get home from work.

Is there anywhere that I can learn about Locality of MP missions? I understand vaguely that it's about some functions happening on the host's computer and others happening on the individual players' computer.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#4 Posted at 2015-10-28 17:34        
     
Almost all commands and functions are impacted with their arguments (local or global) and their effects (local or global)
see:
http://killzonekid.com/arma-scripting-tutorials-locality/
https://community.bistudio.com/wiki/Locality_in_Multiplayer
https://community.bistudio.com/wiki/6thSense.eu:EG#Locality
https://community.bistudio.com/wiki/Multiplayer_framework
https://community.bistudio.com/wiki/Arma_3_Remote_Execution

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 22
In-game name: Wak

 
#5 Posted at 2015-10-28 19:04        
     
As far as I get this, you need the group leader of a group at any time from any computer right?

You don't have to name any units in the editor, there are tons of other ways to refer to the group leader.
//Picked the first player from the list of all players.
_unit = allPlayers select 0;

//The group leader of that player has to be the leader we're looking for.
_leader = leader _unit;
//Because this is really small a COOP mission, there's only a single group with players.

//Now you can use "_leader" anywhere for chat
_leader groupChat "Let's roll out!";

Also don't think of locality as functions that run on the host computer and client computers. There are also dedicated servers and headless clients, it get's really weird at a point, you should read what Pierre posted (In that order too). Except "Multiplayer framework", that page has outdated a lot.

This post was edited by 654wak654 (2015-10-28 23:35, ago)

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 4
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#6 Posted at 2015-10-28 23:14        
     
Kettle is boiling and it looks like I have something to read with my cup of tea.

Thank you Pierre MGI for the links. I enjoy learning how to do something myself rather than constantly asking.

Also, many thanks to you 654wak654. I'm just about to give it a test now and see how it runs.

Cheers Guys


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#7 Posted at 2015-10-29 00:03        
     
And, by the way, if you want a player to be leader anytime, at any place in the group !-)

//In SP with switchable units:
0= [] spawn {while {!isMultiplayer} do {
   private "_unit_sel";
   for "_i" from 0 to (count switchableUnits - 1) do {
      _unit_sel = (switchableUnits select _i);
     call {
        if (isplayer (_unit_sel) && alive (_unit_sel)) exitWith {
          if (_unit_sel getVariable ["switched_unit",false]) exitWith {};
          if (_unit_sel != leader (group _unit_sel)) then {(group _unit_sel) selectLeader _unit_sel; {_x dofollow _unit_sel} forEach units (group _unit_sel);
          _unit_sel setVariable ["switched_unit", true]};
          };
        if (alive _unit_sel && (_unit_sel getVariable ["switched_unit",false])) exitWith {  _unit_sel setVariable ["switched_unit", false]};
        _unit_sel setVariable ["switched_unit", false];
     };
   };
   sleep 2;
 };
};

// in MP, to be sure a player is leader of his group (AI inside), first JIP first served
if (!isServer) exitWith {};
if (!isPlayer leader (group player)) then {for "_i" from 0 to (count units (group player)) -1 do {
   if (isPlayer ((units group player) select _i)) exitwith {[(group player), (units group player) select _i] remoteExec ["selectLeader", groupOwner (group player)]}}};

See selectLeader on BIKI to uderstand this code;

This post was edited by Pierre MGI (2015-10-29 00:11, ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 22
In-game name: Wak

 
#8 Posted at 2015-10-29 09:08        
     
Pierre how about this code for multiplayer? Does the same.
if (!isServer) exitWith {};
_player = allPlayers select 0;
if (!isPlayer leader _player) then {
	{
		if (isPlayer _x) exitWith {
			[group _x, _x] remoteExec ["selectLeader", groupOwner (group _x)];
		};
	} forEach units _player;
};

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#9 Posted at 2015-10-29 15:41        
     
Nice! I forgot objects like _player are OK for leader and units.

This post was edited by Pierre MGI (2015-10-29 15:56, ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 4
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#10 Posted at 2015-11-02 20:43        
     
I just gave your example a try 654wak654 but I'm having a bit of trouble.

# 654wak654 :
You don't have to name any units in the editor, there are tons of other ways to refer to the group leader.
//Picked the first player from the list of all players.
_unit = allPlayers select 0;

//The group leader of that player has to be the leader we're looking for.
_leader = leader _unit;
//Because this is really small a COOP mission, there's only a single group with players.

//Now you can use "_leader" anywhere for chat
_leader groupChat "Let's roll out!";


Where am I meant to type these lines?

I put the first two in the init.sqf in the mission folder to tell the game at launch that *THIS* guy is the group leader. The third line I put in the 'on trigger activation' window of a placed trigger when any member of group is present within its radius. The trigger keeps throwing a tantrum and tells me that there is a "Local variable in Global space".
Am I simply typing this in the wrong place or do I need to change it somehow to become a global command?


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#11 Posted at 2015-11-02 21:05        
     
TamedFury, Wak gave you code to write in init.sqf or any script which runs at start. As _unit and _leader are local variables, you can't split the lines, spreading in multiple scopes (sqf, trigger or else).
Local variables need to stay in a local script, in order to refer to the same thing or return a consistent value.
You can place all the lines in a trigger but, as remembered every week on this forum, you need to execVM an sqf or wrap code in a scheduled event like this 0 = [] spawn {all code you want here}; in on act field of the trigger.

local or global? Each time you can script in local (here is the case) script in local. You can the use _unit in different scripts, for different contexts, avoiding overwriting.
Use global variables each time you want to declare something for all the scripts fired on your PC. That's true for all "name" you write in object editor. Example CAR1 in a Hunter edited object is a variable which refer to this object (even if dead) for all the game.
Furthermore, if you script for MP, have a look at publicVariable. This command, not simple to manage, allows you to share a variable on every PCs (It's not always the case for global ones! JIP issue).

This post was edited by Pierre MGI (2015-11-02 21:13, ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 22
In-game name: Wak

 
#12 Posted at 2015-11-02 21:41        
     
Should clarify, by "you can use it anywhere" I meant "You can use it anywhere in this script". When there is a underscore in front of a variable name it means it's local to it's scope (Pierre explained it, I'm not going to go too much in). You can remove the underscore and change the second statement in to a global variable:
groupLead = leader _unit;

That way you whould be able to use groupLead in a trigger, or anywhere else.
groupLead groupChat "Let's roll out!";

Be careful though, if the trigger is triggered before init.sqf (if players start inside the trigger etc.) it might not work, and will probably print an error in the logs.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage





Tags: Group, Scripting, Talk