Depending on the settings these two can destroy the framerate. Take care.
Also note that these won't work when testing locally, only on dedicated servers!
To make them work locally (but not on servers!) remove the if !(isServer) exitWith {}; part (but not it's contents).
Creating a burning ruin of a building:
Put down a game logic -> location over the building you want destroyed and put this code in it's init:
Code:
nul = [this] execVM "ws_burningbuilding.sqf";
ws_burningbuilding.sqf is:
Code:
// 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;
see this entry for an explanation of the parameters
for only a ruin without fire it's enough to create a logic over the building and put in it's init:
Code:
(getPos this nearestObject "Building") setdamage 1;
2012-03-14_00041.jpg
Destroying a complete city AND setting it on fire:
Create a logic in the center of the town you want to destroy and put
Code:
nul = [this,500,50,100] execVM "ws_cityinruins.sqf";
in the init
Note: Locality for this needs further testing, it might not be identical for all clients.
The ws_cityinruins.sqf:
Code:
// 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","_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" to _count do {
if (round random 100 <= _destructometer) then {
_building = _buildings select _i;
_destroyarray = _destroyarray + _building;
if (round random 100 <= _firechance) then {
format ["_fire%1",_i] = "LocationLogic" createVehicle (getPos _building);
_firearray = _firearray + format ["_fire%1",_i];
};};};
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;