Ambient Life Configs: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Basic information given.)
 
m (Text replacement - " ( *class [a-zA-Z0-9_]+): *([a-zA-Z0-9_]+ *) " to " $1 : $2 ")
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:ArmA: Addon Configuration]]
{{TOC|side}}
== Ambient Life Distribution ==


===Ambient Life Distribution===
There is a ''probabilistic'' way to define ambient life distribution, depending on current ''time'',
There is a ''probabilistic'' way to define ambient life distribution, depending on current ''time'',  
''place'' and ''weather'' conditions, defined in CfgWorlds.
''place'' and ''weather'' conditions, defined in CfgWorlds.


Line 12: Line 12:
to one. In the following example, for instance:
to one. In the following example, for instance:


  probability="deadBody+(1-deadBody)*(0.5-forest*0.1-meadow*0.2)";
  probability = "deadBody+(1-deadBody)*(0.5-forest*0.1-meadow*0.2)";
  probability="(1-deadBody)*(0.5-forest*0.1+meadow*0.2)";
  probability = "(1-deadBody)*(0.5-forest*0.1+meadow*0.2)";
  probability="(1-deadBody)*(0.2*forest)";
  probability = "(1-deadBody)*(0.2*forest)";


Which really sums into one, as one can easily check:
Which really sums into one, as one can easily check:
Line 23: Line 23:
More complete example follows:
More complete example follows:


class CfgWorlds
<syntaxhighlight lang="cpp">
{
class CfgWorlds
  class DefaultWorld
{
  {
class DefaultWorld
    /// ambient life configuration
{
    class Ambient
// ambient life configuration
    {
class Ambient
      class SmallInsects
{
      {
class SmallInsects
        radius=3; //radius in meters, where ambient lives (distance from the player)
{
        cost="(10-5*hills)*(1-night)*(1-rain)*(1-sea)*(1-( (windy*2) min 1))"; //total number of all species
radius = 3; // radius in meters, where ambient lives (distance from the player)
        /// species configuration
cost = "(10-5*hills)*(1-night)*(1-rain)*(1-sea)*(1-( (windy*2) min 1))"; // total number of all species
        class Species
/// species configuration
        {
class Species
          class HouseFly
{
          {
class HouseFly
            probability="deadBody+(1-deadBody)*(0.5-forest*0.1-meadow*0.2)";
{
            cost=1; //when the fly lives, it pays this cost to the total sum cost SmallInsects::cost
probability = "deadBody+(1-deadBody)*(0.5-forest*0.1-meadow*0.2)";
          };
cost = 1; // when the fly lives, it pays this cost to the total sum cost SmallInsects::cost
          class HoneyBee
};
          {
class HoneyBee
            probability="(1-deadBody)*(0.5-forest*0.1+meadow*0.2)";
{
            cost=1;
probability = "(1-deadBody)*(0.5-forest*0.1+meadow*0.2)";
          };
cost = 1;
          class Mosquito
};
          {
class Mosquito
            probability="(1-deadBody)*(0.2*forest)";
{
            cost=1;
probability = "(1-deadBody)*(0.2*forest)";
          };
cost = 1;
        };
};
      };
};
      ...
};
    };
// ...
  };
};
};
};
};
</syntaxhighlight>
 
 
== Basic Ambient Behaviour ==


===Basic ambient behaviour===
Basic ambient behaviour is defined in '''cfgVehicles.hpp'''.
Basic ambient behaviour is defined in '''cfgVehicles.hpp'''.


class CfgNonAIVehicles
<syntaxhighlight lang="cpp">
{
class CfgNonAIVehicles
  class Bird
{
  {
class Bird
    scope = private;
{
    model="";
scope = private;
    simulation = SeaGull; //which CPP class simulate ambient behaviour
model = "";
    reversed = false;     //default is not reversed (ambients are oriented in other way, than a man)
simulation = SeaGull; // which CPP class simulate ambient behaviour
    //straightDistance,minHeight,avgHeight and maxHeight can be overiden by randomMove fsm function
reversed = false; // default is not reversed (ambients are oriented in other way, than a man)
    minHeight=5;
//straightDistance,minHeight,avgHeight and maxHeight can be overiden by randomMove fsm function
    avgHeight=10;
minHeight = 5;
    maxHeight=50;
avgHeight = 10;
    straightDistance=50; // random move will use this to set the maximum distance, where to fly
maxHeight = 50;
    minSpeed=-0.5; // m/s
straightDistance = 50; // random move will use this to set the maximum distance, where to fly
    maxSpeed=20;   // m/s
minSpeed = -0.5; // m/s
    acceleration = 7; //m/s^2
maxSpeed = 20; // m/s
    turning = 1; // angular acceleration - relative (the higher, the more maneuvrable)
acceleration = 7; // m/s^2
    flySound[]={"",db-30,1, 1};
turning = 1; // angular acceleration - relative (the higher, the more maneuvrable)
    singSound[]={"",db-30,1, 1};
flySound[] = { "", db-30, 1, 1 };
    canBeShot=true; //birds can, insect cannot
singSound[] = { "", db-30, 1, 1 };
    airFriction2[]={25,12,2.5};   //defines the matrix for computing friction
canBeShot = true; // birds can, insect cannot
    airFriction1[]={1500,700,100}; //multiplying columns changes friction in given coordinate
airFriction2[] = {25,12,2.5}; // defines the matrix for computing friction
    airFriction0[]={40,20,60};
airFriction1[] = {1500,700,100}; // multiplying columns changes friction in given coordinate
  };
airFriction0[] = {40,20,60};
  ...
};
};
// ...
};
</syntaxhighlight>
 
 
== Ambient Behaviour Specialisation ==


===Ambient behaviour specialization===
For particular species, default ''Bird'' or ''Insect'' values, defined in '''cfgVehicles.hpp''' can
For particular species, default ''Bird'' or ''Insect'' values, defined in '''cfgVehicles.hpp''' can  
be specialized:
be specialized:


class CfgNonAIVehicles
<syntaxhighlight lang="cpp">
{
class CfgNonAIVehicles
  class Insect;
{
  class Bird;
class Insect;
  class ButterFly: Insect
class Bird;
  {
class ButterFly : Insect
    model = "aglais_urticae.p3d";
{
    fsm[] = {"Butterfly"};     //there could be more FSMs for layered FSM system, but it is not implemented yet
model = "aglais_urticae.p3d";
    moves = CfgMovesButterfly; //animation subject is described on other place in wiki
fsm[] = {"Butterfly"}; // there could be more FSMs for layered FSM system, but it is not implemented yet
    //straightDistance,minHeight,avgHeight and maxHeight can be overiden by randomMove fsm function
moves = CfgMovesButterfly; // animation subject is described on other place in wiki
    straightDistance=2; // random move will use this to set the maximum distance, where to fly
//straightDistance,minHeight,avgHeight and maxHeight can be overridden by randomMove fsm function
    minHeight=-0.10; // allow landing
straightDistance = 2; // random move will use this to set the maximum distance, where to fly
    avgHeight=0.3;   // these Height values are used in random movement
minHeight = -0.10; // allow landing
    maxHeight=1.5;
avgHeight = 0.3; // these Height values are used in random movement
    minSpeed=-0.1;   // autopilot tries to make ambient fly within this range
maxHeight = 1.5;
    maxSpeed=1;       // but it is modulated only in Z coordinate, yet (side speed is still problem)
minSpeed = -0.1; // autopilot tries to make ambient fly within this range
    acceleration = 5; // m/s^2 this acceleration is used whenever possible. Ambient cannot fly with less effort.
maxSpeed = 1; // but it is modulated only in Z coordinate, yet (side speed is still problem)
    turning = 5;     // turning ability (less value, less turning ability)
acceleration = 5; // m/s^2 this acceleration is used whenever possible. Ambient cannot fly with less effort.
    reversed = false; // model is oriented in other way, than a man. With true value, ambient flies backwards.
turning = 5; // turning ability (less value, less turning ability)
    autocenter = false; //important for proper rtm animation (bones mounted on proper place)
reversed = false; // model is oriented in another way than a man. With true value, ambient flies backwards.
  };
autocenter = false; // important for proper rtm animation (bones mounted on proper place)
  ...
};
};
// ...
};
</syntaxhighlight>
 
 
{{GameCategory|arma1|Addon Configuration}}

Latest revision as of 10:58, 6 December 2023

Ambient Life Distribution

There is a probabilistic way to define ambient life distribution, depending on current time, place and weather conditions, defined in CfgWorlds.

Layer cost and species probability use Simple Expressions.

Ambient Parameters which can be used inside of expressions:

As far as probabilities are considered, for each Species class, the probabilities need sum to one. In the following example, for instance:

probability = "deadBody+(1-deadBody)*(0.5-forest*0.1-meadow*0.2)";
probability = "(1-deadBody)*(0.5-forest*0.1+meadow*0.2)";
probability = "(1-deadBody)*(0.2*forest)";

Which really sums into one, as one can easily check:

sum = deadBody+(1-deadBody)*(0.5 - 0.1*forest - 0.2*meadow + 0.5 - 0.1*forest + 0.2*meadow + 0.2*forest) =
    = deadBody+(1-deadBody)*1 = 1

More complete example follows:

class CfgWorlds
{
	class DefaultWorld
	{
		// ambient life configuration
		class Ambient
		{
			class SmallInsects
			{
				radius = 3; // radius in meters, where ambient lives (distance from the player)
				cost = "(10-5*hills)*(1-night)*(1-rain)*(1-sea)*(1-( (windy*2) min 1))"; // total number of all species
				/// species configuration
				class Species
				{
					class HouseFly
					{
						probability = "deadBody+(1-deadBody)*(0.5-forest*0.1-meadow*0.2)";
						cost = 1; // when the fly lives, it pays this cost to the total sum cost SmallInsects::cost
					};
					class HoneyBee
					{
						probability = "(1-deadBody)*(0.5-forest*0.1+meadow*0.2)";
						cost = 1;
					};
					class Mosquito
					{
						probability = "(1-deadBody)*(0.2*forest)";
						cost = 1;
					};
				};
			};
			// ...
		};
	};
};


Basic Ambient Behaviour

Basic ambient behaviour is defined in cfgVehicles.hpp.

class CfgNonAIVehicles
{
	class Bird
	{
		scope = private;
		model = "";
		simulation = SeaGull;	// which CPP class simulate ambient behaviour
		reversed = false;		// default is not reversed (ambients are oriented in other way, than a man)
		//straightDistance,minHeight,avgHeight and maxHeight can be overiden by randomMove fsm function
		minHeight = 5;
		avgHeight = 10;
		maxHeight = 50;
		straightDistance = 50; // random move will use this to set the maximum distance, where to fly
		minSpeed = -0.5;	// m/s
		maxSpeed = 20;		// m/s
		acceleration = 7;	// m/s^2
		turning = 1;		// angular acceleration - relative (the higher, the more maneuvrable)
		flySound[]	= { "", db-30, 1, 1 };
		singSound[]	= { "", db-30, 1, 1 };
		canBeShot = true;					// birds can, insect cannot
		airFriction2[] = {25,12,2.5};		// defines the matrix for computing friction
		airFriction1[] = {1500,700,100};	// multiplying columns changes friction in given coordinate
		airFriction0[] = {40,20,60};
	};
	// ...
};


Ambient Behaviour Specialisation

For particular species, default Bird or Insect values, defined in cfgVehicles.hpp can be specialized:

class CfgNonAIVehicles
{
	class Insect;
	class Bird;
	class ButterFly : Insect
	{
		model = "aglais_urticae.p3d";
		fsm[] = {"Butterfly"};		// there could be more FSMs for layered FSM system, but it is not implemented yet
		moves = CfgMovesButterfly;	// animation subject is described on other place in wiki
		//straightDistance,minHeight,avgHeight and maxHeight can be overridden by randomMove fsm function
		straightDistance = 2;		// random move will use this to set the maximum distance, where to fly
		minHeight = -0.10;			// allow landing
		avgHeight = 0.3;			// these Height values are used in random movement
		maxHeight = 1.5;
		minSpeed = -0.1;			// autopilot tries to make ambient fly within this range
		maxSpeed = 1;				// but it is modulated only in Z coordinate, yet (side speed is still problem)
		acceleration = 5;			// m/s^2 this acceleration is used whenever possible. Ambient cannot fly with less effort.
		turning = 5;				// turning ability (less value, less turning ability)
		reversed = false;			// model is oriented in another way than a man. With true value, ambient flies backwards.
		autocenter = false;			// important for proper rtm animation (bones mounted on proper place)
	};
	// ...
};