Jump to content
Sign in to follow this  
.COMmunist

creating unit vs. placing unit

Recommended Posts

I am working on the mission with many units in it. Well, naturally it can create some lagg. I am trying to figure out how to reduce lagg. I am reading about a a command createUnit. Basically you can create units in the goup by some trigger. Here is my question. By the end of the mission 3 platoons of paratroopers will be dropped over the battlefield, so during the game, these 3 plattons just sit there and wait for a chopper. Do you think it will be better to just have 3 squad leaders sit and wait and then when it is time for paradrop, by trigger creating units for those squad leaders (making them into full squads)? Will all this extra scripting/commanding create just as much lagg (or more) than having 3 platoons on the map all this time?

Share this post


Link to post
Share on other sites

If you are only creating a couple of units, it really doesn't matter. But a squad or vehicles you are far better off using the setpos and putting them in from the start.

Share this post


Link to post
Share on other sites

To cache units up front and save performance aswell as group amount:

cache.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> // execute with: [ [unitsArray], [vehiclesArray] ] execVM "cache.sqf";

// should only be executed on the server in MP though.

private ["_grp","_units","_vehicles"];

_units=[];_vehicles=[];

// Process cache units

_grp=createGroup civilian;

{

   _units=_units+[ _x createUnit [[0,0,0], _grp] ];

   sleep 0.5;

} forEach (_this select 0);

// Process cache vehicles

{

   _vehicles=_vehicles+[ _x createVehicle [0,0,0] ];

   sleep 0.5;

} forEach (_this select 1);

// The following will remove the cached units and group, but I do not know with certainty if the script has use then, so if it doesn't help, just remove this

sleep 5;

{deleteVehicle _x} forEach (_units+_vehicles);

deleteGroup _grp;

in init.sqs/sqf:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if(isServer)then

{

  [

     [

        "SoldierWB",

        "SoldierWAT",

        "SoldierWG"

     ],

     [

        "M113",

        "M1Abrams"

     ]

  ] execVM "cache.sqf";

};

Change the units and vehicles listed in to the ones you need later on in the mission

Share this post


Link to post
Share on other sites

Thanks for all the refferences guys. However, you are talking to a noob scripter, to be honest I didn't understand much. Perhaps this one is easier?

I had found the command at OFPEC that creates units around a squad leader by a trigger (f.e. Radio Alpha). It looks like this is what I am looking for, BUT, I tried this and it is not working for me. I guess I am not figuring this one out right. This is what OFPEC had:

group createUnit [type, position, markers, placement, special]

Operand types:

group: Group

[type, position, markers, placement, special]: Array

Type of returned value:

Object

Description:

Creates a unit (person) of the given type (type is a name of a subclass of CfgVehicles) and makes it a member of the given group.

If the markers array contains several marker names, the position of a random one is used.

Otherwise, the given position is used.

The unit is placed inside a circle with this position as its center and placement as its radius.

Special properties can be: "NONE" and "FORM".

Used In:

ArmA

Examples:

unit = group player createUnit ["SoldierWB", position player, [], 0, "FORM"]

Well, I had created a marker, a trigger and a squad leader and tried this out... nothing is happening. So, I understand that I need to put this string into a trigger On Activation part:

unit = group player createUnit ["SoldierWB", position player, [], 0, "FORM"]

where player is me, "SoldierWB" is a type of a infantry unit I am adding, but what is POSITION PLAYER? What is [] and 0? Does anybody know how to use this script? Sorry for so many questions and probably stupid ones too, but I want to figure it out. Please help. Thank you.

Share this post


Link to post
Share on other sites

POSITION PLAYER -> this is the position of the player, (you can also use the command getPos player) any position will also work not just the players

[] -> this is an empty array. "If the markers array contains several marker names, the position of a random one is used. Otherwise, the given position is used."

0 -> this is the radius of the circle. "The unit is placed inside a circle with this position as its center and placement as its radius."

Share this post


Link to post
Share on other sites

Sickboy, for JIP client caching, when the cached units have already been deleted from the server by the time the client joins, could you use this script + createvehiclelocal to cache units only on the local machine? I'm going to check and see if createvehiclelocal works with men class units, but I assume not.. (I need to try that...)

Share this post


Link to post
Share on other sites
Maybe this could help you:

http://www.ofpec.com/index.p....30181.0

Myke out

OK a noob question...how can bring occupation units in an area that has just been cleared from units that were randomly created by the script proposed by Myke? When I had placed the units myself I had a script calling the occupation units after I had destroyed all opposition..

Hope I make sense...

Share this post


Link to post
Share on other sites

if you play arma cause u like the realism dont spawn units.

place them on map, name stop true

until they needed. no lag, no problems.

5 good placed units do more damage then 3 spawned squads

units that spawn right next too, or 200m in front of you, i experience this alot, and it sux.

and for players only seagullspawn, cause its realistic

we all will be seagulls goodnight.gif

tounge2.gif

Share this post


Link to post
Share on other sites

Hey,

Im trying something similar:

"respawnAI.sqs"

Trigger Repeating: Cond: not alive gb1

onAct: [gb1,bgp2] exec "respawnAI.sqs"

1st is units Name, 2nd is a Location

respawnAI.sqs

-------------

Quote[/b] ]

? not local server: exit;

_spawnAIname = _this select 0

_movePlace = _this select 1

_place = getMarkerpos "respawnAIpos"

_grp = createGroup west;

_spawnAIname = _grp createUnit ["SoldierWB", _place, [], 0, "FORM"] ;  

[_spawnAIname] join _grp ;

_spawnAIname move position _movePlace ;

exit

Could anyone help me out please?

It respawns the AI once, but when i kill him again, it doesnt respawn him.

HOWEVER

------------

If I replace _spawnAIname with gb1, it works perfectly.

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  

×