Home   Help Search Login Register  

Author Topic: Random Placement Of A Camp(s) (?)  (Read 1149 times)

0 Members and 1 Guest are viewing this topic.

Offline mrcash2008

  • Members
  • *
Random Placement Of A Camp(s) (?)
« on: 12 Nov 2008, 22:56:02 »
Hi,

Im trying to piece together threads to understand how to randomly place camps at mission start.

Im using Shmalfelden map and currently have a few camps (1 tent with ammo inside, 3 man partol, 1 outside fire). Currently I simply copy and paste and dot them around each forest in fixed positions. Ideally I would like to have it so that array of items could be dragged and placed on the map a number of times at random places for more random mission play (its SF stealth type mission).

I understand using "random" and having ready set placed game logic's but thats for simple single items using the item name. I just cannot think through how to set it up so that its an array of "tent, 3 man patrol around it on safe, and a fire" and then that under a variable name so i can simply have:

"variable name" (the camp) - random -  list of game logic names.

Can anyone help, or point me to a script that maybe covers this idea at all? Just would like to have the camps themselves to be unkown to me on mission start for more dynamic play.

« Last Edit: 12 Nov 2008, 23:07:10 by mrcash2008 »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Random Placement Of A Camp(s) (?)
« Reply #1 on: 13 Nov 2008, 01:04:56 »
Well, there are a number of ways to do this. The best way I can think of, that allows for camps to be interesting and varied and to be location-specific is to manually place a large number of camps and delete all but a few of them at run time:
Code: (deleteCamps.sqf) [Select]
// Create lots of potential camps and place a gamelogic in the centre of each one.
// Pass the names of those gamelogics
// through into the function, along with how many camps should be left at the end.
//
// Run with:
//   camps = [camp1, camp2, camp3, camp4];
//   // Just want 2 camps to remain in the game.
//   [camps, 2, 10] execVM "deleteCamps.sqf";
//   // camps will then contain the logics that at at the position of the camps that are left,
//   // as well as some objNulls, so you can easily see where the camps remain and so
//   // do more processing, for example, setting them as objectives.

_camps = _this select 0; // List of gameLogics
_numCampsToLeave = _this select 1; // How many should be left after deletion.
_radius = _this select 2; // How far out from the game-logic to delete things.

while { (count _camps) > _numCampsToLeave } do
{
    // Choose a random camp from the list.
     _campToDelete = _camps select (floor (random (count _camps)));
     
     // Delete all objects near the camp logic (including that logic).
    {
        deleteVehicle _x;
    } forEach (nearestObjects [_campToDelete, ["All"], _radius]);

    // Delete the deleted camp "logic" from the list.
    _camps = _camps - [objNull];
};

Warning: Untested code...
« Last Edit: 13 Nov 2008, 01:24:16 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)