Jump to content
Sign in to follow this  
Nephris1

Chimney smoke / House light

Recommended Posts

Hi folks,

we all know the Silvie Modul,

where the functions of civialian population and smoking chimney and lightened houses are implemented.

I dont want to have my little village populated but the chimneys to be smoking and some houses lightened.

Therefor i would like to use a script from the module which is fnc_houseEffects.sqf from "Alice\data\scripts\";

But i am not able to figure out how to call that script out off the module.

So could u help me to adapt the script for custom use exterior of the module?

scriptName "Alice\data\scripts\fnc_houseEffects.sqf";
/*
File: fnc_houseEffects.sqf
Author: Karel Moricky

Description:
Creates effects on house (lights in windows, chimney smoke)

Parameter(s):
_this: OBJECT - house
*/

_mode = _this select 0;
_door = _this select 1;
_obj = _door getvariable "ALICE_obj";
_logic = bis_alice_mainscope;

switch (_mode) do {

//--- START
case 1: {
	if (count crew _door > 1) exitwith {};

	//--- Partcile Sources
	_PSlist = [];
	for "_i" from 0 to 10 do {
		_pos = _obj selectionposition format ["AIChimney_small_%1",_i];
		if (_pos distance [0,0,0] == 0) exitwith {};

		if (random 1 > 0.5) then {
			_worldpos = (_obj modeltoworld _pos);

			_PS = "#particlesource" createVehicle _worldpos;
			_PS setParticleCircle [0, [0, 0, 0]];
			_PS setParticleRandom [1, [0, 0, 0], [0.1, 0.1, 0.1], 2, 0.2, [0.05, 0.05, 0.05, 0.05], 0, 0];
			_PS setParticleParams [["\Ca\Data\ParticleEffects\Universal\universal.p3d", 16, 8, 16], "", "Billboard", 1, (4 + random 4), [0,0,0], [0, 0, 0.5 + random 0.5], 1, 1.275, 1, 0.066, [0.4, 1 + random 0.5, 2 + random 2], [[0.4, 0.4, 0.4*1.2, 0.1 + random 0.1], [0.5, 0.5, 0.5*1.2, 0.05 + random 0.05], [0.7, 0.7, 0.7*1.2, 0]], [0], 1, 0, "", "", ""];
			_PS setDropInterval .3;
			_PSlist = _PSlist + [_PS];
		};

	};
	_door setvariable ["BIS_ALICE_PS",_PSlist];

	//--- Global manager of house effects
	if (isnil {_logic getvariable "ALICE_houseffects"}) then {
		_scope = _logic spawn {
			scriptname "Alice\data\scripts\fnc_houseEffects.sqf:Loop";
			_logic = _this;
			while {true} do {
				waituntil {daytime > 17 || daytime < 4};
				_list = _logic getvariable "ALICE_houseffects";
				//_delay = 100 / (count _list + 1);
				{
debuglog str ["Log:::::::::",_x];
					_door = _x;
					_obj = _door getvariable "ALICE_obj";
					_limit = 0.5;
					if (daytime > 17 && daytime < 21) then {_limit = 0.2};
					if (daytime > 0 && daytime < 4) then {_limit = 1};

					//--- Let there be the light!
					for "_i" from 1 to 5 do {
						if (random 1 > _limit) then {
							_obj animate [format ["Lights_%1",_i],1];
						} else {
							_obj animate [format ["Lights_%1",_i],0];
						};
					};
					//sleep _delay;
					sleep 1;
				} foreach _list;
			};
		};
		_logic setvariable ["ALICE_houseffects",[]];
	};
	[_logic,"ALICE_houseffects",[_door]] call bis_fnc_variablespaceadd;
};

//--- END
case 0: {
	_destroyed = if (count _this > 2) then {_this select 2} else {false};

	if (count crew _door > 0 && !_destroyed) exitwith {};

	_PSlist = _door getvariable "BIS_ALICE_PS";
	if (!isnil "_PSlist") then {
		for "_i" from 1 to 5 do {
			_obj animate [format ["Lights_%1",_i],0];
		};
		{deletevehicle _x} foreach _PSlist;

		_door setvariable ["BIS_ALICE_PS",nil];
	};

	[_logic,"ALICE_houseffects",[_door]] call bis_fnc_variablespaceremove;
};

default {};
};

Share this post


Link to post
Share on other sites

I'm actually working on adapting this script to my needs myself.

This is what I have as of now:

//Based on \modules\ALICE\data\scripts\fnc_houseEffects.sqf by Karel Moricky


// chance: 1 - 100% chance | 0.5 = 50% chance | 0 = 0% chance
//         [  [ house (object), chance for lights, chance for smoke ] ]
_houseArray = [[(getMarkerPos "houses") nearestObject 123456, 0.5, 0]];

DFS_houseEffects_serverReady = false;

if (isServer) then
{ //Server only part:
{
	_house = _x select 0;
	if ((_x select 1) > 0) then
	{ //Window lights:
		_windows = [];
		for "_i" from 1 to 5 do
		{
			_light = format ["Lights_%1",_i];

			_chance = 1 - (_x select 1);
			if (random 1 > _chance) then
			{
				_windows set [count _windows, _light];
			};
		};

		_house setVariable ["DFS_houseEffects_windows", _windows, true];
	};

	if ((_x select 2) > 0) then
	{ //Chimney smoke:
		_particlePos = [];
		_count = 0;
		for "_i" from 0 to 10 do
		{
			_pos = _house selectionPosition format ["AIChimney_small_%1", _i];
			if (_pos distance [0,0,0] == 0) exitWith {}; //No such chimney

			_chance = 1 - (_x select 2);
			if (random 1 > _chance) then
			{
				_particlePos set [count _particlePos, (_house modelToWorld _pos)];
			};
		};

		_house setVariable ["DFS_houseEffects_smokes", _particlePos, true];
	};
} forEach _houseArray;

DFS_houseEffects_serverReady = true;
publicVariable "DFS_houseEffects_serverReady";
};

if (!isServer || !isDedicated) then
{ //Client only part:
waitUntil {DFS_houseEffects_serverReady};
{
	_house = _x select 0;
	if ((_x select 1) > 0) then
	{ //Window lights:
		_windows = _house getVariable "DFS_houseEffects_windows";
		{
			_house animate [_x, 1];
		} forEach _windows;
		_particlePos = _house 
	};

	if ((_x select 2) > 0) then
	{ //Chimney smoke:
		_psArray = [];
		_smokes = _house getVariable "DFS_houseEffects_smokes";
		{
			_ps = "#particlesource" createVehicle _x;
			_ps setParticleCircle [0, [0, 0, 0]];
			_ps setParticleRandom [1, [0, 0, 0], [0.1, 0.1, 0.1], 2, 0.2, [0.05, 0.05, 0.05, 0.05], 0, 0];
			_ps setParticleParams [["\Ca\Data\ParticleEffects\Universal\universal.p3d", 16, 8, 16], "", "Billboard", 1, (4 + random 4), [0,0,0], [0, 0, 0.5 + random 0.5], 1, 1.275, 1, 0.066, [0.4, 1 + random 0.5, 2 + random 2], [[0.4, 0.4, 0.4*1.2, 0.1 + random 0.1], [0.5, 0.5, 0.5*1.2, 0.05 + random 0.05], [0.7, 0.7, 0.7*1.2, 0]], [0], 1, 0, "", "", ""];
			_ps setDropInterval 0.3;
			_psArray = _psArray + [_ps];
		} forEach _smokes;
		_house setVariable ["DFS_houseEffects_psArray", _psArray, false];
	};
} forEach _houseArray;
};

Edited by Deadfast

Share this post


Link to post
Share on other sites

Bumping old thread - has anyone tried this in arrowhead? I'm doubting the chimney works but can the rest be adapted for OA?

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
Sign in to follow this  

×