Home   Help Search Login Register  

Author Topic: Creating new group, got some problems  (Read 2969 times)

0 Members and 1 Guest are viewing this topic.

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Creating new group, got some problems
« on: 10 Oct 2010, 15:28:33 »
Well, I asked at BI Forums, but even with support of those people is not working...
My script looks like that:

Code: [Select]
if (isNil { BIS_fnc_init }) then { waitUntil { !isNil { BIS_fnc_init } } };
_resHQ = createCenter resistance;
 
private ["_squad","_member1","_member2","_member3","_member4","_member5","_banditgroup","_soldier1"];
_squad =
[
    "GUE_Soldier_AR",
    "GUE_Soldier_CO",
    "GUE_Soldier_Crew",
    "GUE_Soldier_GL",
    "GUE_Soldier_Sniper",
    "GUE_Soldier_MG",
    "GUE_Soldier_Medic",
    "GUE_Soldier_Pilot",
    "GUE_Soldier_3",
    "GUE_Soldier_2",
    "GUE_Soldier_1",
    "GUE_Soldier_AT",
    "GUE_Soldier_AA",
    "GUE_Soldier_Sab",
    "GUE_Soldier_Scout",
    "GUE_Commander"
];

_member1 = _squad call BIS_fnc_selectRandom;
_member2 = _squad call BIS_fnc_selectRandom;
_member3 = _squad call BIS_fnc_selectRandom;
_member4 = _squad call BIS_fnc_selectRandom;
_member5 = _squad call BIS_fnc_selectRandom;


_banditgroup = creategroup resistance;
_soldier1= _member2 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf}", 0.5, "corporal"];
_soldier2 = _member2 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf}", 0.5, "corporal"];
_soldier3 = _member3 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf}", 0.6, "corporal"];
_soldier4 = _member4 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf}", 0.5, "corporal"];
_soldier5 = _member5 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf}", 0.5, "corporal"];

hint "works";

I have no idea what to do with this. Let me maybe explain how I want that get started:
For test purpose I simply put Alpha activation trigger, while in On Act field I input
Code: [Select]
test = player execVM "Random_squad.sqf";
This is absolutely impossible to fuck up launch progress of the script. My goal is to create group of 5 people, while unit classes are randomly selected from _squad table. Later unit should be attached to Urban Patrol Script, so no waypoints are important. Also, I tried to test without randomness, simply:

Code: [Select]
"GUE_Commander" createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"loon1 = this ;
 this addweapon {binocular}", 0.6, "corporal"];

As an example here:
http://community.bistudio.com/wiki/createUnit

When I launch the script, I do not receive any debug info via -ShowScriptErrors, but no one is respawning. Just like script is started and then immediately... ignored?
I tried also commands:
http://community.bistudio.com/wiki/createUnit_array
And Riouken's help here:
http://forums.bistudio.com/showpost.php?p=1766506&postcount=8

I am pretty sure that script is started property, I cant see any bugs or errors in it. Can you explain me this?

NOTE: logic_bandit_group1 was everything from marker through game logic ending on a mine, but northing was working.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Creating new group, got some problems
« Reply #1 on: 10 Oct 2010, 16:09:05 »
Have you got your centers set up properly? Try placing down a resistance soldier before starting the script, and see if that helps (since that will automatically create a center) - alternatively use the above command to create a center beforehand, i.e.
Code: [Select]
createCenter resistance;
You obviously have to have the BIS functions module placed on the map as well for your script to work :)

Wolfrug out.

« Last Edit: 10 Oct 2010, 16:50:42 by Worldeater »
"When 900 years YOU reach, look as good you will not!"

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Re: Creating new group, got some problems
« Reply #2 on: 10 Oct 2010, 17:05:51 »


It is awesome that finally someone reminded me to put Functions Module on the map, because I simply use them first time and previously ignored that module...
I knew it is gonna be something ridiculously stupid like this  :confused:

Yes, respawn works fine, now 2 questions:
1. If I put a res unit before launching that script (I mean NAPA troops are on the map already) createCenter command is not required?
2. However that works, I receive info "missing ;", I guess somewhere around here:
Code: [Select]
_soldier1= _member2 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf} ;", 0.5, "corporal"];
And I wonder if:
Code: [Select]
"arming = [this] execVM {random_arm_hl.sqf} ;",That line is placed correctly. How should I run other scripts in this array? Example on BI Wiki is made on .sqs script, so I guess it is little obsolete, isnt it?

PS: Who is exactly leader of newly created team. I just found some bugs with usage of UPS, because (I guess) UPS has problems with proper leader finding.
« Last Edit: 10 Oct 2010, 17:22:34 by SaS TrooP »

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Creating new group, got some problems
« Reply #3 on: 10 Oct 2010, 17:21:23 »
Code: [Select]
"arming = [this] execVM {random_arm_hl.sqf} ;",
I guess the curly bracket usage here is some old school OFP style? Looks like it's not supported anymore. If you change them to single quotes it stops complaining.

Code: [Select]
"arming = [this] execVM 'random_arm_hl.sqf'"
try { return true; } finally { return false; }

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Re: Creating new group, got some problems
« Reply #4 on: 10 Oct 2010, 18:06:06 »
Now works property, thanks again for support!

I guess last question is coming in. I don't have any idea how to do this this time, so if you would be so kind and just input me what should I write. I have randomly selected squad, I have randomly selected weapons in script I exec in init of newly created units. But how I can property define the number of units in group? I have always 5 members, how can change this?

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Creating new group, got some problems
« Reply #5 on: 10 Oct 2010, 18:18:14 »
Hiya!

Glad you got it to work, and yeah, it's often the obvious solution that evades us.

Yep, you don't need to create a center if there is already a unit of the side in question placed on the map.

As to your code, well...there are many and various ways of doing it, but the most immediate and obvious one I can think of is to simply add a condition in front of the spawns. So, say, you want 3-5 units to spawn every time:

Code: [Select]
_soldier1= _member2 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf}", 0.5, "corporal"];
_soldier2 = _member2 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf}", 0.5, "corporal"];
_soldier3 = _member3 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf}", 0.6, "corporal"];
if (random 100 > 50) then {_soldier4 = _member4 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf}", 0.5, "corporal"]};
if (random 100 > 50) then {_soldier5 = _member5 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM {random_arm_hl.sqf}", 0.5, "corporal"]};

As mentioned, veeery simplistic. Basically, there is now a roughly 50% chance for each of the two last soldiers to spawn or not to spawn - the same as if you'd place down a group of 5 soldiers, but give two of them a "50% probability of presence". There's any number of alternatives to this, but I just thought I'd suggest the simplest one first :)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Re: Creating new group, got some problems
« Reply #6 on: 10 Oct 2010, 19:04:29 »
It works property, but only and the last question connected to that script is on my tongue. Problably I lack of typical knowledge here, I mean command:

Trick is that when group is destroyed, in Urban Patrol Script you are able to respawn that group once again, and again and again etc. But group will always consist of number of troops defined in script above. So, when we roll for 5 troops in the squad, group will always respawn with 5 and only 5 people.
My plan is to wait the script until whole _banditgroup bites the dust, then the group will be destroyed via deletegroup command (btw, if ALL units in group are dead, isn't the group being deleted on its own, without deletegroup?).
Anyway, when group is eliminated, I will launch the script once again so _banditgroup will be created again, and their number will be rolled again and again and again...
Problem is similar to this one I had here:
http://www.ofpec.com/forum/index.php?topic=35060.0

But this time I can't afford even 1 trigger, because I need to save as much memory as I can (AFAIK, triggers are more demanding than scripts), so I need to hold the script via WaitUntil command till number of troops in _banditgroup will be exactly 0 or less (well...).
Here is my script at this stage:

Code: [Select]
//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: SaS TrooP
//////////////////////////////////////////////////////////////////


if (isNil { BIS_fnc_init }) then { waitUntil { !isNil { BIS_fnc_init } } };
 
private ["_squad","_member1","_member2","_member3","_member4","_member5","_banditgroup","_soldier1","_soldier2","_soldier3","_soldier4","_soldier5"];
_squad =
[
    "GUE_Soldier_AR",
    "GUE_Soldier_CO",
    "GUE_Soldier_Crew",
    "GUE_Soldier_GL",
    "GUE_Soldier_Sniper",
    "GUE_Soldier_MG",
    "GUE_Soldier_Medic",
    "GUE_Soldier_Pilot",
    "GUE_Soldier_3",
    "GUE_Soldier_2",
    "GUE_Soldier_1",
    "GUE_Soldier_AT",
    "GUE_Soldier_AA",
    "GUE_Soldier_Sab",
    "GUE_Soldier_Scout",
    "GUE_Commander"
];


_member1 = _squad call BIS_fnc_selectRandom;
_member2 = _squad call BIS_fnc_selectRandom;
_member3 = _squad call BIS_fnc_selectRandom;
_member4 = _squad call BIS_fnc_selectRandom;
_member5 = _squad call BIS_fnc_selectRandom;
_member6 = _squad call BIS_fnc_selectRandom;
_member7 = _squad call BIS_fnc_selectRandom;


_banditgroup = creategroup resistance;
_soldier1= _member1 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM 'random_arm_hl.sqf'; nul=[this,'kurwamac'] execVM 'scripts\upsmon.sqf';", 0.5, "SERGEANT"];
_soldier2 = _member2 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM 'random_arm_hl.sqf';", 0.5, "corporal"];
if (random 100 > 50) then {_soldier3 = _member3 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM 'random_arm_hl.sqf';", 0.6, "corporal"]};
if (random 100 > 50) then {_soldier4 = _member4 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM 'random_arm_hl.sqf';", 0.5, "corporal"]};
if (random 100 > 50) then {_soldier5 = _member5 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM 'random_arm_hl.sqf';", 0.5, "corporal"]};
if (random 100 > 50) then {_soldier6 = _member6 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM 'random_arm_hl.sqf';", 0.5, "corporal"]};
if (random 100 > 50) then {_soldier7 = _member7 createUnit [getMarkerPos "logic_bandit_group1", _banditgroup,"arming = [this] execVM 'random_arm_hl.sqf';", 0.5, "corporal"]};

hint "works";

sleep 3;
waitUntil {
    (not alive _member1) and (not alive _member2) and (not alive _member3) and (not alive _member4) and (not alive _member5) and (not alive _member6) and (not alive _member7);
    };

hint "dead, rspwn";

deletegroup _banditgroup;
hint "clear, srspwn in 10 sec";
sleep 10;
test = player execVM "random_squad.sqf";

Notice that:
Code: [Select]
waitUntil {
    (not alive _member1) and (not alive _member2) and (not alive _member3) and (not alive _member4) and (not alive _member5) and (not alive _member6) and (not alive _member7);
    };

Is not working. I guess you cant operate with alive command on variables, just on var names. I also guess creating varnames for this lads is not really important.
Can you just tell me if there is better way to define this condition?
I tried to operate varous ways with line:
Code: [Select]
{alive _x} count units thisList < 60
In ways like:
Code: [Select]
{alive _x} count units _banditgroup == 0;
Code: [Select]
count units _banditgroup == 0;
Without success.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Creating new group, got some problems
« Reply #7 on: 11 Oct 2010, 10:46:37 »
Hmm. The line:

Code: [Select]
{alive _x} count units _banditgroup < 1
SHOULD work fine in a waitUntil like that (although you could probably place a sleep in there if you want to make it less taxing, e.g.:
Code: [Select]
waitUntil {sleep 1;{alive _x} count units _banditgroup < 1};
There's really no reason why this wouldn't work. Why don't you try making sure that _banditgroup is properly populated first:

Code: [Select]
hint str (units _banditgroup);
If it returns an array of units, there's no way the alive _X code wouldn't work :)

Edited because Worldeater keeps criticising my code!

Wolfrug out.
« Last Edit: 11 Oct 2010, 11:52:45 by Wolfrug »
"When 900 years YOU reach, look as good you will not!"

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Re: Creating new group, got some problems
« Reply #8 on: 11 Oct 2010, 16:56:57 »
EDIT:

I think I nearly got it working. Take a look at the script now!

I have managed to remove some units randomly, so group is in fact randomly numbered. But I dont consider that solution as best I could create. I need to save as much memory as I can, so there is any other way to define _troop values without respawning whole group?

I tried to do eg.:

Code: [Select]
if !(_troop3 in _company) then {_troop3 = _company select 0};
But it wasnt working. Any ideas?
« Last Edit: 12 Oct 2010, 21:00:05 by SaS TrooP »