Page 1 of 1

Destroyed and burning ambient buildings

Posted: Thu Dec 06, 2012 5:28 pm
by wolfenswan
If used too much or in conjunction with WarFX these scripts can destroy the framerate. Take care.
See this entry for more explanation on how the fire works.

Image

Destroying a list of selected buildings

Code: Select all

// Burning buildings mini script
// By Wolfenswan: wolfenswanarps@gmail.com 
//
// Feature: Destroys a selection of buildings and sets them on fire
//
// Usage: 
// In the editor place gamelogics named burn, burn_1, etc on top of the buildings you want to destroy/see burn
// add object names to _firearray below
// [] execVM "ws_burningbuilding.sqf" in the init.sqf
//
// Customization: 
// Change _minfirestrength if you want a bigger/smaller fire

private ["_firearray","_fire","_building","_firestrength","_burn","_pos","_minfirestrength"]; 

BIS_Effects_Burn=compile preprocessFile "\ca\Data\ParticleEffects\SCRIPTS\destruction\burn.sqf";

//All objects placed over a building, named accordingly
_firearray = [burn,burn_1,burn_2];
_minfirestrength = 5;

{
_pos = getPos _x;
_x setPos [_pos select 0, _pos select 1, 0.1];
_building = _pos nearestObject "Building";
_building setdamage 1;
_firestrength = _minfirestrength + (ceil (random 4));
_burn = [_x,_firestrength,time,false,false] spawn BIS_Effects_Burn;
} forEach _firearray;
Destroying a random selection of buildings with a chance of fire
This script might reduce weird results (e.g. destroyed and burning walls or market stalls), depending on what it picks. You can fine tune it by narrowing down the given class in the nearestObjects check.

Code: Select all

// City in ruins mini script
// By Wolfenswan: wolfenswanarps@gmail.com 
//
// Feature:
// Destroy a  random selection of buildings and sets them on fire
//
// Usage: 
// In the editor place a gamelogic with [this,300,50,50] execVM "ws_cityinruins.sqf" in the init.sqf
// Adjust values accordingly
//
// Customization: 
// Second Number: radius around the gamelogic where buildings are affected
// Third number: chance in 100 that a building in the radius is destroyed
// Fourth number: chance in 100 that a destroyed building is burning
//
// Note:
// Not JIP-compatible

private ["_center","_radius","_fire","_destructometer","_firechance","_buildings","_count","_firestrength","_minfirestrength","_firearray","_destroyarray"];

BIS_Effects_Burn=compile preprocessFile "\ca\Data\ParticleEffects\SCRIPTS\destruction\burn.sqf";
_center = _this select 0;
_radius = _this select 1;
_destructometer = _this select 2;
_firechance = _this select 3;

_minfirestrength = 5;
_buildings = nearestObjects [_center, ["building"], _radius];
_count = count _buildings;
_destroyarray = [];
_firearray = [];

if (isServer) then {
for "_i" from 1 to _count do {
if (round random 100 <= _destructometer) then {
_building = _buildings select _i;
_destroyarray = _destroyarray + [_building];
	if (round random 100 <= _firechance) then {
	_fire = "LocationLogic" createVehicle (getPos _building);
	_firearray = _firearray + [_fire];
	};};};
ws_firearray = _firearray; publicvariable "ws_firearray";
ws_destroyarray = _destroyarray; publicvariable "ws_destroyarray";
};

waituntil {(!isNil "ws_destroyarray")};

{_x setdamage 1;} forEach ws_destroyarray;
{
_firestrength = _minfirestrength + (ceil (random 4));
_burn = [_x,_firestrength,time,false,false] spawn BIS_Effects_Burn;
} forEach ws_firearray;