
-= OFP Blood Effects 1.4 =-

WARNING!!! This addon seriously ups the 'gore factor' in OFP. It is not recommended for use by children under the age of 15.

The authors take no responsibility for this addon; it is meant to be used by adults. The authors ask mission makers to include a warning similar to this in missions that utilise this addon.

This script is MP compatible, and requires OFP version 1.90 (minimum).

Authors:
--------

* concept by Igor Drukov
* scripting / PBO compilation by snYpir
* default blood objects by Asmodeus

Changes:
--------

1.4 - FINAL!
1.4 - Reduced the slight lag each time a blood spray is initiated
1.4 - Added new variables for blood z velocity, removed blood_particle_vertshift
1.4 - Added a new variable (blood_particle_spreadfactor) which determines the probability distribution of blood in the spray
1.4 - Added a new variable (blood_particle_color) which sets the colour of the blood spray
1.4 - Added a new variable (blood_particle_disable) which disables blood particles
1.4 - Added a new variable (blood_object_disable) which disables blood splatters

1.3 - Big code changes to make blood splatter more realistic (more blood closer to the casualty, blood splats now happen exactly when the particles hit the ground). Still not as efficient as I want it, so wait out for 1.4...
1.3 - Added 'blood_bleeding_life' - sets how long 'bleeding' objects remain before disappearing.
1.3 - Many defaults changed to make the blood splatter and bleeding less processor-intensive and more realistic.
1.3 - A list of objects for bleeding can now be specified (and the actual object chosen is randomly chosen).
1.3 - You can now specify damage from bloodloss (must set blood_bleeding_bloodloss_disable = false) to enable.
1.3 - Different decrypted config.bin file now utilised as required (see Advanced Installation below).
1.3 - Parameters to blood_init.sqs in config.cpp now work as expected (use the new config.cpp as per Advanced Installation).
1.3 - Multiplayer works (blood splatter, bleeding and damage from bloodloss). No in-mission changes required, and the seperate 'server' game logic unit is not required.
1.3 - Blood objects updated by Asmodeus.

1.2 - Added support for blood to be defined in a decrypted config.bin file (see Advanced Installation below). This allows blood to be enabled for ALL units in ALL missions and campaigns.
1.2 - Dripping blood now has a minor random position, and comes up through the ground rather than simply appearing.
1.2 - Default maximum number of blood particles reduced to 400 to reduce lag.

1.1 - Implemented bleeding
1.1 - Moved all initialisation from blood_squit.sqs to blood_init.sqs

Installation:
-------------

* Copy OFPEC_Blood.pbo to your \Addons directory.

* Open your mission in the mission editor

* Create a single trigger

- As big as the whole map (axis a and b 20000)
- Activation: Anybody Once
- Condition: this
- On Activation (copy (ctrl-C) then paste (ctrl-V) this directly into the box):

[] exec "\OFPEC_Blood\blood_init.sqs"; "if ({Man} counttype [_x] == 1) then {_x addeventhandler [{hit},{_this exec {\OFPEC_Blood\blood_squirt.sqs}}]}" forEach thislist

Multiplayer Installation:
-------------------------

* Follow the instructions above.

* Insert a 'Empty -> Objects -> OFPEC Blood: MP Enabler' object into your mission (ensures that the OFPEC_Blood addon is inserted into your mission.sqm file header).

Example mission:
----------------

Copy BloodDemo.Eden to your \Users\<your username>\Missions directory and preview in the editor.

Advanced Installation:
----------------------

You can make ALL units in the game (in every mission and campaign) have blood effects enabled by using a decrypted \Res\Bin\config.bin file.

Download it here:

http://members.hn.ozemail.com.au/morpj97/configs.zip

All you have to do is copy \OFPEC_Blood\config.cpp to your \Res\Bin folder.

The changes that have been made to the default config.bin file are as follows (this is simply for your information):

class Man: Land
{

After the line above:

		class EventHandlers
		{
			init="[] exec ""\OFPEC_Blood\blood_init.sqs""";
			hit="_this exec ""\OFPEC_Blood\blood_squirt.sqs""";
		};

And also:

	class PreloadAddons
	{

After the line above:

		class OFPEC_Blood
		{
			list[]={"OFPEC_Blood"};
		};

WARNING! In MP games other players will be notified that you have a modified config. Other players may think you are cheating.

BUG: For some reason, this advanced method does not work for MP games at all (you need to insert the blood trigger into the MP mission as per 'installation'). I am working on a fix.

Settings:
---------

There are two ways to configure blood. They are:

a) by setting variables in your mission's init.sqs file - easy.
b) by passing parameters to blood_init.sqs (required if you are using the blood through modifying your config.cpp file) - advanced.

-======================-
Init.sqs Settings (easy)
-======================-

These are all automatically set by the blood scripts and are entirely optional. You set these in your mission's init.sqs file.

PARTICLE SETTINGS:
------------------

Blood particles are what fly through the air.

------

* the horizontal angle that blood spurts from the exit wound
   - default is 25

blood_particle_dirshift = <number>

------

* minimum speed of blood from the exit wound
   - default is 7

blood_particle_minspeed = <number>

------

* maximum speed of blood from the exit wound
   - default is 9

blood_particle_maxspeed = <number>

------

* minimum vertical speed of blood
   - default is -5

blood_particle_minvertspeed = <number>

------

* maximum vertical speed of blood
   - default is 3

blood_particle_maxvertspeed = <number> 

------

* maximum size of particles
   - default is 0.06

blood_particle_maxsize = <number>

------

* minimum size of particles
   - default is 0.03

blood_particle_minsize = <number>

------

* percentage chance of each blood particle spawning a blood texture on the ground
   - default is 0.75

blood_particle_spawn_chance = <number>

------

* number of blood particles created per wound
   - default is 40

blood_particle_number = <number>

------

* make the number of blood particles created proportional to the damage being inflicted?
   - this means that a damage of '1' would create 'blood_particle_number' particles, whereas a damage of '0.5' would create 'blood_particle_number / 2'
   - default is false

blood_particle_damage_proportional = <boolean>

------

* the amount of blood spread between the various spray settings defined above
   - default is 2
   - reduce to spread blood further, increase to spread less distance

blood_particle_spreadfactor = <number>

------

* the colour of blood particles
   - default is [0.3,0,0,1]
   
blood_particle_color = [<number>,<number>,<number>,<number>]

------

* disable blood particles
   - default is false
   
blood_particle_disable = <boolean>

------

BLOOD TEXTURE SETTINGS:
-----------------------

Blood textures are the objects spawned on the ground where the particles land

------

* time that blood textures hang around for before disappearing
   - default is 30
   - make this value equal -1 to never delete blood objects
   - this is not accurate to the second (it depends on the speed of your machine)

blood_object_life = <number>

------

* list of blood texture objects
   - default is ["ASM_Bldsplat","ASM_Bldchnk","ASM_Bldchnk2","ASM_Bldchnk3"]

blood_object_list = [<string>,...]

------

* relative percentage chance of showing each blood texture object
   - must add up to 1
   - default is [0.1,0.3,0.3,0.3]

blood_object_list_chance = [<number>,...]

------

* the maximum number of blood objects allowed
   - default is 400

blood_object_maximum = <number>

------

* disable blood splatters
   - default is false
   
blood_object_disable = <boolean>

------

BLEEDING SETTINGS:
------------------

Bleeding units will spawn blood textures as they move, and may suffer damage from bloodloss if blood_bleeding_bloodloss_disable equals false.

------

* disable bleeding?
   - default is false

blood_bleeding_disable = <boolean>

------

* list of blood objects to be used for 'bleeding' units
   - in increasing order of severity
   - the actual objects spawned are picked from the lists specified
   - default is [["ASM_Bldchnk3","ASM_Bldchnk2","ASM_Bldchnk"],["ASM_Bldchnk3","ASM_Bldchnk2","ASM_Bldchnk"],["ASM_Bldsplat"]]

blood_bleeding_list = [[<string>,...],...]

------

* list of the amount of damage to use each of the objects in blood_bleeding_list
   - default is [0.4,0.7,1]

blood_bleeding_damage = [<number>,...]

------

* how many seconds between bleeding for damaged units?
   - format [min time in seconds, max time in seconds]
   - default is [[0.5,6],[0.5,3],[0.5,3]]

blood_bleeding_pause = [[<number>,<number>],...]

------

* how many seconds does blood from wounds remain on the ground before disappearing?
   - default is 30

blood_bleeding_life = <number>

------

* damage from bloodloss.
   - this is calculated in DAMAGE PER MINUTE. array elements match those in blood_bleeding_damage.
   - format for each element is [<min damage per minute>,<max damage per minute>].
   - default is [[0,0],[0,0.05],[0.05,0.1]]
      - this means that at a damage of 0.4 - 0.7 (2nd element in blood_bleeding_damage) the unit will suffer between 0 and 0.05 damage from bloodloss per minute

blood_bleeding_bloodloss_damage = [[<number>,<number>],...]

------

* disable damage from bloodloss?
   - default is true

blood_bleeding_bloodloss_disable = <boolean>

-=====================================-
Parameters to blood_init.sqs (advanced)
-=====================================-

You can define the settings for blood via the parameters you pass to blood_init.sqs.

Blood_init.sqs takes 3 parameters. They are:

[[particle settings],[object settings],[bleeding settings]]

The order is as follows (see the descriptions above if you need to):

Particle settings:

[
	<blood_particle_dirshift> (number),
	<blood_particle_minspeed> (number),
	<blood_particle_maxspeed> (number),
	<blood_particle_minvertspeed> (number),
	<blood_particle_maxvertspeed> (number),	
	<blood_particle_maxsize> (number),
	<blood_particle_minsize> (number),
	<blood_particle_spawn_chance> (number),
	<blood_particle_number> (number),
	<blood_particle_damage_proportional> (boolean),
	<blood_particle_spreadfactor> (number),
	<blood_particle_color> ([<number>,<number>,<number>,<number>]),
	<blood_particle_disable> (boolean)
]

Object settings:

[
	<blood_object_life> (number),
	<blood_object_list> ([<string>,...]),
	<blood_object_list_chance> ([<number>,...]),
	<blood_object_maximum> (number),
	<blood_object_disable> (boolean)
]

Bleeding settings:

[
	<blood_bleeding_disable> (boolean),
	<blood_bleeding_list> ([[<string>,...],...]),
	<blood_bleeding_damage> ([<number>,...]),
	<blood_bleeding_pause> ([[<number>,<number>],...]),
	<blood_bleeding_life> (number),
	<blood_bleeding_bloodloss_damage> ([[<number>,<number>],...]),
	<blood_bleeding_bloodloss_disable> (boolean)
]

Note that you don't have to enter in all parameters. For example, to enter in only the object settings, you can use:

[[],[30,["ASM_Bldsplat","ASM_Bldchnk","ASM_Bldchnk2","ASM_Bldchnk3"],[0.1,0.3,0.3,0.3],1000],[]]

Simply use '[]' (an empty array) for default settings.

The rule of thumb is: You have to enter everything to the left of whatever setting you want to specify.

So, if you are calling blood through a config.cpp file and you only wanted to set the life of blood objects to 10, you'd use:

init="[[],[10]] exec ""\OFPEC_Blood\blood_init.sqs""";

How it works:
-------------

Whenever a unit is damaged, the 'hit' eventhandler causes the blood scripts (within OFPEC_Blood.sqs) to be run.

Large particles will be created, representing blood flying from the hit unit. Each particle has a blood_particle_spawn_chance chance of spawning a blood texture on the ground where it lands.

The spawned texture will remain for blood_object_life seconds. If blood_object_life equals -1, the spawned texture will remain forever (on until it is deleted because there are more than blood_object_maximum blood objects on the map).

If more than blood_object_maximum blood objects are spawned, the oldest particles will be deleted to make room for the new ones.

On a 600 mhz machine, 200 is probaly the maximum number of blood objects you'd want to create. On a 1.7 ghz machine 400 is probaly the maximum number you'd want to create.

Note:
-----

Units created with 'CreateVehicle' will not have the blood effects enabled. If the unit you create is named 'my_unit', you could use the following line of code to enable blood effects for that unit:

my_unit addeventhandler [{hit},{_this exec {\OFPEC_Blood\blood_squirt.sqs}}]

Blood objects:
--------------

"ASM_Bldsplat" - A very large almost rectangular pool of blood

"ASM_Bldchnk" - A large round pool

"ASM_Bldchnk2" - A medium round pool

"ASM_Bldchnk3" - A small round pool

Troubleshooting:
----------------

Q: I used the modified config, and so does a friend. However, in MP blood does not work!

A: This is a bug. For some reason, the config.cpp modification does not work for MP games at all (you need to insert the blood trigger into the MP mission as per 'installation'). I am working on a fix.

Q: I have inserted the blood trigger as per 'installation'. However, in MP, I get a 'OFPEC_Blood addon not installed' error message!

A: Insert a 'Empty -> Objects -> OFPEC Blood: MP Enabler' object into your mission as per the 'Multiplayer Installation' instructions above.

Contact:
--------

Contact snYpir at morpj97@hn.ozemail.com.au with any queries or bug reports.

Or ask your question in the following thread in the official forum:

http://www.flashpoint1985.com/cgi-bin/ikonboard301/ikonboard.cgi?s=3ec1646d55a8ffff;act=ST;f=4;t=30241