Home   Help Search Login Register  

Author Topic: Random unit generation  (Read 1440 times)

0 Members and 1 Guest are viewing this topic.

Offline Killzone

  • Members
  • *
  • War is the true Enemy
Random unit generation
« on: 20 Oct 2006, 21:08:17 »
I am not sure if this belongs in advanced scripting or not but please feel free to move it with my apologies.

Is it possible to have a script create a random unit or vehicle?

What I am looking for is a script (That is beyond my knowldedge) that when activated will create either an enemy tank or a soldier or any kind of variation. is that even possible in OFP?

I know how to create units and such but I dont know how to have it choose a random on from say a list of 3 possibles.

Any help would be great.   :good:

I did a search and did not come upon anything like this.
"Everyone dies so deal with it and move on"

                                                      ME

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: Random unit generation
« Reply #1 on: 20 Oct 2006, 21:34:46 »
Open notepad, put in the code below & save as random.sqs (not random.sqs.txt)

After that put a unit (player) on the map, save ur mission & in the missionfolder put the random.sqs
Put a trigger Radio Alpha on the map, make it repeating and in the activation box put [] exec random.sqs

random.sqs
Code: [Select]
?(!local server):exit
_pos = [(getpos player select 0) +5, (getpos player select 1) +10, (getpos player select 2)]
_ran = random 3
? _ran <= 1 : goto "tank"
? _ran <= 2 : goto "chop"
? _ran <= 3 : goto "man"


#tank
"M1Abrams" createvehicle _pos
exit

#chop
"AH64" createvehicle _pos
exit

#man
"SoldierW" createvehicle _pos
exit

_pos can be anything you want though. For example a marker or a gamelogic...

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Random unit generation
« Reply #2 on: 20 Oct 2006, 22:16:15 »
Also may I add that you can edit what is spawned by changing the

"TextHERE" createvehicle _pos

.. part of the line.

Check the COMREF for diffrent vehicle classes (thats units aswell).

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: Random unit generation
« Reply #3 on: 21 Oct 2006, 13:42:22 »
Quote
I am not sure if this belongs in advanced scripting or not but please feel free to move it with my apologies.

The answer is fairly straightforward so the thread belongs here, on the General board.   Well done for thinking about it and well done for getting it right - if in doubt always post here.   :)

Plenty of reviewed ArmA missions for you to play

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Random unit generation
« Reply #4 on: 21 Oct 2006, 17:08:51 »
@killzone

if you're looking for more randomness in your mission, you might want to take a closer look to Mapfacts DAC (Dynamic AI Creator).

You can get mor informations here

Offline Killzone

  • Members
  • *
  • War is the true Enemy
Re: Random unit generation
« Reply #5 on: 21 Oct 2006, 21:31:57 »
@Seven

Thanks That is what I was looking for. It works great.  I have been working at designing life on an island that when you get within a certain distance of an object in the center of a city it activates a script which loads civillians walking about giving the illusion that all the cities or towns are populated. the units delete when getting a certain distance away from said object.  The thing is I also wanted some cities to come under attack upon entering them and this is where your script comes in handy and keeps me from knowing exactly what is coming. I have modified it to meet my needs with you getting the credit. Thanks again.

@ JasonO

I was aware of this but thank you. the problem with my scripting skills is I am more of a copy and paste hack instead of a scripter.  ;)

@myke13021

I downloaded that a while back and forgot about it. I have read great reviews on it and will give it a look.
"Everyone dies so deal with it and move on"

                                                      ME