Home   Help Search Login Register  

Author Topic: SQF syntax in Operation Flashpoint  (Read 1924 times)

0 Members and 1 Guest are viewing this topic.

Offline Ext3rmin4tor

  • Members
  • *
SQF syntax in Operation Flashpoint
« on: 11 Dec 2008, 12:13:10 »
I'm going to make a new campaign based on the WW2 Pack addon for OFP. Since I learnt the SQF syntax for ArmA finding it very useful and better than the old SQS syntax, I wanted to use SQF as more as possible also in OFP (Resistence 1.96 of course). Though I noticed there are some differences, this one in particular may be a problem: there are no "sleep" and "waitUntil" commands for SQF syntax (the Biki and comref say that they were introduced in ArmA 1.0). I know that it is not possible to use the "~" and "@" operators in SQF scripts normally used in SQS scripts so I wanted to ask if any of you knows if there are equivalent commands for OFP.

If not maybe I've figured out how to manually make the script stop and wait for a condition, take a look and say if this might work:

Code: [Select]
//SLEEP FUNCTION

//the script sleeps for 5 seconds
for [{_currentTime = _time}, {_time - _currentTime <= 5}, {}] do {//empty block};


(the reserved variable time tracks the elapsed time since the script has started running) this basically force the script to execute an empty loop (so that it is blocked on that line) until five seconds have elapsed (_time - _currentTime is the time spent in the loop).

Code: [Select]
//WAIT UNTIL FUNCTION

//this waits until the boolean condition is satisfied

for [{}, {!boolean condition}, {}] do {//empty block};


it's like the previous one but the loop breaks when the condition is satisfied.

« Last Edit: 11 Dec 2008, 13:19:18 by Ext3rmin4tor »
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline zwobot

  • Members
  • *
Re: SQF syntax in Operation Flashpoint
« Reply #1 on: 14 Dec 2008, 21:50:41 »
You cannot suspend a SQF function in Ofp for a give time like it's possible in Arma and it's not their intenden use anyway. You have to use a script for this. You should use functions to do tasks that need to be done often and as quickly as possible (like calculating a position for example). Functions are ideal for this because they can be precompiled at mission start which reduces the execution time in contrast to scripts which are a bit slower.
"Executing tactics in real combat is the hardest thing one can ever do...well I've never given birth but..well whatever."

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: SQF syntax in Operation Flashpoint
« Reply #2 on: 16 Dec 2008, 09:30:14 »
for/do doesn't work in OFP so you would need to use while/do, and I believe in OFP that is limited to 10 000 (or was it 1000) loops and with a pauseless loop that limit is reached very fast as the loop loops on every frame.
When the loop limit is reached you will get a error message, IIRC it was 'generic error in expression' or something like that.
And as the sqf functions in OFP pause the game/other scripts/whatever during it's execution having it perform a longer pause might give you pretty odd results.

Besides, the sqf function in OFP is completely different thing than the sqf script in ArmA, they differ in execution and interpretation (other pre-compiled, the other read 'on the run').
The latter was designed for ArmA to replace the horrid sqs scripting and works basically the same as sqs only performs more effectively, whereas as already pointed out, in OFP sqf serves a purpose of a function which generally is used for a fast and short data manipulation to return a value. Of course the returned value is not mandatory, but the key word is short and fast.

So I'm sorry, with OFP you're stuck with sqs. Of course you can still use functions as much as possible (called from an sqs script) but the performance benefit due to the completely different design than a sqf script might turn to negative with too extensive use..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Ext3rmin4tor

  • Members
  • *
Re: SQF syntax in Operation Flashpoint
« Reply #3 on: 16 Dec 2008, 11:45:33 »
The problem is in OFP the only way to run a SQF function is the call command so the calling script must wait for the second one to end. Well I thinl I'll complete the campaing for ArmA I'm currently  working on and then decide. Meanwhile someone could release some good WWII addons for ArmA, I've already seen that they released the beta version of WWII Normandy, there are a lot of nice tanks like Pzkw IV, V , Tiger I and II and for the allies the M4A4 Sherman and the M26 Pershing plus all the infantry units. The problem is it would be cool to have also Japanese and Russian armies, plus british forces for the allies.
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline zwobot

  • Members
  • *
Re: SQF syntax in Operation Flashpoint
« Reply #4 on: 16 Dec 2008, 14:28:40 »
Meanwhile someone could release some good WWII addons for ArmA, I've already seen that they released the beta version of WWII Normandy, there are a lot of nice tanks like Pzkw IV, V , Tiger I and II and for the allies the M4A4 Sherman and the M26 Pershing plus all the infantry units. The problem is it would be cool to have also Japanese and Russian armies, plus british forces for the allies.
And how does this relate to the current topic?  :P ;)
"Executing tactics in real combat is the hardest thing one can ever do...well I've never given birth but..well whatever."

Offline Ext3rmin4tor

  • Members
  • *
Re: SQF syntax in Operation Flashpoint
« Reply #5 on: 16 Dec 2008, 14:38:24 »
Becase I initially told that I was coming back on OFP because I wanted to make a WWII campaign and then I need all the infos about SQF syntax
How can you shoot women and children?
Easy! Ya' just don't lead'em so much! Ain't war hell?!!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: SQF syntax in Operation Flashpoint
« Reply #6 on: 17 Dec 2008, 10:22:07 »
Quote
The problem is in OFP the only way to run a SQF function is the call command so the calling script must wait for the second one to end.
That's what we've tried to explain to you  :P
call and execVM are exactly what defines how the sqf is treated, as a pre-compiled function or as a script.

You can't use only sqf in OFP because it's not intended to be used that way.
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.