Home   Help Search Login Register  

Author Topic: Anybody and .sqs  (Read 858 times)

0 Members and 1 Guest are viewing this topic.

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Anybody and .sqs
« on: 10 Mar 2005, 23:55:16 »
Simple question, however I cannot find the answer.

How does one make something activational by anyone in a .sqs file?
Example, like
@(Anybody distance pitofdeath < 5)
hint"Some one is awful close to the pit of death!!"

-thanks
« Last Edit: 10 Mar 2005, 23:55:26 by RujiK »
I like your approach, lets see your departure.
Download the New Flashlight Script!

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Anybody and .sqs
« Reply #1 on: 11 Mar 2005, 00:31:50 »
Create an array of all the units in the map by making a trigger over the whole map

Area:  whole map
Activation box:  anybody present
Condition:  this
Name:  triggerAll

In the script:-

#toploop

~10

_trigList = list triggerAll
_crystallisedList = +_trigList

_i=0
_k=count _crystallisedList

#innerLoop
~0.05
? (_crystallisedList select _i) distance pitOfDeath < 5 : hint"Some one is awful close to the pit of death!!"
_i=_i+1
? _i => _k : goto "toploop"
goto "innerloop"


That is not guaranteed, or even close, but hopefully you get the idea and some time with the comref and a bit of experimentation should do the rest.

Plenty of reviewed ArmA missions for you to play

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Re:Anybody and .sqs
« Reply #2 on: 11 Mar 2005, 00:40:30 »
MMM! Great Idea! Thanks alot!
(Also the pit of death thing was just an example...)
I like your approach, lets see your departure.
Download the New Flashlight Script!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Anybody and .sqs
« Reply #3 on: 13 Mar 2005, 03:18:54 »
Why do you need to make a fixed copy(_crystallisedList) of the variable _trigList?
« Last Edit: 13 Mar 2005, 03:20:00 by Mr.Peanut »
urp!

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Anybody and .sqs
« Reply #4 on: 14 Mar 2005, 01:02:52 »
Well.... maybe you don't.    However, _triglist is dynamic:  it updates automatically as the units in the trigger area change.    If the array changes in the middle of the loop, this could screw up the count thing and so on.  

Much better to crystallise the array.   That way you are dealing with a one, known array rather than a constantly changing array.

Hope that makes sense.   If it doesn't, imagine doing it with a dynamic array of three units, when one of them gets killed during the first pass of #innerloop.   Not pretty.
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Anybody and .sqs
« Reply #5 on: 14 Mar 2005, 08:23:36 »
I believe something like this would work instead of the loop:

@({_x distance pitofdeath < 5} count _crystallisedList > 0)


you could even use:

@({_x distance pitofdeath < 5} count list triggerAll> 0)

as dynamic changes should not matter here.

I have not tested it so it might need some brackets as follows:

@({(_x distance pitofdeath) < 5} count (list triggerAll) > 0)

The script will continue only when a loon is closer than 5 to the pod
« Last Edit: 14 Mar 2005, 08:55:18 by THobson »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Anybody and .sqs
« Reply #6 on: 15 Mar 2005, 14:21:18 »
So _trigList is acting more like a pointer than a variable. Handy but weird.  Does this only occur with local variables, or would a global variable also act dynamically?

Well.... maybe you don't.    However, _triglist is dynamic:  it updates automatically as the units in the trigger area change.    If the array changes in the middle of the loop, this could screw up the count thing and so on.  
« Last Edit: 15 Mar 2005, 14:23:15 by Mr.Peanut »
urp!

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Anybody and .sqs
« Reply #7 on: 15 Mar 2005, 16:35:19 »
AFIK it only works this way for arrays.

If a is an array then  

b = a

does not create another copy of the array, it creates a pointer to the single instance of the array.

To create a copy of the array you need

b = + a

EDIT:

Well what do you kow.  I remembered correctly, just found this in comref:

Quote
Array assignment

Description:
Assignment used on arrays assigns only pointer to the same array to the target variable. When b is an array, after executing a = b both a and b represent the same array. When b is changed, a is changed as well. One particular situation that can lead to this behaviour is aList = list sensor_name. You can force creating a copy of array by using unary operator +Array
« Last Edit: 15 Mar 2005, 16:42:06 by THobson »

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Re:Anybody and .sqs
« Reply #8 on: 15 Mar 2005, 18:51:12 »
Ok peeps thanks for the help heres what I was doing:
I gave your user a Fired eventhandler so if you were near any unit when you fired some guy would yell "What was that?!" and come running over.
Thanks for the help.
I like your approach, lets see your departure.
Download the New Flashlight Script!