Jump to content
Heavensrevenger

Cannot Lock/Target spawned in Vehicles

Recommended Posts

So I want to make Cuise Missile that can be shot down. So far I've made the following code:
 

this addEventHandler ["Fired",   
{   
 params ["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile","_vehicle"]; 
 _drone = "O_T_UAV_04_CAS_F" createVehicle (getPosATL _projectile); 
 _drone attachTo [_projectile,[0,0,0]]; 
_drone setObjectTextureGlobal [_index, ""];  
createVehicleCrew _drone;


nul = [_drone, _projectile] spawn {  
params ["_drone","_projectile"];  
waitUntil {!alive _drone};  
_bomb = "SatchelCharge_Remote_Ammo_Scripted" createVehicle getPos _projectile;  
_bomb setDamage 1; 
deleteVehicle _projectile;   
deleteVehicle _drone;   
};  
}];

I works great (beside that the drones pylons stay visible, which I haven't found a fix for) and you can manually destroy the cruise missile with an autocannon. But you cant lock it for some reason. Even if you turn the engine on the spawned drone on you just get the rectangel but not the sound/diamond with dot in the middle.
Anyone know why? (Code is copied from the MK 41 Init Field)

Share this post


Link to post
Share on other sites

Hi, when you create any air vehicle, the engine thinks the vehicle is on the ground or at least that's how i understand it. You can fix that by changing createVehicle syntax and set it as "FLY" under special argument. Other method would be to use commands (setPos then move or addWaypoint) so the AI realizes it's in the air, but it's not necessary here. setVehicleTIPars is to help target vehicle immediately. I also added setVehicleAmmo to hide rockets that were on the drone, but sadly you can't retexture the rotor blade or hide collision lights, but hey, it's better than nothing 😄.

this addEventHandler ["Fired",    
{    
 params ["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile","_vehicle"];  
 _drone = createVehicle ["O_T_UAV_04_CAS_F", [0,0,1000], [], 0, "FLY"];
_drone setObjectTextureGlobal [0, ""];
createVehicleCrew _drone; 
_drone setVehicleTIPars [1,1,1];
_drone engineOn TRUE;
_drone setVehicleAmmo 0;
_drone attachTo [_projectile,[0,0,0]];
nul = [_drone, _projectile] spawn {   
params ["_drone","_projectile"];
waitUntil {!alive _drone};   
_bomb = "SatchelCharge_Remote_Ammo_Scripted" createVehicle getPos _projectile;   
_bomb setDamage 1;  
deleteVehicle _projectile;    
deleteVehicle _drone;    
}; 
}];
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you so much! Also the rockets were the biggest concern as the rotorblade is hidden in the smoke anyway and until now I hadnt even noticed the lights.

Share this post


Link to post
Share on other sites

Alright, for anyone interested, this is the code for the missiles (i managed to turn off the lights, the mk41 will be nato)

this addEventHandler ["Fired",    
{    
 params ["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile","_vehicle"];  
 _drone = createVehicle ["B_UAV_02_F", [0,0,1000], [], 0, "FLY"];  
_drone disableCollisionWith _unit;  
_drone attachTo [_projectile,[0,0,0]];  
_drone setObjectTextureGlobal [_index, ""];   
createVehicleCrew _drone; 
_drone disableAI "LIGHTS"; 
_drone disableCollisionWith _vehicle;  
_drone setVehicleAmmo 0; 
_drone setVehicleTIPars [1,1,1]; 
_drone engineOn true; 
_drone doMove (position _drone); 
nul = [_drone, _projectile] spawn {   
params ["_drone","_projectile"];   
waitUntil {!alive _drone};   
_bomb = "SatchelCharge_Remote_Ammo_Scripted" createVehicle getPos _projectile;   
_bomb setDamage 1;  
deleteVehicle _projectile;    
deleteVehicle _drone;    
};   
}];

and this code can be used for mortars (mortar has to be csat / mortar rounds will only be targeted by nato)

this addEventHandler ["Fired",    
{    
 params ["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile","_vehicle"];  
 _drone = createVehicle ["O_T_UAV_04_CAS_F", [0,0,1000], [], 0]; 
_drone disableCollisionWith _unit;  
_drone attachTo [_projectile,[0,0,0]];  
_drone setObjectTextureGlobal [_index, ""];   
createVehicleCrew _drone; 
_drone disableAI "LIGHTS"; 
 
_drone disableCollisionWith _vehicle;  
_drone setVehicleAmmo 0; 
_drone setCollisionLight false; 
nul = [_drone, _projectile] spawn {   
params ["_drone","_projectile"];   
waitUntil {!alive _drone};   
_bomb = "SatchelCharge_Remote_Ammo_Scripted" createVehicle getPos _projectile;   
_bomb setDamage 1;  
deleteVehicle _projectile;    
deleteVehicle _drone;    
};   
}];

This is awesome. Thank you all for helping me

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

×