Jump to content
Sign in to follow this  
Rg

Make A City/Town Ruined/Destroyed At Mission Start?

Recommended Posts

Having a beaten and battered City/Town can be great to have for missions, both visually and for gameplay (Random destruction, not completely leveled).

I know you can get something like this accomplished by dropping a bunch of GBU's on buildings at mission start, but this is not acceptable if you want to setup a town with strategically placed units and vehicles at the start.

Q: Is there anyway, maybe via a script, to automatically destroy all or parts of buildings within a certain radius?

Share this post


Link to post
Share on other sites
Not sure of a radius per se, but I have been able to knock down parts of cities with one trigger and muptile GameLogics...each named differently. The destroyed buidlings look great too.. Id be interested in a diff way if anyone knows how

http://forums.bistudio.com/showthread.php?p=1441229#post1441229

Thanks for the reply. Thats an interesting method using game logics. I tried it out and there are two issues that came up.

1) setDamage to buildings still hurts or kills units near by from building collapse.

2) This seems to completely level buildings rather then using the new destructible building feature allowing certain sections of a building to be carved out.

This is definitely better then nothing and I'll probably be using it from time to time, but hopefully another method can be thought up.

Share this post


Link to post
Share on other sites

Rg, are you talking about putting AI units or player units (or both) in the damaged town? I have a hunch that it'll be hard to make a damaged town before the game starts (and units are initialized).

I ask because if you're putting AI in, you can spawn them after a certain delay, like after the dust settles from the GBUs or setDamage or whatever, via a trigger to a little createUnit/createVehicle/createGroup script(s). Another workaround would be to start the units nearby and just use waypoints to move them to position after a set amount of time.

Not perfect, but might be the easy route. If you're comfortable with triggers as delays/conditions for waypoints, that would go a long way, really.

Share this post


Link to post
Share on other sites

@F2k Sel

I should have tested setDamage on more buildings. I just quickly tested three buldings on Utes using values (0.5, 0.75, and 1.0). The buildings I tried with <1 damage did not show chunks missing, just minor changes like broken glass. I'll test this on more buildings tonight that I know for sure break into sections.

Can those lines of code to protect units simply be used in the init of a trigger or does a script need to be run?

@Lucky

I was talking about both Players and AI. It's a bummer there can't be an easier way about this.

I don't have experiance with creating units with waypoints via script outside of ups and dac, but I'm more then comfortable using waypoints with conditions, so that is what I will have to settle with. Player start points will have to be outside of town or use some tricks at mission start (allowdamage/blackout/fadesound).

Thanks guys,

Share this post


Link to post
Share on other sites

setHit:

Code fixed, and tested.

Place some object in the town.

Init Line:

_ruin = this execVM "ruin.sqf";

ruin.sqf

private ["_blgs", "_blg", "_blgtyp", "_scts", "_hitmx", "_sctcl", "_sct"];
_blgs = nearestObjects [_this, ["Building"], 700];
{ 
_blg = _x;
_blgtyp = typeOf _blg;
_scts = [];
_hitmx = (count (configFile >> "CfgVehicles" >> _blgtyp >> "HitPoints")) - 1;
for "_i" from 0 to _hitmx do {
	_sctcl = (configFile >> "CfgVehicles" >> _blgtyp >> "HitPoints") select _i;
	_sct = getText(_sctcl >> "name");
	_scts = _scts + [_sct];
};
_blg setDamage 0.51;
if((count _scts) < 2) then {_blg setDamage 0.44;};
{_blg setHit[_x,1];} forEach _scts;
} forEach _blgs;

Ruins:

Is this a special model?

	class DestructionEffects : DestructionEffects {
		class Ruin1 {
			simulation = "ruin";
			type = "\CA\buildings2\Ind_CementWorks\Ind_Mlyn\Ind_Mlyn_01_ruins";
			position = "";
			intensity = 1;
			interval = 1;
			lifeTime = 1;
		};
	};

Not sure if this is just the flattened building model.

Edited by tcp

Share this post


Link to post
Share on other sites
setHit:

Code not tested.

Place some object in the town.

Init Line:

this execVM "ruin.sqf";

ruin.sqf

private ["_blg", "_blgs", "_blgcls", "_hitcl", "_scts", "_hitmx", "_i", "_sctcl", "_sct"];
_blgs = nearestObjects [_this, ["Building"], 400];
{ 
_blg = _x;
_blgcls = typeOf _blg;
_hitcl = configFile >> "CfgVehicles" >> _blgcls >> "HitPoints";
_scts = [];
_hitmx = (count _hitcl) - 1;
for "_i" from 0 to _hitmx do {
	_sctcl = _hitcl select _i;
	_sct = getText(_sctcl >> "name");
	_scts = _scts + _sct;
};

{_blg setHit[_x,(0.5 + (random 0.5))];} forEach _scts;
} forEach _blgs;

Ruins:

Is this a special model?

	class DestructionEffects : DestructionEffects {
		class Ruin1 {
			simulation = "ruin";
			type = "\CA\buildings2\Ind_CementWorks\Ind_Mlyn\Ind_Mlyn_01_ruins";
			position = "";
			intensity = 1;
			interval = 1;
			lifeTime = 1;
		};
	};

Not sure if this is just the flattened building model.

nah doesnt work nothing happens

Share this post


Link to post
Share on other sites

OK, code fixed above. It works, but some buildings have limited damage models.

I also added the following code with a 50% chance to collapse building that don't have more than 1 damage section. However, keep in mind, while setHit doesn't hurt nearby units, collapsing the building with setDamage will, so you'll have to move/protect your units.

private ["_blgs", "_blg", "_blgtyp", "_scts", "_hitmx", "_sctcl", "_sct", "_chance"];
_blgs = nearestObjects [_this, ["Building"], 700];
{ 
_blg = _x;
_blgtyp = typeOf _blg;
_scts = [];
_hitmx = (count (configFile >> "CfgVehicles" >> _blgtyp >> "HitPoints")) - 1;
for "_i" from 0 to _hitmx do {
	_sctcl = (configFile >> "CfgVehicles" >> _blgtyp >> "HitPoints") select _i;
	_sct = getText(_sctcl >> "name");
	_scts = _scts + [_sct];
};
_chance = random 1;
if(((count _scts) < 2) && (_chance < 0.5)) then {_blg setDamage 1;};
{_blg setHit[_x,1];} forEach _scts;
} forEach _blgs;

Edited by tcp

Share this post


Link to post
Share on other sites

There could be a work around without using a script, unless you want to use an existing village on Chernarus, to set up your mission. Otherwise you could use the editor upgrade and create a town in ruins for yourself. There are lot of ruin models you can place anywhere you see fit and create your own scenario. no risk that units get hurt or killed.

But in case you have to set up your mission in an existing village, than go for a script.

regards

nettrucker

Share this post


Link to post
Share on other sites

Yea, it would definitely look better if you only used the buildings that have multiple damage models.

Share this post


Link to post
Share on other sites

Yeap, I jumped the gun earlier. There was only one building in that town that broke off into sections. I never fully tested the destuctible buildings in A2, so I didn't realise how few of these sectional buildings there were.

Having AI move into town after the town destruction is acceptable. I just have to do something else for static weapons and empty vehicles.

@tcp

That looks super easy to use. I'll definitely give it a try tonight.

If I'm reading it right, the radius is 700m and it gathers all buildings within that. Then adds a 50% random chance that the buildings with less than 2 sections will be leveled?

@nettrucker

I actually did that a few times in A1, but it's kind of a pain in the ass to create an entire demolished town. However, I may still use some of those objects from time to time just to add some more rubble to existing towns.

Share this post


Link to post
Share on other sites

Updated to protect objects from collapse damage. If this doesn't work or still disrupts unit placement, then they can probably be setPos underground and restored after.

Place some object in the town with Init Line:

_ruin = [this,700] execVM "ruin.sqf";

ruin.sqf

private ["_center", "_radius", "_near", "_blgs", "_blg", "_blgtyp", "_scts", "_hitmx", "_i", "_sctcl", "_sct", "_chance"];
_center = getPos(_this select 0);
_radius = _this select 1;
_near = _center nearObjects _radius;
_blgs = [];
{
if(_x isKindOf "Building") then {_blgs = _blgs + [_x];} else {_x allowDamage false;};
} forEach _near;
{ 
_blg = _x;
_blgtyp = typeOf _blg;
_scts = [];
_hitmx = (count (configFile >> "CfgVehicles" >> _blgtyp >> "HitPoints")) - 1;
for "_i" from 0 to _hitmx do {
	_sctcl = (configFile >> "CfgVehicles" >> _blgtyp >> "HitPoints") select _i;
	_sct = getText(_sctcl >> "name");
	_scts = _scts + [_sct];
};
_chance = random 1;
if(((count _scts) < 2) && (_chance < 0.5)) then {_blg setDamage 1;};
{_blg setHit[_x,1];} forEach _scts;
} forEach _blgs;
sleep 1;
{_x allowDamage true;} forEach _near;

Share this post


Link to post
Share on other sites

You rock! Works great.

It's going to make missions very challenging to clear an area of hidden enemy.

Many thanks. :yay:

Share this post


Link to post
Share on other sites

Why not just do a simple

{_x setdamage 1;} foreach nearestObjects [_object, [], 500];

where _object is just a random unit you spawned in the middle of town... this destroys everything in sight in a 500m radius. Houses, vehicles, trees, everything is leveled.

Share this post


Link to post
Share on other sites

Maybe you should read the post. The whole point was that nobody wants pancake buildings. Some of the bigger buildings have multiple damage models that make them look like they got hit hard but are still standing.

Maybe setting a few trees on fire would add to the look though.

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  

×