Jump to content
johnnyboy

How to create underwater bubble FX and underwater blood Fx

Recommended Posts

I need to script underwater bubbles, and underwater blood.

 

For a marine salvage mission, I want player to attach simulated inflatable objects to a sunken wreck, and inflate them to raise the wreck.  This inflation should generate a lot of bubble effects.

 

I also want to create blood underwater on demand. This would be the same blood you see when you shoot a unit under water.

 

Any help is appreciated!

Share this post


Link to post
Share on other sites

I've been using these for some own stuff of mine. Here you go:

TAG_fnc_BUBBLES

Spoiler

/*
	Function: TAG_fnc_BUBBLES
	Author: BIS Bubble module, HallyG
	SPAWNS BLOOMIN BUBBBBBBBBBBLES
	
	Arguments(s):
	0: Emitter Position <OBJECT, POSITION>
	1: Bubble size  (default: 1) <NUMBER>
	2: Bubble drop interval (rate at which particles are emitted, smaller = MORE BUBBLES)  (default: 1) <NUMBER>
	2: Bubble velocity (from source) [X speed, Y speed, Z speed]  (default: [0,0,1]) <ARRAY>
	3: Bubble lifetime (default: 5) <NUMBER>
	
	Return Value:
	Emitter <OBJECT>
		
	Example:
	[
		getPos player,
		1,
		0.01,
		[0,0,-1],
		10
	] call TAG_fnc_BUBBLES;
__________________________________________________________________*/
params [ 
	["_position", [0,0,0], [[]]], 
	["_size", 1, [0]], 
	["_dropInterval", 0.1, [0]], 
	["_speed", [0, 0, 1], [[]], [3]], 
	["_lifeTime", 5, [0]] 
]; 
_speed params ["_speedX", "_speedY", "_speedZ"]; 

_position = _position call {
	if (_this isEqualType objNull) exitWith {getPosATL _this};
	_this
};
	
if ((_position select 2 > -0.01) && (surfaceIsWater _position)) then {
	_position = _position vectorAdd [0,0,-0.1];
};

_source = "#particlesource" createVehicleLocal _position; 
_source setParticleParams [ 
	["\A3\data_f\ParticleEffects\Universal\Universal",16,13,7,0], 
	"", "Billboard", 1, 50, [0, 0, 0],
	[_speedX, _speedY, _speedZ],
	0, 1, 1, 15, 
	[0.05 * _size], 
	[[1,1,1,-2]], 
	[1000], 0.12, 0.045, "", "", "" 
]; 
	 
// CHANGE THESE TO IMPROVE YOUR BUBBLES
// Sets randomization of particle source parameters
_source setParticleRandom [ 
	20,  					// lifeTimeVar
	[0,0,0], 				// positionVar
	[2,2,0], 				// moveVelocityVar --> BIS module default ([0.02,0.02,0]) 
	0,						// rotationVelocityVar
	(0.005 * _size), 		// sizeVar
	[0,0,0,1], 				// colorVar
	0.003,					// randomDirectionPeriodVar --> BIS module default (0) 
	0 						// randomDirectionIntensityVar --> BIS module default (0)
];
	 
_source setDropInterval _dropInterval; 
_source

 

 

 

TAG_fnc_BLOOD

Spoiler

/*
	Function: TAG_fnc_BLOOD
	Author: BIS, HallyG
	SPAWNS BLOODY BLOOD
	
	Arguments(s):
	0: Emitter Position <OBJECT, POSITION>
	1: Damage, 0 -1. Large numbers produce lots of particles   (default: 0.2) <NUMBER>
	2: Bullet speed (default: 10) <NUMBER>
	2: Surface Normal (default: [0,0,0]) <ARRAY>
	3: Bullet Direction (default: [0,0,5]) <ARRAY>
	
	Return Value:
	Emitter <OBJECT>
		
	Example:
	[
		player,
		0.1, 10,
		[0,0,0],
		[0,0,10]
	] call TAG_fnc_BLOOD
__________________________________________________________________*/
params [ 
	["_position", [0,0,0], [[], objNull]],
	["_damage", 0.2, [0]],
	["_bulletSpeed", 10, [0]],
	["_surfaceNormal", [0,0,0], [[]], [3]],
	["_bulletDirection", [0,0,5], [[]], [3]]
]; 
_bulletDirection params ["_bulletDirectionX", "_bulletDirectionY", "_bulletDirectionZ"]; 
_surfaceNormal params ["_surfaceNormalX", "_surfaceNormalY", "_surfaceNormalZ"]; 
	
_position = _position call {
	if (_this isEqualType objNull) exitWith {getPosATL _this};
	_this
};

_damage = (_damage min 1) max 0;
_source = "#particlesource" createVehicleLocal _position;
_source setPosATL _position;

_source setParticleParams [
	[
		"\A3\data_f\ParticleEffects\Universal\Universal",
		16,
		13,
		1,
		0
	],
	"",
	"Billboard",
	1,
	3,
	[0,0,0],
	[
		(- (_bulletDirectionX * 2 - _surfaceNormalX / 4) * _bulletSpeed / 200) * (_damage + 0.2),
		(- (_bulletDirectionY * 2 - _surfaceNormalY / 4) * _bulletSpeed / 200) * (_damage + 0.2),
		(- (_bulletDirectionZ * 2 - _surfaceNormalZ / 4) * _bulletSpeed / 200) * (_damage + 0.2)
	],
	1,
	1.275,
	1,
	10,
	[0.02 + (0.06 * _damage),0.17 + (0.51 * _damage),0.23 + (0.69 * _damage), 0.27 + (0.8 * _damage),0.31 + (0.93 * _damage),0.34 + (1.01 * _damage)],
	[[1,0.8,0.8,0.5],[1,0.8,0.8,0.4],[1,0.8,0.8,0.3],[1,0.8,0.8,0.22],[1,0.8,0.8,0.16],[1,0.8,0.8,0.08],[1,0.8,0.8,0.01]],
	[0.1],
	0,
	0,
	"",
	"",
	"",
	0
];


_source setParticleRandom [ 
	4,
	[0.01, 0.01, 0.01],
	[0.5 * _damage, 0.5 * _damage, 0.5 * _damage],
	1,		
	0.02, 		
	[0,0,0,0.2], 
	0,				
	0, 
	360
];

_source setDropInterval (0.09 * (1.1 - _damage));	
_source

 

 

 

TAG_fnc_BLOOD uses an ATL position. So if you use:

(getPosATL player) vectorAdd [0,0, HEIGHT ABOVE SEA FLOOR]

As the first argument it should be fine

  • Like 3

Share this post


Link to post
Share on other sites

Wow, perfect.  Thanks much for the bloomin' bubbles and bloody blood!  I owe you a couple pints mate.

 

Maybe you could educate me a bit on this...When I read the two scripts, I don't see a parameter saying "bubbles" or "blood".   How does Universal translate into these entirely different looking particles?  How did you find these...experimentation?

  • Like 1

Share this post


Link to post
Share on other sites

Butterflies!....underwater bubbles!....underwater blood!.....wtf are you up to dude! :don11:

  • Like 2

Share this post


Link to post
Share on other sites
Just now, Evil Organ said:

Butterflies!....underwater bubbles!....underwater blood!.....wtf are you up to dude! :don11:

Connect the dots my friend...  All will be revealed in good time!

  • Like 3

Share this post


Link to post
Share on other sites

cfgCloudlets in the config viewer. It displays the particle parameters for most of the particles used in the game. Some of the parameters can have a formula (similar to the one in TAG_fnc_BLOOD) which alter some of the parameters passed upon the arguments provided. 

 

Added to that it involves some experiment in the editor by changing their random velocities, rotation and stuff.

 

I think it creates a generic particle and just changes its colour (including transparency), velocity and more.

So for example a 'blood' particle is darker, more opaque and heavier than a 'bubble' particle. I'd post links to the wiki pages but I'm not at my computer right now. 

 

 

Haha, I can't say but it's fairly out there (I feel like constant studying for my finals has added to its absurdity..)

 

 

  • Like 3

Share this post


Link to post
Share on other sites
4 hours ago, johnnyboy said:

Connect the dots my friend...  All will be revealed in good time!

Is this what the whole exploding butterflies were all about the other day?

*shakes head* , how in gods name is this going to make sense. 

Share this post


Link to post
Share on other sites
On 5/16/2017 at 4:07 AM, HallyG said:

TAG_fnc_BLOOD

  Reveal hidden contents


/*
	Function: TAG_fnc_BLOOD
	Author: BIS, HallyG
	SPAWNS BLOODY BLOOD
	
	Arguments(s):
	0: Emitter Position <OBJECT, POSITION>
	1: Damage, 0 -1. Large numbers produce lots of particles   (default: 0.2) <NUMBER>
	2: Bullet speed (default: 10) <NUMBER>
	2: Surface Normal (default: [0,0,0]) <ARRAY>
	3: Bullet Direction (default: [0,0,5]) <ARRAY>
	
	Return Value:
	Emitter <OBJECT>
		
	Example:
	[
		player,
		0.1, 10,
		[0,0,0],
		[0,0,10]
	] call TAG_fnc_BLOOD
__________________________________________________________________*/
params [ 
	["_position", [0,0,0], [[], objNull]],
	["_damage", 0.2, [0]],
	["_bulletSpeed", 10, [0]],
	["_surfaceNormal", [0,0,0], [[]], [3]],
	["_bulletDirection", [0,0,5], [[]], [3]]
]; 
_bulletDirection params ["_bulletDirectionX", "_bulletDirectionY", "_bulletDirectionZ"]; 
_surfaceNormal params ["_surfaceNormalX", "_surfaceNormalY", "_surfaceNormalZ"]; 
	
_position = _position call {
	if (_this isEqualType objNull) exitWith {getPosATL _this};
	_this
};

_damage = (_damage min 1) max 0;
_source = "#particlesource" createVehicleLocal _position;
_source setPosATL _position;

_source setParticleParams [
	[
		"\A3\data_f\ParticleEffects\Universal\Universal",
		16,
		13,
		1,
		0
	],
	"",
	"Billboard",
	1,
	3,
	[0,0,0],
	[
		(- (_bulletDirectionX * 2 - _surfaceNormalX / 4) * _bulletSpeed / 200) * (_damage + 0.2),
		(- (_bulletDirectionY * 2 - _surfaceNormalY / 4) * _bulletSpeed / 200) * (_damage + 0.2),
		(- (_bulletDirectionZ * 2 - _surfaceNormalZ / 4) * _bulletSpeed / 200) * (_damage + 0.2)
	],
	1,
	1.275,
	1,
	10,
	[0.02 + (0.06 * _damage),0.17 + (0.51 * _damage),0.23 + (0.69 * _damage), 0.27 + (0.8 * _damage),0.31 + (0.93 * _damage),0.34 + (1.01 * _damage)],
	[[1,0.8,0.8,0.5],[1,0.8,0.8,0.4],[1,0.8,0.8,0.3],[1,0.8,0.8,0.22],[1,0.8,0.8,0.16],[1,0.8,0.8,0.08],[1,0.8,0.8,0.01]],
	[0.1],
	0,
	0,
	"",
	"",
	"",
	0
];


_source setParticleRandom [ 
	4,
	[0.01, 0.01, 0.01],
	[0.5 * _damage, 0.5 * _damage, 0.5 * _damage],
	1,		
	0.02, 		
	[0,0,0,0.2], 
	0,				
	0, 
	360
];

_source setDropInterval (0.09 * (1.1 - _damage));	
_source

 

 

 

TAG_fnc_BLOOD uses an ATL position. So if you use:


(getPosATL player) vectorAdd [0,0, HEIGHT ABOVE SEA FLOOR]

As the first argument it should be fine

 

Hey, i am fairly new to scripting, where would I put these sections in? init.sqf ? And "(getPosATL player) vectorAdd [0,0, HEIGHT ABOVE SEA FLOOR]" on the player? (Assuming this still works after 4 years)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×