Home   Help Search Login Register  

Author Topic: Problem with fire command with group arrays  (Read 669 times)

0 Members and 2 Guests are viewing this topic.

Shuko

  • Guest
Problem with fire command with group arrays
« on: 26 Aug 2004, 20:08:53 »
Ok, I'll try to make this as simple as possible. I have a group which members I've put into an array. In a script I loop through them and make them dowatch and fire. Like this:

_g = units mygroup

_s = _g select _i
_s dowatch [mytarget]
_s fire "myweapon"

So, everything, including dowatch is working perfectly, except the damn units won't fire.

I tried by giving a name to one of them and used that in the script, everything worked, but I can't have it hardcoded. I tested with hint that it actually is using the right unit names/callsigns (like GUER Alpha Black:1).

Anyone know of a workaround or something to this thing?

Offline Jezuro

  • Members
  • *
  • Hookah 4 lyfe!
    • Jezuro's ArmA Workshop
Re:Problem with fire command with group arrays
« Reply #1 on: 26 Aug 2004, 21:33:25 »
The fire command stuff is not so easy as it looks  :-\ You know, what this command usually show, is a man aiming his rifle up (probably targeting clouds  ;D) and firing a single shot. You cannot even force him to shoot at watching object.

In this case, you'll probably have to use the DoFire command, which is not at all reliable, but will surely do a better job than fire...
"We are Her salvation, and through Her command we shall live forever. I will not die. Not here. Not now. Never!!!"

Shuko

  • Guest
Re:Problem with fire command with group arrays
« Reply #2 on: 27 Aug 2004, 09:49:07 »
Well, if I just name the shooter to "guy1" or something and use that in the script for the fire command. It work's perfectly.  ::)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Problem with fire command with group arrays
« Reply #3 on: 27 Aug 2004, 09:52:42 »
Add something like this to the loop and see what you get:  it might illuminate the problem.

hint format ["_s is %1", _s]

This feels like an array/element problem, not a fire problem.
Plenty of reviewed ArmA missions for you to play

Shuko

  • Guest
Re:Problem with fire command with group arrays
« Reply #4 on: 27 Aug 2004, 10:31:27 »
I did mention in the first post that I tested it. It is correctly printing:

GUER Alpha Black:1
GUER Alpha Black:2
GUER Alpha Black:3

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Problem with fire command with group arrays
« Reply #5 on: 27 Aug 2004, 10:36:34 »
That'll teach me to re-read the the original post and not just the new reply.   ;D

Sounds like OFP is being her usual fickle self.   I think it might be workaround time.    Could you use a couple of forEach commands instead of a loop?

Plenty of reviewed ArmA missions for you to play

Unnamed

  • Guest
Re:Problem with fire command with group arrays
« Reply #6 on: 27 Aug 2004, 14:32:07 »
Do you have a pause in your loop? A delay of ~0.01 between each unit firing worked for me when I did something similar.

Shuko

  • Guest
Re:Problem with fire command with group arrays
« Reply #7 on: 27 Aug 2004, 15:09:24 »
Of course I do, even tried with 5+ secs.

Anyway, made a lazy man's workaround and changed it so that instead of passing a group to the script you pass an array of the units. It's less advanced and more work for the mission maker, but I'm happy since it actually works.  ;)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Problem with fire command with group arrays
« Reply #8 on: 27 Aug 2004, 19:02:31 »
I'd bet it would have worked the original way if you used doTarget and doFire instead of doWatch and fire...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Problem with fire command with group arrays
« Reply #9 on: 27 Aug 2004, 19:05:56 »
is the script executed right from a init field or init.sqs? If so do a 1 sec delay at the very start of the script.
Not all is lost.

Offline Jezuro

  • Members
  • *
  • Hookah 4 lyfe!
    • Jezuro's ArmA Workshop
Re:Problem with fire command with group arrays
« Reply #10 on: 27 Aug 2004, 19:34:13 »
And do you have the proper names of weapons instead of "myweapon"?
"We are Her salvation, and through Her command we shall live forever. I will not die. Not here. Not now. Never!!!"

Unnamed

  • Guest
Re:Problem with fire command with group arrays
« Reply #11 on: 28 Aug 2004, 08:56:38 »
Quote
Anyway, made a lazy man's workaround and changed it so that instead of passing a group to the script you pass an array of the units

Sounds like your group might be wrong. The command units, returns an array of units in that group. But without the entire script, it's just a guessing game :)

But if it works with individual units and works with a user compiled array, but not with a group array. Then I assume its units mygroup that is causing the problem?

Quote
is the script executed right from a init field or init.sqs

Yep this will effect groups, as groups are only defined once every unit is created. For example you cant return a valid group from a function called from the init event of an addon.
« Last Edit: 28 Aug 2004, 09:16:56 by Unnamed »