Jump to content
Sign in to follow this  
ICE - RIDDICK

Having trouble with a unit script Im trying to change up

Recommended Posts

Im trying to change up the pre defined weapons that these AI spawn with. and change it to what I have here.

//Anti Vehicle
_leader = _group createunit ["Soldier_AA_PMC", [(_pos select 0) + 10, _pos select 1, 0], [], 0.5, "Form"];
_leader removeAllWeapons_x;
_leader addMagazine "SMAW_HEAA";
_leader addMagazine "SMAW_HEAA";
_leader addWeapon "SMAW";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addWeapon "M4A1_AIM_CAMO";

//Support
_man2 = _group createunit ["Soldier_GL_PMC", [(_pos select 0) - 30, _pos select 1, 0], [], 0.5, "Form"];
_man2 removeAllWeapons_x;
_man2 addMagazine "100Rnd_556x45_BetaCMag";
_man2 addMagazine "100Rnd_556x45_BetaCMag";
_man2 addWeapon "MG36";

I have 4 ai spawning with what Im doing. This is only the first 2 of the group. the problem is that as the code sits only 1 AI spawns in and he still has his default weapon load out and not what Im trying to change it to. I am new to the scripiting thing and I have googled this to death. Any ideas, Thanks

Share this post


Link to post
Share on other sites

removeallweapons _leader is the correct syntax. It should work if you change that, as I don't see any other errors. To be sure, double check your magazine and weapon names here

Share this post


Link to post
Share on other sites

So it should be like this? Also is there away to keep them from killing each other when the mission spawns in?

//Anti Vehicle
_leader = _group createunit ["Soldier_AA_PMC", [(_pos select 0) + 10, _pos select 1, 0], [], 0.5, "Form"];
removeAllWeapons_leader;  <------------like that
_leader addMagazine "SMAW_HEAA";
_leader addMagazine "SMAW_HEAA";
_leader addWeapon "SMAW";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addWeapon "M4A1_AIM_CAMO";

//Support
_man2 = _group createunit ["Soldier_GL_PMC", [(_pos select 0) - 30, _pos select 1, 0], [], 0.5, "Form"];
removeAllWeapons_man2;   <----------------like that
_man2 addMagazine "100Rnd_556x45_BetaCMag";
_man2 addMagazine "100Rnd_556x45_BetaCMag";
_man2 addWeapon "MG36";

Share this post


Link to post
Share on other sites

removeallweapons _leader;

Notice the space between. Also they shouldn't be killing eachother since they're in the same group. Did you define _group previously in your script? PMC's side is resistance, so you should define _group like this:

_rescenter = createCenter RESISTANCE; // If you have no other resistance units (PMC, TK, UN CDF) on the map, this is required for createGroup to work
_group = createGroup RESISTANCE;

You don't need to use capslock actually, I'm just used to that.

Share this post


Link to post
Share on other sites

This is what the entire smallgroup.sqf file looks like. It for wasteland server mod, Random missions, Sorry to sound like a Idiot but really struggling with the coding and understanding were it all goes.

//	@file Version: 1.0
//	@file Name: smallGroup.sqf
//	@file Author: [404] Deadbeat
//	@file Created: 08/12/2012 21:58
//	@file Args:

if(!X_Server) exitWith {};

private ["_group","_pos","_leader","_man2","_man3","_man4"];

_group = _this select 0;
_pos = _this select 1;

//Anti Vehicle
_leader = _group createunit ["Soldier_AA_PMC", [(_pos select 0) + 10, _pos select 1, 0], [], 0.5, "Form"];
removeallweapons _leader;
_leader addMagazine "SMAW_HEAA";
_leader addMagazine "SMAW_HEAA";
_leader addWeapon "SMAW";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addWeapon "M4A1_AIM_CAMO";

//Support
_man2 = _group createunit ["Soldier_GL_PMC", [(_pos select 0) - 30, _pos select 1, 0], [], 0.5, "Form"];
removeremoveallweaponseapons _man2;
_man2 addMagazine "100Rnd_556x45_BetaCMag";
_man2 addMagazine "100Rnd_556x45_BetaCMag";
_man2 addWeapon "MG36";

//Rifleman
_man3 = _group createunit ["Soldier_M4A3_PMC", [_pos select 0, (_pos select 1) + 30, 0], [], 0.5, "Form"];
removeallweapons _man3;
_man3 addMagazine "30Rnd_556x45_Stanag";
_man3 addMagazine "30Rnd_556x45_Stanag";
_man3 addMagazine "30Rnd_556x45_Stanag";
_man3 addMagazine "1Rnd_HE_M203";
_man3 addMagazine "1Rnd_HE_M203";
_man3 addMagazine "1Rnd_HE_M203";
_man3 addWeapon "M4A1_HWS_GL_CAMO";

//Sniper
_man4 = _group createunit ["Soldier_Sniper_PMC", [_pos select 0, (_pos select 1) - 30, 0], [], 0.5, "Form"];
removeallweapons _man4;
_man4 addMagazine "30Rnd_556x45_Stanag";
_man4 addMagazine "30Rnd_556x45_Stanag";
_man4 addMagazine "30Rnd_556x45_Stanag";
_man4 addWeapon "M4SPR ";

_leader = leader _group;
_man1 setVehicleInit "null = [group this,(getPos this)] execVM 'server\functions\defendArea.sqf'";
processInitCommands;

Edited by dknight903

Share this post


Link to post
Share on other sites

Are you passing anything to the script when executing it? Since you execute it like this: nul = [group,position] execVM "smallgroup.sqf";

Share this post


Link to post
Share on other sites

I don't think so If I follow u. Pretty much the mod run random mission across the map. It determines what size unit it spawns for the type of mission. If u would like to see the other files I can post him here.

Share this post


Link to post
Share on other sites

How does your execVM for smallgroup.sqf look?

_this select 0 and _this select 1 select from the array you passed to the execVM, that's why I ask.

You also have "removeremoveallweapons" on the Support Class.

Additionally, post what -showscripterrors shows you when executing this script (which you find in your arma2.rpt file)

Share this post


Link to post
Share on other sites

Sorry been a few day, I work night so this is the first chance I have to get back here and answer your questions.

removeremoveallweapons that was a typeo on my part.

This is the entire smallgroup.sqf file with what I think is the way u were telling me it needed to look.

//	@file Version: 1.0
//	@file Name: smallGroup.sqf
//	@file Author: [404] Deadbeat
//	@file Created: 08/12/2012 21:58
//	@file Args:

if(!X_Server) exitWith {};

private ["_group","_pos","_leader","_man2","_man3","_man4"];

_group = _this select 0;
_pos = _this select 1;

//Anti Vehicle
_leader = _group createunit ["Soldier_AA_PMC", [(_pos select 0) + 10, _pos select 1, 0], [], 0.5, "Form"];
removeallweapons _leader;
_leader addMagazine "SMAW_HEAA";
_leader addMagazine "SMAW_HEAA";
_leader addWeapon "SMAW";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addMagazine "30Rnd_556x45_Stanag";
_leader addWeapon "M4A1_AIM_CAMO";

//Support
_man2 = _group createunit ["Soldier_GL_PMC", [(_pos select 0) - 30, _pos select 1, 0], [], 0.5, "Form"];
removeallweapons _man2;
_man2 addMagazine "100Rnd_556x45_BetaCMag";
_man2 addMagazine "100Rnd_556x45_BetaCMag";
_man2 addWeapon "MG36";

//Rifleman
_man3 = _group createunit ["Soldier_M4A3_PMC", [_pos select 0, (_pos select 1) + 30, 0], [], 0.5, "Form"];
removeallweapons _man3
_man3 addMagazine "30Rnd_556x45_Stanag";
_man3 addMagazine "30Rnd_556x45_Stanag";
_man3 addMagazine "30Rnd_556x45_Stanag";
_man3 addMagazine "1Rnd_HE_M203";
_man3 addMagazine "1Rnd_HE_M203";
_man3 addMagazine "1Rnd_HE_M203";
_man3 addWeapon "M4A1_HWS_GL_CAMO";

//Sniper
_man4 = _group createunit ["Soldier_Sniper_PMC", [_pos select 0, (_pos select 1) - 30, 0], [], 0.5, "Form"];
removeallweapons _man4
_man4 addMagazine "30Rnd_556x45_Stanag";
_man4 addMagazine "30Rnd_556x45_Stanag";
_man4 addMagazine "30Rnd_556x45_Stanag";
_man4 addWeapon "M4SPR ";

_leader = leader _group;
_man1 setVehicleInit "null = [group this,(getPos this)] execVM 'server\functions\defendArea.sqf'";
processInitCommands;

This is the execVM for the small group.

CivGrpS = createGroup civilian;
[CivGrpS,_randomPos]execVM "server\missions\createUnits\smallGroup.sqf";

Share this post


Link to post
Share on other sites

Do you have other civilian units on the map? If not, add this to the execVM:

civcenter = createCenter civilian;

also in your script:

if(!isServer) exitWith{};

should be the correct syntax.

Also in your execVM, how is _randomPos defined?

Share this post


Link to post
Share on other sites

Ok there are 3 group.sql file running. Normally on 2 at any given time. smallGroup.sql, midGroup.sql and largeGroup.sql

This is 1 of the mission files that call up the smallGroup.sql

//	@file Version: 1.0
//	@file Name: mission_AirWreck.sqf
//	@file Author: [404] Deadbeat
//	@file Created: 08/12/2012 15:19
//	@file Args:

//Side Mission Colour = #4BC9B0 - Turquoise 
//Main Mission Colour = #52bf90 - Light blue
//Fail Mission Colour = #FF1717 - Light red
//Fail Mission Colour = #17FF41 - Light green
//Sub Colour = #FFF - White

if(!isServer) exitwith {};
diag_log format["WASTELAND SERVER - Mission Started"];
private ["_unitsAlive","_playerPresent","_missionType","_successTextColour","_mainTextColour","_failTextColour","_subTextColour","_picture","_vehicleName","_rad","_centerPos","_missionTimeOut","_missionDelayTime","_missionTriggerRadius","_missionPlayerRadius","_flatAreas","_randomArea","_hint","_startTime","_currTime","_result","_c130wreck","_box","_box2"];

//Mission Initialization.
_rad=20000;
_result = 0;
_missionType = "Aircraft Wreck";
_mainTextColour = "#4BC9B0";
_successTextColour = "#17FF41";
_failTextColour = "#FF1717";
_subTextColour = "#FFFFFF";
_missionTimeOut = 1800;
_missionDelayTime = 600;
_missionPlayerRadius = 50;
_centerPos = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
_flatAreas = nearestLocations [_centerPos, ["FlatArea"], _rad];
_randomPos = getpos (_flatAreas select random (count _flatAreas -1));

if(str(mainMissionPos) == str(_randomPos)) then
{
_flatAreas = _flatAreas - _randomPos;    
};
_randomPos = getpos (_flatAreas select random (count _flatAreas -1));
sideMissionPos = str(_randomPos);

//Tell everyone their will be a mission soon.
_hint = parseText format ["<t align='center' color='%2' shadow='2' size='1.75'>Side Objective</t><br/><t align='center' color='%2'>------------------------------</t><br/><t color='%3' size='1.0'>Starting in %1 Minutes</t>", _missionDelayTime / 60, _mainTextColour, _subTextColour];
[nil,nil,rHINT,_hint] call RE;

//Wait till the mission is ready to be ran.
diag_log format["WASTELAND SERVER - Mission Waiting to run"];
_startTime = floor(time);
waitUntil
{ 
   _currTime = floor(time);
   if(_currTime - _startTime >= _missionDelayTime) then {_result = 1;};
   (_result == 1)
};
diag_log format["WASTELAND SERVER - Mission Resumed"];
_result = 0;

//Add marker to client marker array.
clientMissionMarkers set [count clientMissionMarkers,["AirWreck_Marker",_randomPos,"Aircraft Wreck"]];
publicVariable "clientMissionMarkers";

_c130wreck = createVehicle ["C130J_US_EP1",[(_randomPos select 0) + 50, (_randomPos select 1) + 50,0],[], 0, "NONE"];
_c130wreck setdamage 1;
_c130wreck setVariable["original",1,true];

_box = createVehicle ["USLaunchersBox",[(_randomPos select 0), (_randomPos select 1),0],[], 0, "NONE"];
[_box] execVM "server\missions\customWeaponCrates\makeBasicLaunchers.sqf";

_box2 = createVehicle ["USSpecialWeaponsBox",[(_randomPos select 0), (_randomPos select 1) - 10,0],[], 0, "NONE"];
[_box2] execVM "server\missions\customWeaponCrates\makeBasicWeapons.sqf";

_picture = getText (configFile >> "cfgVehicles" >> typeOf _c130wreck >> "picture");
_vehicleName = getText (configFile >> "cfgVehicles" >> typeOf _c130wreck >> "displayName");
_hint = parseText format ["<t align='center' color='%4' shadow='2' size='1.75'>Side Objective</t><br/><t align='center' color='%4'>------------------------------</t><br/><t align='center' color='%5' size='1.25'>%1</t><br/><t align='center'><img size='5' image='%2'/></t><br/><t align='center' color='%5'>A<t color='%4'> %3</t>, has come down under enemy fire!</t>", _missionType, _picture, _vehicleName, _mainTextColour, _subTextColour];
[nil,nil,rHINT,_hint] call RE;

CivGrpS = createGroup civilian;
[CivGrpS,_randomPos]execVM "server\missions\createUnits\smallGroup.sqf";

diag_log format["WASTELAND SERVER - Mission Waiting to be Finished"];
_startTime = floor(time);
waitUntil
{
   sleep 1; 
_playerPresent = false;
   _currTime = floor(time);
   if(_currTime - _startTime >= _missionTimeOut) then {_result = 1;};
   {if((isPlayer _x) AND (_x distance _box <= _missionPlayerRadius)) then {_playerPresent = true};}forEach playableUnits;
   _unitsAlive = ({alive _x} count units CivGrpS);
   (_result == 1) OR ((_playerPresent) AND (_unitsAlive < 1)) OR ((damage _box) == 1)
};

if(_result == 1) then
{
//Mission Failed.
   deleteVehicle _box;
   deleteVehicle _box2;
   deleteVehicle _c130wreck;
   {deleteVehicle _x;}forEach units CivGrps;
   deleteGroup CivGrpS;
   _hint = parseText format ["<t align='center' color='%4' shadow='2' size='1.75'>Objective Failed</t><br/><t align='center' color='%4'>------------------------------</t><br/><t align='center' color='%5' size='1.25'>%1</t><br/><t align='center'><img size='5' image='%2'/></t><br/><t align='center' color='%5'>Objective failed, better luck next time</t>", _missionType, _picture, _vehicleName, _failTextColour, _subTextColour];
[nil,nil,rHINT,_hint] call RE;
   diag_log format["WASTELAND SERVER - Mission Failed"];
} else {
//Mission Complete.
   deleteVehicle _c130wreck;
   deleteGroup CivGrpS;
   _hint = parseText format ["<t align='center' color='%4' shadow='2' size='1.75'>Objective Complete</t><br/><t align='center' color='%4'>------------------------------</t><br/><t align='center' color='%5' size='1.25'>%1</t><br/><t align='center'><img size='5' image='%2'/></t><br/><t align='center' color='%5'>The ammo caches have been collected well done team</t>", _missionType, _picture, _vehicleName, _successTextColour, _subTextColour];
[nil,nil,rHINT,_hint] call RE;
   diag_log format["WASTELAND SERVER - Mission Finished"];
};

//Remove marker from client marker array.
{
   if(_x select 0 == "AirWreck_Marker") then
   {
   	clientMissionMarkers set [_forEachIndex, "REMOVETHISCRAP"];
	clientMissionMarkers = clientMissionMarkers - ["REMOVETHISCRAP"];
       publicVariable "clientMissionMarkers";    
   };
}forEach clientMissionMarkers;
sideMissionRunning = false;

So your saying it should look like this

civcenter = createCenter civilian;;
[CivGrpS,_randomPos]execVM "server\missions\createUnits\smallGroup.sqf";

if(!isServer) exitWith{};

Edited by dknight903

Share this post


Link to post
Share on other sites

civcenter = createCenter civilian;
CivGrpS = createGroup civilian
[CivGrpS,_randomPos] execVM "server\missions\createUnits\smallGroup.sqf";

This is what it should look like.

Share this post


Link to post
Share on other sites

Use that instead of if (!X_Server) exitWith which you had in your script.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×