OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: SneakyPete on 26 Apr 2005, 13:38:13
-
Is it best when starting a mission to set the idenity of your men, set position, behaviour and add/remove weapons etc from their init field or from a sqs file (init.sqs)?
Why? :-\
-
Like many things - it depends.
When I am using instructions that are unit specific I might use the init field of the unit. But when I am applying the same instructions to whole groups or even to the whole of one side - then the init.sqs is my preferred choice. The reason is: - it is easy to see what I have done, I don't have to go round opening lots of units to see; and it is easy to change it all if I want to.
To give you an example. This is from an init.sqs:
{_x removeMagazines "HandGrenade"} forEach [Karl,Yuri,Marek,Pavel]
{if ((random 100) < 50) then {_x addMagazine "HandGrenade"}} forEach [Karl,Yuri,Marek,Pavel]It removes all the HandGrenades from some selected people and then with a 50% probability adds one back.
If I want to change this I just go the sqs file and not the init field of each unit.
-
Thanks THobson,
I just wondered if there was a right way and a wrong way, and agree for large group specific stuff the init.sqs is easier to update and edit.
Cheers :)
Didn't know about the probability thing, now that is neat.
-
There is a lot that is frustrating - but there is a huge amount that is unbelievably neat.
-
Like THob said, it depends. But a good coder always take system requirements into his code. So if you have a handful of units the init field would be better IMO. Otherwise you'd have to assign a variable to the unit and that will lock up memory. If you'd use the init field then you only execute a line of commands once at the start of the game.
:beat: *Gets Shot* :beat:
-
In general it's not a big deal. There are some commands (for example some switchmoves) that don't work from init lines, though I'm not sure if they work from init.sqs.
It depends totally on circumstances. If you wanted to do compicated things to a few groups its probably better to use init.sqs. If you want to do simple things to a lot of groups its probably better to use init lines.
Note that both init.sqs and init fields are executed before triggers.