Heya anyone and everyone,
struggling here trying to get a script to deploy a bomb above a thrown IR grenade. Anyone got some pointers?
// Function to execute the bomb spawning process
private _deployBomb = { params ["_projectile"];
// Define the bomb type
private _bombType = "Bo_GBU12_LGB";
// Get the position of the grenade and adjust for 300m above
private _grenadePos = getPosASL _projectile; private _spawnPos = [_grenadePos select 0, _grenadePos select 1, (_grenadePos select 2) + 300];
// Spawn the bomb private
_bomb = createVehicle [_bombType, _spawnPos, [], 0, "NONE"];
// Apply gravity to the bomb
_bomb setVelocity [0, 0, -10];
// Add an event handler for when the bomb hits the ground
_bomb addEventHandler ["Hit", { params ["_bomb", "_hitObj", "_damage", "_instigator", "_hitPos", "_hitPart"];
// Explode the bomb
_bomb setDamage 1; }]; };
// Attach the event handler to the player
player addEventHandler ["FiredMan", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
// Check if the fired ammo is the B_IR_Grenade
if (_ammo == "B_IR_Grenade") {
// Call the bomb deployment function with a slight delay to ensure the grenade exists in the world
[_projectile] spawn _deployBomb; }
}];
if (isClient) {
// Execute the script for each
player ["deployBombFromGrenade.sqf"] remoteExec ["execVM", 0, true]; }