Hi all
I am a totaly noob at script coding but otherwise, I was managed to "re-done" a script by picking lines codes from some "real" coders,
so my coding skill is near to zero
I specify for Chernarus map and SINGLE PLAYER
So the goal of this script is to:
-1- spawn a "C130J" with a trigger activated only by the player
-2- "C130J" must fly above a "H invisible" target (my "H" invisible is called "drop1")
-3- "C130J" drop "Misc_cargo_cont_net2" attached with "chute" and "greensmoke"
-4- "C130J" fly a few moment and is deleted when far from player
-5- When "Misc_cargo_cont_net2" reach the ground, "chute" is deleted
-6- Delete "Misc_cargo_cont_net2" and recreate the same object
-7- Create another "greensmoke" at the same place of "Misc_cargo_cont_net2"
-8- Create "ClutterCutter" around "Misc_cargo_cont_net2"
-9- Create (ramdom 4) + 4 lootpiles around "Misc_cargo_cont_net2"
-10- Ramdomized loot table for the lootpiles
This script work but have 2 problems:
- When the player activate the trigger, there is 2/3 chances the C130J appear and imediatly do a 90° or avoid the target "drop1", and never approch (flying in circles then disappear)
- There is allways only 1 lootpile around the "Misc_cargo_cont_net2"
I setted the spawn chance "MedBox0" at 3 to be able to see all lootpiles locations but this item never spawn
only all others items on the table list respawn (weapons, food, etc..)
My trigger command is:
_nul=[getpos drop1,"Misc_cargo_cont_net2",120] execVM "dropspawn2.sqf";
Condition:
(vehicle player) in thislist;
dropspawn2.sqf
Any help would be very appreciated ! thx in advance
I am a totaly noob at script coding but otherwise, I was managed to "re-done" a script by picking lines codes from some "real" coders,
so my coding skill is near to zero
I specify for Chernarus map and SINGLE PLAYER
So the goal of this script is to:
-1- spawn a "C130J" with a trigger activated only by the player
-2- "C130J" must fly above a "H invisible" target (my "H" invisible is called "drop1")
-3- "C130J" drop "Misc_cargo_cont_net2" attached with "chute" and "greensmoke"
-4- "C130J" fly a few moment and is deleted when far from player
-5- When "Misc_cargo_cont_net2" reach the ground, "chute" is deleted
-6- Delete "Misc_cargo_cont_net2" and recreate the same object
-7- Create another "greensmoke" at the same place of "Misc_cargo_cont_net2"
-8- Create "ClutterCutter" around "Misc_cargo_cont_net2"
-9- Create (ramdom 4) + 4 lootpiles around "Misc_cargo_cont_net2"
-10- Ramdomized loot table for the lootpiles
This script work but have 2 problems:
- When the player activate the trigger, there is 2/3 chances the C130J appear and imediatly do a 90° or avoid the target "drop1", and never approch (flying in circles then disappear)
- There is allways only 1 lootpile around the "Misc_cargo_cont_net2"
I setted the spawn chance "MedBox0" at 3 to be able to see all lootpiles locations but this item never spawn
only all others items on the table list respawn (weapons, food, etc..)
My trigger command is:
_nul=[getpos drop1,"Misc_cargo_cont_net2",120] execVM "dropspawn2.sqf";
Condition:
(vehicle player) in thislist;
dropspawn2.sqf
Code:
_pos = _this select 0;
_spawntype = _this select 1;
_dir = _this select 2;
_airtype = "C130J";
_type = "GUE_Soldier_Pilot";
mygroup = creategroup side player;
_target = createVehicle ["testsphere2",[_pos select 0,_pos select 1,-10], [], 0, "FLY"];
_target setpos [_pos select 0,_pos select 1,200];
_target setDir _dir;
_vdir = vectorDir _target;
_target setpos [(_pos select 0) + (_vdir select 0) * 26, (_pos select 1) + (_vdir select 1) * 26,200];
_apos = getposasl _target;
_npos = [(_pos select 0) + (_vdir select 0) * -1500, (_pos select 1) + (_vdir select 1) * -1500, 300];
_vehicle = createVehicle [_airtype,_npos, [], 0, "FLY"];
_vehicle setpos _npos;
_vehicle setDir _dir;
_vehicle setvelocity [(_vdir select 0)*50,(_vdir select 1)*50, 5];
_type createUnit [_npos, mygroup,"pilot=this;"];
_pilot = pilot;
_pilot moveindriver _vehicle;
_pilot reveal _target;
_pilot doMove _npos;
_pilot dotarget _target;
_pilot dowatch _target;
_pilot FlyInHeight 300;
_vehicle FlyInHeight 300;
//message
titleText ["I hear a plane...","PLAIN DOWN"]; titleFadeOut 20;
//while {_vehicle distance _target > 40} do {
// sleep 0.5;
sleep 25;
// if(_vehicle distance _target < 600) then {
// _pilot FlyInHeight 300;
_pilot doMove _npos;
// };
//};
_bpos = _vehicle ModelToWorld [0,-12,-5.5];
_bomb = _spawntype createVehicle _bpos;
_bomb setpos _bpos;
_bomb setDir direction _vehicle;
_chute = "ParachuteMediumWest" createVehicle getpos _bomb;
_chute setpos (_bomb ModelToWorld [0,0,3]);
_bomb attachTo [_chute,[0,0,0]];
//Add SmokeShellgreen to _chute
_smoke = "SmokeShellgreen" createVehicle getpos _bomb;
_smoke setpos (_bomb ModelToWorld [0,0,4]);
_smoke attachTo [_chute,[0,0.3,0]];
deletevehicle _target;
sleep 0.05;
//CODE FROM SBROS
//Waiting of a landing of a ammo box
waitUntil {((getPos _bomb) select 2) < 1};
//Unhitching of a box from a parachute
detach _bomb;
//Lifting the ammo box on the ground level
_bomb setpos [(getpos _bomb select 0), (getpos _bomb select 1), 0];
//Create new ammo box
_bam = "Misc_cargo_cont_net2" createVehicle [(getpos _bomb select 0),(getpos _bomb select 1),(getpos _bomb select 2)+0];
//Delete old ammo box
deletevehicle _bomb;
//Add SmokeShellgreen to _bam
_smoke = "SmokeShellgreen" createVehicle getpos _bam;
_smoke attachTo [_bam,[0,0,0]];
sleep 1;
//CREATING LOOT CRATE
//_crashModel = _bam
//_pos = (getPos _bam)
_lootRadius = 0.35;
_lootTable = ["HeliCrash"] call BIS_fnc_selectRandom;
_crashName = getText (configFile >> "CfgVehicles" >> _heliModel >> "displayName");
//Create ClutterCutter around _bam
_crashcleaner = createVehicle ["ClutterCutter_EP1", (getPos _bam), [], 0, "CAN_COLLIDE"];
//Ramdom WeaponHolder quantity
_num = round(random 4) + 4;
_config = configFile >> "CfgBuildingLoot" >> _lootTable;
_itemTypes = [
["","trash"],
["","food"],
["","military"],
["SVD_Camo","weapon"],
["PK_DZ","weapon"],
["Sa58V_RCO_EP1","weapon"],
["Sa58V_CCO_EP1","weapon"],
["Remington870_lamp","weapon"],
["DMR","weapon"],
["kpfs_glock17SD","weapon"],
["KPFS_P220","weapon"],
["KPFS_MPi_KMKIX","weapon"],
["KPFS_MP5A3SD","weapon"],
["KPFS_G3SG1","weapon"],
["KPFS_G3DMR2","weapon"],
["AmmoBoxSmall_556","object"],
["NVGoggles","weapon"],
["MedBox0","object"]
];
_itemChance = [
0.54,
0.30,
0.24,
0.06,
0.03,
0.08,
0.10,
0.09,
0.03,
0.08,
0.10,
0.06,
0.05,
0.04,
0.04,
0.02,
3.04
];
_weights = [];
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
_cntWeights = count _weights;
_index = _weights call BIS_fnc_selectRandom;
//Creating the Lootpiles outside of the _bam
for "_x" from 1 to _num do {
//Create loot
_index = floor(random _cntWeights);
_index = _weights select _index;
_itemType = _itemTypes select _index;
//Let the Loot spawn in a non-perfect circle around _bam
//_lootPos = [(getPos _bam), ((random 4)+6), random 360] call BIS_fnc_relPos;
_lootPos = [_bam, ((random 4)+6), random 360] call BIS_fnc_relPos;
[_itemType select 0, _itemType select 1, _lootPos, 0] call spawn_loot;
diag_log(format["CRASHSPAWNER: Loot spawn at '%1' with loot table '%2'", _lootPos, sizeOf(_bam)]);
//ReammoBox is preferred parent class here, as WeaponHolder wouldn't match MedBox0 and other such items.
//_nearby = (getPos _bam) nearObjects ["ReammoBox", sizeOf(_bam)];
_nearby = _bam nearObjects ["ReammoBox", sizeOf(_bam)];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};
//_plane FlyInHeight 300;
sleep 1;
_plane FlyInHeight 300;
_pilot doMove [(_pos select 0) + (_vdir select 0) * 800, (_pos select 1) + (_vdir select 1) * 800, 500];
sleep 15;
deletevehicle _vehicle;
deletevehicle _pilot;
Any help would be very appreciated ! thx in advance
Last edited: