Home   Help Search Login Register  

Author Topic: sqs vs init field???  (Read 742 times)

0 Members and 1 Guest are viewing this topic.

SneakyPete

  • Guest
sqs vs init field???
« 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?  :-\


Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:sqs vs init field???
« Reply #1 on: 26 Apr 2005, 14:10:47 »
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:
Code: [Select]
{_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.
« Last Edit: 26 Apr 2005, 14:17:49 by THobson »

SneakyPete

  • Guest
Re:sqs vs init field???
« Reply #2 on: 26 Apr 2005, 14:20:34 »
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.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:sqs vs init field???
« Reply #3 on: 26 Apr 2005, 14:24:06 »
There is a lot that is frustrating - but there is a huge amount that is unbelievably neat.

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:sqs vs init field???
« Reply #4 on: 26 Apr 2005, 15:22:45 »
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:

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:sqs vs init field???
« Reply #5 on: 26 Apr 2005, 15:27:07 »
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.
Plenty of reviewed ArmA missions for you to play