OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: PSPSoldier534 on 14 Dec 2008, 20:23:01

Title: New here, need help!
Post by: PSPSoldier534 on 14 Dec 2008, 20:23:01
Hi, I've been browsing these boards since they came up, and I'm glad I joined up. I like making addons, and I'm making animations. But, how can I allow soldiers to shoot when playing a scripted animation? Any help is appreciated :).
Title: Re: New here, need help!
Post by: zwobot on 14 Dec 2008, 21:44:30
fire (http://community.bistudio.com/wiki/fire) and doFire (http://community.bistudio.com/wiki/doFire) come into my mind. But I don't know if they work while an animatin is played via switchMove or playMove...
Title: Re: New here, need help!
Post by: PSPSoldier534 on 14 Dec 2008, 21:57:58
I know those commands, but I want to give the player an ability to shoot when say leaning (via SwitchMove or Playmove).
Title: Re: New here, need help!
Post by: zwobot on 14 Dec 2008, 22:01:56
So you are talking about animation packs which provide lean animations for the player (like in WGL or GRAA?). If this is the case you should contact for example Sanctuary; he seems to be very competent with animations. I'm sure he can tell you whats possible and what isn't.
Title: Re: New here, need help!
Post by: PSPSoldier534 on 15 Dec 2008, 02:09:25
Sorta. Like maybe a rappel animation where the player can shoot.

Edit: I know I got an addon pack that let me. Can't remember which though :(.
Title: Re: New here, need help!
Post by: johnnyboy on 15 Dec 2008, 06:25:18
You can script AI to shoot while moving by using UseWeapon command.  Attached is a sample mission with a script called shootAndMove.sqf. 

The core part of the script that controls shooting and moving is this:

Code: [Select]
  while { alive _foe and (_count < 25) and (_shooter distance _foe) > 10 and alive _shooter} do
      {
      _shooter reveal _foe;
      _shooter dotarget _foe;
      sleep (_delay + .3);
      // move and shoot occurs here
      _shooter playmove _move;
      sleep (_delay + ((random 3) * .2));   
      _gameLogic action ["useWeapon",_shooter,_shooter,0];
      //_shooter dotarget _foe;
      sleep (_delay + ((random 4) * .2));
      _gameLogic action ["useWeapon",_shooter,_shooter,0];
      sleep (_delay + ((random 3) * .2));
      _gameLogic action ["useWeapon",_shooter,_shooter,0];
      _count = _count + 1;
   };

Title: Re: New here, need help!
Post by: Ext3rmin4tor on 15 Dec 2008, 16:00:46
Sorry for the OT but does the commands "sleep" and "waitUntil" work under OFP 1.96???
Title: Re: New here, need help!
Post by: zwobot on 15 Dec 2008, 17:23:30
No they don't. See in the biki: http://community.bistudio.com/wiki/sleep (http://community.bistudio.com/wiki/sleep) and http://community.bistudio.com/wiki/waitUntil (http://community.bistudio.com/wiki/waitUntil) they are both available in Arma only.
You have to use ~ or @ in Ofp and they only work in SQS scripts, not SQF functions.
Title: Re: New here, need help!
Post by: Ext3rmin4tor on 15 Dec 2008, 17:35:38
Thanks because I wrote a thread on how making those functions manually for OFP but noone replied. So somehow when you write scripts for OFP you're still bound to SQS syntax, right?
Title: Re: New here, need help!
Post by: zwobot on 15 Dec 2008, 18:23:13
No, not really. You can use both SQS and SQF in Ofp. However there are subtle differences in syntax (from Ofp to Arma) and as said before some commands are not available in Ofp.
Functions in Ofp should be used for what their name suggests: functions. That means providing a very special task which is needed several times in a mission. You can really think of them as methods of functions you might know from "normal" programming.
Also the execution is different: Script execution (http://community.bistudio.com/wiki/Script_%28File%29#Execution) and function execution (http://community.bistudio.com/wiki/function#Execution) (Arma specific)
Title: Re: New here, need help!
Post by: Ext3rmin4tor on 15 Dec 2008, 18:29:01
Just as I thought, the problem is that SQF syntax lets you get rid of the horrible "spaghetti-code" you're forced to use (you use often the goto function) when programming with SQS syntax since it is line based and you can't write code blocks on multiple lines. In any case if you have time read the thread "SQF syntax in Operation Flashpoint" where I wrote some code that might help in suspending a script made in SQF syntax and tell me what you think.
Title: Re: New here, need help!
Post by: PSPSoldier534 on 20 Dec 2008, 22:17:11
Is it possible to give them cover nodes?
Title: Re: New here, need help!
Post by: johnnyboy on 26 Dec 2008, 23:50:31
Sorry guys, the example I posted was for ARMA not OFP...so that code may not be OFP compatible.  Not sure.

For cover nodes, you can create game logics as nodes, and have ai dotarget or dowatch the game logics.  Or AI can dowatch a position.  It requires scripting to achieve.
Title: Re: New here, need help!
Post by: Ext3rmin4tor on 29 Dec 2008, 11:04:55
It is not compatible with OFP if you look at my previous question