OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Killzone on 20 Oct 2006, 21:08:17

Title: Random unit generation
Post by: Killzone 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.
Title: Re: Random unit generation
Post by: Seven 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...
Title: Re: Random unit generation
Post by: JasonO 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).
Title: Re: Random unit generation
Post by: macguba 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.   :)

Title: Re: Random unit generation
Post by: myke13021 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 (http://www.mapfact.net/include.php?path=content/download_eng.php&contentid=487)
Title: Re: Random unit generation
Post by: Killzone 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.