Jump to content

Recommended Posts

Dynamic Shipwreck Spawner by Vandeanson

 

After a few weeks people realized that all was lost in Chernarus.

With the inland being too dangerous for traveling, many gathered as much supplies as they could, loaded it into their boats and took off into the open sea. Many did not make it through the harsh weather conditions and currents...

 

Nowadays, lucky survivors might still stumble across the rusty remains of such endeavors, washed up along the shores, when wandering along Chernarus coastlines...

 

Showcase Videos:

 

 

Functions of the script

- random selection of wreck placement at any shore (with v. 2.0, it is no longer needed to place markers)

- random selection of lootable props to be placed around that markere wreck

- the wreck will be deleted after 3600 seconds and the script will loop, starting from scratch

 

How to create, use and Install the script:

Step 1 - init.sqf

1. Open notepad.

2. Copy this code ------->  [] execVM "shipwreck.sqf";  

3. Paste the code into your notepad doc.

4. Save the notepad document with this name ----->  init.sqf

5. Move the init.sqf to your mission folder.

===================================

Note - if you already have an init.sqf then just add the code from 2 to it.

 

Step 2 - shipwreck.sqf

1. Open notepad.

2. Copy this code ------> from the spoiler below

3. Paste the code into your notepad doc.

4. Save the notepad document with this name ------> shipwreck.sqf

5. Move the shipwreck.sqf to your mission folder.

=========================================

 

NO MARKERS NEED TO BE PLACED!


shipwreck.sqf

Spoiler

//VANDEANSONS DYNAMIC SHIPWRECK SPAWNER
//AUGUST 3, 2018
//VERSION 2.0
//DEPENDENCIES: RAVAGE & CBA IF YOU WANT TO USE THE RAVAGE LOOT FUNCTION

while {true} do {// THIS LOOPS THE SCRIPT

//1.1 SOME DETAILS THAT CAN BE CONFIGURED:
_despawnSleepRnd = 3600; // (REFERENCE FOR CODE UNDER ITEM 5)SETS THE TIMER IN SECONDS FOR THE WRECK TO DESPAWN, WILL SELECT A RANDOM NUMBER (E.G. 3600: IT WILL SELECT A RANDOM NUMBER BETWEEN 1 AND 3600)
_despawnSleepFix = 1000;// (REFERENCE FOR CODE UNDER ITEM 5)SETS A FIX TIMER IN SECONDS THAT WILL RUN AFTER THE RANDOM TIMER
_despanPauseProxy = 300;// (REFERENCE FOR CODE UNDER ITEM 6)SETS A RADIUS AROUND THE WRECKS POSITION.WHEN THE PLAYER IS WITHIN THIS RADIUS, DESPAWNING IS PAUSED
_wreckspawnMinRange = 1000; //MINIMUM DISTANCE FROM PLAYER WHERE THE WRECK CAN SPAWN
_wreckspawnMaxRange = 3000;//MAXIMUM DISTANCE FROM PLAYER WHERE THE WRECK CAN SPAWN
//////////////////////
/////////////////////////////////////////////////////////////////////
//2. ARRAYS OF OBJECTS, STRUCTURES AND ITEMS THAT WILL SPAWN/////////
/////////////////////////////////////////////////////////////////////
//2.1. LOOTABLE OBJECTS AND WRECKS
_objectsArray = ["Land_Sack_F","Land_BarrelTrash_F","Land_Sacks_goods_F","Land_CratesWooden_F","Land_Cages_F","Land_GarbagePallet_F","Land_GarbageBarrel_01_F","Land_Pallets_F",
"Land_Garbage_square5_F","Land_CratesShabby_F","Land_CanisterPlastic_F","Land_Garbage_line_F","Land_WoodenBox_F","Land_Sacks_heap_F","Land_PaperBox_closed_F","Land_GarbageBags_F",
"Land_Pallets_F","Land_GarbageBags_F"];

_wreckArray = ["Land_Boat_06_wreck_F","Land_Wreck_Traw2_F","Land_Wreck_Traw_F","Land_UWreck_FishingBoat_F"];

/////////////////////////////////////////////////////////////////////
//3. ARRAYS OF ITEMS THAT WILL SPAWN/////////
/////////////////////////////////////////////////////////////////////
//TIP: THE MORE OFTEN AN ITEM APPEARS IN AN ARRAY, THE MORE LIKELY IT IS THAT THIS ITEM WILL SPAWN. HENCE, YOU COULD ENTER COMMON ITEMS 4 TIMES AND RARE ITEMS ONLY ONCE
_moneyArray = ["rvg_money"];

_itemsArray =[
"rvg_canOpener",
"rvg_plasticBottlePurified",
"rvg_spirit",
"rvg_franta",
"rvg_milk",
"rvg_rice",
"rvg_hose",
"rvg_guttingKnife",
"rvg_tire",
"rvg_purificationTablets",
"rvg_flare",
"rvg_matches",
"rvg_Geiger",
"rvg_toolkit",
"rvg_antiRad",
"muzzle_snds_B",
"muzzle_snds_L",
"acc_flashlight_pistol",
"optic_DMS"
];

_attachmentsArray =[
"muzzle_snds_B",
"muzzle_snds_L",
"acc_flashlight_pistol",
"optic_DMS"
];

_WeaponArray = ["hgun_Rook40_F"];

_medicalArray =[
"FirstAidKit",
"rvg_spirit",
"rvg_franta",
"rvg_beans",
"rvg_bacon",
"rvg_milk",
"rvg_rice",
"rvg_hose",
"rvg_purificationTablets"];

_explosivesArray = [
"HandGrenade",
"SmokeShellBlue",
"SmokeShellGreen",
"SmokeShellOrange",
"SmokeShellPurple",
"SmokeShellRed",
"SmokeShell",
"SmokeShellYellow",
"DemoCharge_Remote_Mag",
"ClaymoreDirectionalMine_Remote_Mag",
"SatchelCharge_Remote_Mag",
"APERSTripMine_Wire_Mag",
"APERSMine_Range_Mag"
];

/////////////////////////////////////////////////////////////////////
//4. SPAWNER:
//THIS PART;
//-  SELECTS RANDOM ITEMS, OBJECTS, WRECKS FROM POINT 4. ABOVE
//-  CREATES A RANDOWN SPAWNPOINT FOR THE WRECK
//-  SPAWNS WRECKS, OBJECTS AND THE LOOTBOX
//-  DISABLE DAMAGE OF SPAWNED WRECKS, OBJECTS OR LOOTBOX
//-  SET THE DIRECTION THE OBJECT OR STRUCTURE IS HEADING/////////
/////////////////////////////////////////////////////////////////////
//4.1 WRECK SPAWN

_wreckpos = [getPosATL player, _wreckspawnMinRange, _wreckspawnMaxRange, 5, 0, 100, 1, [], []] call BIS_fnc_findSafePos;
_wreck = _wreckArray call BIS_fnc_selectRandom createVehicle _wreckpos;
_wreck allowDamage false; // DISABLE DAMANGE FOR THE OBJECT
_wreck setDir (random 359); // SET DIRECTION

//4.2 LOOTBOX THAT YOU WANT TO LOOT FOR FANCY STUFF! NOTES BELOW:
sleep 0.2;
		_item = _moneyArray select (floor (random (count _moneyArray))); // SELECTS AN ITEM OUT OF THE RESPECTIVE ARRAY FOR THE FIRST LOOT POSITION IN ITEMBOX
    _item2 = _itemsArray select (floor (random (count _itemsArray)));// SELECTS AN ITEM OUT OF THE RESPECTIVE ARRAY FOR NEXT LOOT POSITION IN ITEMBOX
    _item3 = _medicalArray select (floor (random (count _medicalArray)));// SAME FOR NEXT LOOT POSITION
    _item4 = _itemsArray select (floor (random (count _itemsArray)));// SAME FOR NEXT LOOT POSITION
    _item5 = _attachmentsArray select (floor (random (count _attachmentsArray)));// SAME FOR NEXT LOOT POSITION
    _explo = _explosivesArray select (floor (random (count _explosivesArray))); //SAME FOR NEXT LOOT POSITION BUT SELECTS AN EXPLOSIVE FROM EXLOSIVES ARRAY
    _weapon = _weaponArray select (floor (random (count _weaponArray))); // SELECTS A RANDOM WEAPON FROM THE WEAPON ARRAY FOR THE FIRST WEAPON LOOT POSITION OF THE LOOTBOX
    _weapon1 = _weaponArray select (floor (random (count _weaponArray)));// SELECTS A RANDOM WEAPON FROM THE WEAPON ARRAY FOR THE NEXT WEAPON LOOT POSITION OF THE LOOTBOX
		_itemBox = "B_CargoNet_01_ammo_F" createVehicle [0,0,0]; // SPAWNS THE LOOT BOX
		_itemBox allowDamage false; // DISABLE DAMAGE FOR LOOTBOX
    _itemBox setDir (90); // ORIENTATION OF THE LOOTBOX
		clearMagazineCargoGlobal _itembox; // CLEAR CONTENT OF LOOTBOX
		clearWeaponCargoGlobal _itembox;
		clearItemCargoGlobal _itembox;
		clearBackpackCargoGlobal _itembox;
    _positembox = [getPosATL _wreck, 1, 15, 2, 0, 100, 0] call BIS_fnc_findSafePos;
    _itemBox setPos _positembox;
		_itemBox additemCargoGlobal [_item, 50 +random 50]; // SPAWNS THE ITEMS THAT WHERE RANDOMLY SELECTED FOR THIS LOOT POSITION. IN THIS EXAMPLE THE ARRAY ONLY CONTAINS RVG_MONEY, HENCE IT WILL SPAWN 50 X RVG_MONEY + A RANDOM AMOUNT OF 0-50 IN ADDITION
    _itemBox additemCargoGlobal [_item2, 1 +random 1];// SPAWNS THE ITEMS THAT WHERE RANDOMLY SELECTED FOR THIS LOOT POSITION. 1 FOR SURE AND WITH A CHANCE TO SPAWN 1 ADDITIONAL ITEM
    _itemBox additemCargoGlobal [_item5, 1 +random 1];// SPAWNS THE ITEMS THAT WHERE RANDOMLY SELECTED FOR THIS LOOT POSITION.1 FOR SURE AND WITH A CHANCE TO SPAWN 1 ADDITIONAL ITEM
    _itemBox addMagazineCargoGlobal [_explo, 1 +random 2];// SPAWNS THE EXPLOSIVES THAT WHERE RANDOMLY SELECTED FOR THIS LOOT POSITION. NOTE THAT MAGAZINES AND EXPLOSIVES NEED TO BE SPAWNED USING "ADDMAGAZINECARGOGLOBAL" 1 FOR SURE AND WITH A CHANCE TO SPAWN 2 ADDITIONAL ITEM
    _itemBox additemCargoGlobal [_item3, 1 +random 2];// SPAWNS THE ITEMS THAT WHERE RANDOMLY SELECTED FOR THIS LOOT POSITION.1 FOR SURE AND WITH A CHANCE TO SPAWN 1 ADDITIONAL ITEM
    _itemBox additemCargoGlobal [_item4, 1 +random 1];// SPAWNS THE ITEMS THAT WHERE RANDOMLY SELECTED FOR THIS LOOT POSITION.1 FOR SURE AND WITH A CHANCE TO SPAWN 1 ADDITIONAL ITEM
    _itemBox addWeaponCargo [_weapon,1 +random 1];// SPAWNS THE WEAPON THAT WHERE RANDOMLY SELECTED FOR THIS LOOT POSITION.1 FOR SURE AND WITH A CHANCE TO SPAWN 1 ADDITIONAL ITEM
    _magazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"); // SELECTS MATCHING MAGAZINES FOR THE WEAPON SPAWNED
    _mag = _magazines select (floor (random (count _magazines)));// SELECTS MATCHING MAGAZINES FOR THE WEAPON SPAWNED
    _itemBox addMagazineCargoGlobal [_mag, 2 +random 4];// SPAWNS 2 MATCHING MAGAZINES PLUS RANDOM AMOUNT OF 4 IN ADDITION
    _itemBox addWeaponCargo [_weapon1,1 +random 1]; // SAME AS ABOVE
    _magazines = getArray (configFile >> "CfgWeapons" >> _weapon1 >> "magazines");// SAME AS ABOVE
    _mag = _magazines select (floor (random (count _magazines)));// SAME AS ABOVE
    _itemBox addMagazineCargoGlobal [_mag, 2 +random 4];// SAME AS ABOVE

/////4.3 Ambient or lootable props (if ravage mod is active) selection and spawn point relative to _mark
sleep 0.3;
    _pos1 = [getPosATL _wreck, 5, 20, 2, 0, 100, 0] call BIS_fnc_findSafePos;
    _object1 = _objectsArray call BIS_fnc_selectRandom createVehicle _pos1;
    _object1 allowDamage false;
    _object1 setDir (random 359);


    _pos2 = [getPosATL _wreck, 5, 20, 2, 0, 100, 0] call BIS_fnc_findSafePos;
    _object2 = _objectsArray call BIS_fnc_selectRandom createVehicle _pos2;
    _object2 allowDamage false;
    _object2 setDir (random 359);

    _pos3 = [getPosATL _wreck, 5, 20, 2, 0, 100, 0] call BIS_fnc_findSafePos;
    _object3 = _objectsArray call BIS_fnc_selectRandom createVehicle _pos3;
    _object3 allowDamage false;
    _object3 setDir (random 359);

    _pos4 = [getPosATL _wreck, 5, 20, 2, 0, 100, 0] call BIS_fnc_findSafePos;
    _object4 = _objectsArray call BIS_fnc_selectRandom createVehicle _pos4;
    _object4 allowDamage false;
    _object4 setDir (random 359);

    _pos5 = [getPosATL _wreck, 5, 20, 2, 0, 100, 0] call BIS_fnc_findSafePos;
    _object5 = _objectsArray call BIS_fnc_selectRandom createVehicle _pos5;
    _object5 allowDamage false;
    _object5 setDir (random 359);

    _pos6 = [getPosATL _wreck, 5, 20, 2, 0, 100, 0] call BIS_fnc_findSafePos;
    _object6 = _objectsArray call BIS_fnc_selectRandom createVehicle _pos6;
    _object6 allowDamage false;
    _object6 setDir (random 359);

    _pos7 = [getPosATL _wreck, 5, 20, 2, 0, 100, 0] call BIS_fnc_findSafePos;
    _object7 = _objectsArray call BIS_fnc_selectRandom createVehicle _pos7;
    _object7 allowDamage false;
    _object7 setDir (random 359);

////////////////////////////////////////
//5. TIMER IN SECONDS UNTIL THE WRECK DESPAWNS AND RESPAWNS AGAIN
///////////////////////////////////////////////////////
Sleep (random _despawnSleepRnd);Sleep _despawnSleepFix; // (CHANGE FIGURES UNDER ITEM 1.1)FIRST NUMBER STES A RANDOM AMOUNT OF SECONDS BETWEEN 1-3600 AND THE SECOND NUMBER SETS A DEFINITE TIMER OF 1000 SECODS. SO THE WRECK WILL RESPAWN EARLIEST AFTER 1000 SECONDS AND AT MAXIMUM AFTER 4600 SECONDS OR IF POINT 9. BELOW IS THE CASE.

////////////////////
//6. PAUSE DESPAWN, IF PLAYER IS TOO CLOSE TO THE WRECK
//////////////////////
WaitUntil {player distance (GetPos _wreck) > _despanPauseProxy}; // (CHANGE FIGURES UNDER ITEM 1.1)IF THE PLAYER IS WITHIN xyz METERS CLOSE TO THE MAIN MARKER, THE SCRIPT WILL PAUSE AND WILL NOT DESPAWN. THE SCRIPT WILL PROCEED ONCE THE PLAYER IS FURTHER AWAY THAN 200 METERS.

///////////////////////////
//7. DESPAWN/DELETION/////
///////////////////////////
//- ANY SPAWNED OBJECT RECEIVES A REFERENCE (EG. _ITEMBOX) AND NEEDS TO BE DELETED AS SHOWN BELOW
deleteVehicle _itembox;
deleteVehicle _wreck;
deleteVehicle _object1;
deleteVehicle _object2;
deleteVehicle _object3;
deleteVehicle _object4;
deleteVehicle _object5;
deleteVehicle _object6;
deleteVehicle _object7;
};

 

 

Dependencies:

None except Ravage and CBA (if you want to use the ravage looting system)

The script works without mods too.

 

Changelog:

v.2:

- need for marker placement removed

- complete randomization of object placement arround wreck

- some clean up

Edited by Vandeanson
min max distances where still in testing mode, changed it to 1k and 3k
  • Like 6
  • Thanks 5

Share this post


Link to post
Share on other sites

Good Stuff!

 

Congratulation Vandeanson!

 

Very good for survival environments!

 

(... to be honest i had in mind to create a script like this !  It's a Great idea!!!! )

 

Thanks for this nice script!!

Share this post


Link to post
Share on other sites

I've tried the latest version on the United Sahrani terrain and it doesn't seem to be working for me. I'm calling it properly and NOT adding markers and placed my character on the shoreline hoping to see sweet sweet wrecks...

 

Since it detects a safe place and Sahrani  beaches have slopes would that be a possible reason?

 

Any thoughts? 

Share this post


Link to post
Share on other sites
3 hours ago, JasonTheRed said:

I've tried the latest version on the United Sahrani terrain and it doesn't seem to be working for me. I'm calling it properly and NOT adding markers and placed my character on the shoreline hoping to see sweet sweet wrecks...

 

Since it detects a safe place and Sahrani  beaches have slopes would that be a possible reason?

 

Any thoughts? 

thanks, i will test on the mentioned map, did you alter the script in any way? Note that they spawn quite some distance away from the player.

 

for testing, you could also alter the min max distance, so the wrecks spawn closer:

change the minimum to 20 and the max to 70

_wreckspawnMinRange = 1000; //MINIMUM DISTANCE FROM PLAYER WHERE THE WRECK CAN SPAWN

 

_wreckspawnMaxRange = 3000;//MAXIMUM DISTANCE FROM PLAYER WHERE THE WRECK CAN SPAWN

 

else i will check next occasion;)

Share this post


Link to post
Share on other sites

I like it...good idea.  Why not spawn partially submerged sometimes?   Make the player work for his loot sometimes..  :)

  • Like 3

Share this post


Link to post
Share on other sites
12 hours ago, johnnyboy said:

I like it...good idea.  Why not spawn partially submerged sometimes?   Make the player work for his loot sometimes..  :)

morning jhonny! yeah i thought about that, but i think accessing inventory does not work underwater so i would have to find a workaround there, i think picking up items from the ground works however, gotta do some testing;)

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

×