Jump to content
itisnotlogical

Strange behaviour with enable/disableSimulation and allowDamage

Recommended Posts

Intended behavior: A bomb goes off. After the explosion, several invisible not-simulated units are shown and start playing hurt animations as if they'd been there the whole time. The player can use first aid kits, causing them to fall unconscious; otherwise they die after some time has elapsed.

What actually happens: When "enableSimulation" and "allowDamage" are called, the force from the explosion is suddenly applied after it already happened, while said units were invisible and not simulated.
 

Scripts affecting the relevant units:

 

detonate.sqf

// stop certain units from being damaged in the blast

{_x allowDamage false} forEach units injured;
{_x allowDamage false} forEach units group player;

deadD_1 disableAI "all"; // doStop stopped working...
deadD disableAI "all";

// blow up convoy lead vehicle, end the non-gameplay section and really begin the mission
sat1 = "SatchelCharge_Remote_Ammo_Scripted" createVehicle position bomber;
sat1 setDamage 1;
sat2 = "SatchelCharge_Remote_Ammo_Scripted" createVehicle position dead;
sat2 setDamage 1;

deadD_1 enableAI "all";
deadD enableAI "all";

{deleteVehicle _x} forEach units civs_delete;
deleteVehicle bomber;

sleep 3;
group player leaveVehicle dead_1;
{_x allowDamage true} forEach units group player;

sleep 3;
["tsk_bravo", "CANCELED"] call BIS_fnc_taskSetState;
moveOut player;
// reactivate HUD, see scripts\setup.sqf
showHUD [
true,
true,
true,
true,
true,
true,
true,
true,
true,
true
];

sleep 3;
saveGame;

sleep 8;
// enable units for the next section
[evilGroup_1, true] call fn_setGroupActive;
[evilGroup_1] call fn_makeGroupStupid;
sleep 8;
[evilGroup_2, true] call fn_setGroupActive;
[evilGroup_2] call fn_makeGroupStupid;

injured_setup.sqf: (called in a trigger after evilGroup_1 and evilGroup_2 are eliminated)

hint "If needed, there are more first aid kits in the Strider.";
{[_x, 120] execVM "scripts\hurtCiv.sqf"} forEach units injured;
{_x enableSimulation true} forEach units injured;
{_x allowDamage true} forEach units injured;
{_x hideObject false} forEach units injured;
{_x addEventHandler ["Killed",{
if (_this # 1 == player) then {
execVM "scripts\murder.sqf";
};}
]} forEach units injured;
sleep 10;
[evilGroup_3, true] call fn_setGroupActive;
[evilGroup_3] call fn_makeGroupStupid;
sleep 10;
[evilGroup_4, true] call fn_setGroupActive;
[evilGroup_4] call fn_makeGroupStupid;

hurtCiv.sqf:

/*
Ultra-dumb script for fake injured civilians
Presumably not compatible with ACE 3
All lefts reserved
*/

params ["_target", ["_deathTime", 0, [0]]];

_target setCaptive true; // prevents AI war crimers from shooting "wounded" units
_target setDamage 0.5;
_target setSpeaker "NoVoice";

private _anim = selectRandom ["Acts_CivilInjuredArms_1", "Acts_CivilInjuredChest_1", "Acts_CivilInjuredGeneral_1", "Acts_CivilInjuredLegs_1"];
_target switchMove _anim;
//hint "start";

if (_deathTime > 0) then 
{
	_deathCount = 0;
	while {(_deathCount < _deathTime) and (damage _target >= 0.5) and (damage _target < 1)} do {
		sleep 1;
		_deathCount = _deathCount + 1;
		_target playMove _anim; // cause animation to loop
		//hint str _deathCount;
	};
	//hint "while ended";
	if ((_deathCount == _deathTime) or (damage _target == 1)) then {
		_target switchMove "Acts_InjuredLyingRifle01"; // otherwise unit will animate while dead
		_target setDamage 1;
		hint "Ded";
	} 
	else {
		_target switchMove "Acts_InjuredLyingRifle01";
		_target setUnconscious true;
	};
}
else
{
	waitUntil {sleep 1; damage _target < 0.5};
	_target setUnconscious true;
	_target switchMove "Acts_InjuredLyingRifle01";
	sleep 1;
};

 

Share this post


Link to post
Share on other sites

Disabling simulation and hiding a unit don't make it invulnerable by explosion. You can't hurt it by guns.
Disabling simulation makes the cinematic of explosion apply when enabling the sim again.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, itisnotlogical said:

I guess I'll have to go with createUnit then. Thank you for the clarification.

Or teleport them.

  • Like 1

Share this post


Link to post
Share on other sites
11 hours ago, pierremgi said:

Or teleport them.

That's what I would do.  For each of the hidden units, record their position and direction in a setVariable, then setpos them to position [0,0,0].   Then when time comes to reveal these units, setpos them back to original position and reset their direction.  Its not hard to do.

  • Like 1

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

×