Home   Help Search Login Register  

Author Topic: Random positions  (Read 1770 times)

0 Members and 1 Guest are viewing this topic.

Wolf

  • Guest
Random positions
« on: 14 Sep 2002, 04:47:57 »
Alright, heres the scenario.
You have to go to a town, and there you will get some information from a civilian, then you'll have to go to one of four possible locations.
I need to know how to randomly select between those four places.
So that its never the same place as before.
I also need to do this without scripts.
I have 1.46
Thank you.

I have one more question.
I need someone to be captured, and added to your squad, and I need to prevent him from having a gun.
So how would I constantly check if he has one, then emmediatly remove it?
« Last Edit: 14 Sep 2002, 05:13:18 by Wolf »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Random positions
« Reply #1 on: 14 Sep 2002, 11:36:18 »
Use the random number command  

random 4

which will generate a random number between 0 and 4.    Depending on the number generated make a certain variable true which is turn makes trigger true which opens up a set of waypoints or whatever.

However, you don't want to use scripts .... (thinks hard .... hmmmm) ..... ok, set up 4 triggers, each one triggered by your dude being present.   Make them rectangular and small (like 2m by 2m) and place them around the civilian in a block.     (Like four quarters of a square with the civvy in the middle.)    

When your dude approaches the civvy one of the triggers fires and does what needs to be done.    Use variables to fix it so that once one trigger is fired the others can't be.       Use getpos setpos to set the positions of the triggers relative to the civvy, and make the position of the civvy  random by using placement radius.   That way it is likely that your dude will fire a different trigger on each attempt because he will approach the civvy from a different direction, since the civvy is in a different place.

On the second point, you could just have a looping script

#start
dude1 removeallweapons
~3
goto "start"

and not bother with checking, which is only makes the script more complicated anyway.   Alternatively load him up with weapons of one type and ammo with another, and maybe the AI won't be smart enough to sort it out.

Hope the foregoing gibberish helps ... with a bit of luck somebody will come up with more elegant solutions.

Plenty of reviewed ArmA missions for you to play

Wolf

  • Guest
Re:Random positions
« Reply #2 on: 14 Sep 2002, 16:50:01 »
Thanks for the second help, that should be easy enough to implement.

During the night I was thinking about the first one.
And since I have absolutly no scripting I don't know if this would work, or how to set it up.

Random 4

1 trig1 = true

2 trig2 = true

3 trig3 =true

4 trig4 = true

That, if the random number is 2 it avtivates trig2, whcih in turn would activate a trigger with a trig2 in the condition line.
BUT
I have no cluse how to set up this script with the proper : { stuff, plus I don't even know if this is possible.
Anyone know?
Thanks.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Random positions
« Reply #3 on: 14 Sep 2002, 17:49:02 »
Wolf, you're nearly there m8.    That is exactly the right idea and it is definitely possible.     I'm only a few weeks ahead of you on the scripting front so I commend to you Johan Gustavsson's scripting tutorial in Getting started in the Ed Depot for the basics.

In the meantime, try this.    Create a trigger, activated as you will, and in the activation field put

[] exec "randomscript.sqs"

Now create a text file (use Notepad) called randomscript.sqs (make sure it isn't randomscript.sqs.txt which will mess things up ... save it as "all files" not as a "text file") and put it in the mission folder along with the mission.sqm file.

In the text file put this:-

; this is a script to generate a random number, which sets the main dude off in one of four directions.
; thanks to all in the OFPEC forums for help with this script

trig1=false
trig2=false
trig3=false
trig4=false

_choice = random 4

?0<=_choice<1:trig1=true
?1<=_choice<2:trig2=true
?2<=_choice<3:trig3=true
?3<=_choice<=4:trig4=true

exit


And that's it!     If the random number is between 1 and 2 then trig2 (which you can use in the condition field of a trigger) would be set to true.     If you want to make some possibilities more likely and others less likely you can obviously change the numbers around a bit.  

_choice is a local variable (it only applies inside this particular script) just to make manipulation of the random number easier.

starting a line with ; just tells the game that this line is a note and not an instruction

? ... :  is the if-then command


 - I haven't tested this so I'm not claiming that its a working script
 - if anything makes no sense at all just ask
 - scripting is actually pretty easy, don't be scared of it.  It's also very powerful.    If this one doesn't work have a look at the tute and check out the official and unofficial command refs and see where I've gone wrong.  I always look at both because they give you a slightly different angle on the same thing.    

If anybody has a better idea, or spots a mistake in this, please point it out.
 




Plenty of reviewed ArmA missions for you to play

CrashnBurn

  • Guest
Re:Random positions
« Reply #4 on: 14 Sep 2002, 18:31:48 »
There's a better method of randomly placing the civilian. Put 3 empty type markers, and group them to the civilian. Put one of your triggers at each marker location, and the 4th at his location where you placed him in the editor. When the map starts, the civilian will randomly spawn at one of the 3 markers, or the location he was placed at in the editor. This way, you can set exact (but random) locations for him to be at, and you can be sure the triggers will activate because he will be at a marker location.
« Last Edit: 14 Sep 2002, 18:33:46 by CrashnBurn »

Wolf

  • Guest
Re:Random positions
« Reply #5 on: 14 Sep 2002, 19:30:40 »
Thanks all, I'll both methods and see which one works best. Be back to let you know. Again thanks.

Wolf

  • Guest
Re:Random positions
« Reply #6 on: 14 Sep 2002, 21:25:28 »
Ok, I tryed the Empty markers and they work fine.
So questions one and two have been answered.
Thanks

But now I have one more.
Is it possible to detect what height the player is at?
I need to detect when the player reaches the top floor of a building, but only when he gets to the top floor.

Wolf

  • Guest
Re:Random positions
« Reply #7 on: 15 Sep 2002, 06:26:18 »
Alright, one and two are solved, can anyone help with three?

Is it possible to detect what height the player is at?
I need to detect when the player reaches the top floor of a building, but only when he gets to the top floor.

Thanks all.

Kaliyuga

  • Guest
Re:Random positions
« Reply #8 on: 15 Sep 2002, 06:48:02 »
 Well.. how about you place an object in the second floor of the house, and name it. Then make your condition for the trigger be
player distance < .5 objectname  

you could use a lower number too.. like .25 meters or something if you needed.


Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:Random positions
« Reply #9 on: 15 Sep 2002, 06:57:29 »

getpos player select 2

will return height AGL.  So run a test trigger, say radio Alpha that returns
hint ["%1", format getpos player select 2]

take that number, take a little off, and make your activation trigger set to
getpos player select 2 > height
where height is that number
Dinger/Cfit

Wolf

  • Guest
Re:Random positions
« Reply #10 on: 15 Sep 2002, 07:00:01 »
It seems like I'm gonna have to go by that method, but I'd have to have it a short distance or you'd still set it off right below it.
I'll give the distance a try.
If anyone knows another way? I'd like to know.
Thank you.

Wolf

  • Guest
Re:Random positions
« Reply #11 on: 15 Sep 2002, 20:16:40 »
Well, all probs have been solved as nessacery, thanks all.